00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035
00036
00037
00038
00039
00040 #include <strings.h>
00041 #include <string.h>
00042 #include <stdio.h>
00043 #include <math.h>
00044 #include <libgen.h>
00045
00046
00047
00048 #include <cpl.h>
00049
00050
00051 #include <irplib_utils.h>
00052
00053
00054 #include <sinfo_pro_types.h>
00055 #include <sinfo_product_config.h>
00056 #include <sinfo_prepare_stacked_frames_config.h>
00057 #include <sinfo_objnod_config.h>
00058 #include <sinfo_skycor_config.h>
00059 #include <sinfo_psf_config.h>
00060 #include <sinfo_standard_star_config.h>
00061 #include <sinfo_new_prepare_stacked_frames.h>
00062 #include <sinfo_new_cubes_coadd.h>
00063 #include <sinfo_new_stdstar.h>
00064 #include <sinfo_new_psf.h>
00065 #include <sinfo_key_names.h>
00066 #include <sinfo_raw_types.h>
00067 #include <sinfo_functions.h>
00068 #include <sinfo_tpl_utils.h>
00069 #include <sinfo_tpl_dfs.h>
00070 #include <sinfo_hidden.h>
00071 #include <sinfo_globals.h>
00072 #include <sinfo_msg.h>
00073 #include <sinfo_rec_utils.h>
00074 #include <sinfo_error.h>
00075 #include <sinfo_utils_wrappers.h>
00076
00077
00078
00079
00080
00081 static int sinfo_rec_jitter_create(cpl_plugin *) ;
00082 static int sinfo_rec_jitter_exec(cpl_plugin *) ;
00083 static int sinfo_rec_jitter_destroy(cpl_plugin *) ;
00084 static int sinfo_rec_jitter(cpl_parameterlist *config, cpl_frameset *set);
00085
00086
00087
00088
00089 static char sinfo_rec_jitter_description1[] =
00090 "This recipe performs science data reduction.\n"
00091 "The input files are:\n"
00092 "science object and sky frames with tags OBJECT_NODDING and SKY_NODDING or\n"
00093 "Telluric standard star frames and sky frames with tags STD and SKY_STD or\n"
00094 "PSF standard star and sky frames with tags \n"
00095 "PSF_CALIBRATOR and SKY_PSF_CALIBRATOR\n"
00096 "and Master calibration frames:\n";
00097
00098
00099 static char sinfo_rec_jitter_description2[] =
00100 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00101 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00102 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00103 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00104 "A corresponding (band) distortion table with tag DISTORTION\n"
00105 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
00106
00107
00108 static char sinfo_rec_jitter_description3[] =
00109 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00110 "A reference table with the position of the first "
00111 "column with tag FIRST_COLUMN\n"
00112 "Relevant outputs are:\n"
00113 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00114 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00115 "An average along Z of the reconstructed cube \n"
00116 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00117 "The bad pixel map associated to the cube \n"
00118 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n";
00119
00120
00121 static char sinfo_rec_jitter_description4[] =
00122 "Information on relevant parameters can be found with\n"
00123 "esorex --params sinfo_rec_jitter\n"
00124 "esorex --help sinfo_rec_jitter\n"
00125 "\n";
00126
00127 static char sinfo_rec_jitter_description[1400];
00128
00129
00130
00131
00132
00136
00138
00147
00148
00149 int
00150 cpl_plugin_get_info(cpl_pluginlist *list)
00151 {
00152
00153 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00154 cpl_plugin *plugin = &recipe->interface;
00155
00156 strcpy(sinfo_rec_jitter_description,sinfo_rec_jitter_description1);
00157 strcat(sinfo_rec_jitter_description,sinfo_rec_jitter_description2);
00158 strcat(sinfo_rec_jitter_description,sinfo_rec_jitter_description3);
00159 strcat(sinfo_rec_jitter_description,sinfo_rec_jitter_description4);
00160
00161 cpl_plugin_init(plugin,
00162 CPL_PLUGIN_API,
00163 SINFONI_BINARY_VERSION,
00164 CPL_PLUGIN_TYPE_RECIPE,
00165 "sinfo_rec_jitter",
00166 "Object or STD star or PSF star data reduction",
00167 sinfo_rec_jitter_description,
00168 "Andrea Modigliani",
00169 "Andrea.Mdigliani@eso.org",
00170 sinfo_get_license(),
00171 sinfo_rec_jitter_create,
00172 sinfo_rec_jitter_exec,
00173 sinfo_rec_jitter_destroy);
00174
00175 cpl_pluginlist_append(list, plugin);
00176
00177 return 0;
00178
00179 }
00180
00181
00189
00190 static int sinfo_rec_jitter_create(cpl_plugin *plugin)
00191 {
00192 cpl_recipe * recipe ;
00193
00194
00195 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00196 recipe = (cpl_recipe *)plugin ;
00197 else return -1 ;
00198 cpl_error_reset();
00199 irplib_reset();
00200
00201
00202 recipe->parameters = cpl_parameterlist_new() ;
00203
00204
00205
00206
00207
00208
00209 sinfo_product_config_add(recipe->parameters);
00210 sinfo_prepare_stacked_frames_config_add(recipe->parameters);
00211 sinfo_objnod_config_add(recipe->parameters);
00212 sinfo_skycor_config_add(recipe->parameters);
00213 sinfo_standard_star_config_add(recipe->parameters);
00214 sinfo_psf_config_add(recipe->parameters);
00215
00216 return 0;
00217
00218 }
00219
00220
00226
00227 static int sinfo_rec_jitter_exec(cpl_plugin *plugin)
00228 {
00229
00230 cpl_recipe *recipe = (cpl_recipe *) plugin;
00231
00232
00233 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00234 recipe = (cpl_recipe *)plugin ;
00235 else return -1 ;
00236
00237 return sinfo_rec_jitter(recipe->parameters, recipe->frames);
00238
00239 }
00240
00241
00247
00248 static int sinfo_rec_jitter_destroy(cpl_plugin *plugin)
00249 {
00250
00251 cpl_recipe * recipe ;
00252
00253
00254 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00255 recipe = (cpl_recipe *)plugin ;
00256 else return -1 ;
00257
00258 cpl_parameterlist_delete(recipe->parameters);
00259
00260 return 0;
00261
00262 }
00263
00264
00271
00272
00273
00274
00275
00276
00277 static int sinfo_rec_jitter(cpl_parameterlist *config, cpl_frameset *set)
00278 {
00279 const char* pro_ctg_cube;
00280 cpl_parameter* p=NULL;
00281 int psf_sw=0;
00282 int std_sw=0;
00283 sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00284 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00285
00286 if(sinfo_dfs_set_groups(set)) {
00287 sinfo_msg_error("Cannot indentify RAW and CALIB frames") ;
00288 return -1;
00289 }
00290
00291
00292
00293
00294
00295 ck0(sinfo_cub_stk_frames(config,&set,cpl_func,&pro_ctg_cube),
00296 "Cannot stack RAW frames") ;
00297
00298
00299
00300
00301 sinfo_msg("------------------------------") ;
00302 sinfo_msg("COADDING CUBES");
00303 sinfo_msg("------------------------------") ;
00304
00305 ck0(sinfo_new_cubes_coadd(cpl_func,config, set, pro_ctg_cube),
00306 "COADDING CUBES") ;
00307
00308 sinfo_msg("------------------------------") ;
00309 sinfo_msg("COADDED CUBES");
00310 sinfo_msg("------------------------------") ;
00311
00312
00313
00314
00315
00316 if((strcmp(pro_ctg_cube,PRO_COADD_OBJ) == 0) ||
00317 (strcmp(pro_ctg_cube,PRO_COADD_PSF) == 0) ||
00318 (strcmp(pro_ctg_cube,PRO_COADD_STD) == 0) ||
00319 (strcmp(pro_ctg_cube,PRO_COADD_PUPIL) == 0) ) {
00320
00321
00322 p = cpl_parameterlist_find(config, "sinfoni.psf.switch");
00323 psf_sw = cpl_parameter_get_bool(p);
00324 sinfo_msg("switch=%d",psf_sw);
00325 if(psf_sw) {
00326 sinfo_msg("------------------------------") ;
00327 sinfo_msg("REDUCE PSF STD STAR FRAMES");
00328 sinfo_msg("------------------------------") ;
00329 if ( -1 == sinfo_new_psf(cpl_func,config,set) ) {
00330 sinfo_msg_error("REDUCING PSF STD STAR FRAMES") ;
00331 } else {
00332 sinfo_msg("SUCCESS REDUCE PSF STD STAR FRAMES") ;
00333 }
00334 }
00335
00336 p = cpl_parameterlist_find(config, "sinfoni.std_star.switch");
00337 std_sw = cpl_parameter_get_bool(p);
00338 sinfo_msg("switch=%d",std_sw);
00339 if(std_sw) {
00340 sinfo_msg("------------------------------") ;
00341 sinfo_msg("STD STAR DATA REDUCTION");
00342 sinfo_msg("------------------------------") ;
00343 if ( -1 == sinfo_new_stdstar(cpl_func,config, set ) ) {
00344 sinfo_msg_error("REDUCING STD STAR DATA") ;
00345 } else {
00346 sinfo_msg("STD STAR DATA REDUCTION SUCCESS") ;
00347 }
00348 }
00349 }
00350 return 0 ;
00351 cleanup:
00352 irplib_error_dump(CPL_MSG_ERROR,CPL_MSG_ERROR);
00353 return -1;
00354
00355 }
00356