X-shooter Pipeline Reference Manual 3.8.15
xsh_detmon_lg.h
Go to the documentation of this file.
1/* $Id: xsh_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 XSH_IRPLIB_DETMON_LG_H
29#define XSH_IRPLIB_DETMON_LG_H
30
31/*----------------------------------------------------------------------------
32 Includes
33 ----------------------------------------------------------------------------*/
34
35#include <cpl.h>
36#include <xsh_cpl_size.h>
37
38/*----------------------------------------------------------------------------
39 Prototypes
40 ----------------------------------------------------------------------------*/
41/* Define here the DO.CATG keywords */
42#define DETMON_LG_ON_RAW_OLD "ON_RAW"
43#define DETMON_LG_OFF_RAW_OLD "OFF_RAW"
44#define DETMON_LG_ON_RAW_NEW "DETMON_LAMP_ON"
45#define DETMON_LG_OFF_RAW_NEW "DETMON_LAMP_OFF"
46
47
48#define NIR TRUE
49#define OPT FALSE
50
51#define DETMON_QC_COUNTS_MIN "ESO QC COUNTS MIN"
52#define DETMON_QC_COUNTS_MIN_C "Minimum median value used in linearity test (in a user defined region) [ADU]"
53
54#define DETMON_QC_COUNTS_MAX "ESO QC COUNTS MAX"
55#define DETMON_QC_COUNTS_MAX_C "Maximum median value used in linearity test (in a user defined region) [ADU]"
56
57#define DETMON_QC_CONAD "ESO QC CONAD"
58#define DETMON_QC_CONAD_C "Conversion from e- to ADUs [ADU/e-]"
59
60#define DETMON_QC_CONAD_CORR "ESO QC CONAD CORR"
61#define DETMON_QC_CONAD_CORR_C "CONAD value taken QC.AUTOCORR into account [ADU/e-]"
62
63#define DETMON_QC_GAIN "ESO QC GAIN"
64#define DETMON_QC_GAIN_C "GAIN (see QC.METHOD) [e-/ADU]"
65
66#define DETMON_QC_GAIN_MSE "ESO QC GAIN MSE"
67#define DETMON_QC_GAIN_MSE_C "Measured Squared error in GAIN computation"
68
69#define DETMON_QC_RON "ESO QC RON"
70#define DETMON_QC_RON_C "RON obtained as independent term (PTC method)"
71
72#define DETMON_QC_AUTOCORR "ESO QC AUTOCORR"
73#define DETMON_QC_AUTOCORR_C "Autocorrelation factor computed as sum of " \
74 "all pixels in autocorrelation image"
75#define DETMON_QC_GAIN_CORR "ESO QC GAIN CORR"
76#define DETMON_QC_GAIN_CORR_C "GAIN taken QC.AUTOCORR into account [e-/ADU]"
77
78#define DETMON_QC_LAMP_FLUX "ESO QC LAMP FLUX"
79#define DETMON_QC_LAMP_FLUX_C "Lamp flux"
80
81#define DETMON_QC_NUM_BPM "ESO QC NUM BPM"
82#define DETMON_QC_NUM_BPM_C "Number of bad pixels detected according to "\
83 "polynomial information"
84
85#define DETMON_QC_LAMP_STAB "ESO QC LAMP STAB"
86#define DETMON_QC_LAMP_STAB_C "Lamp stability"
87
88#define DETMON_QC_METHOD "ESO QC METHOD"
89#define DETMON_QC_METHOD_C "Method applied to compute GAIN"
90
91#define DETMON_QC_LIN_EFF "ESO QC LIN EFF"
92#define DETMON_QC_LIN_EFF_C "Effective non-linearity correction"
93
94#define DETMON_QC_LIN_EFF_FLUX "ESO QC LIN EFF FLUX"
95#define DETMON_QC_LIN_EFF_FLUX_C "FLux level at which effective non-linearity correction is computed"
96
97#define DETMON_QC_LIN_COEF "ESO QC LIN COEF"
98#define DETMON_QC_LIN_COEF_C "Linearity coefficient value"
99
100
101#define DETMON_QC_LIN_COEF_ERR "ESO QC LIN EFF ERR"
102#define DETMON_QC_LIN_COEF_ERR_C "Linearity coefficient error value"
103#define DETMON_QC_LIN_COEF_MSE_ERR_C "Linearity coefficient measured square error value"
104
105
106#define DETMON_QC_ERRFIT "ESO QC ERRFIT"
107#define DETMON_QC_ERRFIT_C "Error of fit"
108#define DETMON_QC_ERRFIT_MSE_C "Measured square error of fit"
109
110
111#define DETMON_QC_CONTAM "ESO QC CONTAM"
112#define DETMON_QC_CONTAM_C "Detector contamination in a region"
113
114#define DETMON_QC_FPN "ESO QC FPN"
115#define DETMON_QC_FPN_C "Flat pattern noise"
116
117/* Macros to generate the recipe(s) description(s) */
118#define xsh_detmon_lg_get_description(RECIPE_NAME, PIPE_NAME, \
119 DETMON_LG_ON_RAW_NEW, \
120 DETMON_LG_OFF_RAW_NEW, \
121 DETMON_LG_ON_RAW_OLD, \
122 DETMON_LG_OFF_RAW_OLD) \
123 RECIPE_NAME " -- " PIPE_NAME " linearity/gain recipe for OPT/IR.\n" \
124 "The files listed in the Set Of Frames must be tagged:\n" \
125 "the raw-on-file.fits "DETMON_LG_ON_RAW_NEW" and\n" \
126 "the raw-off-file.fits "DETMON_LG_OFF_RAW_NEW"\n" \
127 "For backward compatibility are alternatively still supported the following tags:\n" \
128 "the raw-on-file.fits "DETMON_LG_ON_RAW_OLD" and\n" \
129 "the raw-off-file.fits "DETMON_LG_OFF_RAW_OLD"\n" \
130 "The recipe requires at least order+1 valid pairs of ON frames\n" \
131 "and order+1 valid pairs of OFF frames, \n" \
132 "where order is the value of the 'order' parameter.\n" \
133 "There is no requirement for pairs of OFF frames if collapse parameter " \
134 "is set to true.\n" \
135 "Frames with median flux over --filter will be excluded from the " \
136 "computation.\n" \
137 "To perform a stability check you need frames with at least 2 DIT " \
138 "values\n" \
139 "NOTE for multiextension cases: it is mandatory to modify the --exts " \
140 "parameter, either to -1 (all extensions) or to any valid extension nb.\n" \
141 "\n" \
142 "The output PRO.CATG are:\n" \
143 "GAIN_INFO - the gain table\n" \
144 "DET_LIN_INFO - the linearity table\n" \
145 "BP_MAP_NL - the bad pixel map (only produced with --pix2pix=TRUE)\n" \
146 "COEFFS_CUBE - the fit coefficient cube (only produced with --pix2pix=TRUE)\n"
147
148#define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
149
150typedef unsigned long irplib_gain_flag;
151
152#define IRPLIB_GAIN_PTC ((irplib_gain_flag) 1 << 1)
153#define IRPLIB_GAIN_MEDIAN ((irplib_gain_flag) 1 << 2)
154#define IRPLIB_GAIN_NO_COLLAPSE ((irplib_gain_flag) 1 << 3)
155#define IRPLIB_GAIN_COLLAPSE ((irplib_gain_flag) 1 << 4)
156#define IRPLIB_GAIN_WITH_AUTOCORR ((irplib_gain_flag) 1 << 5)
157#define IRPLIB_GAIN_WITH_RESCALE ((irplib_gain_flag) 1 << 6)
158#define IRPLIB_GAIN_OPT ((irplib_gain_flag) 1 << 7)
159#define IRPLIB_GAIN_NIR ((irplib_gain_flag) 1 << 8)
160
161typedef unsigned long irplib_lin_flag;
162
163#define IRPLIB_LIN_NO_COLLAPSE ((irplib_lin_flag) 1 << 10)
164#define IRPLIB_LIN_COLLAPSE ((irplib_lin_flag) 1 << 11)
165#define IRPLIB_LIN_PIX2PIX ((irplib_lin_flag) 1 << 12)
166#define IRPLIB_LIN_WITH_RESCALE ((irplib_lin_flag) 1 << 13)
167#define IRPLIB_LIN_OPT ((irplib_lin_flag) 1 << 14)
168#define IRPLIB_LIN_NIR ((irplib_lin_flag) 1 << 15)
169
170/*----------------------------------------------------------------------------
171 Prototypes
172 ----------------------------------------------------------------------------*/
173
174cpl_error_code
175xsh_detmon_lg(cpl_frameset * frameset,
176 const cpl_parameterlist * parlist,
177 const char * tag_on,
178 const char * tag_off,
179 const char * recipe_name,
180 const char * pipeline_name,
181 const char * pafregexp,
182 const cpl_propertylist * pro_lintbl,
183 const cpl_propertylist * pro_gaintbl,
184 const cpl_propertylist * pro_coeffscube,
185 const cpl_propertylist * pro_bpm,
186 const cpl_propertylist * pro_corr,
187 const cpl_propertylist * pro_diff,
188 const char * package,
189 int (* compare) (const cpl_frame *,
190 const cpl_frame *),
191 int (* load_fset) (const cpl_frameset *,
192 cpl_type,
193 cpl_imagelist *),
194 const cpl_boolean opt_nir);
195
196
197cpl_image * xsh_detmon_image_correlate(const cpl_image *,
198 const cpl_image *,
199 const int ,
200 const int );
201
202cpl_error_code
204 const char *,
205 const char *);
206
207cpl_error_code
208xsh_detmon_lg_fill_parlist_nir_default_mr(cpl_parameterlist * parlist,
209 const char *recipe_name,
210 const char *pipeline_name);
211
212cpl_error_code
214 const char *,
215 const char *);
216
217cpl_error_code
218xsh_detmon_lg_fill_parlist_opt_default_mr(cpl_parameterlist * parlist,
219 const char *recipe_name,
220 const char *pipeline_name);
221
222cpl_error_code
223xsh_detmon_lg_fill_parlist(cpl_parameterlist * parlist,
224 const char *recipe_name, const char *pipeline_name,
225 const char *method,
226 int order,
227 double kappa,
228 int niter,
229 int llx,
230 int lly,
231 int urx,
232 int ury,
233 int ref_level,
234 const char * intermediate,
235 const char * autocorr,
236 const char * collapse,
237 const char * rescale,
238 const char * pix2pix,
239 const char * bpmbin,
240 int filter,
241 int m,
242 int n,
243 double tolerance,
244 const char * pafgen,
245 const char * pafname,
246 int llx1,
247 int lly1,
248 int urx1,
249 int ury1,
250 int llx2,
251 int lly2,
252 int urx2,
253 int ury2,
254 int llx3,
255 int lly3,
256 int urx3,
257 int ury3,
258 int llx4,
259 int lly4,
260 int urx4,
261 int ury4,
262 int llx5,
263 int lly5,
264 int urx5,
265 int ury5,
266 int exts,
267 cpl_boolean opt_nir);
268
269cpl_image *
270xsh_detmon_autocorrelate(const cpl_image *,
271 const int, const int);
272
273cpl_table *
274xsh_detmon_gain(const cpl_imagelist *,
275 const cpl_imagelist *,
276 const cpl_vector *,
277 const cpl_vector *,
278 double ,
279 int ,
280 int ,
281 int ,
282 int ,
283 double ,
284 int ,
285 int ,
286 int ,
287 cpl_propertylist *,
288 unsigned ,
289 cpl_imagelist **,
290 cpl_imagelist **);
291
292cpl_table *
293xsh_detmon_lin(const cpl_imagelist *,
294 const cpl_imagelist *,
295 const cpl_vector *,
296 double ,
297 int ,
298 int ,
299 int ,
300 int ,
301 int ,
302 int ,
303 double,
304 cpl_boolean,
305 cpl_propertylist *,
306 unsigned ,
307 cpl_imagelist **,
308 cpl_image **);
309
310cpl_error_code
311xsh_detmon_lg_set_tag(cpl_frameset* set, const char** tag_on, const char** tag_off);
312#endif
cpl_boolean opt_nir
Definition: xsh_detmon.c:100
int exts
Definition: xsh_detmon.c:98
double kappa
Definition: xsh_detmon_lg.c:81
const char * pafname
int ref_level
Definition: xsh_detmon_lg.c:89
int llx1
Definition: xsh_detmon_lg.c:93
int urx5
int niter
Definition: xsh_detmon_lg.c:82
cpl_boolean bpmbin
int(* load_fset)(const cpl_frameset *, cpl_type, cpl_imagelist *)
cpl_boolean autocorr
cpl_boolean pafgen
int lly
Definition: xsh_detmon_lg.c:86
int lly5
int lly3
cpl_boolean rescale
int ury2
int llx2
Definition: xsh_detmon_lg.c:97
int ury5
int llx
Definition: xsh_detmon_lg.c:85
int m
Definition: xsh_detmon_lg.c:91
int n
Definition: xsh_detmon_lg.c:92
cpl_boolean intermediate
const char * method
Definition: xsh_detmon_lg.c:78
int urx
Definition: xsh_detmon_lg.c:87
double tolerance
int ury
Definition: xsh_detmon_lg.c:88
int urx2
Definition: xsh_detmon_lg.c:99
int lly4
int llx4
int ury3
int urx1
Definition: xsh_detmon_lg.c:95
int lly2
Definition: xsh_detmon_lg.c:98
int llx3
int order
Definition: xsh_detmon_lg.c:80
int ury4
int lly1
Definition: xsh_detmon_lg.c:94
cpl_boolean collapse
int urx3
int ury1
Definition: xsh_detmon_lg.c:96
int urx4
int filter
int llx5
cpl_boolean pix2pix
cpl_error_code xsh_detmon_lg_fill_parlist(cpl_parameterlist *parlist, const char *recipe_name, const char *pipeline_name, const char *method, int order, double kappa, int niter, int llx, int lly, int urx, int ury, int ref_level, const char *intermediate, const char *autocorr, const char *collapse, const char *rescale, const char *pix2pix, const char *bpmbin, int filter, int m, int n, double tolerance, const char *pafgen, const char *pafname, int llx1, int lly1, int urx1, int ury1, int llx2, int lly2, int urx2, int ury2, int llx3, int lly3, int urx3, int ury3, int llx4, int lly4, int urx4, int ury4, int llx5, int lly5, int urx5, int ury5, int exts, cpl_boolean opt_nir)
Generic parlist filling for Lin/Gain recipe.
cpl_error_code xsh_detmon_lg_fill_parlist_opt_default(cpl_parameterlist *, const char *, const char *)
Parlist filling with OPT required parameters and its default values.
unsigned long irplib_lin_flag
cpl_error_code xsh_detmon_lg_fill_parlist_nir_default_mr(cpl_parameterlist *parlist, const char *recipe_name, const char *pipeline_name)
cpl_error_code xsh_detmon_lg_fill_parlist_nir_default(cpl_parameterlist *, const char *, const char *)
Parlist filling with NIR required parameters and its default values.
cpl_error_code xsh_detmon_lg_set_tag(cpl_frameset *set, const char **tag_on, const char **tag_off)
cpl_table * xsh_detmon_gain(const cpl_imagelist *, const cpl_imagelist *, const cpl_vector *, const cpl_vector *, double, int, int, int, int, double, int, int, int, cpl_propertylist *, unsigned, cpl_imagelist **, cpl_imagelist **)
Gain computation.
cpl_image * xsh_detmon_image_correlate(const cpl_image *, const cpl_image *, const int, const int)
cpl_image * xsh_detmon_autocorrelate(const cpl_image *, const int, const int)
cpl_error_code xsh_detmon_lg_fill_parlist_opt_default_mr(cpl_parameterlist *parlist, const char *recipe_name, const char *pipeline_name)
unsigned long irplib_gain_flag
cpl_error_code xsh_detmon_lg(cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *tag_on, const char *tag_off, const char *recipe_name, const char *pipeline_name, const char *pafregexp, const cpl_propertylist *pro_lintbl, const cpl_propertylist *pro_gaintbl, const cpl_propertylist *pro_coeffscube, const cpl_propertylist *pro_bpm, const cpl_propertylist *pro_corr, const cpl_propertylist *pro_diff, const char *package, int(*compare)(const cpl_frame *, const cpl_frame *), int(*load_fset)(const cpl_frameset *, cpl_type, cpl_imagelist *), const cpl_boolean opt_nir)
cpl_table * xsh_detmon_lin(const cpl_imagelist *, const cpl_imagelist *, const cpl_vector *, double, int, int, int, int, int, int, double, cpl_boolean, cpl_propertylist *, unsigned, cpl_imagelist **, cpl_image **)
Linearity computation.