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 } xsh_pre;
00098
00099 #include <xsh_badpixelmap.h>
00100
00101
00102
00103
00104
00105
00106
00107 xsh_pre* xsh_pre_create( cpl_frame* raw, cpl_frame* bpmap, cpl_image* bias,
00108 xsh_instrument* instr,const int pre_overscan_corr);
00109 xsh_pre* xsh_pre_wavemap_create(cpl_frame* raw, xsh_pre * sci,
00110 xsh_instrument* instr) ;
00111 void xsh_pre_free(xsh_pre** pre);
00112 xsh_pre* xsh_pre_load(cpl_frame* frame, xsh_instrument* instr);
00113 void xsh_pre_init_with_header(xsh_pre* pre, cpl_propertylist* header);
00114 xsh_pre* xsh_pre_duplicate(const xsh_pre *pre);
00115 cpl_frame* xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag,int temp);
00116 cpl_frame* xsh_pre_save_product(xsh_pre *pre, cpl_frame* frame,
00117 cpl_frameset* frameset,const cpl_parameterlist* parameters,
00118 const char* recipe_id, const char *prefix );
00119
00120 xsh_pre* xsh_pre_new(int size_x, int size_y);
00121
00122
00123 int xsh_pre_get_nx(const xsh_pre *pre);
00124 int xsh_pre_get_ny(const xsh_pre *pre);
00125 int xsh_pre_get_binx( const xsh_pre *pre ) ;
00126 int xsh_pre_get_biny( const xsh_pre *pre ) ;
00127
00128 void xsh_pre_from_raw_get(xsh_pre* pre, double raw_x, double raw_y, double* x, double* y);
00129 float xsh_pre_get_pszx(const xsh_pre *pre);
00130 float xsh_pre_get_pszy(const xsh_pre *pre);
00131 float xsh_pre_get_gain(const xsh_pre *pre);
00132 cpl_frame_group xsh_pre_get_group(const xsh_pre* pre);
00133 cpl_mask* xsh_pre_get_bpmap(const xsh_pre* pre);
00134
00135
00136 void xsh_pre_dump(const xsh_pre *pre, FILE *stream);
00137
00138
00139 void xsh_pre_add(xsh_pre * self, const xsh_pre *right);
00140 void xsh_pre_subtract(xsh_pre* self, const xsh_pre *right);
00141 void xsh_pre_divide(xsh_pre* self, const xsh_pre *right, double threshold);
00142 void xsh_pre_multiply_scalar(const xsh_pre *pre, double x);
00143 void xsh_pre_multiply_image(const xsh_pre *pre, cpl_image* img);
00144 void xsh_pre_multiply (xsh_pre* self, const xsh_pre * right, double threshold);
00145
00146 cpl_frame * xsh_pre_frame_subtract( cpl_frame * one, cpl_frame *two,
00147 const char *fname, xsh_instrument * instr ) ;
00148 cpl_image* xsh_pre_abs (const xsh_pre * pre);
00149
00150 int xsh_pre_window_best_median_flux_pos( xsh_pre* pre, int xcen, int ycen,
00151 int search_window_hsize, int running_median_hsize, int* xadj, int* yadj);
00152 double xsh_pre_data_window_median_flux_pa(xsh_pre* pre, int x, int y,
00153 int size_x, int size_y,double* tab);
00154 double xsh_pre_data_window_sample_flux_pa(xsh_pre* pre, int x, int y,
00155 int size_x, int size_y, double* tab,
00156 const char* method,
00157 double min_window_frac );
00158
00159 double xsh_pre_data_window_min_flux_pa(xsh_pre* pre, int x, int y,
00160 int size_x, int size_y, double* tab );
00161
00162 double xsh_pre_data_window_median_flux(xsh_pre* pre, int x, int y,
00163 int size_x, int size_y);
00164 void xsh_pre_normalize( xsh_pre* self);
00165 void xsh_pre_median_mean_stdev( xsh_pre * preFrame, double * mean,
00166 double * median, double * stdev ) ;
00167
00168 void xsh_pre_median_mean_stdev_window( xsh_pre * preFrame, double * mean,
00169 double * median, double * stdev,
00170 const int llx, const int lly,
00171 const int urx, const int ury );
00172
00173
00174
00175 const
00176 cpl_propertylist *xsh_pre_get_header_const(const xsh_pre *pre);
00177 cpl_propertylist *xsh_pre_get_header ( xsh_pre *pre);
00178
00179 const
00180 cpl_image *xsh_pre_get_data_const(const xsh_pre *pre);
00181 cpl_image *xsh_pre_get_data ( xsh_pre *pre);
00182
00183 const
00184 cpl_image *xsh_pre_get_errs_const(const xsh_pre *pre);
00185 cpl_image *xsh_pre_get_errs ( xsh_pre *pre);
00186
00187 const
00188 cpl_image *xsh_pre_get_qual_const(const xsh_pre *pre);
00189 cpl_image *xsh_pre_get_qual ( xsh_pre *pre);
00190
00191 const
00192 double *xsh_pre_get_data_buffer_const(const xsh_pre *pre);
00193 double *xsh_pre_get_data_buffer ( xsh_pre *pre);
00194
00195 const
00196 double *xsh_pre_get_errs_buffer_const(const xsh_pre *pre);
00197 double *xsh_pre_get_errs_buffer ( xsh_pre *pre);
00198
00199 void xsh_pre_turn( xsh_pre * pre, int rot ) ;
00200 void xsh_pre_flip( xsh_pre * pre, int angle);
00201 void xsh_pre_extract( xsh_pre *pre, int xmin, int ymin, int xmax, int ymax);
00202 cpl_frame*
00203 xsh_frameset_average_pre(cpl_frameset *set,
00204 xsh_instrument* instr,
00205 const char* tag);
00206
00207
00208 cpl_frameset* xsh_pre_frameset_subtract_frame( cpl_frameset *set,
00209 cpl_frame *sub,
00210 const char* spec,
00211 xsh_instrument *instr );
00212
00213 void xsh_pre_subtract_scalar (const xsh_pre * pre, double x);
00214 void xsh_pre_add_scalar (const xsh_pre * pre, double x);
00215 void xsh_pre_divide_scalar (const xsh_pre * pre, double x);
00216
00217
00218 #endif