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 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
00034
00035 #include <string.h>
00036
00037
00038 #include <cpl.h>
00039
00040
00041 #include <xsh_dfs.h>
00042
00043 #include <xsh_parameters.h>
00044 #include <xsh_utils.h>
00045 #include <xsh_drl.h>
00046 #include <xsh_msg.h>
00047 #include <xsh_pfits.h>
00048 #include <xsh_error.h>
00049
00050
00051
00052
00053
00054
00055 #define RECIPE_ID "xsh_util_bpmap_nl_raw2pre"
00056 #define RECIPE_AUTHOR "A.Modigliani"
00057 #define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
00058 #define PRO_IMA "PRO_IMA"
00059 #define KEY_VALUE_HPRO_DID "PRO-1.15"
00060
00061
00062
00063
00064 static int xsh_util_bpmap_nl_raw2pre_create(cpl_plugin *) ;
00065 static int xsh_util_bpmap_nl_raw2pre_exec(cpl_plugin *) ;
00066 static int xsh_util_bpmap_nl_raw2pre_destroy(cpl_plugin *) ;
00067 static int xsh_util_bpmap_nl_raw2pre(cpl_parameterlist *, cpl_frameset *) ;
00068
00069
00070
00071
00072
00073 static char
00074 xsh_util_bpmap_nl_raw2pre_description_short[] = "Converts RAW_BP_MAP_NL to BP_MAP_NL";
00075 static char xsh_util_bpmap_nl_raw2pre_description[] =
00076 "This recipe converts RAW_BP_MAP_NL to BP_MAP_NL.\n"
00077 "Information on relevant parameters can be found with\n"
00078 "esorex --params xsh_util_bpmap_nl_raw2pre\n"
00079 "esorex --help xsh_util_bpmap_nl_raw2pre\n"
00080 "\n";
00081
00082
00083
00084
00085
00090
00091
00093
00101
00102 int cpl_plugin_get_info(cpl_pluginlist * list)
00103 {
00104 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00105 cpl_plugin * plugin = &recipe->interface ;
00106
00107 cpl_plugin_init(plugin,
00108 CPL_PLUGIN_API,
00109 XSH_BINARY_VERSION,
00110 CPL_PLUGIN_TYPE_RECIPE,
00111 RECIPE_ID,
00112 xsh_util_bpmap_nl_raw2pre_description_short,
00113 xsh_util_bpmap_nl_raw2pre_description,
00114 RECIPE_AUTHOR,
00115 RECIPE_CONTACT,
00116 xsh_get_license(),
00117 xsh_util_bpmap_nl_raw2pre_create,
00118 xsh_util_bpmap_nl_raw2pre_exec,
00119 xsh_util_bpmap_nl_raw2pre_destroy) ;
00120
00121 cpl_pluginlist_append(list, plugin) ;
00122
00123 return 0;
00124 }
00125
00126
00135
00136 static int xsh_util_bpmap_nl_raw2pre_create(cpl_plugin * plugin)
00137 {
00138 cpl_recipe * recipe ;
00139
00140
00141
00142 xsh_init();
00143
00144
00145 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00146 recipe = (cpl_recipe *)plugin ;
00147 else return -1 ;
00148 cpl_error_reset();
00149
00150
00151
00152 recipe->parameters = cpl_parameterlist_new() ;
00153
00154
00155 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00156
00157 cleanup:
00158
00159
00160 return 0;
00161 }
00162
00163
00169
00170 static int xsh_util_bpmap_nl_raw2pre_exec(cpl_plugin * plugin)
00171 {
00172 cpl_recipe * recipe ;
00173 int code=0;
00174 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00175
00176
00177 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00178 recipe = (cpl_recipe *)plugin ;
00179 else return -1 ;
00180 cpl_error_reset();
00181
00182 code = xsh_util_bpmap_nl_raw2pre(recipe->parameters, recipe->frames) ;
00183
00184
00185 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00186
00187
00188 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00189 }
00190
00191 return code ;
00192 }
00193
00194
00200
00201 static int xsh_util_bpmap_nl_raw2pre_destroy(cpl_plugin * plugin)
00202 {
00203 cpl_recipe * recipe ;
00204
00205
00206 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00207 recipe = (cpl_recipe *)plugin ;
00208 else return -1 ;
00209
00210 cpl_parameterlist_delete(recipe->parameters) ;
00211 return 0 ;
00212 }
00213
00214
00221
00222 static int
00223 xsh_util_bpmap_nl_raw2pre( cpl_parameterlist * parlist,
00224 cpl_frameset * framelist)
00225 {
00226 xsh_instrument* instrument=NULL;
00227
00228
00229 cpl_frame* bpmap_nl=NULL;
00230 xsh_pre* pre_bp_nl = NULL;
00231 cpl_frame* bp_nl_frame=NULL;
00232 char* bp_nl_tag=NULL;
00233 char* bp_nl_name=NULL;
00234 const char* pro_catg=NULL;
00235 const char* recipe_tags[1] = {XSH_RAW_BP_MAP_NL};
00236 int recipe_tags_size = 1;
00237 cpl_frameset* raws=NULL;
00238 cpl_frameset* calib=NULL;
00239
00240
00241 xsh_msg("Welcome to XSHOOTER Pipeline release %d.%d.%d",
00242 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
00243
00244 check( xsh_begin( framelist, parlist, &instrument, &raws, &calib,
00245 recipe_tags, recipe_tags_size,
00246 RECIPE_ID, XSH_BINARY_VERSION,
00247 xsh_util_bpmap_nl_raw2pre_description_short ) ) ;
00248
00249 bpmap_nl=xsh_find_frame_with_tag(framelist,XSH_RAW_BP_MAP_NL,instrument);
00250 check( pre_bp_nl = xsh_pre_create(bpmap_nl , NULL, NULL, instrument,0));
00251 bp_nl_tag=cpl_sprintf("%s_%s",XSH_BP_MAP_NL,
00252 xsh_instrument_arm_tostring( instrument ));
00253
00254 bp_nl_name=cpl_sprintf("%s.fits",bp_nl_tag);
00255 check( bp_nl_frame = xsh_pre_save( pre_bp_nl, bp_nl_name,bp_nl_tag,1 ));
00256 cpl_frameset_insert(framelist, bp_nl_frame);
00257 check(pro_catg=XSH_GET_TAG_FROM_ARM(XSH_MASTER_BP_MAP,instrument));
00258
00259 check( xsh_add_product_bpmap(bp_nl_frame, framelist, parlist,
00260 RECIPE_ID, instrument, pro_catg ));
00261
00262
00263 cleanup:
00264
00265
00266
00267 xsh_pre_free(&pre_bp_nl);
00268 xsh_free(bp_nl_name);
00269 xsh_free(bp_nl_tag);
00270 xsh_free_frameset(&raws);
00271 xsh_free_frameset(&calib);
00272
00273
00274 xsh_instrument_free(&instrument);
00275
00276 if (cpl_error_get_code()) {
00277 return -1 ;
00278 } else {
00279 return 0 ;
00280 }
00281 }