28 #ifndef IRPLIB_DETMON_LG_H
29 #define IRPLIB_DETMON_LG_H
41 #define DETMON_LG_ON_RAW_OLD "ON_RAW"
42 #define DETMON_LG_OFF_RAW_OLD "OFF_RAW"
43 #define DETMON_LG_ON_RAW_NEW "DETMON_LAMP_ON"
44 #define DETMON_LG_OFF_RAW_NEW "DETMON_LAMP_OFF"
50 #define DETMON_QC_COUNTS_MIN "ESO QC COUNTS MIN"
51 #define DETMON_QC_COUNTS_MIN_C "Minimum median value used in linearity test (in a user defined region) [ADU]"
53 #define DETMON_QC_COUNTS_MAX "ESO QC COUNTS MAX"
54 #define DETMON_QC_COUNTS_MAX_C "Maximum median value used in linearity test (in a user defined region) [ADU]"
56 #define DETMON_QC_CONAD "ESO QC CONAD"
57 #define DETMON_QC_CONAD_C "Conversion from e- to ADUs [ADU/e-]"
59 #define DETMON_QC_CONAD_CORR "ESO QC CONAD CORR"
60 #define DETMON_QC_CONAD_CORR_C "CONAD value taken QC.AUTOCORR into account [ADU/e-]"
62 #define DETMON_QC_GAIN "ESO QC GAIN"
63 #define DETMON_QC_GAIN_C "GAIN (see QC.METHOD) [e-/ADU]"
65 #define DETMON_QC_GAIN_MSE "ESO QC GAIN MSE"
66 #define DETMON_QC_GAIN_MSE_C "Measured Squared error in GAIN computation"
68 #define DETMON_QC_RON "ESO QC RON"
69 #define DETMON_QC_RON_C "RON obtained as independent term (PTC method)"
71 #define DETMON_QC_AUTOCORR "ESO QC AUTOCORR"
72 #define DETMON_QC_AUTOCORR_C "Autocorrelation factor computed as sum of " \
73 "all pixels in autocorrelation image"
74 #define DETMON_QC_GAIN_CORR "ESO QC GAIN CORR"
75 #define DETMON_QC_GAIN_CORR_C "GAIN taken QC.AUTOCORR into account [e-/ADU]"
77 #define DETMON_QC_LAMP_FLUX "ESO QC LAMP FLUX"
78 #define DETMON_QC_LAMP_FLUX_C "Lamp flux"
80 #define DETMON_QC_NUM_BPM "ESO QC NUM BPM"
81 #define DETMON_QC_NUM_BPM_C "Number of bad pixels detected according to "\
82 "polynomial information"
84 #define DETMON_QC_LAMP_STAB "ESO QC LAMP STAB"
85 #define DETMON_QC_LAMP_STAB_C "Lamp stability"
87 #define DETMON_QC_METHOD "ESO QC METHOD"
88 #define DETMON_QC_METHOD_C "Method applied to compute GAIN"
90 #define DETMON_QC_LIN_EFF "ESO QC LIN EFF"
91 #define DETMON_QC_LIN_EFF_C "Effective non-linearity correction"
93 #define DETMON_QC_LIN_EFF_FLUX "ESO QC LIN EFF FLUX"
94 #define DETMON_QC_LIN_EFF_FLUX_C "FLux level at which effective non-linearity correction is computed"
96 #define DETMON_QC_LIN_COEF "ESO QC LIN COEF"
97 #define DETMON_QC_LIN_COEF_C "Linearity coefficient value"
100 #define DETMON_QC_LIN_COEF_ERR "ESO QC LIN EFF ERR"
101 #define DETMON_QC_LIN_COEF_ERR_C "Linearity coefficient error value"
102 #define DETMON_QC_LIN_COEF_MSE_ERR_C "Linearity coefficient measured square error value"
105 #define DETMON_QC_ERRFIT "ESO QC ERRFIT"
106 #define DETMON_QC_ERRFIT_C "Error of fit"
107 #define DETMON_QC_ERRFIT_MSE_C "Measured square error of fit"
110 #define DETMON_QC_CONTAM "ESO QC CONTAM"
111 #define DETMON_QC_CONTAM_C "Detector contamination in a region"
113 #define DETMON_QC_FPN "ESO QC FPN"
114 #define DETMON_QC_FPN_C "Flat pattern noise"
117 #define detmon_lg_get_description(RECIPE_NAME, PIPE_NAME, \
118 DETMON_LG_ON_RAW_NEW, \
119 DETMON_LG_OFF_RAW_NEW, \
120 DETMON_LG_ON_RAW_OLD, \
121 DETMON_LG_OFF_RAW_OLD) \
122 RECIPE_NAME " -- " PIPE_NAME " linearity/gain recipe for OPT/IR.\n" \
123 "The files listed in the Set Of Frames must be tagged:\n" \
124 "the raw-on-file.fits "DETMON_LG_ON_RAW_NEW" and\n" \
125 "the raw-off-file.fits "DETMON_LG_OFF_RAW_NEW"\n" \
126 "For backward compatibility are alternatively still supported the following tags:\n" \
127 "the raw-on-file.fits "DETMON_LG_ON_RAW_OLD" and\n" \
128 "the raw-off-file.fits "DETMON_LG_OFF_RAW_OLD"\n" \
129 "The recipe requires at least order+1 valid pairs of ON frames\n" \
130 "and order+1 valid pairs of OFF frames, \n" \
131 "where order is the value of the 'order' parameter.\n" \
132 "There is no requirement for pairs of OFF frames if collapse parameter " \
133 "is set to true.\n" \
134 "Frames with median flux over --filter will be excluded from the " \
136 "To perform a stability check you need frames with at least 2 DIT " \
138 "NOTE for multiextension cases: it is mandatory to modify the --exts " \
139 "parameter, either to -1 (all extensions) or to any valid extension nb.\n" \
141 "The output PRO.CATG are:\n" \
142 "GAIN_INFO - the gain table\n" \
143 "DET_LIN_INFO - the linearity table\n" \
144 "BP_MAP_NL - the bad pixel map (only produced with --pix2pix=TRUE)\n" \
145 "COEFFS_CUBE - the fit coefficient cube (only produced with --pix2pix=TRUE)\n"
147 #define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
149 typedef unsigned long irplib_gain_flag;
151 #define IRPLIB_GAIN_PTC ((irplib_gain_flag) 1 << 1)
152 #define IRPLIB_GAIN_MEDIAN ((irplib_gain_flag) 1 << 2)
153 #define IRPLIB_GAIN_NO_COLLAPSE ((irplib_gain_flag) 1 << 3)
154 #define IRPLIB_GAIN_COLLAPSE ((irplib_gain_flag) 1 << 4)
155 #define IRPLIB_GAIN_WITH_AUTOCORR ((irplib_gain_flag) 1 << 5)
156 #define IRPLIB_GAIN_WITH_RESCALE ((irplib_gain_flag) 1 << 6)
157 #define IRPLIB_GAIN_OPT ((irplib_gain_flag) 1 << 7)
158 #define IRPLIB_GAIN_NIR ((irplib_gain_flag) 1 << 8)
160 typedef unsigned long irplib_lin_flag;
162 #define IRPLIB_LIN_NO_COLLAPSE ((irplib_lin_flag) 1 << 10)
163 #define IRPLIB_LIN_COLLAPSE ((irplib_lin_flag) 1 << 11)
164 #define IRPLIB_LIN_PIX2PIX ((irplib_lin_flag) 1 << 12)
165 #define IRPLIB_LIN_WITH_RESCALE ((irplib_lin_flag) 1 << 13)
166 #define IRPLIB_LIN_OPT ((irplib_lin_flag) 1 << 14)
167 #define IRPLIB_LIN_NIR ((irplib_lin_flag) 1 << 15)
174 detmon_lg(cpl_frameset * frameset,
175 const cpl_parameterlist * parlist,
177 const char * tag_off,
178 const char * recipe_name,
179 const char * pipeline_name,
180 const char * pafregexp,
181 const cpl_propertylist * pro_lintbl,
182 const cpl_propertylist * pro_gaintbl,
183 const cpl_propertylist * pro_coeffscube,
184 const cpl_propertylist * pro_bpm,
185 const cpl_propertylist * pro_corr,
186 const cpl_propertylist * pro_diff,
187 const char * package,
188 int (* compare) (
const cpl_frame *,
190 int (* load_fset) (
const cpl_frameset *,
193 const cpl_boolean opt_nir);
196 cpl_image * detmon_image_correlate(
const cpl_image *,
202 detmon_lg_fill_parlist_nir_default(cpl_parameterlist *,
207 detmon_lg_fill_parlist_nir_default_mr(cpl_parameterlist * parlist,
208 const char *recipe_name,
209 const char *pipeline_name);
212 detmon_lg_fill_parlist_opt_default(cpl_parameterlist *,
217 detmon_lg_fill_parlist_opt_default_mr(cpl_parameterlist * parlist,
218 const char *recipe_name,
219 const char *pipeline_name);
222 detmon_lg_fill_parlist(cpl_parameterlist * parlist,
223 const char *recipe_name,
const char *pipeline_name,
233 const char * intermediate,
234 const char * autocorr,
235 const char * collapse,
236 const char * rescale,
237 const char * pix2pix,
244 const char * pafname,
266 cpl_boolean opt_nir);
269 detmon_autocorrelate(
const cpl_image *,
270 const int,
const int);
273 detmon_gain(
const cpl_imagelist *,
274 const cpl_imagelist *,
292 detmon_lin(
const cpl_imagelist *,
293 const cpl_imagelist *,
310 detmon_lg_set_tag(cpl_frameset* set,
const char** tag_on,
const char** tag_off);