ERIS Pipeline Reference Manual 1.9.2
eris_ifu_pupil.c
1/* $Id: eris_ifu_recipe.c,v 1.33 2013-03-26 17:00:45 jtaylor Exp $
2 *
3 * This file is part of the ERIS Pipeline
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 02110-1301 USA
19 */
20
21/*
22 * $Author: jtaylor $
23 * $Date: 2013-03-26 17:00:45 $
24 * $Revision: 1.33 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32/*-----------------------------------------------------------------------------
33 Includes
34 -----------------------------------------------------------------------------*/
35#include <cpl.h>
36#include <string.h>
37#include <strings.h>
38#include "eris_ifu_error.h"
39#include <eris_ifu_jitter_interface.h>
40#include <eris_ifu_stdstar_static.h>
41#include <eris_ifu_jitter_static.h>
42#include <eris_ifu_lambda_corr.h>
43#include <eris_ifu_resample.h>
44#include <eris_ifu_strehl.h>
45#include <eris_ifu_extract_spec_static.h>
46#include <eris_ifu_efficiency_response.h>
47#include <eris_utils.h>
48#define M1_RADIUS 8.15
49#define M2_RADIUS 0.9
50
51/*-----------------------------------------------------------------------------
52 Static variables
53 -----------------------------------------------------------------------------*/
54#define CONTEXT "eris.eris_ifu_pupil"
55
56static const char eris_ifu_pupil_description[] = "\
57This recipe monitors the telescope pupil position.\n\
58\n\
59When an OH_SPEC file is provided in the SOF the recipe will use the OH lines\n\
60to correct the lambda calibration.\n\
61\n\
62-----------------------------------------------------------------------------\n\
63Input files:\n\
64 DO CATG Explanation Required #Frames\n\
65 ------- ----------- -------- -------\n\
66 science exposures with corresponding sky exposures: \n\
67 PUPIL_LAMP or PUPIL_SKY On exposure Y ? \n\
68 \n\
69 and calibration frames: \n\
70 DISTORTION Table with distortion correction pars. Y 1 \n\
71 WAVE_MAP Wavelength calibration map Y 1 \n\
72 OH_SPEC Vector holding OH lines (note 4) Y 1 \n\
73 MASTER_DARK Optional master dark image N [0,1]\n\
74 MASTER_FLAT Optional master flat image N [0,1]\n\
75 BPM_DARK Optional bad pixel mask (note 1 & 3) N [0,1]\n\
76 BPM_FLAT Optional bad pixel mask (note 2 & 3) N [0,1]\n\
77 BPM_LINEARITY Optional bad pixel mask (note 3) N [0,1]\n\
78 EXTCOEFF_TABLE Table with atmospheric extinction N [0,1]\n\
79\n\
80 and only in case of old SINFONIE way of distortion correction:\n\
81 DISTANCES Table with slitlet distances \n\
82 with cube.slitlet-detection=\"DIST\" Y 1 \n\
83 SLITLET_POS Table with slitlet edge positions \n\
84 with cube.slitlet-detection=\"EDGE\" Y 1 \n\
85\n\
86Output files:\n\
87 DO CATG Explanation Product Depth\n\
88 ------- ------------------------------------------- -------------\n\
89 OBJECT_CUBE reconstructed object expoure (note 5) PD_AUX\n\
90 SKY_CUBE reconstructed sky exposure (note 6) PD_AUX\n\
91\n\
92Note 1) When BPM_DARK is provided this will be used as hot bad pixel mask.\n\
93 Otherwise the qualiiy extension of MASTER_DARK will be used.\n\
94Note 2 When BPM_FLAT is provided this will be used as cold bad pixel mask.\n\
95 Otherwise the qualiiy extension of MASTER_FLAT will be used.\n\
96Note 3) All BPMs will be ORed.\n\
97Note 4) OH_SPEC can be a FITS file holding a single OH spectrum in the primary\n\
98 HDU or a FITS file with several extensions each of them holding an OH spectrum\n\
99 for one of the bands J,H,K,HK.\n\
100 The pipeline package provides the file eris_oh_spec.fits holding OH spectra\n\
101 for all bands.\n\
102\n\
103Information on relevant parameters may be found with\n\
104 esorex --params "REC_NAME_PUPIL"\n\
105 esorex --help "REC_NAME_PUPIL"\n\
106\n\
107QC parameters:\n\
108ESO QC LAMBDA SHIFT UM OH based shift of the central wavelength in [um]\n\
109ESO QC LAMBDA SHIFT PIXEL OH based shift of the central wavelength in [pixel]\n\
110";
111
112/*-----------------------------------------------------------------------------
113 Private function prototypes
114 -----------------------------------------------------------------------------*/
115
116cpl_recipe_define(eris_ifu_pupil, ERIS_BINARY_VERSION, "Erich Wiezorrek",
117 PACKAGE_BUGREPORT, "2019",
118 "This recipe reconstruct data cubes from std stars exposures",
119 eris_ifu_pupil_description);
120
121#define RECIPE_NAME "eris_ifu_pupil"
122
123
124/*-----------------------------------------------------------------------------
125 Function code
126 -----------------------------------------------------------------------------*/
127
128/*----------------------------------------------------------------------------*/
136/*----------------------------------------------------------------------------*/
137static cpl_error_code eris_ifu_pupil_fill_parameterlist(cpl_parameterlist *pl)
138{
139 cpl_error_code err = CPL_ERROR_NONE;
140
141 TRY
142 {
145 REC_NAME_PUPIL, M_PUPIL, pl));
148 REC_NAME_PUPIL, M_PUPIL, pl));
149 } CATCH {
150 err = cpl_error_get_code();
151 }
152
153 return err;
154}
155
156//static cpl_error_code
157//eris_ifu_remove_noflat_products(const cpl_frameset *frameset_noflat){
158
159// cpl_size nframes = cpl_frameset_get_size(frameset_noflat);
160// const cpl_frame* frame = NULL;
161// const char* fname = NULL;
162// char* cmd;
163// for(cpl_size i = 0; i < nframes; i++) {
164// frame = cpl_frameset_get_position_const(frameset_noflat, i);
165// if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_PRODUCT) {
166// fname = cpl_frame_get_filename(frame);
167// cmd = cpl_sprintf("rm -f %s",fname);
168// system(cmd);
169// cpl_free(cmd);
170// }
171// }
172// eris_check_error_code("eris_ifu_remove_noflat_products");
173// return cpl_error_get_code();
174//}
175
176/*----------------------------------------------------------------------------*/
183/*----------------------------------------------------------------------------*/
184static int eris_ifu_pupil(cpl_frameset *frameset,
185 const cpl_parameterlist * parlist)
186{
187 /* check required input tags are present */
188 const int ntags = 1;
189 const char* required_tags[1] = {
190 ERIS_IFU_CALIB_OH_SPEC
191 };
192
193 cpl_ensure_code(CPL_ERROR_NONE ==
194 eris_dfs_check_input_tags(frameset, required_tags, ntags, 1),
195 CPL_ERROR_ILLEGAL_INPUT);
196
197 /* duplicate raw frameset BEFORE processing data */
198 cpl_frame* flat_frame = NULL;
199 cpl_frameset* frameset_noflat = NULL;
200// cpl_boolean is_std_flux = CPL_FALSE;
201// cpl_boolean is_pupil = CPL_FALSE;
202// if(cpl_frameset_find(frameset,"PUPIL_LAMP") != NULL) {
203// is_pupil = CPL_TRUE;
204// }
205 flat_frame = cpl_frameset_find(frameset, ERIS_IFU_CALIB_FLATFIELD);
206 if (flat_frame != NULL) {
207
208 frameset_noflat = cpl_frameset_duplicate(frameset);
209 cpl_frameset_erase(frameset_noflat,ERIS_IFU_CALIB_FLATFIELD);
210
211 }
212
213 eris_stdstar_reduction_common(frameset, parlist, CPL_TRUE, CONTEXT, RECIPE_NAME);
214
215
216 if (flat_frame != NULL) {
217 cpl_frameset_delete(frameset_noflat);
218 }
219 eris_check_error_code("eris_ifu_pupil");
220 return (int)cpl_error_get_code();
221}
222
223
224
#define BRK_IF_ERROR(function)
If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.
#define TRY
Beginning of a TRY-block.
#define CATCH
End of a TRY-block, beginning of a CATCH-block.
cpl_error_code eris_ifu_stdstar_fill_common_parameterlist(const char *recipeName, jitterModes jitterMode, cpl_parameterlist *pl)
Fill parameter list with standard star-specific parameters.
cpl_error_code eris_ifu_jitter_fill_common_parameterlist(const char *recipeName, jitterModes jitterMode, cpl_parameterlist *pl)
Fill parameter list with common jitter recipe parameters.
cpl_error_code eris_stdstar_reduction_common(cpl_frameset *frameset, const cpl_parameterlist *parlist, cpl_boolean apply_flat_field, const char *context, const char *recipe_name)
Main standard star data reduction pipeline orchestration function.
cpl_error_code eris_check_error_code(const char *func_id)
handle CPL errors
Definition: eris_utils.c:56