ERIS Pipeline Reference Manual 1.9.2
eris_nix_cal_det.c
1/* $Id$
2 *
3 * This file is part of the ERIS Pipeline
4 * Copyright (C) 2017 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 02110-1301 USA
19 */
20
21/*
22 * $Author$
23 * $Date$
24 * $Revision$
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35//#include <libgen.h>
36//#include <math.h>
37//#include <string.h>
38
39//#include "casu_utils.h"
40//#include "casu_mods.h"
41
42//#include "eris_utils.h"
43//#include "eris_nix_utils.h"
44//#include "eris_pfits.h"
45//#include "eris_dfs.h"
46#include "eris_nix_dfs.h"
47//#include "eris_nix_master_bpm.h"
48//#include "eris_nix_master_dark.h"
49//#include "eris_nix_gain_linearity.h"
50
51#include "eris_nix_scired.h"
52//#include <hdrl.h>
53
54#include <cpl.h>
55
56/*-----------------------------------------------------------------------------
57 Static variables
58 -----------------------------------------------------------------------------*/
59
60static const char eris_nix_cal_det_description[] =
61"This recipe removes the detector signature from "
62ERIS_NIX_RAW_OBJECT_JITTER_DO_CATG",\n"
63ERIS_NIX_RAW_SKY_JITTER_DO_CATG" and "
64ERIS_NIX_RAW_STD_JITTER_DO_CATG" frames. "
65"This comprises dark subtraction,\n"
66"linearization, flat-fielding, association with the master \n"
67"bad-pixel mask, and correction of image rotation.\n"
68"\n"
69"Input files:\n"
70"\n"
71" DO CATG Explanation Req. #Frames\n"
72" ------- ----------- --- -------\n"
73" "ERIS_NIX_RAW_OBJECT_JITTER_DO_CATG
74 " object jitter frames N 0-n\n"
75" "ERIS_NIX_RAW_SKY_JITTER_DO_CATG
76 " offset sky jitter N 0-n\n"
77" frames\n"
78" "ERIS_NIX_RAW_STD_JITTER_DO_CATG
79 " standard jitter N 0-n\n"
80" frames\n"
81" "ERIS_NIX_RAW_OBJECT_LSS_JITTER_DO_CATG
82 " object LSS jitter N 0-n\n"
83" frames\n"
84" "ERIS_NIX_RAW_SKY_LSS_JITTER_DO_CATG
85 " sky LSS jitter N 0-n\n"
86" frames\n"
87" "ERIS_NIX_RAW_STD_LSS_JITTER_DO_CATG
88 " standard LSS jitter N 0-n\n"
89" frames\n"
90" "ERIS_NIX_MASTER_DARK_IMG_PRO_CATG
91 " a MASTER_DARK with Y 1\n"
92" matching detector \n"
93" configuration\n"
94" "ERIS_NIX_MASTER_BPM_LAMP_PRO_CATG
95 " a lamp MASTER_BPM Y 1\n"
96" or\n"
97" "ERIS_NIX_MASTER_BPM_SKY_PRO_CATG
98 " a sky MASTER_BPM Y 1\n"
99" "ERIS_NIX_MASTER_FLAT_LAMP_HIFREQ_PRO_CATG
100 " a lamp hifreq flat N 0 or 1\n"
101" matching observing \n"
102" configuration\n"
103" "ERIS_NIX_MASTER_FLAT_SKY_HIFREQ_PRO_CATG
104 " a sky hifreq flat N 0 or 1\n"
105" matching observing \n"
106" configuration\n"
107" "ERIS_NIX_MASTER_FLAT_LAMP_LOFREQ_PRO_CATG
108 " a lamp hifreq flat N 0 or 1\n"
109" matching observing \n"
110" configuration\n"
111" "ERIS_NIX_MASTER_FLAT_SKY_LOFREQ_PRO_CATG
112 " a sky hifreq flat N 0 or 1\n"
113" matching observing \n"
114" configuration\n"
115" "ERIS_NIX_MASTER_FLAT_TWILIGHT_LOFREQ_PRO_CATG"\n"
116" a twilight lofreq flat N 0 or 1\n"
117" matching observing \n"
118" configuration (preferred\n"
119" over the LAMP version\n"
120" below)\n"
121" "ERIS_NIX_GAIN_PRO_CATG
122 " DETMON gain information N 0 or 1\n"
123" e.g. in file \n"
124" detmon_ir_lg_gain_table.fits\n"
125" "ERIS_NIX_COEFFS_CUBE_PRO_CATG
126 " DETMON linearity curves N 0 or 1\n"
127" e.g. in file \n"
128" detmon_ir_coeffs_cube.fits\n"
129" "ERIS_NIX_NL_BPM_PRO_CATG
130 " DETMON non-linear bpm N 0 or 1\n"
131" e.g. in file \n"
132" detmon_ir_lg_bpm.fits\n"
133" "ERIS_NIX_WCS_REFINE_PRO_CATG
134 " NIX wcs refinement file N 0 or 1\n"
135" with updated CD-matrix\n"
136" to correct image \n"
137" rotation\n"
138"\n"
139"Output files:\n"
140"\n"
141" DO CATG Explanation \n"
142" ------- ----------- \n"
143" "ERIS_NIX_CAL_DET_OBJECT_JITTER_PRO_CATG
144 " Calibrated results.\n"
145" or "ERIS_NIX_CAL_DET_SKY_JITTER_PRO_CATG"\n"
146" or "ERIS_NIX_CAL_DET_STD_JITTER_PRO_CATG"\n"
147" or "ERIS_NIX_CAL_DET_OBJECT_LSS_JITTER_PRO_CATG"\n"
148" or "ERIS_NIX_CAL_DET_SKY_LSS_JITTER_PRO_CATG"\n"
149" or "ERIS_NIX_CAL_DET_STD_LSS_JITTER_PRO_CATG"\n"
150"\n"
151" The output will be a FITS file named 'cal_det_<inputname>.fits',\n"
152" with extensions:\n"
153" - DATA the result data.\n"
154" - ERR the result error plane.\n"
155" - DQ the result data quality plane.\n"
156" - CONFIDENCE the result confidence plane.\n"
157"\n";
158
159#define RECIPE_NAME "eris_nix_cal_det"
160#define CONTEXT "eris."RECIPE_NAME
161/*-----------------------------------------------------------------------------
162 Private function prototypes
163 -----------------------------------------------------------------------------*/
164
165cpl_recipe_define(eris_nix_cal_det, ERIS_BINARY_VERSION,
166 "John Lightfoot",
167 PACKAGE_BUGREPORT, "2017",
168 "Remove detector signature from frames",
169 eris_nix_cal_det_description);
170
171/*-----------------------------------------------------------------------------
172 Function code
173 -----------------------------------------------------------------------------*/
174
175/*----------------------------------------------------------------------------*/
183/*----------------------------------------------------------------------------*/
184
185static cpl_error_code eris_nix_cal_det_fill_parameterlist(
186 cpl_parameterlist * self) {
187
188 if (cpl_error_get_code() != CPL_ERROR_NONE) return cpl_error_get_code();
189
190 cpl_parameter* p;
191
192 p = cpl_parameter_new_enum(CONTEXT".fill-rejected",
193 CPL_TYPE_STRING,
194 "how to treat reject pixel",
195 CONTEXT,
196 "set_value", 3,
197 "set_value",
198 "set_NaN",
199 "noop");
200 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fill-rejected");
201 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
202 cpl_parameterlist_append(self, p);
203
204 p = cpl_parameter_new_value(CONTEXT".fill-value",
205 CPL_TYPE_DOUBLE,
206 "value to use in 'set_value' case",
207 CONTEXT, 0.0);
208 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fill-value");
209 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
210 cpl_parameterlist_append(self, p);
211
212 /* Flag to decide whether to apply corrected CD matrices to data */
213
214 p = cpl_parameter_new_value(CONTEXT".cd_matrix_modify",
215 CPL_TYPE_BOOL,
216 "TRUE to insert corrected CD-matrix",
217 CONTEXT, CPL_TRUE);
218 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cd-matrix-modify");
219 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
220 cpl_parameterlist_append(self, p);
221
222 // coords of pixel to be used for diagnostics during reduction
223 eris_nix_pixel_coord_diagnostic_param_set(CONTEXT, self);
224
225 p = cpl_parameter_new_range(CONTEXT".collapse_cube", CPL_TYPE_INT,
226 "May collapse cube if DET.FRAM.FORMAT is cube. Possible values: "
227 "0, no collapse; 1, mean collapse; 2, median collapse;"
228 "3, weighted mean",
229 CONTEXT, 0, 0, 3);
230 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "collapse-cube");
231 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
232 cpl_parameterlist_append(self, p);
233
234 return 0;
235}
236
237
238/*----------------------------------------------------------------------------*/
245/*----------------------------------------------------------------------------*/
246
247static int eris_nix_cal_det(cpl_frameset * frameset,
248 const cpl_parameterlist * parlist) {
249
250 eris_nix_scired_cal_det(frameset, parlist, RECIPE_NAME, CONTEXT);
251
252 return (int) cpl_error_get_code();
253}
cpl_error_code eris_nix_scired_cal_det(cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *context)
This function removes the detector signature from science frames.