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 #include <xsh_dfs.h>
00041 #include <xsh_data_pre.h>
00042 #include <xsh_parameters.h>
00043 #include <xsh_drl.h>
00044 #include <xsh_msg.h>
00045 #include <xsh_pfits.h>
00046 #include <xsh_error.h>
00047 #include <xsh_utils.h>
00048 #include <xsh_utils_image.h>
00049
00050
00051
00052
00053
00054 #define XSH_UTL_IMA_OVERSAMPLE_RECIPE_ID "xsh_util_ima_oversample"
00055 #define XSH_UTL_IMA_OVERSAMPLE_RECIPE_AUTHOR "A.Modigliani"
00056 #define XSH_UTL_IMA_OVERSAMPLE_RECIPE_CONTACT "Andrea.Modigliani@eso.org"
00057 #define PRO_IMA "PRO_IMA_UVB"
00058 #define KEY_VALUE_HPRO_DID "PRO-1.15"
00059
00060
00061
00062
00063 static int xsh_util_ima_oversample_create(cpl_plugin *) ;
00064 static int xsh_util_ima_oversample_exec(cpl_plugin *) ;
00065 static int xsh_util_ima_oversample_destroy(cpl_plugin *) ;
00066 static int xsh_util_ima_oversample(cpl_parameterlist *, cpl_frameset *) ;
00067
00068
00069
00070
00071
00072 static char
00073 xsh_util_ima_oversample_description_short[] = "Oversample image(s)";
00074 static char xsh_util_ima_oversample_description[] =
00075 "This recipe performs image oversampling (no flux conservation).\n"
00076 "The input files should be list in an input file (no need to specify a tag)\n"
00077 "The output are resampled images with filenames\n"
00078 "binX_binY_filename.fits, \n"
00079 "where X and Y are the input binx/y parameters values\n"
00080 "Information on relevant parameters can be found with\n"
00081 "esorex --params xsh_util_ima_oversample\n"
00082 "esorex --help xsh_util_ima_oversample\n"
00083 "\n";
00084
00085
00086
00087
00088
00093
00094
00096
00104
00105 int cpl_plugin_get_info(cpl_pluginlist * list)
00106 {
00107 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00108 cpl_plugin * plugin = &recipe->interface ;
00109
00110 cpl_plugin_init(plugin,
00111 CPL_PLUGIN_API,
00112 XSH_BINARY_VERSION,
00113 CPL_PLUGIN_TYPE_RECIPE,
00114 XSH_UTL_IMA_OVERSAMPLE_RECIPE_ID,
00115 xsh_util_ima_oversample_description_short,
00116 xsh_util_ima_oversample_description,
00117 XSH_UTL_IMA_OVERSAMPLE_RECIPE_AUTHOR,
00118 XSH_UTL_IMA_OVERSAMPLE_RECIPE_CONTACT,
00119 xsh_get_license(),
00120 xsh_util_ima_oversample_create,
00121 xsh_util_ima_oversample_exec,
00122 xsh_util_ima_oversample_destroy) ;
00123
00124 cpl_pluginlist_append(list, plugin) ;
00125
00126 return 0;
00127 }
00128
00129
00138
00139 static int xsh_util_ima_oversample_create(cpl_plugin * plugin)
00140 {
00141 cpl_recipe * recipe ;
00142 cpl_parameter * p ;
00143
00144
00145 xsh_init();
00146
00147
00148 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00149 recipe = (cpl_recipe *)plugin ;
00150 else return -1 ;
00151 cpl_error_reset();
00152
00153
00154
00155 recipe->parameters = cpl_parameterlist_new() ;
00156
00157
00158
00159 check( xsh_parameters_generic(XSH_UTL_IMA_OVERSAMPLE_RECIPE_ID,
00160 recipe->parameters ) ) ;
00161 xsh_parameters_decode_bp(XSH_UTL_IMA_OVERSAMPLE_RECIPE_ID,recipe->parameters,-1);
00162
00163 p = cpl_parameter_new_range("xsh.xsh_util_ima_oversample.fctx",
00164 CPL_TYPE_INT,
00165 "Over-sampling X factor: pix_size_i/pix_size_o",
00166 "xsh.xsh_util_ima_oversample",1,1,2);
00167 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fctx") ;
00168 cpl_parameterlist_append(recipe->parameters, p) ;
00169
00170 p = cpl_parameter_new_range("xsh.xsh_util_ima_oversample.fcty",
00171 CPL_TYPE_INT,
00172 "Over-sampling Y factor: pix_size_i/pix_size_o",
00173 "xsh.xsh_util_ima_oversample",1,1,2);
00174 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fcty") ;
00175 cpl_parameterlist_append(recipe->parameters, p) ;
00176
00177 cleanup:
00178
00179
00180 return 0;
00181 }
00182
00183
00189
00190 static int xsh_util_ima_oversample_exec(cpl_plugin * plugin)
00191 {
00192 cpl_recipe * recipe ;
00193 int code=0;
00194 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00195
00196
00197 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00198 recipe = (cpl_recipe *)plugin ;
00199 else return -1 ;
00200 cpl_error_reset();
00201
00202 code = xsh_util_ima_oversample(recipe->parameters, recipe->frames) ;
00203
00204
00205 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00206
00207
00208 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00209 }
00210
00211 return code ;
00212 }
00213
00214
00220
00221 static int xsh_util_ima_oversample_destroy(cpl_plugin * plugin)
00222 {
00223 cpl_recipe * recipe ;
00224
00225
00226 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00227 recipe = (cpl_recipe *)plugin ;
00228 else return -1 ;
00229
00230 cpl_parameterlist_delete(recipe->parameters) ;
00231 return 0 ;
00232 }
00233
00234
00241
00242 static int
00243 xsh_util_ima_oversample( cpl_parameterlist * parlist,
00244 cpl_frameset * frames)
00245 {
00246 cpl_parameter * param= NULL ;
00247 cpl_frame* frm=NULL;
00248 cpl_image* ima_dat=NULL;
00249
00250 cpl_image* ima_datr=NULL;
00251 cpl_propertylist* plist=NULL;
00252 cpl_propertylist* hext=NULL;
00253
00254 int fctx=1;
00255 int fcty=1;
00256 int nfrm=0;
00257
00258 cpl_frame* frm_new=NULL;
00259
00260 xsh_msg("Welcome to XSHOOTER Pipeline release %d.%d.%d",
00261 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
00262
00263
00264
00265 check(param=cpl_parameterlist_find(parlist,
00266 "xsh.xsh_util_ima_oversample.fctx"));
00267 check(fctx=cpl_parameter_get_int(param));
00268
00269
00270 check(param=cpl_parameterlist_find(parlist,
00271 "xsh.xsh_util_ima_oversample.fcty"));
00272 check(fcty=cpl_parameter_get_int(param));
00273 nfrm=cpl_frameset_get_size(frames);
00274
00275
00276 for (frm = cpl_frameset_get_first(frames);
00277 frm != NULL;
00278 frm = cpl_frameset_get_next(frames)) {
00279
00280 frm_new=xsh_frame_image_mult_by_fct(frm,fctx,fcty);
00281
00282 }
00283
00284 cleanup:
00285 xsh_free_image(&ima_dat);
00286 xsh_free_image(&ima_datr);
00287 xsh_free_propertylist(&plist);
00288 xsh_free_propertylist(&hext);
00289
00290 if (cpl_error_get_code()) {
00291 return -1 ;
00292 } else {
00293 return 0 ;
00294 }
00295
00296 }