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
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035
00036
00037
00038
00039
00040
00041 #include <strings.h>
00042 #include <string.h>
00043 #include <stdio.h>
00044 #include <math.h>
00045 #include <libgen.h>
00046
00047
00048
00049 #include <cpl.h>
00050 #include <irplib_utils.h>
00051
00052
00053
00054
00055 #include <sinfo_pro_types.h>
00056 #include <sinfo_product_config.h>
00057 #include <sinfo_prepare_stacked_frames_config.h>
00058 #include <sinfo_objnod_config.h>
00059 #include <sinfo_new_cubes_coadd.h>
00060 #include <sinfo_new_prepare_stacked_frames.h>
00061 #include <sinfo_skycor_config.h>
00062 #include <sinfo_key_names.h>
00063 #include <sinfo_raw_types.h>
00064 #include <sinfo_functions.h>
00065 #include <sinfo_tpl_utils.h>
00066 #include <sinfo_tpl_dfs.h>
00067 #include <sinfo_hidden.h>
00068 #include <sinfo_globals.h>
00069 #include <sinfo_msg.h>
00070 #include <sinfo_rec_utils.h>
00071 #include <sinfo_error.h>
00072 #include <sinfo_utils_wrappers.h>
00073
00074
00075
00076
00077
00078
00079 static int sinfo_rec_objnod_create(cpl_plugin *) ;
00080 static int sinfo_rec_objnod_exec(cpl_plugin *) ;
00081 static int sinfo_rec_objnod_destroy(cpl_plugin *) ;
00082 static int sinfo_rec_objnod(cpl_parameterlist *, cpl_frameset *);
00083
00084
00085
00086
00087
00088 static char sinfo_rec_objnod_description1[] =
00089 "This recipe performs science data reduction.\n"
00090 "The input files are science object and sky frames with tags \n"
00091 "OBJECT_NODDING and SKY_NODDING\n"
00092 "Master calibration frames:\n";
00093
00094
00095 static char sinfo_rec_objnod_description2[] =
00096 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00097 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00098 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00099 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00100 "A corresponding (band) distortion table with tag DISTORTION\n"
00101 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
00102
00103
00104 static char sinfo_rec_objnod_description3[] =
00105 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00106 "A reference table with the position of the first "
00107 "column with tag FIRST_COLUMN\n"
00108 "Relevant outputs are:\n"
00109 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00110 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00111 "An average along Z of the reconstructed cube \n"
00112 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00113 "The bad pixel map associated to the cube \n"
00114 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n";
00115
00116
00117 static char sinfo_rec_objnod_description4[] =
00118 "Information on relevant parameters can be found with\n"
00119 "esorex --params sinfo_rec_objnod\n"
00120 "esorex --help sinfo_rec_objnod\n"
00121 "\n";
00122
00123 static char sinfo_rec_objnod_description[1300];
00124
00125
00126
00127
00128
00132
00134
00143
00144
00145
00146 int
00147 cpl_plugin_get_info(cpl_pluginlist *list)
00148 {
00149
00150 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00151 cpl_plugin *plugin = &recipe->interface;
00152
00153 strcpy(sinfo_rec_objnod_description,sinfo_rec_objnod_description1);
00154 strcat(sinfo_rec_objnod_description,sinfo_rec_objnod_description2);
00155 strcat(sinfo_rec_objnod_description,sinfo_rec_objnod_description3);
00156 strcat(sinfo_rec_objnod_description,sinfo_rec_objnod_description4);
00157
00158 cpl_plugin_init(plugin,
00159 CPL_PLUGIN_API,
00160 SINFONI_BINARY_VERSION,
00161 CPL_PLUGIN_TYPE_RECIPE,
00162 "sinfo_rec_objnod",
00163 "Object data reduction",
00164 sinfo_rec_objnod_description,
00165 "Andrea Modigliani",
00166 "Andrea.Mdigliani@eso.org",
00167 sinfo_get_license(),
00168 sinfo_rec_objnod_create,
00169 sinfo_rec_objnod_exec,
00170 sinfo_rec_objnod_destroy);
00171
00172 cpl_pluginlist_append(list, plugin);
00173
00174 return 0;
00175
00176 }
00177
00178
00186
00187 static int sinfo_rec_objnod_create(cpl_plugin *plugin)
00188 {
00189 cpl_recipe * recipe ;
00190
00191
00192 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00193 recipe = (cpl_recipe *)plugin ;
00194 else return -1 ;
00195 irplib_reset();
00196 cpl_error_reset();
00197
00198
00199 recipe->parameters = cpl_parameterlist_new() ;
00200
00201
00202
00203
00204
00205 sinfo_product_config_add(recipe->parameters);
00206 sinfo_prepare_stacked_frames_config_add(recipe->parameters);
00207 sinfo_objnod_config_add(recipe->parameters);
00208 sinfo_skycor_config_add(recipe->parameters);
00209
00210 return 0;
00211
00212 }
00213
00214
00220
00221 static int sinfo_rec_objnod_exec(cpl_plugin *plugin)
00222 {
00223 cpl_recipe * recipe ;
00224
00225 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00226
00227
00228 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00229 recipe = (cpl_recipe *)plugin ;
00230 else return -1 ;
00231
00232 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00233
00234
00235 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00236 }
00237
00238 return sinfo_rec_objnod(recipe->parameters, recipe->frames);
00239
00240 }
00241
00247
00248 static int sinfo_rec_objnod_destroy(cpl_plugin *plugin)
00249 {
00250 cpl_recipe *recipe = (cpl_recipe *) plugin;
00251
00252
00253 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00254 recipe = (cpl_recipe *)plugin ;
00255 else return -1 ;
00256
00257 cpl_parameterlist_delete(recipe->parameters);
00258
00259 return 0;
00260
00261 }
00262
00263
00270
00271
00272
00273
00274
00275
00276 static int sinfo_rec_objnod(cpl_parameterlist *config, cpl_frameset *set)
00277 {
00278 const char* pro_ctg_cube;
00279 sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00280 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00281
00282 if(sinfo_dfs_set_groups(set)) {
00283 sinfo_msg_error("Cannot indentify RAW and CALIB frames") ;
00284 return -1;
00285 }
00286
00287
00288
00289
00290
00291 ck0(sinfo_cub_stk_frames(config,&set,cpl_func,&pro_ctg_cube),
00292 "Cannot stack RAW frames") ;
00293
00294
00295
00296
00297
00298
00299 sinfo_msg("------------------------------") ;
00300 sinfo_msg("COADDING CUBES");
00301 sinfo_msg("------------------------------") ;
00302
00303
00304 ck0(sinfo_new_cubes_coadd(cpl_func,config, set, pro_ctg_cube),
00305 "COADDING CUBES") ;
00306
00307 sinfo_msg("------------------------------") ;
00308 sinfo_msg("COADDED CUBES");
00309 sinfo_msg("------------------------------") ;
00310
00311 cleanup:
00312 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00313 return -1;
00314 } else {
00315 return 0;
00316 }
00317
00318 }