38#include "eris_ifu_error.h"
39#include <eris_ifu_jitter_interface.h>
40#include <eris_ifu_jitter_static.h>
41#include <eris_ifu_stdstar_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>
54#define CONTEXT "eris.eris_ifu_stdstar"
56static const char eris_ifu_stdstar_description[] =
"\
57This recipe performs ERIS/SPIFFIER science data reduction.\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\
62-----------------------------------------------------------------------------\n\
64 DO CATG Explanation Required #Frames\n\
65 ------- ----------- -------- -------\n\
66 science exposures with corresponding sky exposures: \n\
67 OBJ Science object exposure Y ? \n\
68 SKY_OBJ Sky exposure Y ? \n\
70 STD Standard star exposure Y ? \n\
71 SKY_STD Standard star sky exposure Y ? \n\
73 PSF_CALIBRATOR PSF calibration source Y ? \n\
74 SKY_PSF_CALIBRATOR PSF calibration sky exposure Y ? \n\
76 and calibration frames: \n\
77 DISTORTION Table with distortion correction pars. Y 1 \n\
78 WAVE_MAP Wavelength calibration map Y 1 \n\
79 OH_SPEC Vector holding OH lines (note 4) Y 1 \n\
80 MASTER_DARK Optional master dark image N [0,1]\n\
81 MASTER_FLAT Optional master flat image N [0,1]\n\
82 BPM_DARK Optional bad pixel mask (note 1 & 3) N [0,1]\n\
83 BPM_FLAT Optional bad pixel mask (note 2 & 3) N [0,1]\n\
84 BPM_LINEARITY Optional bad pixel mask (note 3) N [0,1]\n\
85 EXTCOEFF_TABLE Table with atmospheric extinction N [0,1]\n\
86 FLUX_STD_CATALOG Table with ref flux std star spectra N [0,1]\n\
87 EFFICIENCY_WINDOWS Table with ranges to compute efficiency N [0,1]\n\
88 FIT_AREAS Table with ranges to perform fit N [0,1]\n\
89 QUALITY_AREAS Table with quality regions area N [0,1]\n\
90 RESP_FIT_POINTS_CATALOG Table with points where to fit resp N [0,1]\n\
91 RESPONSE_WINDOWS Table with regions for response computation N [0,1]\n\
92 TELL_MOD_CATALOG Catalog with tellurics models N [0,1]\n\
94 and only in case of old SINFONIE way of distortion correction:\n\
95 DISTANCES Table with slitlet distances \n\
96 with cube.slitlet-detection=\"DIST\" Y 1 \n\
97 SLITLET_POS Table with slitlet edge positions \n\
98 with cube.slitlet-detection=\"EDGE\" Y 1 \n\
101 DO CATG Explanation Product Depth\n\
102 ------- ------------------------------------------- -------------\n\
103 OBJECT_CUBE reconstructed object expoure (note 5) PD_AUX\n\
104 SKY_CUBE reconstructed sky exposure (note 6) PD_AUX\n\
106Note 1) When BPM_DARK is provided this will be used as hot bad pixel mask.\n\
107 Otherwise the qualiiy extension of MASTER_DARK will be used.\n\
108Note 2 When BPM_FLAT is provided this will be used as cold bad pixel mask.\n\
109 Otherwise the qualiiy extension of MASTER_FLAT will be used.\n\
110Note 3) All BPMs will be ORed.\n\
111Note 4) OH_SPEC can be a FITS file holding a single OH spectrum in the primary\n\
112 HDU or a FITS file with several extensions each of them holding an OH spectrum\n\
113 for one of the bands J,H,K,HK.\n\
114 The pipeline package provides the file eris_oh_spec.fits holding OH spectra\n\
116Note 5) If SKY_TWEAK is selected no image will be subtracted, else if there is\n\
117 a matching sky exposure this exposure will be subtracted. Else if a masterDark\n\
118 image is available this image will be subtracted\n\
119Note 6) If SKY_TWEAK is selected no image will be subtracted. Else if a masterDark\n\
120 image is available this image will be subtracted\n\
122Information on relevant parameters may be found with\n\
123 esorex --params "REC_NAME_STDSTAR
"\n\
124 esorex --help "REC_NAME_STDSTAR
"\n\
127ESO QC LAMBDA SHIFT UM OH based shift of the central wavelength in [um]\n\
128ESO QC LAMBDA SHIFT PIXEL OH based shift of the central wavelength in [pixel]\n\
135cpl_recipe_define(eris_ifu_stdstar, ERIS_BINARY_VERSION,
"Erich Wiezorrek",
136 PACKAGE_BUGREPORT,
"2019",
137 "This recipe reconstruct data cubes from std stars exposures",
138 eris_ifu_stdstar_description);
140#define RECIPE_NAME "eris_ifu_stdstar"
156static cpl_error_code eris_ifu_stdstar_fill_parameterlist(cpl_parameterlist *pl)
158 cpl_error_code err = CPL_ERROR_NONE;
164 REC_NAME_STDSTAR, M_STDSTAR, pl));
167 REC_NAME_STDSTAR, M_STDSTAR, pl));
169 err = cpl_error_get_code();
176eris_ifu_remove_noflat_products(
const cpl_frameset *frameset_noflat){
178 cpl_size nframes = cpl_frameset_get_size(frameset_noflat);
179 const cpl_frame* frame = NULL;
180 const char* fname = NULL;
182 for(cpl_size i = 0; i < nframes; i++) {
183 frame = cpl_frameset_get_position_const(frameset_noflat, i);
184 if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_PRODUCT) {
185 fname = cpl_frame_get_filename(frame);
186 cmd = cpl_sprintf(
"rm -f %s",fname);
192 return cpl_error_get_code();
203static int eris_ifu_stdstar(cpl_frameset *frameset,
204 const cpl_parameterlist * parlist)
208 const char* required_tags[1] = {
209 ERIS_IFU_CALIB_OH_SPEC
212 cpl_ensure_code(CPL_ERROR_NONE ==
213 eris_dfs_check_input_tags(frameset, required_tags, ntags, 1),
214 CPL_ERROR_ILLEGAL_INPUT);
217 cpl_frame* flat_frame = NULL;
218 cpl_frameset* frameset_noflat = NULL;
219 cpl_boolean is_std_flux = CPL_FALSE;
220 if(cpl_frameset_find(frameset,
"STD") != NULL ||
221 cpl_frameset_find(frameset,
"STD_FLUX") != NULL) {
222 is_std_flux = CPL_TRUE;
224 flat_frame = cpl_frameset_find(frameset, ERIS_IFU_CALIB_FLATFIELD);
225 if (flat_frame != NULL) {
227 frameset_noflat = cpl_frameset_duplicate(frameset);
228 cpl_frameset_erase(frameset_noflat,ERIS_IFU_CALIB_FLATFIELD);
234 if (is_std_flux && flat_frame != NULL) {
238 eris_print_rec_status(3);
239 cpl_frame* eff_frame = cpl_frameset_find(frameset_noflat,
240 ERIS_IFU_PRO_JITTER_EFFICIENCY);
241 if(eff_frame != NULL) {
242 cpl_frameset_insert(frameset, cpl_frame_duplicate(eff_frame));
243 cpl_frameset_erase_frame(frameset_noflat,eff_frame);
245 eris_ifu_remove_noflat_products(frameset_noflat);
248 if (flat_frame != NULL) {
249 cpl_frameset_delete(frameset_noflat);
252 return (
int)cpl_error_get_code();
#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