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