73#define RECIPE_ID "xsh_scired_ifu_offset"
74#define RECIPE_AUTHOR "A.Modigliani, J.Vernet, P. Bristow"
75#define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
96"Reduce science IFU on-off exposures and build a 3D cube";
99"This recipe Reduce science IFU on-off exposures and build a 3D cube\n\
101 - A set of 2xn Science frames, \
102 Tag = OBJECT_IFU_OFFSET_arm, SKY_IFU_arm\n\
103 - A spectral format table (Tag = SPECTRAL_FORMAT_TAB_arm)\n\
104 - A master flat frame (Tag = MASTER_FLAT_IFU_arm)\n\
105 - An order table frame(Tag = ORDER_TABLE_EDGES_IFU_arm)\n\
106 - 3 wave solution frames, one per slitlet (Tag = WAVE_TAB_ARC_IFU_slitlet_arm)\n\
107 where 'slitlet' is DOWN, CEN or UP\n\
108 - [OPTIONAL] A dispersion table (Tag = DISP_TAB_IFU_arm)\n\
109 - [OPTIONAL] A non-linear badpixel map (Tag = BP_MAP_NL_arm)\n\
110 - [OPTIONAL] A reference badpixel map (Tag = BP_MAP_RP_arm)\n\
112 - Merged 3D data cube (PREFIX_MERGE3D_DATA_OBJ_arm)\n\
113 - QC Traces of 3D data cube (PREFIX_MERGE3D_TRACE_OBJ_arm)\n\
114 - Order by order 3D data cube (PREFIX_ORDER3D_DATA_OBJ_arm)\n\
115 - Order by order 3D qual cube (IFU_CFG_COR_arm)\n\
116 - Order by order 3D qual cube (PREFIX_MERGE3D_DATA_SKY_arm)\n\
117 - where PREFIX is SCI, FLUX, TELL if input raw DPR.TYPE contains OBJECT or FLUX or TELLURIC\n\
118 - 1 Spectrum merge 3D, PRO.CATG=MERGE3D_IFU_arm\n" ;
135 cpl_recipe *recipe = NULL;
136 cpl_plugin *plugin = NULL;
138 recipe = cpl_calloc(1,
sizeof(*recipe));
139 if ( recipe == NULL ){
143 plugin = &recipe->interface ;
145 cpl_plugin_init(plugin,
148 CPL_PLUGIN_TYPE_RECIPE,
159 cpl_pluginlist_append(list, plugin);
161 return (cpl_error_get_code() != CPL_ERROR_NONE);
177 cpl_recipe *recipe = NULL;
201 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin");
203 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
204 CPL_ERROR_TYPE_MISMATCH,
205 "Plugin is not a recipe");
207 recipe = (cpl_recipe *)plugin;
210 recipe->parameters = cpl_parameterlist_new();
211 assure( recipe->parameters != NULL,
212 CPL_ERROR_ILLEGAL_OUTPUT,
213 "Memory allocation failed!");
254 "compute-map", FALSE,
255 "if TRUE recompute (wave and slit) maps from the dispersion solution. If sky-subtract is set to TRUE this must be set to TRUE."));
259 "if TRUE trace object position on each IFU slice. In this case order TAB edges is required"));
264 "Input AFC corrected model/wave solution and science frame check. If TRUE the recipe verify that the input mode/wave solution is AFC corrected, its INS.OPTIi.NAME is 'Pin_0.5 ', and its OBS.ID and OBS.TARG.NAME values matches with the corresponding values of the science frame."));
267 "cut-uvb-spectrum", TRUE,
268 "TRUE if recipe cuts the UVB spectrum at 556 nm (dichroich)"));
271 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
289 cpl_recipe *recipe = NULL;
293 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin");
296 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
297 CPL_ERROR_TYPE_MISMATCH,
"Plugin is not a recipe");
299 recipe = (cpl_recipe *)plugin;
305 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
325 xsh_msg_dbg_low(
"rectify params: radius=%g bin_lambda=%g bin_space=%g",
329 return cpl_error_get_code();
348 cpl_frame* frame=NULL;
349 const char* name=NULL;
350 cpl_propertylist* plist=NULL;
354 check(frame=cpl_frameset_get_frame(raws,0));
355 check(name=cpl_frame_get_filename(frame));
356 check(plist=cpl_propertylist_load(name,0));
413 return cpl_error_get_code();
427 cpl_recipe *recipe = NULL;
432 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin" );
435 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
436 CPL_ERROR_TYPE_MISMATCH,
"Plugin is not a recipe");
438 recipe = (cpl_recipe *)plugin;
443 if (cpl_error_get_code() != CPL_ERROR_NONE)
464 cpl_frameset* frameset)
467 int recipe_tags_size = 4;
471 cpl_frame *spectral_format_frame = NULL;
472 cpl_frame *ifu_cfg_tab_frame = NULL ;
473 cpl_frame *ifu_cfg_cor_frame = NULL ;
478 cpl_frameset* raws = NULL;
479 cpl_frameset* calib = NULL;
482 cpl_frame* bpmap = NULL;
483 cpl_frame * master_bias = NULL ;
484 cpl_frame * master_dark = NULL ;
485 cpl_frame* master_flat = NULL;
486 cpl_frame* order_tab_edges = NULL;
487 cpl_frame * wavesol_frame = NULL ;
488 cpl_frame * model_config_frame = NULL ;
490 cpl_frame * slice_offset_frame = NULL ;
491 cpl_frameset * raw_object = NULL, * raw_sky = NULL ;
505 cpl_frameset * sub_frameset = NULL ;
507 cpl_frameset * clean_frameset = NULL ;
509 cpl_frame * comb_obj_frame = NULL ;
510 cpl_frameset * rect2_frameset = NULL ;
514 cpl_frameset * res_1D_frameset = NULL ;
515 cpl_frameset * res_2D_frameset = NULL ;
516 cpl_frame * data_cube = NULL ;
517 cpl_frameset * ext_frameset = NULL ;
518 cpl_frameset * ext_frameset_tables = NULL ;
522 char * file_tag = NULL;
523 cpl_frame* grid_backg=NULL;
524 cpl_frame* frame_backg=NULL;
525 cpl_frameset * ext_frameset_images = NULL ;
526 cpl_frameset * rect2_frameset_tables = NULL ;
529 char rec_prefix[256];
530 char sky_prefix[256];
533 int do_compute_map = TRUE;
534 int recipe_use_model = FALSE;
537 cpl_frame *wavemap = NULL ;
538 cpl_frame *slitmap = NULL ;
539 cpl_frame *disp_tab_frame = NULL;
540 cpl_frame* comb_sky_frame=NULL;
541 int pre_overscan_corr=0;
542 cpl_frame* ifu_sky_map=NULL;
545 cpl_frameset* crh_clean_obj = NULL;
546 cpl_frameset* crh_clean_sky = NULL;
547 cpl_frame* sky_map_frm = NULL;
548 int do_flatfield = 1;
553 recipe_tags, recipe_tags_size,
559 "Instrument NOT in Ifu Mode" ) ;
562 check( nb_raw_frames = cpl_frameset_get_size( raws ) ) ;
563 xsh_msg(
"Nb of Raw frames: %d", nb_raw_frames ) ;
568 int even_nb = nb_raw_frames % 2 ;
605 if(model_config_frame==NULL) {
622 (model_config_frame == NULL && wavesol_frame != NULL ) );
658 xsh_msg(
"Use Max Possible Slit" ) ;
693 check(strcpy(rec_prefix,(
const char*)prefix));
697 if ( model_config_frame == NULL){
698 xsh_msg(
"RECIPE USE WAVE SOLUTION");
699 recipe_use_model = FALSE;
700 do_compute_map = TRUE;
704 recipe_use_model = TRUE;
707 if ( do_compute_map && recipe_use_model==FALSE){
713 xsh_msg(
"cmap=%d wavemap=%p slitmap=%p",do_computemap,wavemap,slitmap);
714 if( (do_computemap == 1) &&
715 (wavemap ==NULL || slitmap ==NULL )
717 if (model_config_frame != NULL) {
722 master_flat, model_config_frame, calib,
instrument,
723 do_computemap, use_model, rec_prefix,
724 &wavemap, &slitmap));
728 if( nb_sub_frames==0 ) {
729 xsh_msg_error(
"nb_sub_frames=%d something wrong check your input raws",nb_sub_frames);
768 if (do_flatfield == 1) {
771 clean_frameset = cpl_frameset_duplicate(sub_frameset);
865 xsh_msg(
"Combining all frames" ) ;
867 "ALL", (
void*)NULL ) ;
880 spectral_format_frame,
881 model_config_frame,wavesol_frame,
884 parameters,rectify_par,
RECIPE_ID,rec_prefix,1));
890 spectral_format_frame,
891 model_config_frame,wavesol_frame,
894 parameters,rectify_par,
RECIPE_ID,rec_prefix,0));
static xsh_instrument * instrument
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static cpl_error_code xsh_params_bin_scale(cpl_frameset *raws, xsh_background_param *backg, xsh_opt_extract_param *opt_extract_par, int *sub_sky_nbkpts1, int *sub_sky_nbkpts2)
Interpret the command line options and execute the data processing.
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
#define XSH_ASSURE_NOT_ILLEGAL(cond)
#define assure(CONDITION, ERROR_CODE,...)
#define xsh_error_dump(level)
#define xsh_error_reset()
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
#define xsh_msg_warning(...)
Print an warning message.
#define xsh_msg_error(...)
Print an error message.
#define xsh_msg(...)
Print a message on info level.
#define xsh_msg_dbg_low(...)
int xsh_pfits_get_binx(const cpl_propertylist *plist)
find out the BINX value
int xsh_pfits_get_biny(const cpl_propertylist *plist)
find out the BINY value
cpl_frame * xsh_combine_offset(cpl_frameset *rawFrames, const char *result_name, xsh_stack_param *stack_par, xsh_instrument *instr, cpl_imagelist **list, cpl_image **crh_ima, const int save_tmp)
static cpl_error_code xsh_params_monitor(xsh_rectify_param *rectify_par)
monitor parameters value
static char xsh_scired_ifu_offset_description[]
static char xsh_scired_ifu_offset_description_short[]
cpl_frameset * xsh_subtract_sky_offset(cpl_frameset *object_raws, cpl_frameset *sky_raws, int nraws, xsh_instrument *instrument)
void xsh_free_parameterlist(cpl_parameterlist **p)
Deallocate a parameter list and set the pointer to NULL.
const char * xsh_set_recipe_sky_file_prefix(char *rec_prefix)
Set recipe sky frames prefix.
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.
char * xsh_set_recipe_file_prefix(cpl_frameset *raw, const char *recipe)
Set recipe frames prefix.
const char * xsh_get_license(void)
Get the pipeline copyright and license.
char * xsh_stringcat_any(const char *s,...)
Concatenate an arbitrary number of strings.
cpl_frame * xsh_util_frameset_collapse_mean(cpl_frameset *set, xsh_instrument *instrument)
Compute mean frame from a list of (IMAGE) framesets.
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.
cpl_error_code xsh_rectify_params_set_defaults(cpl_parameterlist *pars, const char *rec_id, xsh_instrument *inst, xsh_rectify_param *rectify_par)
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
cpl_error_code xsh_end(const char *recipe_id, cpl_frameset *frames, cpl_parameterlist *parameters)
Recipe termination.
cpl_frame * xsh_find_spectral_format(cpl_frameset *frames, xsh_instrument *instr)
Find spectral format frame.
int xsh_dfs_split_offset(cpl_frameset *input, const char *object_tag, const char *sky_tag, cpl_frameset **object, cpl_frameset **sky)
split input RAW offset sof in OBJECT_... and SKY_... framesets
cpl_frame * xsh_find_disp_tab(cpl_frameset *frames, xsh_instrument *instr)
Find Dispersol tab frame. The frame returned should not be free by the caller.
cpl_frame * xsh_find_order_tab_edges(cpl_frameset *frames, xsh_instrument *instr)
Find an order tab EDGES.
void xsh_add_product_image(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
cpl_error_code xsh_ensure_raws_input_offset_recipe_is_proper(cpl_frameset **raws, xsh_instrument *instrument)
Make sure input frames is an even number (eventually removes the last from the input list)
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
cpl_frame * xsh_find_master_flat(cpl_frameset *frames, xsh_instrument *instr)
Find master flat frame.
cpl_error_code xsh_frameset_check_uniform_exptime(cpl_frameset *raws, xsh_instrument *inst)
#define XSH_MOD_CFG_OPT_AFC
#define XSH_STD_FLUX_IFU_OFFSET
#define XSH_STD_TELL_IFU_OFFSET
#define XSH_OBJECT_IFU_OFFSET
cpl_frame * xsh_check_load_master_bpmap(cpl_frameset *calib, xsh_instrument *inst, const char *rec_id)
void xsh_check_get_map(cpl_frame *disp_tab_frame, cpl_frame *order_tab_edges, cpl_frame *crhm_frame, cpl_frame *model_config_frame, cpl_frameset *calib, xsh_instrument *instrument, int do_computemap, int recipe_use_model, const char *rec_prefix, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame)
Check function to get wave and slit maps.
void xsh_parameters_pre_overscan(const char *recipe_id, cpl_parameterlist *plist)
void xsh_parameters_new_boolean(cpl_parameterlist *list, const char *recipe_id, const char *name, int value, const char *comment)
void xsh_parameters_stack_create(const char *recipe_id, cpl_parameterlist *list, xsh_stack_param sp)
create the RON determination parameters in a parameters list
int xsh_parameters_get_boolean(const cpl_parameterlist *list, const char *recipe_id, const char *name)
xsh_stack_param * xsh_stack_frames_get(const char *recipe_id, cpl_parameterlist *list)
get the detect arclines parameters in a parameters list
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_localize_obj_create(const char *recipe_id, cpl_parameterlist *plist, xsh_localize_obj_param p)
void xsh_parameters_clipping_crh_create(const char *recipe_id, cpl_parameterlist *list, xsh_clipping_param p)
create the crh clipping parameters in a parameters list
void xsh_parameters_rectify_create(const char *recipe_id, cpl_parameterlist *plist, xsh_rectify_param p)
xsh_bary_corr_param * xsh_parameters_bary_corr_get(const char *recipe_id, cpl_parameterlist *list)
get the barycentric correction parameters in a parameters list
xsh_rectify_param * xsh_parameters_rectify_get(const char *recipe_id, cpl_parameterlist *list)
void xsh_parameters_bary_corr_create(const char *recipe_id, cpl_parameterlist *list, xsh_bary_corr_param p)
create the barycentric correction parameters in a parameters list
void xsh_parameters_remove_crh_single_create(const char *recipe_id, cpl_parameterlist *plist, xsh_remove_crh_single_param p)
xsh_remove_crh_single_param * xsh_parameters_remove_crh_single_get(const char *recipe_id, cpl_parameterlist *list)
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
cpl_error_code xsh_recipe_params_check(cpl_parameterlist *parameters, xsh_instrument *instrument, const char *rec_id)
static int xsh_scired_ifu_offset_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static int xsh_scired_ifu_offset_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static void xsh_scired_ifu_offset(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
static int xsh_scired_ifu_offset_create(cpl_plugin *)
Setup the recipe options.
#define XSH_FREE(POINTER)
cpl_error_code xsh_build_ifu_cube(cpl_frame *div_frame, cpl_frame *ifu_cfg_tab_frame, cpl_frame *ifu_cfg_cor_frame, cpl_frame *spectral_format_frame, cpl_frame *model_config_frame, cpl_frame *wavesol_frame, xsh_instrument *instrument, cpl_frameset *frameset, cpl_parameterlist *parameters, xsh_rectify_param *rectify_par, const char *recipe_id, const char *rec_prefix, const int frame_is_object)
Reconstruct IFU cube.
cpl_frame * xsh_build_ifu_map(cpl_frame *div_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, xsh_instrument *instrument)
Reconstruct IFU cube.
cpl_frameset * xsh_frameset_crh_single(cpl_frameset *raws, xsh_remove_crh_single_param *crh_single_par, cpl_frame *sky_map_frm, xsh_instrument *instrument, const char *prefix, const char *spec)
Generates a new frameset with each frame CRH-single rejected from input frameset.
cpl_frameset * xsh_frameset_mflat_divide(cpl_frameset *input, cpl_frame *mflat, xsh_instrument *instrument)
Generates a new frameset with each frame mflat divided input frameset.