51 #include <irplib_utils.h>
54 #include <sinfo_pro_types.h>
55 #include <sinfo_product_config.h>
56 #include <sinfo_prepare_stacked_frames_config.h>
57 #include <sinfo_objnod_config.h>
58 #include <sinfo_standard_star_config.h>
59 #include <sinfo_psf_config.h>
60 #include <sinfo_skycor_config.h>
61 #include <sinfo_new_objnod.h>
62 #include <sinfo_new_stdstar.h>
63 #include <sinfo_new_psf.h>
64 #include <sinfo_new_prepare_stacked_frames.h>
65 #include <sinfo_new_cubes_coadd.h>
66 #include <sinfo_key_names.h>
67 #include <sinfo_raw_types.h>
68 #include <sinfo_functions.h>
69 #include <sinfo_tpl_utils.h>
70 #include <sinfo_tpl_dfs.h>
71 #include <sinfo_hidden.h>
72 #include <sinfo_globals.h>
73 #include <sinfo_msg.h>
74 #include <sinfo_rec_utils.h>
75 #include <sinfo_error.h>
76 #include <sinfo_utils_wrappers.h>
81 static int sinfo_step_jitter_create(cpl_plugin *) ;
82 static int sinfo_step_jitter_exec(cpl_plugin *) ;
83 static int sinfo_step_jitter_destroy(cpl_plugin *) ;
84 static int sinfo_step_jitter(cpl_parameterlist *config, cpl_frameset *
set);
89 static char sinfo_step_jitter_description1[] =
90 "This recipe performs science data reduction.\n"
91 "The input files are:\n"
92 "science object and sky frames with tags OBJECT_NODDING and SKY_NODDING or\n"
93 "Telluric standard star frames and sky frames with tags STD and SKY_STD or\n"
94 "PSF standard star and sky frames with tags \n"
95 "PSF_CALIBRATOR and SKY_PSF_CALIBRATOR\n"
96 "and Master calibration frames:\n";
99 static char sinfo_step_jitter_description2[] =
100 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
101 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
102 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
103 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
104 "A corresponding (band) distortion table with tag DISTORTION\n"
105 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
108 static char sinfo_step_jitter_description3[] =
109 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
110 "A reference table with the position of the first "
111 "column with tag FIRST_COLUMN\n"
112 "Relevant outputs are:\n"
113 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
114 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
115 "An average along Z of the reconstructed cube \n"
116 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
117 "The bad pixel map associated to the cube \n"
118 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n"
122 static char sinfo_step_jitter_description[1400];
150 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
151 cpl_plugin *plugin = &recipe->interface;
153 strcpy(sinfo_step_jitter_description,sinfo_step_jitter_description1);
154 strcat(sinfo_step_jitter_description,sinfo_step_jitter_description2);
155 strcat(sinfo_step_jitter_description,sinfo_step_jitter_description3);
157 cpl_plugin_init(plugin,
159 SINFONI_BINARY_VERSION,
160 CPL_PLUGIN_TYPE_RECIPE,
162 "Object or STD star or PSF star data reduction",
163 sinfo_step_jitter_description,
165 "Andrea.Mdigliani@eso.org",
167 sinfo_step_jitter_create,
168 sinfo_step_jitter_exec,
169 sinfo_step_jitter_destroy);
171 cpl_pluginlist_append(list, plugin);
186 static int sinfo_step_jitter_create(cpl_plugin *plugin)
188 cpl_recipe * recipe ;
191 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
192 recipe = (cpl_recipe *)plugin ;
196 recipe->parameters = cpl_parameterlist_new() ;
204 sinfo_product_config_add(recipe->parameters);
205 sinfo_prepare_stacked_frames_config_add(recipe->parameters);
206 sinfo_objnod_config_add(recipe->parameters);
207 sinfo_skycor_config_add(recipe->parameters);
208 sinfo_standard_star_config_add(recipe->parameters);
209 sinfo_psf_config_add(recipe->parameters);
222 static int sinfo_step_jitter_exec(cpl_plugin *plugin)
225 cpl_recipe *recipe = (cpl_recipe *) plugin;
228 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
229 recipe = (cpl_recipe *)plugin ;
232 return sinfo_step_jitter(recipe->parameters, recipe->frames);
243 static int sinfo_step_jitter_destroy(cpl_plugin *plugin)
246 cpl_recipe * recipe ;
249 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
250 recipe = (cpl_recipe *)plugin ;
253 cpl_parameterlist_delete(recipe->parameters);
272 static int sinfo_step_jitter(cpl_parameterlist *config, cpl_frameset *
set)
274 const char* pro_ctg_cube=NULL;
276 cpl_parameter* p=NULL;
279 cpl_frameset* obj_set=NULL;
280 cpl_frame* obj_frm=NULL;
281 char tag[FILE_NAME_SZ];
282 cpl_frameset* ref_set=NULL;
284 if(sinfo_dfs_set_groups(
set)) {
290 check_nomsg(ref_set=cpl_frameset_duplicate(
set));
291 obj_set=cpl_frameset_new();
292 sinfo_extract_obj_products(
set,obj_set);
293 if(NULL == (obj_frm = cpl_frameset_get_frame(obj_set,0))) {
295 cpl_frameset_delete(obj_set);
300 strcpy(tag,cpl_frame_get_tag(obj_frm));
301 if(NULL!=sinfo_new_set_obj_procatg(tag)){
302 pro_ctg_cube=sinfo_new_set_obj_procatg(tag);
305 cpl_frameset_delete(obj_set);
308 cpl_frameset_delete(obj_set);
338 p = cpl_parameterlist_find(config,
"sinfoni.psf.switch");
339 psf_sw = cpl_parameter_get_bool(p);
340 sinfo_msg(
"switch=%d",psf_sw);
342 sinfo_msg(
"------------------------------") ;
343 sinfo_msg(
"REDUCE PSF STD STAR FRAMES");
344 sinfo_msg(
"------------------------------") ;
345 if ( -1 == (ind = sinfo_new_psf(cpl_func,config,
set,ref_set) ) )
347 sinfo_msg(
"no: %d\n", ind) ;
350 sinfo_msg(
"SUCCESS REDUCE PSF STD STAR FRAMES") ;
354 p = cpl_parameterlist_find(config,
"sinfoni.std_star.switch");
355 std_sw = cpl_parameter_get_bool(p);
356 sinfo_msg(
"switch=%d",std_sw);
358 sinfo_msg(
"------------------------------") ;
359 sinfo_msg(
"STD STAR DATA REDUCTION");
360 sinfo_msg(
"------------------------------") ;
363 if ( -1 == (ind = sinfo_new_stdstar(cpl_func,config,
set,ref_set) ) )
365 sinfo_msg(
"REDUCING STD STAR DATA No: %d",ind) ;
368 sinfo_msg(
"STD STAR DATA REDUCTION SUCCESS") ;