55#define XSH_UTL_IMA_ARITH_RECIPE_ID "xsh_util_ima_rebin"
56#define XSH_UTL_IMA_ARITH_RECIPE_AUTHOR "A.Modigliani"
57#define XSH_UTL_IMA_ARITH_RECIPE_CONTACT "Andrea.Modigliani@eso.org"
58#define PRO_IMA "PRO_IMA_UVB"
59#define KEY_VALUE_HPRO_DID "PRO-1.15"
76"This recipe performs image rebinning (no flux conservation).\n"
77"The input files should be list in an input file (no need to specify a tag)\n"
78"The output are resampled images with filenames\n"
79"binX_binY_filename.fits, \n"
80"where X and Y are the input binx/y parameters values\n"
81"Information on relevant parameters can be found with\n"
82"esorex --params xsh_util_ima_rebin\n"
83"esorex --help xsh_util_ima_rebin\n"
108 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe ) ;
109 cpl_plugin * plugin = &recipe->interface ;
111 cpl_plugin_init(plugin,
114 CPL_PLUGIN_TYPE_RECIPE,
125 cpl_pluginlist_append(list, plugin) ;
142 cpl_recipe * recipe ;
149 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
150 recipe = (cpl_recipe *)plugin ;
156 recipe->parameters = cpl_parameterlist_new() ;
161 recipe->parameters ) ) ;
164 p = cpl_parameter_new_range(
"xsh.xsh_util_ima_rebin.binx",
166 "Rebinning X factor: pix_size_o/pix_size_i",
167 "xsh.xsh_util_ima_rebin",1,1,2);
168 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"binx") ;
169 cpl_parameterlist_append(recipe->parameters, p) ;
173 p = cpl_parameter_new_range(
"xsh.xsh_util_ima_rebin.biny",
175 "Rebinning Y factor: pix_size_o/pix_size_i",
176 "xsh.xsh_util_ima_rebin",1,1,2);
177 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"biny") ;
178 cpl_parameterlist_append(recipe->parameters, p) ;
195 cpl_recipe * recipe ;
197 cpl_errorstate initial_errorstate = cpl_errorstate_get();
200 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
201 recipe = (cpl_recipe *)plugin ;
208 if (!cpl_errorstate_is_equal(initial_errorstate)) {
211 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
226 cpl_recipe * recipe ;
229 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
230 recipe = (cpl_recipe *)plugin ;
233 cpl_parameterlist_delete(recipe->parameters) ;
247 cpl_frameset * frames)
249 cpl_parameter * param= NULL ;
251 cpl_image* ima_tot=NULL;
252 cpl_image* ima_pre=NULL;
253 cpl_image* ima_ove=NULL;
254 cpl_image* ima_dat=NULL;
256 cpl_image* ima_datr=NULL;
257 cpl_image* ima_prer=NULL;
258 cpl_image* ima_over=NULL;
260 cpl_image* ima_new=NULL;
261 cpl_propertylist* plist=NULL;
262 cpl_propertylist* hext=NULL;
267 const char* name=NULL;
286 const char* base_name=NULL;
289 xsh_msg(
"Welcome to XSHOOTER Pipeline release %d.%d.%d",
290 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
294 check(param=cpl_parameterlist_find(parlist,
295 "xsh.xsh_util_ima_rebin.binx"));
296 check(
binx=cpl_parameter_get_int(param));
299 check(param=cpl_parameterlist_find(parlist,
300 "xsh.xsh_util_ima_rebin.biny"));
301 check(
biny=cpl_parameter_get_int(param));
302 nfrm=cpl_frameset_get_size(frames);
305 for (i = 0; i < nfrm; i++) {
306 frm=cpl_frameset_get_frame(frames,i);
308 check(name=cpl_frame_get_filename(frm));
309 next=cpl_frame_get_nextensions(frm);
310 check(plist=cpl_propertylist_load(name,0));
317 xsh_msg(
"Prescan: %d,%d Overscan: %d,%d",prscx,prscy,ovscx,ovscy);
331 xsh_msg(
"Prescan: %d,%d Overscan: %d,%d",prscx,prscy,ovscx,ovscy);
333 if(cpl_propertylist_has(plist,
XSH_CDELT1) > 0) {
340 cpl_propertylist_append_double(plist,
XSH_CDELT1,2);
347 if(cpl_propertylist_has(plist,
XSH_CDELT2) > 0) {
354 cpl_propertylist_append_double(plist,
XSH_CDELT2,2);
359 for(k=0;k<=next;k++) {
360 check(ima_tot=cpl_image_load(name,CPL_TYPE_FLOAT,0,k));
361 check(hext=cpl_propertylist_load(name,k));
363 check(
nx=cpl_image_get_size_x(ima_tot));
364 check(
ny=cpl_image_get_size_y(ima_tot));
366 check(ima_dat=cpl_image_extract(ima_tot,prscx+1,prscy+1,
nx-ovscx,
ny-ovscy));
367 check(ima_pre=cpl_image_extract(ima_tot,1,prscy+1,prscx,
ny));
368 check(ima_ove=cpl_image_extract(ima_tot,
nx-ovscx+1,prscy+1,
nx,
ny));
370 sprintf(new_name,
"pre_binx%d_biny%d_%s",
binx,
biny,base_name);
374 sprintf(new_name,
"ove_binx%d_biny%d_%s",
binx,
biny,base_name);
378 sprintf(new_name,
"dat_binx%d_biny%d_%s",
binx,
biny,base_name);
383 check(ima_datr=cpl_image_extract_subsample(ima_dat,
binx,
biny));
384 check(ima_prer=cpl_image_extract_subsample(ima_pre,
binx,
biny));
385 check(ima_over=cpl_image_extract_subsample(ima_ove,
binx,
biny));
387 check(nxpr=cpl_image_get_size_x(ima_prer));
388 check(nypr=cpl_image_get_size_y(ima_prer));
389 check(nxor=cpl_image_get_size_x(ima_over));
390 check(nyor=cpl_image_get_size_y(ima_over));
391 check(nxdr=cpl_image_get_size_x(ima_datr));
392 check(nydr=cpl_image_get_size_y(ima_datr));
394 check(ima_new=cpl_image_new(nxpr+nxdr+nxor,
ny/2,
396 check(cpl_image_copy(ima_new,ima_prer,1,1));
397 check(cpl_image_copy(ima_new,ima_datr,1+nxpr,1));
398 check(cpl_image_copy(ima_new,ima_over,1+nxpr+nxdr,1));
400 sprintf(new_name,
"datr_binx%d_biny%d_%s",
binx,
biny,base_name);
404 sprintf(new_name,
"binx%d_biny%d_%s",
binx,
biny,base_name);
405 xsh_msg(
"new_name=%s",new_name);
437 if (cpl_error_get_code()) {
#define xsh_msg(...)
Print a message on info level.
int xsh_pfits_get_ovscx(const cpl_propertylist *plist)
find out the OVSCX value
double xsh_pfits_get_cdelt2(const cpl_propertylist *plist)
find out the cdelt2
int xsh_pfits_get_ovscy(const cpl_propertylist *plist)
find out the OVSCY value
double xsh_pfits_get_cdelt1(const cpl_propertylist *plist)
find out the cdelt1
int xsh_pfits_get_prscx(const cpl_propertylist *plist)
find out the PRSCX value
int xsh_pfits_get_prscy(const cpl_propertylist *plist)
find out the PRSCY value
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int xsh_util_ima_rebin(cpl_parameterlist *, cpl_frameset *)
Get the command line options and execute the data reduction.
static int xsh_util_ima_rebin_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static int xsh_util_ima_rebin_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static int xsh_util_ima_rebin_create(cpl_plugin *)
Setup the recipe options
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
char * xsh_get_basename(const char *filename)
Return base filename.
const char * xsh_get_license(void)
Get the pipeline copyright and license.
void xsh_init(void)
Reset library state.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
static char xsh_util_ima_rebin_description_short[]
#define XSH_UTL_IMA_ARITH_RECIPE_AUTHOR
static char xsh_util_ima_rebin_description[]
#define XSH_UTL_IMA_ARITH_RECIPE_ID
#define XSH_UTL_IMA_ARITH_RECIPE_CONTACT