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
00042
00043
00044
00045
00046
00047
00048
00049 #include <xsh_dfs.h>
00050 #include <xsh_data_pre.h>
00051 #include <xsh_parameters.h>
00052 #include <xsh_drl.h>
00053 #include <xsh_msg.h>
00054 #include <xsh_pfits.h>
00055 #include <xsh_error.h>
00056
00057
00058
00059
00060
00061
00062
00063 #define XSH_UTL_BPMAP2RP_RECIPE_ID "xsh_util_bpmap2rp"
00064 #define XSH_UTL_BPMAP2RP_RECIPE_AUTHOR "A.Modigliani"
00065 #define XSH_UTL_BPMAP2RP_RECIPE_CONTACT "Andrea.Modigliani@eso.org"
00066 #define PRO_IMA "PRO_IMA_UVB"
00067 #define KEY_VALUE_HPRO_DID "PRO-1.15"
00068
00069
00070
00071
00072 static int xsh_util_bpmap2rp_create(cpl_plugin *) ;
00073 static int xsh_util_bpmap2rp_exec(cpl_plugin *) ;
00074 static int xsh_util_bpmap2rp_destroy(cpl_plugin *) ;
00075 static int xsh_util_bpmap2rp(cpl_parameterlist *, cpl_frameset *) ;
00076
00077
00078
00079
00080
00081 static char
00082 xsh_util_bpmap2rp_description_short[] = "Converts BP map code to RP code";
00083 static char xsh_util_bpmap2rp_description[] =
00084 "This recipe performs image computation.\n"
00085 "Information on relevant parameters can be found with\n"
00086 "esorex --params xsh_util_bpmap2rp\n"
00087 "esorex --help xsh_util_bpmap2rp\n"
00088 "\n";
00089
00090
00091
00092
00093
00098
00099
00101
00109
00110 int cpl_plugin_get_info(cpl_pluginlist * list)
00111 {
00112 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00113 cpl_plugin * plugin = &recipe->interface ;
00114
00115 cpl_plugin_init(plugin,
00116 CPL_PLUGIN_API,
00117 XSH_BINARY_VERSION,
00118 CPL_PLUGIN_TYPE_RECIPE,
00119 XSH_UTL_BPMAP2RP_RECIPE_ID,
00120 xsh_util_bpmap2rp_description_short,
00121 xsh_util_bpmap2rp_description,
00122 XSH_UTL_BPMAP2RP_RECIPE_AUTHOR,
00123 XSH_UTL_BPMAP2RP_RECIPE_CONTACT,
00124 xsh_get_license(),
00125 xsh_util_bpmap2rp_create,
00126 xsh_util_bpmap2rp_exec,
00127 xsh_util_bpmap2rp_destroy) ;
00128
00129 cpl_pluginlist_append(list, plugin) ;
00130
00131 return 0;
00132 }
00133
00134
00143
00144 static int xsh_util_bpmap2rp_create(cpl_plugin * plugin)
00145 {
00146 cpl_recipe * recipe ;
00147 cpl_parameter * p ;
00148
00149
00150 xsh_init();
00151
00152
00153 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00154 recipe = (cpl_recipe *)plugin ;
00155 else return -1 ;
00156 cpl_error_reset();
00157
00158
00159
00160 recipe->parameters = cpl_parameterlist_new() ;
00161
00162
00163
00164 check( xsh_parameters_generic(XSH_UTL_BPMAP2RP_RECIPE_ID,
00165 recipe->parameters ) ) ;
00166 xsh_parameters_decode_bp(XSH_UTL_BPMAP2RP_RECIPE_ID,recipe->parameters,-1);
00167
00168
00169 p = cpl_parameter_new_value("xsh.xsh_util_bpmap2rp.op",
00170 CPL_TYPE_STRING,
00171 "A possible operation",
00172 "xsh.xsh_util_bpmap2rp","+");
00173 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00174 cpl_parameterlist_append(recipe->parameters, p) ;
00175
00176
00177 p = cpl_parameter_new_value("xsh.xsh_util_bpmap2rp.value",
00178 CPL_TYPE_DOUBLE, "a value", "xsh.xsh_util_bpmap2rp", 9999.) ;
00179 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "value") ;
00180 cpl_parameterlist_append(recipe->parameters, p) ;
00181 cleanup:
00182
00183
00184 return 0;
00185 }
00186
00187
00193
00194 static int xsh_util_bpmap2rp_exec(cpl_plugin * plugin)
00195 {
00196 cpl_recipe * recipe ;
00197 int code=0;
00198 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00199
00200
00201 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00202 recipe = (cpl_recipe *)plugin ;
00203 else return -1 ;
00204 cpl_error_reset();
00205
00206 code = xsh_util_bpmap2rp(recipe->parameters, recipe->frames) ;
00207
00208
00209 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00210
00211
00212 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00213 }
00214
00215 return code ;
00216 }
00217
00218
00224
00225 static int xsh_util_bpmap2rp_destroy(cpl_plugin * plugin)
00226 {
00227 cpl_recipe * recipe ;
00228
00229
00230 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00231 recipe = (cpl_recipe *)plugin ;
00232 else return -1 ;
00233
00234 cpl_parameterlist_delete(recipe->parameters) ;
00235 return 0 ;
00236 }
00237
00238
00245
00246 static int
00247 xsh_util_bpmap2rp( cpl_parameterlist * parlist,
00248 cpl_frameset * framelist)
00249 {
00250 cpl_image * ima=NULL ;
00251 cpl_propertylist * head=NULL ;
00252 int n=0;
00253 int i=0;
00254 const char* name=NULL;
00255 cpl_frame* frm=NULL;
00256
00257 xsh_msg("Welcome to XSHOOTER Pipeline release %d.%d.%d",
00258 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
00259
00260 n=cpl_frameset_get_size(framelist);
00261 if(n<1) {
00262 xsh_msg_error("Empty input frame list!");
00263 goto cleanup ;
00264 }
00265
00266
00267 for(i=0;i<n;i++) {
00268 frm=cpl_frameset_get_frame(framelist,i);
00269 name=cpl_frame_get_filename(frm);
00270 ima=cpl_image_load(name,CPL_TYPE_FLOAT,0,0);
00271 head=cpl_propertylist_load(name,0);
00272 xsh_bpmap_bitwise_to_flag(ima,QFLAG_CALIB_FILE_DEFECT);
00273 cpl_image_save(ima,name,CPL_BPP_IEEE_FLOAT,head,CPL_IO_DEFAULT);
00274 xsh_free_propertylist(&head);
00275 xsh_free_image(&ima);
00276 }
00277
00278 cleanup:
00279
00280 xsh_free_image(&ima);
00281 xsh_free_propertylist(&head) ;
00282
00283 if (cpl_error_get_code()) {
00284 return -1 ;
00285 } else {
00286 return 0 ;
00287 }
00288
00289 }