00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef XSH_DATA_PRE_H
00028 #define XSH_DATA_PRE_H
00029
00030
00031
00032
00033 #include <xsh_data_instrument.h>
00034
00035 #include <cpl.h>
00036 #include <xsh_error.h>
00037
00038
00039
00040
00041
00042 #define XSH_PRE_DATA_TYPE CPL_TYPE_FLOAT
00043 #define XSH_PRE_DATA_BPP CPL_BPP_IEEE_FLOAT
00044 #define XSH_PRE_ERRS_TYPE CPL_TYPE_FLOAT
00045 #define XSH_PRE_ERRS_BPP CPL_BPP_IEEE_FLOAT
00046 #define XSH_PRE_QUAL_TYPE CPL_TYPE_INT
00047 #define XSH_PRE_QUAL_BPP CPL_BPP_32_SIGNED
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #define XSH_NIR_DEFAULT_CUT 4
00059 #define XSH_NIR_DEFAULT_CUT_X 4
00060 #define XSH_NIR_DEFAULT_CUT_Y 20
00061
00062 #define XSH_WINDOW_MEDIAN_FRAC 0.3333
00063
00064 typedef struct {
00065 cpl_image *data;
00066 cpl_propertylist *data_header;
00067
00068 cpl_image *errs;
00069 cpl_propertylist *errs_header;
00070
00071 cpl_image *qual;
00072 cpl_propertylist *qual_header;
00073
00074 cpl_frame_group group;
00075
00076 xsh_instrument* instrument;
00077
00078 int naxis1, naxis2;
00079
00080 int binx, biny;
00081
00082 int nx, ny;
00083
00084 int cutx, cuty;
00085
00086 int cutmx, cutmy;
00087
00088 float pszx, pszy;
00089
00090 float gain;
00091
00092 float exptime;
00093
00094 double ron;
00095
00096 double conad;
00097
00098 int decode_bp;
00099 } xsh_pre;
00100
00101 #include <xsh_badpixelmap.h>
00102
00103
00104
00105
00106
00107
00108
00109 xsh_pre* xsh_pre_create( cpl_frame* raw, cpl_frame* bpmap, cpl_image* bias,
00110 xsh_instrument* instr,const int pre_overscan_corr,const bool flag_neg_and_thresh_pix);
00111 xsh_pre* xsh_pre_wavemap_create(cpl_frame* raw, xsh_pre * sci,
00112 xsh_instrument* instr) ;
00113 void xsh_pre_free(xsh_pre** pre);
00114 xsh_pre* xsh_pre_load(cpl_frame* frame, xsh_instrument* instr);
00115 void xsh_pre_init_with_header(xsh_pre* pre, cpl_propertylist* header);
00116 xsh_pre* xsh_pre_duplicate(const xsh_pre *pre);
00117 cpl_frame* xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag,int temp);
00118 cpl_frame* xsh_pre_save_product(xsh_pre *pre, cpl_frame* frame,
00119 cpl_frameset* frameset,const cpl_parameterlist* parameters,
00120 const char* recipe_id, const char *prefix );
00121
00122 xsh_pre* xsh_pre_new(int size_x, int size_y);
00123
00124
00125 int xsh_pre_get_nx(const xsh_pre *pre);
00126 int xsh_pre_get_ny(const xsh_pre *pre);
00127 int xsh_pre_get_binx( const xsh_pre *pre ) ;
00128 int xsh_pre_get_biny( const xsh_pre *pre ) ;
00129
00130 void xsh_pre_from_raw_get(xsh_pre* pre, double raw_x, double raw_y, double* x, double* y);
00131 float xsh_pre_get_pszx(const xsh_pre *pre);
00132 float xsh_pre_get_pszy(const xsh_pre *pre);
00133 float xsh_pre_get_gain(const xsh_pre *pre);
00134 cpl_frame_group xsh_pre_get_group(const xsh_pre* pre);
00135 cpl_mask* xsh_pre_get_bpmap(const xsh_pre* pre);
00136
00137
00138 void xsh_pre_dump(const xsh_pre *pre, FILE *stream);
00139
00140
00141 void xsh_pre_add(xsh_pre * self, const xsh_pre *right);
00142 void xsh_pre_subtract(xsh_pre* self, const xsh_pre *right);
00143 void xsh_pre_divide(xsh_pre* self, const xsh_pre *right, double threshold);
00144 void xsh_pre_multiply_scalar(const xsh_pre *pre, double x);
00145 void xsh_pre_multiply_image(const xsh_pre *pre, cpl_image* img);
00146 void xsh_pre_multiply (xsh_pre* self, const xsh_pre * right, double threshold);
00147
00148 cpl_frame * xsh_pre_frame_subtract( cpl_frame * one, cpl_frame *two,
00149 const char *fname, xsh_instrument * instr,
00150 const int clean_temp ) ;
00151 cpl_image* xsh_pre_abs (const xsh_pre * pre);
00152
00153 int xsh_pre_window_best_median_flux_pos( xsh_pre* pre, int xcen, int ycen,
00154 int search_window_hsize, int running_median_hsize, int* xadj, int* yadj);
00155 double xsh_pre_data_window_median_flux_pa(xsh_pre* pre, int x, int y,
00156 int size_x, int size_y,double* tab,int* status);
00157
00158 void xsh_pre_normalize( xsh_pre* self);
00159 void xsh_pre_median_mean_stdev( xsh_pre * preFrame, double * mean,
00160 double * median, double * stdev ) ;
00161
00162 void xsh_pre_median_mean_stdev_window( xsh_pre * preFrame, double * mean,
00163 double * median, double * stdev,
00164 const int llx, const int lly,
00165 const int urx, const int ury );
00166
00167
00168
00169 const
00170 cpl_propertylist *xsh_pre_get_header_const(const xsh_pre *pre);
00171 cpl_propertylist *xsh_pre_get_header ( xsh_pre *pre);
00172
00173 const
00174 cpl_image *xsh_pre_get_data_const(const xsh_pre *pre);
00175 cpl_image *xsh_pre_get_data ( xsh_pre *pre);
00176
00177 const
00178 cpl_image *xsh_pre_get_errs_const(const xsh_pre *pre);
00179 cpl_image *xsh_pre_get_errs ( xsh_pre *pre);
00180
00181 const
00182 cpl_image *xsh_pre_get_qual_const(const xsh_pre *pre);
00183 cpl_image *xsh_pre_get_qual ( xsh_pre *pre);
00184
00185 const
00186 double *xsh_pre_get_data_buffer_const(const xsh_pre *pre);
00187 double *xsh_pre_get_data_buffer ( xsh_pre *pre);
00188
00189 const
00190 double *xsh_pre_get_errs_buffer_const(const xsh_pre *pre);
00191 double *xsh_pre_get_errs_buffer ( xsh_pre *pre);
00192
00193 void xsh_pre_turn( xsh_pre * pre, int rot ) ;
00194 void xsh_pre_flip( xsh_pre * pre, int angle);
00195 void xsh_pre_extract( xsh_pre *pre, int xmin, int ymin, int xmax, int ymax);
00196 cpl_frame*
00197 xsh_frameset_average_pre(cpl_frameset *set,
00198 xsh_instrument* instr,
00199 const char* tag);
00200
00201
00202 cpl_frameset* xsh_pre_frameset_subtract_frame( cpl_frameset *set,
00203 cpl_frame *sub,
00204 const char* spec,
00205 xsh_instrument *instr);
00206
00207 void xsh_pre_subtract_scalar (const xsh_pre * pre, double x);
00208 void xsh_pre_add_scalar (const xsh_pre * pre, double x);
00209 void xsh_pre_divide_scalar (const xsh_pre * pre, double x);
00210 xsh_pre* xsh_pre_subsample (xsh_pre* self, const int binx, const int biny, const int rescale,xsh_instrument* inst);
00211
00212 #endif