51 #include <irplib_utils.h>
54 #include <sinfo_utilities.h>
55 #include <sinfo_pro_types.h>
56 #include <sinfo_general_config.h>
57 #include <sinfo_product_config.h>
58 #include <sinfo_prepare_stacked_frames_config.h>
59 #include <sinfo_objnod_config.h>
60 #include <sinfo_skycor_config.h>
61 #include <sinfo_psf_config.h>
62 #include <sinfo_standard_star_config.h>
63 #include <sinfo_new_prepare_stacked_frames.h>
64 #include <sinfo_new_cubes_coadd.h>
65 #include <sinfo_new_stdstar.h>
66 #include <sinfo_new_psf.h>
67 #include <sinfo_key_names.h>
68 #include <sinfo_raw_types.h>
69 #include <sinfo_functions.h>
70 #include <sinfo_tpl_utils.h>
71 #include <sinfo_tpl_dfs.h>
72 #include <sinfo_hidden.h>
73 #include <sinfo_globals.h>
74 #include <sinfo_msg.h>
75 #include <sinfo_rec_utils.h>
76 #include <sinfo_error.h>
77 #include <sinfo_utils_wrappers.h>
83 static int sinfo_rec_jitter_create(cpl_plugin *) ;
84 static int sinfo_rec_jitter_exec(cpl_plugin *) ;
85 static int sinfo_rec_jitter_destroy(cpl_plugin *) ;
86 static int sinfo_rec_jitter(cpl_parameterlist *config, cpl_frameset *set);
91 static char sinfo_rec_jitter_description1[] =
92 "This recipe performs science data reduction.\n"
93 "The input files are:\n"
94 "science object and sky frames with tags OBJECT_NODDING and SKY_NODDING or\n"
95 "Telluric standard star frames and sky frames with tags STD and SKY_STD or\n"
96 "PSF standard star and sky frames with tags \n"
97 "PSF_CALIBRATOR and SKY_PSF_CALIBRATOR\n"
98 "and Master calibration frames:\n";
101 static char sinfo_rec_jitter_description2[] =
102 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
103 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
104 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
105 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
106 "A corresponding (band) distortion table with tag DISTORTION\n"
107 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
110 static char sinfo_rec_jitter_description3[] =
111 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
112 "A reference table with the position of the first "
113 "column with tag FIRST_COLUMN\n"
114 "Relevant outputs are:\n"
115 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
116 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
117 "An average along Z of the reconstructed cube \n"
118 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
119 "The bad pixel map associated to the cube \n"
120 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n"
123 static char sinfo_rec_jitter_description[1400];
149 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
150 cpl_plugin *plugin = &recipe->interface;
152 strcpy(sinfo_rec_jitter_description,sinfo_rec_jitter_description1);
153 strcat(sinfo_rec_jitter_description,sinfo_rec_jitter_description2);
154 strcat(sinfo_rec_jitter_description,sinfo_rec_jitter_description3);
156 cpl_plugin_init(plugin,
158 SINFONI_BINARY_VERSION,
159 CPL_PLUGIN_TYPE_RECIPE,
161 "Object or STD star or PSF star data reduction",
162 sinfo_rec_jitter_description,
164 "Andrea.Mdigliani@eso.org",
166 sinfo_rec_jitter_create,
167 sinfo_rec_jitter_exec,
168 sinfo_rec_jitter_destroy);
170 cpl_pluginlist_append(list, plugin);
185 static int sinfo_rec_jitter_create(cpl_plugin *plugin)
187 cpl_recipe * recipe ;
191 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
192 recipe = (cpl_recipe *)plugin ;
198 recipe->parameters = cpl_parameterlist_new() ;
205 sinfo_general_config_add(recipe->parameters);
206 sinfo_product_config_add(recipe->parameters);
207 sinfo_prepare_stacked_frames_config_add(recipe->parameters);
208 sinfo_objnod_config_add(recipe->parameters);
209 sinfo_skycor_config_add(recipe->parameters);
210 sinfo_standard_star_config_add(recipe->parameters);
211 sinfo_psf_config_add(recipe->parameters);
226 static int sinfo_rec_jitter_exec(cpl_plugin *plugin)
229 cpl_recipe *recipe = (cpl_recipe *) plugin;
231 cpl_errorstate initial_errorstate = cpl_errorstate_get();
234 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
235 recipe = (cpl_recipe *)plugin ;
238 if (!cpl_errorstate_is_equal(initial_errorstate)) {
241 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
243 return sinfo_rec_jitter(recipe->parameters, recipe->frames);
254 static int sinfo_rec_jitter_destroy(cpl_plugin *plugin)
257 cpl_recipe * recipe ;
260 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
261 recipe = (cpl_recipe *)plugin ;
264 cpl_parameterlist_delete(recipe->parameters);
283 static int sinfo_rec_jitter(cpl_parameterlist *config, cpl_frameset *set)
285 const char* pro_ctg_cube;
286 cpl_parameter* p=NULL;
289 cpl_frameset* ref_set=NULL;
292 sinfo_msg(
"Welcome to SINFONI Pipeline release %d.%d.%d",
293 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
295 if(sinfo_dfs_set_groups(set)) {
300 check_nomsg(p=cpl_parameterlist_find(config,
"sinfoni.general.lc_sw"));
301 check_nomsg(line_cor=cpl_parameter_get_bool(p));
303 check_nomsg(sinfo_ima_line_cor(config,set));
306 check_nomsg(ref_set=cpl_frameset_duplicate(set));
311 ck0(sinfo_cub_stk_frames(config,&set,cpl_func,&pro_ctg_cube),
312 "Cannot stack RAW frames") ;
317 sinfo_msg(
"------------------------------") ;
318 sinfo_msg(
"COADDING CUBES");
319 sinfo_msg(
"------------------------------") ;
320 ck0(sinfo_new_cubes_coadd(cpl_func,config, set, pro_ctg_cube),
323 sinfo_msg(
"------------------------------") ;
324 sinfo_msg(
"COADDED CUBES");
325 sinfo_msg(
"------------------------------") ;
331 if((strcmp(pro_ctg_cube,PRO_COADD_PSF) == 0) ||
332 (strcmp(pro_ctg_cube,PRO_COADD_STD) == 0) ||
333 (strcmp(pro_ctg_cube,PRO_COADD_PUPIL) == 0) ) {
336 p = cpl_parameterlist_find(config,
"sinfoni.psf.switch");
337 psf_sw = cpl_parameter_get_bool(p);
338 sinfo_msg(
"switch=%d",psf_sw);
340 sinfo_msg(
"------------------------------") ;
341 sinfo_msg(
"REDUCE PSF STD STAR FRAMES");
342 sinfo_msg(
"------------------------------") ;
343 if ( -1 == sinfo_new_psf(cpl_func,config,set,set) ) {
347 sinfo_msg(
"SUCCESS REDUCE PSF STD STAR FRAMES") ;
351 p = cpl_parameterlist_find(config,
"sinfoni.std_star.switch");
352 std_sw = cpl_parameter_get_bool(p);
353 sinfo_msg(
"switch=%d",std_sw);
355 sinfo_msg(
"------------------------------") ;
356 sinfo_msg(
"STD STAR DATA REDUCTION");
357 sinfo_msg(
"------------------------------") ;
358 if ( -1 == sinfo_new_stdstar(cpl_func,config, set,set ) ) {
362 sinfo_msg(
"STD STAR DATA REDUCTION SUCCESS") ;
368 sinfo_free_frameset(&ref_set);
369 if (cpl_error_get_code() != CPL_ERROR_NONE) {
370 sinfo_check_rec_status(0);
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
void irplib_reset(void)
Reset IRPLIB state.
#define sinfo_msg_error(...)
Print an error message.