X-shooter Pipeline Reference Manual 3.8.15
xsh_data_pre.h
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2012-11-30 16:07:18 $
23 * $Revision: 1.65 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifndef XSH_DATA_PRE_H
28#define XSH_DATA_PRE_H
29
30/*----------------------------------------------------------------------------
31 Includes
32 ----------------------------------------------------------------------------*/
33#include <xsh_data_instrument.h>
34
35#include <cpl.h>
36#include <xsh_error.h>
37
38/*----------------------------------------------------------------------------
39 Typedefs
40 ----------------------------------------------------------------------------*/
41
42#define XSH_PRE_DATA_TYPE CPL_TYPE_FLOAT
43#define XSH_PRE_DATA_BPP CPL_BPP_IEEE_FLOAT
44#define XSH_PRE_ERRS_TYPE CPL_TYPE_FLOAT
45#define XSH_PRE_ERRS_BPP CPL_BPP_IEEE_FLOAT
46#define XSH_PRE_QUAL_TYPE CPL_TYPE_INT
47#define XSH_PRE_QUAL_BPP CPL_BPP_32_SIGNED
48
49/* NIR have RON and CONAD now
50
51#define XSH_NIR_DEFAULT_RON 1.43
52#define XSH_NIR_DEFAULT_CONAD 0.36
53#define XSH_NIR_DEFAULT_GAIN 2.78
54
55*/
56
57/* cut in pixels along X, Y on RAW data */
58#define XSH_NIR_DEFAULT_CUT 4
59#define XSH_NIR_DEFAULT_CUT_X 4
60#define XSH_NIR_DEFAULT_CUT_Y 20
61
62#define XSH_WINDOW_MEDIAN_FRAC 0.3333
63
64typedef struct {
65 cpl_image *data;
66 cpl_propertylist *data_header;
67
68 cpl_image *errs;
69 cpl_propertylist *errs_header;
70
71 cpl_image *qual;
72 cpl_propertylist *qual_header;
73
74 cpl_frame_group group;
75 /* instrument related with PRE */
77 /* NAXIS1 and NAXIS2 keywords */
78 int naxis1, naxis2;
79 /* BINX et BINY keywords */
80 int binx, biny;
81 /* image size (DATA,ERRS,QUAL) in pixels */
82 int nx, ny;
83 /* translation in X,Y between detector and image */
84 int cutx, cuty;
85 /* max in X,Y of the cut */
86 int cutmx, cutmy;
87 /* pixels size in microns */
88 float pszx, pszy;
89 /* conversion from eletcrons to ADU */
90 float gain;
91 /* exposure time */
92 float exptime;
93 /* ron */
94 double ron;
95 /* conad */
96 double conad;
97 /* decode_bp */
99} xsh_pre;
100
101#include <xsh_badpixelmap.h>
102
103
104/*----------------------------------------------------------------------------
105 Methods
106 ----------------------------------------------------------------------------*/
107
108/* Create/destroy */
109xsh_pre* xsh_pre_create( cpl_frame* raw, cpl_frame* bpmap, cpl_image* bias,
110 xsh_instrument* instr,const int pre_overscan_corr,const bool flag_neg_and_thresh_pix);
112 xsh_instrument* instr) ;
113void xsh_pre_free(xsh_pre** pre);
114xsh_pre* xsh_pre_load(cpl_frame* frame, xsh_instrument* instr);
115void xsh_pre_init_with_header(xsh_pre* pre, cpl_propertylist* header);
117cpl_frame* xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag,int temp);
118cpl_frame* xsh_pre_save_product(xsh_pre *pre, cpl_frame* frame,
119 cpl_frameset* frameset,const cpl_parameterlist* parameters,
120 const char* recipe_id, const char *prefix );
121
122xsh_pre* xsh_pre_new(int size_x, int size_y);
123
124/* get */
125int xsh_pre_get_nx(const xsh_pre *pre);
126int xsh_pre_get_ny(const xsh_pre *pre);
127int xsh_pre_get_binx( const xsh_pre *pre ) ;
128int xsh_pre_get_biny( const xsh_pre *pre ) ;
129
130void xsh_pre_from_raw_get(xsh_pre* pre, double raw_x, double raw_y, double* x, double* y);
131float xsh_pre_get_pszx(const xsh_pre *pre);
132float xsh_pre_get_pszy(const xsh_pre *pre);
133float xsh_pre_get_gain(const xsh_pre *pre);
134cpl_frame_group xsh_pre_get_group(const xsh_pre* pre);
135cpl_mask* xsh_pre_get_bpmap(const xsh_pre* pre);
136
137/* I/O */
138void xsh_pre_dump(const xsh_pre *pre, FILE *stream);
139
140/* Standard arithmetic operations used by several recipes */
141void xsh_pre_add(xsh_pre * self, const xsh_pre *right);
142void xsh_pre_subtract(xsh_pre* self, const xsh_pre *right);
143void xsh_pre_divide(xsh_pre* self, const xsh_pre *right, const int is_flat, double threshold);
144void xsh_pre_multiply_scalar(const xsh_pre *pre, double x);
145void xsh_pre_multiply_image(const xsh_pre *pre, cpl_image* img);
146void xsh_pre_multiply (xsh_pre* self, const xsh_pre * right, double threshold);
147
148cpl_frame * xsh_pre_frame_subtract( cpl_frame * one, cpl_frame *two,
149 const char *fname, xsh_instrument * instr,
150 const int clean_temp ) ;
151cpl_image* xsh_pre_abs (const xsh_pre * pre);
152/* special computation on data */
153int xsh_pre_window_best_median_flux_pos( xsh_pre* pre, int xcen, int ycen,
154 int search_window_hsize, int running_median_hsize, int* xadj, int* yadj);
155double xsh_pre_data_window_median_flux_pa(xsh_pre* pre, int x, int y,
156 int size_x, int size_y,double* tab,int* status);
157
158void xsh_pre_normalize( xsh_pre* self);
159void xsh_pre_median_mean_stdev( xsh_pre * preFrame, double * mean,
160 double * median, double * stdev ) ;
161
162void xsh_pre_median_mean_stdev_window( xsh_pre * preFrame, double * mean,
163 double * median, double * stdev,
164 const int llx, const int lly,
165 const int urx, const int ury );
166/* Accessor functions
167 * (const/non-const variants of each)
168 */
169const
170cpl_propertylist *xsh_pre_get_header_const(const xsh_pre *pre);
171cpl_propertylist *xsh_pre_get_header ( xsh_pre *pre);
172
173const
174cpl_image *xsh_pre_get_data_const(const xsh_pre *pre);
175cpl_image *xsh_pre_get_data ( xsh_pre *pre);
176
177const
178cpl_image *xsh_pre_get_errs_const(const xsh_pre *pre);
179cpl_image *xsh_pre_get_errs ( xsh_pre *pre);
180
181const
182cpl_image *xsh_pre_get_qual_const(const xsh_pre *pre);
183cpl_image *xsh_pre_get_qual ( xsh_pre *pre);
184
185const
186double *xsh_pre_get_data_buffer_const(const xsh_pre *pre);
187double *xsh_pre_get_data_buffer ( xsh_pre *pre);
188
189const
190double *xsh_pre_get_errs_buffer_const(const xsh_pre *pre);
191double *xsh_pre_get_errs_buffer ( xsh_pre *pre);
192
193void xsh_pre_turn( xsh_pre * pre, int rot ) ;
194void xsh_pre_flip( xsh_pre * pre, int angle);
195void xsh_pre_extract( xsh_pre *pre, int xmin, int ymin, int xmax, int ymax);
196cpl_frame*
197xsh_frameset_average_pre(cpl_frameset *set,
198 xsh_instrument* instr,
199 const char* tag);
200
201
202cpl_frameset* xsh_pre_frameset_subtract_frame( cpl_frameset *set,
203 cpl_frame *sub,
204 const char* spec,
205 xsh_instrument *instr);
206
207void xsh_pre_subtract_scalar (const xsh_pre * pre, double x);
208void xsh_pre_add_scalar (const xsh_pre * pre, double x);
209void xsh_pre_divide_scalar (const xsh_pre * pre, double x);
210xsh_pre* xsh_pre_subsample (xsh_pre* self, const int binx, const int biny, const int rescale,xsh_instrument* inst);
211
212/* The following is exposed for SDP format generation in xsh_dfs.c */
213double xsh_compute_ron_nir(const double dit);
214
215#endif
int binx
int biny
void xsh_pre_add(xsh_pre *self, const xsh_pre *right)
Add two PRE images.
cpl_image * xsh_pre_get_data(xsh_pre *pre)
Get data.
xsh_pre * xsh_pre_duplicate(const xsh_pre *pre)
Copy a PRE structure.
Definition: xsh_data_pre.c:953
void xsh_pre_flip(xsh_pre *pre, int angle)
Flip an image on a given miror line.
void xsh_pre_from_raw_get(xsh_pre *pre, double raw_x, double raw_y, double *x, double *y)
Get x, y coordinates in image from RAW coordinates.
double * xsh_pre_get_data_buffer(xsh_pre *pre)
Get data buffer.
double * xsh_pre_get_errs_buffer(xsh_pre *pre)
Get errs buffer.
cpl_frame * xsh_pre_save_product(xsh_pre *pre, cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, const char *prefix)
Save PRE frame like a product on disk.
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
Definition: xsh_data_pre.c:849
void xsh_pre_extract(xsh_pre *pre, int xmin, int ymin, int xmax, int ymax)
Create a sub pre image.
cpl_mask * xsh_pre_get_bpmap(const xsh_pre *pre)
Get bpmap of pre structure.
cpl_frame_group xsh_pre_get_group(const xsh_pre *pre)
Get ny of pre structure.
const double * xsh_pre_get_errs_buffer_const(const xsh_pre *pre)
Get errs buffer.
void xsh_pre_divide(xsh_pre *self, const xsh_pre *right, const int is_flat, double threshold)
Divide a PRE image from another.
void xsh_pre_multiply_image(const xsh_pre *pre, cpl_image *img)
multiply a frame in PRE format by an image
cpl_image * xsh_pre_get_qual(xsh_pre *pre)
Get qual.
void xsh_pre_divide_scalar(const xsh_pre *pre, double x)
divides a frame in PRE format by a scalar
int xsh_pre_get_ny(const xsh_pre *pre)
Get ny of pre structure.
int xsh_pre_window_best_median_flux_pos(xsh_pre *pre, int xcen, int ycen, int search_window_hsize, int running_median_hsize, int *xadj, int *yadj)
Search pixel position of best running median flux in the search window.
void xsh_pre_multiply_scalar(const xsh_pre *pre, double x)
multiply a frame in PRE format by a scalar
cpl_image * xsh_pre_abs(const xsh_pre *pre)
computes absolute value of a frame in PRE format
float xsh_pre_get_pszx(const xsh_pre *pre)
Get pszx of pre structure.
void xsh_pre_add_scalar(const xsh_pre *pre, double x)
add a scalar to a frame in PRE format
int xsh_pre_get_binx(const xsh_pre *pre)
Get binx of pre structure.
void xsh_pre_turn(xsh_pre *pre, int rot)
cpl_frame * xsh_pre_frame_subtract(cpl_frame *one, cpl_frame *two, const char *fname, xsh_instrument *instr, const int clean_temp)
Subtract 2 frames (in XSH_PRE format) Just loads the 2 frames, subtract (xsh_pre_subtract) and save r...
xsh_pre * xsh_pre_new(int size_x, int size_y)
Create new PRE image.
void xsh_pre_normalize(xsh_pre *self)
Normalize data flux.
void xsh_pre_multiply(xsh_pre *self, const xsh_pre *right, double threshold)
Multiply a PRE image from another.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
Definition: xsh_data_pre.c:823
const cpl_image * xsh_pre_get_data_const(const xsh_pre *pre)
Get data.
int xsh_pre_get_biny(const xsh_pre *pre)
Get biny of pre structure.
xsh_pre * xsh_pre_create(cpl_frame *raw, cpl_frame *bpmap, cpl_image *bias, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
Create a XSH_PRE from a raw frame.
Definition: xsh_data_pre.c:450
int xsh_pre_get_nx(const xsh_pre *pre)
Get nx of pre structure.
float xsh_pre_get_pszy(const xsh_pre *pre)
Get pszy of pre structure.
double xsh_compute_ron_nir(const double dit)
Definition: xsh_data_pre.c:247
cpl_frame * xsh_frameset_average_pre(cpl_frameset *set, xsh_instrument *instr, const char *tag)
Average set of frames in PRE format.
xsh_pre * xsh_pre_subsample(xsh_pre *self, const int binx, const int biny, const int rescale, xsh_instrument *inst)
Subsample a PRE image of a bin factor binx X biny.
cpl_frameset * xsh_pre_frameset_subtract_frame(cpl_frameset *set, cpl_frame *sub, const char *spec, xsh_instrument *instr)
Subtract 2 frames (in XSH_PRE format) Just loads the 2 frames, subtract (xsh_pre_subtract) and save r...
void xsh_pre_subtract_scalar(const xsh_pre *pre, double x)
subtract a scalar from a frame in PRE format
double xsh_pre_data_window_median_flux_pa(xsh_pre *pre, int x, int y, int size_x, int size_y, double *tab, int *status)
compute median sample value on the data window with preallocated memory tab. Only good pixels codes a...
cpl_propertylist * xsh_pre_get_header(xsh_pre *pre)
Get header.
const cpl_propertylist * xsh_pre_get_header_const(const xsh_pre *pre)
Get header.
const double * xsh_pre_get_data_buffer_const(const xsh_pre *pre)
Get data buffer.
void xsh_pre_subtract(xsh_pre *self, const xsh_pre *right)
Subtract one PRE image from another The data units are subtracted data = data1 - data2 The error imag...
float xsh_pre_get_gain(const xsh_pre *pre)
Get gain of pre structure.
const cpl_image * xsh_pre_get_qual_const(const xsh_pre *pre)
Get QUAL.
cpl_image * xsh_pre_get_errs(xsh_pre *pre)
Get errs.
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
void xsh_pre_median_mean_stdev_window(xsh_pre *preFrame, double *mean, double *median, double *stdev, const int llx, const int lly, const int urx, const int ury)
const cpl_image * xsh_pre_get_errs_const(const xsh_pre *pre)
Get errs.
void xsh_pre_dump(const xsh_pre *pre, FILE *stream)
Dump image to stream.
void xsh_pre_median_mean_stdev(xsh_pre *preFrame, double *mean, double *median, double *stdev)
int * y
int * x
int decode_bp
Definition: xsh_data_pre.h:98
double ron
Definition: xsh_data_pre.h:94
cpl_image * qual
Definition: xsh_data_pre.h:71
float exptime
Definition: xsh_data_pre.h:92
cpl_frame_group group
Definition: xsh_data_pre.h:74
double conad
Definition: xsh_data_pre.h:96
cpl_propertylist * qual_header
Definition: xsh_data_pre.h:72
cpl_image * data
Definition: xsh_data_pre.h:65
cpl_propertylist * errs_header
Definition: xsh_data_pre.h:69
int naxis1
Definition: xsh_data_pre.h:78
xsh_instrument * instrument
Definition: xsh_data_pre.h:76
cpl_propertylist * data_header
Definition: xsh_data_pre.h:66
int binx
Definition: xsh_data_pre.h:80
cpl_image * errs
Definition: xsh_data_pre.h:68
float pszx
Definition: xsh_data_pre.h:88
int cutx
Definition: xsh_data_pre.h:84
float gain
Definition: xsh_data_pre.h:90
int cutmx
Definition: xsh_data_pre.h:86
xsh_pre * xsh_pre_wavemap_create(cpl_frame *raw, xsh_pre *sci, xsh_instrument *instr)
void xsh_pre_init_with_header(xsh_pre *pre, cpl_propertylist *header)
int lly
Definition: xsh_detmon_lg.c:86
cpl_boolean rescale
int threshold
Definition: xsh_detmon_lg.c:90
int llx
Definition: xsh_detmon_lg.c:85
int urx
Definition: xsh_detmon_lg.c:87
int ury
Definition: xsh_detmon_lg.c:88
int ny