56#define RECIPE_ID "xsh_util_afc"
57#define RECIPE_AUTHOR "A.Modigliani"
58#define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
59#define PRO_IMA "PRO_IMA_UVB"
60#define KEY_VALUE_HPRO_DID "PRO-1.15"
62#define SPEED_LIGHT 2.99792458*1.E8
63#define TEL_AREA 51.2e4
71static int xsh_util_afc(cpl_parameterlist *, cpl_frameset *) ;
80"This recipe compute shift of AFC frame with respect to reference pos.\n"
81"The input files should be tagged as: \n"
82"AFC frame: AFC_arm,\n"
83"AFC pos table: AFC_POS_arm,\n"
84"The output is a table with measured positions, shifts and QC\n"
85"Information on relevant parameters can be found with\n"
86"esorex --params xsh_util_afc\n"
87"esorex --help xsh_util_afc\n"
112 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe ) ;
113 cpl_plugin * plugin = &recipe->interface ;
115 cpl_plugin_init(plugin,
118 CPL_PLUGIN_TYPE_RECIPE,
129 cpl_pluginlist_append(list, plugin) ;
146 cpl_recipe * recipe ;
152 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
153 recipe = (cpl_recipe *)plugin ;
159 recipe->parameters = cpl_parameterlist_new() ;
164 recipe->parameters ) ) ;
182 cpl_recipe * recipe ;
184 cpl_errorstate initial_errorstate = cpl_errorstate_get();
187 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
188 recipe = (cpl_recipe *)plugin ;
192 code =
xsh_util_afc(recipe->parameters, recipe->frames) ;
195 if (!cpl_errorstate_is_equal(initial_errorstate)) {
198 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
213 cpl_recipe * recipe ;
216 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
217 recipe = (cpl_recipe *)plugin ;
220 cpl_parameterlist_delete(recipe->parameters) ;
235 cpl_frameset * frames)
238 int recipe_tags_size = 1;
242 cpl_frame* frm_tab=NULL;
243 cpl_frame* frm_afc=NULL;
245 cpl_frameset* raws=NULL;
246 cpl_frameset* calib=NULL;
248 cpl_image* ima_afc=NULL;
249 cpl_table* tbl_afc=NULL;
251 const char* name=NULL;
260 cpl_propertylist* plist=NULL;
271 cpl_frame* frm_tab_afc=NULL;
272 const char* tag=NULL;
275 xsh_msg(
"Welcome to XSHOOTER Pipeline release %d.%d.%d",
276 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
281 recipe_tags, recipe_tags_size,
292 check(name=cpl_frame_get_filename(frm_afc));
294 check(ima_afc=cpl_image_load(name,CPL_TYPE_DOUBLE,0,0));
295 check(name=cpl_frame_get_filename(frm_tab));
296 check(tbl_afc=cpl_table_load(name,1,0));
297 check(nrow=cpl_table_get_nrow(tbl_afc));
299 cpl_table_new_column(tbl_afc,
"XM",CPL_TYPE_FLOAT);
300 cpl_table_new_column(tbl_afc,
"YM",CPL_TYPE_FLOAT);
301 cpl_table_fill_column_window_float(tbl_afc,
"XM",0,nrow,-1);
302 cpl_table_fill_column_window_float(tbl_afc,
"YM",0,nrow,-1);
304 check(px=cpl_table_get_data_float(tbl_afc,
"X"));
305 check(py=cpl_table_get_data_float(tbl_afc,
"Y"));
307 check(pxm=cpl_table_get_data_float(tbl_afc,
"XM"));
308 check(pym=cpl_table_get_data_float(tbl_afc,
"YM"));
311 for(i=0;i<nrow;i++) {
319 check(xc=cpl_image_get_centroid_x_window(ima_afc,
322 check(yc=cpl_image_get_centroid_y_window(ima_afc,
330 cpl_table_duplicate_column(tbl_afc,
"RESX",tbl_afc,
"XM");
331 cpl_table_duplicate_column(tbl_afc,
"RESY",tbl_afc,
"YM");
333 cpl_table_subtract_columns(tbl_afc,
"RESX",
"X");
334 cpl_table_subtract_columns(tbl_afc,
"RESY",
"Y");
336 resx_med=cpl_table_get_column_median(tbl_afc,
"RESX");
337 resy_med=cpl_table_get_column_median(tbl_afc,
"RESY");
339 resx_avg=cpl_table_get_column_mean(tbl_afc,
"RESX");
340 resy_avg=cpl_table_get_column_mean(tbl_afc,
"RESY");
341 xsh_msg(
"AFC med shift X: %g Y: %g",resx_med,resy_med);
342 xsh_msg(
"AFC avg shift X: %g Y: %g",resx_avg,resy_avg);
344 sprintf(afc_name,
"%s.fits",tag);
345 check(plist=cpl_propertylist_new());
350 check(cpl_table_save(tbl_afc,plist,NULL,afc_name,CPL_IO_DEFAULT));
352 CPL_FRAME_TYPE_TABLE,
353 CPL_FRAME_GROUP_PRODUCT,
354 CPL_FRAME_LEVEL_FINAL));
367 if (cpl_error_get_code()) {
static xsh_instrument * instrument
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
#define xsh_msg(...)
Print a message on info level.
static int xsh_util_afc_create(cpl_plugin *)
Setup the recipe options
static int xsh_util_afc_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int xsh_util_afc(cpl_parameterlist *, cpl_frameset *)
Get the command line options and execute the data reduction.
static int xsh_util_afc_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
const char * xsh_get_license(void)
Get the pipeline copyright and license.
void xsh_init(void)
Reset library state.
cpl_error_code xsh_begin(cpl_frameset *frames, const cpl_parameterlist *parameters, xsh_instrument **instrument, cpl_frameset **raws, cpl_frameset **calib, const char *tag_list[], int tag_list_size, const char *recipe_id, unsigned int binary_version, const char *short_descr)
Recipe initialization.
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
void xsh_add_product_table(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
Save Table product (input frame has several extensions, 1 table per extension)
cpl_frame * xsh_frame_product(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level)
Creates a frame with given characteristics.
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
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)
#define XSH_QC_AFC_RESY_MED
#define XSH_QC_AFC_RESX_MED
#define XSH_QC_AFC_RESY_AVG
#define XSH_QC_AFC_RESX_AVG
static char xsh_util_afc_description_short[]
static char xsh_util_afc_description[]