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 "[ADU/e-] Conversion from e- to ADUs"
59#define DETMON_QC_CONAD_CORR "ESO QC CONAD CORR"
60#define DETMON_QC_CONAD_CORR_C "[ADU/e-] CONAD value taken QC.AUTOCORR into account"
62#define DETMON_QC_GAIN "ESO QC GAIN"
63#define DETMON_QC_GAIN_C "[e-/ADU] GAIN (see QC.METHOD)"
65#define DETMON_QC_GAIN_ERR "ESO QC GAIN ERR"
66#define DETMON_QC_GAIN_ERR_C "[e-/ADU] Error on GAIN"
68#define DETMON_QC_GAIN_MSE "ESO QC GAIN MSE"
69#define DETMON_QC_GAIN_MSE_C "Measured Squared error in GAIN computation"
71#define DETMON_QC_RON "ESO QC RON"
72#define DETMON_QC_RON_C "RON obtained as independent term (PTC method)"
74#define DETMON_QC_AUTOCORR "ESO QC AUTOCORR"
75#define DETMON_QC_AUTOCORR_C "Autocorrelation factor computed as sum of " \
76 "all pixels in autocorrelation image"
77#define DETMON_QC_GAIN_CORR "ESO QC GAIN CORR"
78#define DETMON_QC_GAIN_CORR_C "[e-/ADU] GAIN taken QC.AUTOCORR into account"
80#define DETMON_QC_LAMP_FLUX "ESO QC LAMP FLUX"
81#define DETMON_QC_LAMP_FLUX_C "Lamp flux"
83#define DETMON_QC_NUM_BPM "ESO QC NUM BPM"
84#define DETMON_QC_NUM_BPM_C "Number of bad pixels detected according to "\
85 "polynomial information"
87#define DETMON_QC_LAMP_STAB "ESO QC LAMP STAB"
88#define DETMON_QC_LAMP_STAB_C "Lamp stability"
90#define DETMON_QC_METHOD "ESO QC METHOD"
91#define DETMON_QC_METHOD_C "Method applied to compute GAIN"
93#define DETMON_QC_LIN_EFF "ESO QC LIN EFF"
94#define DETMON_QC_LIN_EFF_C "Effective non-linearity correction"
96#define DETMON_QC_LIN_EFF_FLUX "ESO QC LIN EFF FLUX"
97#define DETMON_QC_LIN_EFF_FLUX_C "FLux level at which effective non-linearity correction is computed"
99#define DETMON_QC_LIN_COEF "ESO QC LIN COEF"
100#define DETMON_QC_LIN_COEF_C "Linearity coefficient value"
103#define DETMON_QC_LIN_COEF_ERR "ESO QC LIN EFF ERR"
104#define DETMON_QC_LIN_COEF_ERR_C "Linearity coefficient error value"
105#define DETMON_QC_LIN_COEF_MSE_ERR_C "Linearity coefficient measured square error value"
108#define DETMON_QC_ERRFIT "ESO QC ERRFIT"
109#define DETMON_QC_ERRFIT_C "Error of fit"
110#define DETMON_QC_ERRFIT_MSE_C "Measured square error of fit"
113#define DETMON_QC_CONTAM "ESO QC CONTAM"
114#define DETMON_QC_CONTAM_C "Detector contamination in a region"
116#define DETMON_QC_FPN "ESO QC FPN"
117#define DETMON_QC_FPN_C "Flat pattern noise"
120#define detmon_lg_get_description(RECIPE_NAME, PIPE_NAME, \
121 DETMON_LG_ON_RAW_NEW, \
122 DETMON_LG_OFF_RAW_NEW, \
123 DETMON_LG_ON_RAW_OLD, \
124 DETMON_LG_OFF_RAW_OLD) \
125 RECIPE_NAME " -- " PIPE_NAME " linearity/gain recipe for OPT/IR.\n" \
126 "The files listed in the Set Of Frames must be tagged:\n" \
127 "the raw-on-file.fits "DETMON_LG_ON_RAW_NEW" and\n" \
128 "the raw-off-file.fits "DETMON_LG_OFF_RAW_NEW"\n" \
129 "For backward compatibility are alternatively still supported the following tags:\n" \
130 "the raw-on-file.fits "DETMON_LG_ON_RAW_OLD" and\n" \
131 "the raw-off-file.fits "DETMON_LG_OFF_RAW_OLD"\n" \
132 "The recipe requires at least order+1 valid pairs of ON frames\n" \
133 "and order+1 valid pairs of OFF frames, \n" \
134 "where order is the value of the 'order' parameter.\n" \
135 "There is no requirement for pairs of OFF frames if collapse parameter " \
136 "is set to true.\n" \
137 "Frames with median flux over --filter will be excluded from the " \
139 "To perform a stability check you need frames with at least 2 DIT " \
141 "NOTE for multiextension cases: it is mandatory to modify the --exts " \
142 "parameter, either to -1 (all extensions) or to any valid extension nb.\n" \
144 "The output PRO.CATG are:\n" \
145 "GAIN_INFO - the gain table\n" \
146 "DET_LIN_INFO - the linearity table\n" \
147 "BP_MAP_NL - the bad pixel map (only produced with --pix2pix=TRUE)\n" \
148 "COEFFS_CUBE - the fit coefficient cube (only produced with --pix2pix=TRUE)\n"
150#define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
152typedef unsigned long irplib_gain_flag;
154#define IRPLIB_GAIN_PTC ((irplib_gain_flag) 1 << 1)
155#define IRPLIB_GAIN_MEDIAN ((irplib_gain_flag) 1 << 2)
156#define IRPLIB_GAIN_NO_COLLAPSE ((irplib_gain_flag) 1 << 3)
157#define IRPLIB_GAIN_COLLAPSE ((irplib_gain_flag) 1 << 4)
158#define IRPLIB_GAIN_WITH_AUTOCORR ((irplib_gain_flag) 1 << 5)
159#define IRPLIB_GAIN_WITH_RESCALE ((irplib_gain_flag) 1 << 6)
160#define IRPLIB_GAIN_OPT ((irplib_gain_flag) 1 << 7)
161#define IRPLIB_GAIN_NIR ((irplib_gain_flag) 1 << 8)
163typedef unsigned long irplib_lin_flag;
165#define IRPLIB_LIN_NO_COLLAPSE ((irplib_lin_flag) 1 << 10)
166#define IRPLIB_LIN_COLLAPSE ((irplib_lin_flag) 1 << 11)
167#define IRPLIB_LIN_PIX2PIX ((irplib_lin_flag) 1 << 12)
168#define IRPLIB_LIN_WITH_RESCALE ((irplib_lin_flag) 1 << 13)
169#define IRPLIB_LIN_OPT ((irplib_lin_flag) 1 << 14)
170#define IRPLIB_LIN_NIR ((irplib_lin_flag) 1 << 15)
177detmon_lg(cpl_frameset * frameset,
178 const cpl_parameterlist * parlist,
180 const char * tag_off,
181 const char * recipe_name,
182 const char * pipeline_name,
183 const char * pafregexp,
184 const cpl_propertylist * pro_lintbl,
185 const cpl_propertylist * pro_gaintbl,
186 const cpl_propertylist * pro_coeffscube,
187 const cpl_propertylist * pro_bpm,
188 const cpl_propertylist * pro_corr,
189 const cpl_propertylist * pro_diff,
190 const char * package,
191 int (* compare) (
const cpl_frame *,
193 int (* load_fset) (
const cpl_frameset *,
196 const cpl_boolean opt_nir);
199cpl_image * detmon_image_correlate(
const cpl_image *,
205detmon_lg_fill_parlist_nir_default(cpl_parameterlist *,
210detmon_lg_fill_parlist_nir_default_mr(cpl_parameterlist * parlist,
211 const char *recipe_name,
212 const char *pipeline_name);
215detmon_lg_fill_parlist_opt_default(cpl_parameterlist *,
220detmon_lg_fill_parlist_opt_default_mr(cpl_parameterlist * parlist,
221 const char *recipe_name,
222 const char *pipeline_name);
225detmon_lg_fill_parlist(cpl_parameterlist * parlist,
226 const char *recipe_name,
const char *pipeline_name,
236 const char * intermediate,
237 const char * autocorr,
238 const char * collapse,
239 const char * rescale,
240 const char * pix2pix,
247 const char * pafname,
269 cpl_boolean opt_nir);
272detmon_autocorrelate(
const cpl_image *,
273 const int,
const int);
276detmon_gain(
const cpl_imagelist *,
277 const cpl_imagelist *,
295detmon_lin(
const cpl_imagelist *,
296 const cpl_imagelist *,
313detmon_lg_set_tag(cpl_frameset* set,
const char** tag_on,
const char** tag_off);