ERIS Pipeline Reference Manual 1.8.15
detmon_lg.h
1/* $Id: detmon_lg.h,v 1.4 2013-06-18 13:34:19 jtaylor Exp $
2 *
3 * This file is part of the irplib package
4 * Copyright (C) 2002, 2003 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: jtaylor $
23 * $Date: 2013-06-18 13:34:19 $
24 * $Revision: 1.4 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifndef IRPLIB_DETMON_LG_H
29#define IRPLIB_DETMON_LG_H
30
31/*----------------------------------------------------------------------------
32 Includes
33 ----------------------------------------------------------------------------*/
34
35#include <cpl.h>
36
37/*----------------------------------------------------------------------------
38 Defines
39 ----------------------------------------------------------------------------*/
40/* Define here the DO.CATG keywords */
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"
45
46
47#define NIR TRUE
48#define OPT FALSE
49
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]"
52
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]"
55
56#define DETMON_QC_CONAD "ESO QC CONAD"
57#define DETMON_QC_CONAD_C "[ADU/e-] Conversion from e- to ADUs"
58
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"
61
62#define DETMON_QC_GAIN "ESO QC GAIN"
63#define DETMON_QC_GAIN_C "[e-/ADU] GAIN (see QC.METHOD)"
64
65#define DETMON_QC_GAIN_ERR "ESO QC GAIN ERR"
66#define DETMON_QC_GAIN_ERR_C "[e-/ADU] Error on GAIN"
67
68#define DETMON_QC_GAIN_MSE "ESO QC GAIN MSE"
69#define DETMON_QC_GAIN_MSE_C "Measured Squared error in GAIN computation"
70
71#define DETMON_QC_RON "ESO QC RON"
72#define DETMON_QC_RON_C "RON obtained as independent term (PTC method)"
73
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"
79
80#define DETMON_QC_LAMP_FLUX "ESO QC LAMP FLUX"
81#define DETMON_QC_LAMP_FLUX_C "Lamp flux"
82
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"
86
87#define DETMON_QC_LAMP_STAB "ESO QC LAMP STAB"
88#define DETMON_QC_LAMP_STAB_C "Lamp stability"
89
90#define DETMON_QC_METHOD "ESO QC METHOD"
91#define DETMON_QC_METHOD_C "Method applied to compute GAIN"
92
93#define DETMON_QC_LIN_EFF "ESO QC LIN EFF"
94#define DETMON_QC_LIN_EFF_C "Effective non-linearity correction"
95
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"
98
99#define DETMON_QC_LIN_COEF "ESO QC LIN COEF"
100#define DETMON_QC_LIN_COEF_C "Linearity coefficient value"
101
102
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"
106
107
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"
111
112
113#define DETMON_QC_CONTAM "ESO QC CONTAM"
114#define DETMON_QC_CONTAM_C "Detector contamination in a region"
115
116#define DETMON_QC_FPN "ESO QC FPN"
117#define DETMON_QC_FPN_C "Flat pattern noise"
118
119/* Macros to generate the recipe(s) description(s) */
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 " \
138 "computation.\n" \
139 "To perform a stability check you need frames with at least 2 DIT " \
140 "values\n" \
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" \
143 "\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"
149
150#define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
151
152typedef unsigned long irplib_gain_flag;
153
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)
162
163typedef unsigned long irplib_lin_flag;
164
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)
171
172/*----------------------------------------------------------------------------
173 Prototypes
174 ----------------------------------------------------------------------------*/
175
176cpl_error_code
177detmon_lg(cpl_frameset * frameset,
178 const cpl_parameterlist * parlist,
179 const char * tag_on,
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 *,
192 const cpl_frame *),
193 int (* load_fset) (const cpl_frameset *,
194 cpl_type,
195 cpl_imagelist *),
196 const cpl_boolean opt_nir);
197
198
199cpl_image * detmon_image_correlate(const cpl_image *,
200 const cpl_image *,
201 const int ,
202 const int );
203
204cpl_error_code
205detmon_lg_fill_parlist_nir_default(cpl_parameterlist *,
206 const char *,
207 const char *);
208
209cpl_error_code
210detmon_lg_fill_parlist_nir_default_mr(cpl_parameterlist * parlist,
211 const char *recipe_name,
212 const char *pipeline_name);
213
214cpl_error_code
215detmon_lg_fill_parlist_opt_default(cpl_parameterlist *,
216 const char *,
217 const char *);
218
219cpl_error_code
220detmon_lg_fill_parlist_opt_default_mr(cpl_parameterlist * parlist,
221 const char *recipe_name,
222 const char *pipeline_name);
223
224cpl_error_code
225detmon_lg_fill_parlist(cpl_parameterlist * parlist,
226 const char *recipe_name, const char *pipeline_name,
227 const char *method,
228 int order,
229 double kappa,
230 int niter,
231 int llx,
232 int lly,
233 int urx,
234 int ury,
235 int ref_level,
236 const char * intermediate,
237 const char * autocorr,
238 const char * collapse,
239 const char * rescale,
240 const char * pix2pix,
241 const char * bpmbin,
242 int filter,
243 int m,
244 int n,
245 double tolerance,
246 const char * pafgen,
247 const char * pafname,
248 int llx1,
249 int lly1,
250 int urx1,
251 int ury1,
252 int llx2,
253 int lly2,
254 int urx2,
255 int ury2,
256 int llx3,
257 int lly3,
258 int urx3,
259 int ury3,
260 int llx4,
261 int lly4,
262 int urx4,
263 int ury4,
264 int llx5,
265 int lly5,
266 int urx5,
267 int ury5,
268 int exts,
269 cpl_boolean opt_nir);
270
271cpl_image *
272detmon_autocorrelate(const cpl_image *,
273 const int, const int);
274
275cpl_table *
276detmon_gain(const cpl_imagelist *,
277 const cpl_imagelist *,
278 const cpl_vector *,
279 const cpl_vector *,
280 double ,
281 int ,
282 int ,
283 int ,
284 int ,
285 double ,
286 int ,
287 int ,
288 int ,
289 cpl_propertylist *,
290 unsigned ,
291 cpl_imagelist **,
292 cpl_imagelist **);
293
294cpl_table *
295detmon_lin(const cpl_imagelist *,
296 const cpl_imagelist *,
297 const cpl_vector *,
298 double ,
299 int ,
300 int ,
301 int ,
302 int ,
303 int ,
304 int ,
305 double,
306 cpl_boolean,
307 cpl_propertylist *,
308 unsigned ,
309 cpl_imagelist **,
310 cpl_image **);
311
312cpl_error_code
313detmon_lg_set_tag(cpl_frameset* set, const char** tag_on, const char** tag_off);
314
315#endif