ERIS Pipeline Reference Manual 1.9.2
eris_nix_pupil.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_pupil_description[] =
61"This recipe performs QC on "
62ERIS_NIX_RAW_PUPIL_LAMP_OPEN_DO_CATG",\n"
63ERIS_NIX_RAW_PUPIL_LAMP_MASK_DO_CATG" and "
64ERIS_NIX_RAW_PUPIL_SKY_OPEN_DO_CATG" and "
65ERIS_NIX_RAW_PUPIL_SKY_MASK_DO_CATG" and "
66ERIS_NIX_RAW_PUPIL_BKG_OPEN_DO_CATG" and "
67ERIS_NIX_RAW_PUPIL_BKG_MASK_DO_CATG" and "
68ERIS_NIX_RAW_PUPIL_DARK_OPEN_DO_CATG" and"
69ERIS_NIX_RAW_PUPIL_DARK_MASK_DO_CATG" frames. "
70"This comprises dark subtraction,\n"
71"linearization, flat-fielding, association with the master \n"
72"bad-pixel mask, and correction of image rotation.\n"
73"\n"
74"Input files:\n"
75"\n"
76" DO CATG Explanation Req. #Frames\n"
77" ------- ----------- --- -------\n"
78" "ERIS_NIX_RAW_PUPIL_LAMP_DO_CATG
79 " pupil lamp frames N 0-n\n"
80" "ERIS_NIX_RAW_PUPIL_SKY_DO_CATG
81 " pupil sky frames N 0-n\n"
82" "ERIS_NIX_RAW_PUPIL_BKG_DO_CATG
83 " pupil bkg frames N 0-n\n"
84" "ERIS_NIX_RAW_PUPIL_DARK_DO_CATG
85 " pupil dark frames N 0-n\n"
86
87" "ERIS_NIX_MASTER_DARK_IMG_PRO_CATG
88 " a MASTER_DARK with Y 1\n"
89" matching detector \n"
90" configuration\n"
91" "ERIS_NIX_MASTER_BPM_LAMP_PRO_CATG
92 " a lamp MASTER_BPM Y 1\n"
93" or\n"
94" "ERIS_NIX_MASTER_BPM_SKY_PRO_CATG
95 " a sky MASTER_BPM Y 1\n"
96" "ERIS_NIX_MASTER_FLAT_LAMP_HIFREQ_PRO_CATG
97 " a lamp hifreq flat N 0 or 1\n"
98" matching observing \n"
99" configuration\n"
100" "ERIS_NIX_MASTER_FLAT_SKY_HIFREQ_PRO_CATG
101 " a sky hifreq flat N 0 or 1\n"
102" matching observing \n"
103" configuration\n"
104" "ERIS_NIX_MASTER_FLAT_LAMP_LOFREQ_PRO_CATG
105 " a lamp hifreq flat N 0 or 1\n"
106" matching observing \n"
107" configuration\n"
108" "ERIS_NIX_MASTER_FLAT_SKY_LOFREQ_PRO_CATG
109 " a sky hifreq flat N 0 or 1\n"
110" matching observing \n"
111" configuration\n"
112" "ERIS_NIX_MASTER_FLAT_TWILIGHT_LOFREQ_PRO_CATG"\n"
113" a twilight lofreq flat N 0 or 1\n"
114" matching observing \n"
115" configuration (preferred\n"
116" over the LAMP version\n"
117" below)\n"
118" "ERIS_NIX_GAIN_PRO_CATG
119 " DETMON gain information N 0 or 1\n"
120" e.g. in file \n"
121" detmon_ir_lg_gain_table.fits\n"
122" "ERIS_NIX_COEFFS_CUBE_PRO_CATG
123 " DETMON linearity curves N 0 or 1\n"
124" e.g. in file \n"
125" detmon_ir_coeffs_cube.fits\n"
126" "ERIS_NIX_NL_BPM_PRO_CATG
127 " DETMON non-linear bpm N 0 or 1\n"
128" e.g. in file \n"
129" detmon_ir_lg_bpm.fits\n"
130" "ERIS_NIX_WCS_REFINE_PRO_CATG
131 " NIX wcs refinement file N 0 or 1\n"
132" with updated CD-matrix\n"
133" to correct image \n"
134" rotation\n"
135"\n"
136"Output files:\n"
137"\n"
138" DO CATG Explanation \n"
139" ------- ----------- \n"
140" PREF_OPEN, PREF_JHK, PREF_CROSS, PREF_SAM (PREF=PUPIL_LAMP, PUPIL_SKY_PUPIL_DARK or PUPIL_BKG)"
141 " Calibrated results (detector signature removed).\n"
142"\n"
143" The output will be a FITS file named 'cal_det_<inputname>.fits',\n"
144" with extensions:\n"
145" - DATA the result data.\n"
146" - ERR the result error plane.\n"
147" - DQ the result data quality plane.\n"
148" - CONFIDENCE the result confidence plane.\n"
149"\n";
150
151#define RECIPE_NAME "eris_nix_pupil"
152#define CONTEXT "eris."RECIPE_NAME
153/*-----------------------------------------------------------------------------
154 Private function prototypes
155 -----------------------------------------------------------------------------*/
156
157cpl_recipe_define(eris_nix_pupil, ERIS_BINARY_VERSION,
158 "Andrea Modigliani, John Lightfoot",
159 PACKAGE_BUGREPORT, "2017",
160 "Remove detector signature from PUPIL frames",
161 eris_nix_pupil_description);
162
163/*-----------------------------------------------------------------------------
164 Function code
165 -----------------------------------------------------------------------------*/
166
167/*----------------------------------------------------------------------------*/
175/*----------------------------------------------------------------------------*/
176
177static cpl_error_code eris_nix_pupil_fill_parameterlist(
178 cpl_parameterlist * self) {
179
180 if (cpl_error_get_code() != CPL_ERROR_NONE) return cpl_error_get_code();
181
182 cpl_parameter* p;
183
184 p = cpl_parameter_new_enum(CONTEXT".fill-rejected",
185 CPL_TYPE_STRING,
186 "how to treat reject pixel",
187 CONTEXT,
188 "set_value", 3,
189 "set_value",
190 "set_NaN",
191 "noop");
192 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fill-rejected");
193 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
194 cpl_parameterlist_append(self, p);
195
196 p = cpl_parameter_new_value(CONTEXT".fill-value",
197 CPL_TYPE_DOUBLE,
198 "value to use in 'set_value' case",
199 CONTEXT, 0.0);
200 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fill-value");
201 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
202 cpl_parameterlist_append(self, p);
203
204 /* Flag to decide whether to apply corrected CD matrices to data */
205
206 p = cpl_parameter_new_value(CONTEXT".cd_matrix_modify",
207 CPL_TYPE_BOOL,
208 "TRUE to insert corrected CD-matrix",
209 CONTEXT, CPL_FALSE);
210 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cd-matrix-modify");
211 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
212 cpl_parameterlist_append(self, p);
213
214 // coords of pixel to be used for diagnostics during reduction
215 eris_nix_pixel_coord_diagnostic_param_set(CONTEXT, self);
216
217 p = cpl_parameter_new_range(CONTEXT".collapse_cube", CPL_TYPE_INT,
218 "May collapse cube if DET.FRAM.FORMAT is cube. Possible values: "
219 "0, no collapse; 1, mean collapse; 2, median collapse;"
220 "3, weighted mean",
221 CONTEXT, 0, 0, 3);
222 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "collapse-cube");
223 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
224 cpl_parameterlist_append(self, p);
225
226 return 0;
227}
228
229
230/*----------------------------------------------------------------------------*/
237/*----------------------------------------------------------------------------*/
238
239static int eris_nix_pupil(cpl_frameset * frameset,
240 const cpl_parameterlist * parlist) {
241
242 eris_nix_scired_cal_det(frameset, parlist, RECIPE_NAME, CONTEXT);
243
244 return (int) cpl_error_get_code();
245}
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.