X-shooter Pipeline Reference Manual 3.8.15
xsh_util_ifu_stare.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2013-01-30 10:22:50 $
23 * $Revisieon: 1.10 $
24 *
25*/
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*----------------------------------------------------------------------------*/
39/*----------------------------------------------------------------------------*/
42/*-----------------------------------------------------------------------------
43 Includes
44 ----------------------------------------------------------------------------*/
45
46
47/* DRL steps */
48
49/* Error handling */
50#include <xsh_error.h>
51/* Utility fonctions */
52#include <xsh_utils.h>
53#include <xsh_utils_ifu.h>
55#include <xsh_utils_image.h>
56#include <xsh_model_utils.h>
57#include <xsh_model_io.h>
58#include <xsh_msg.h>
59/* DFS functions */
60#include <xsh_dfs.h>
61#include <xsh_pfits.h>
62/* DRL functions */
63#include <xsh_drl.h>
64#include <xsh_drl_check.h>
66/* Library */
67#include <cpl.h>
68/* CRH Remove */
69
70/*-----------------------------------------------------------------------------
71 Defines
72 ----------------------------------------------------------------------------*/
73
74#define RECIPE_ID "xsh_scired_ifu_stare"
75#define RECIPE_AUTHOR "A.Modigliani, J.Vernet, P. Bristow"
76#define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
77
78/*-----------------------------------------------------------------------------
79 Functions prototypes
80 ----------------------------------------------------------------------------*/
81
82/*
83 * Plugin initalization, execute and cleanup handlers
84 */
85
86static int xsh_scired_ifu_stare_create(cpl_plugin *);
87static int xsh_scired_ifu_stare_exec(cpl_plugin *);
88static int xsh_scired_ifu_stare_destroy(cpl_plugin *);
89
90/* The actual executor function */
91static void xsh_scired_ifu_stare(cpl_parameterlist *, cpl_frameset *);
92
93/*-----------------------------------------------------------------------------
94 Static variables
95 ----------------------------------------------------------------------------*/
97"Reduce science IFU stare exposures and build a 3D cube";
98
100"This recipe reduce science IFU stare exposures with 3D cube generation\n\
101Input Frames : \n\
102 - A set of n Science frames ( n == 1 or >=3, \
103 Tag = OBJECT_IFU_STARE_UVB)\n\
104 - A spectral format table frame (Tag = SPECTRAL_FORMAT_TAB_arm)\n\
105 - [UVB,VIS] A master bias frame (Tag = MASTER_BIAS_arm)\n\
106 - A master dark frame (Tag = MASTER_DARK_arm)\n\
107 - A master flat frame (Tag = MASTER_FLAT_IFU_arm)\n\
108 - An order edges table frame(Tag = ORDER_TAB_EDGES_IFU_arm)\n\
109 - [physmod] An AFC corrected model cfg frame (Tag = XSH_MOD_CFG_OPT_AFC_arm)\n\
110 - [poly] An AFC corrected model wavesol frame (Tag = WAVE_TAB_AFC_arm)\n\
111 - [OPTIONAL] A non-linear badpixel map (Tag = BP_MAP_NL_arm)\n\
112 - [OPTIONAL] A reference badpixel map (Tag = BP_MAP_RP_arm)\n\
113Products : \n\
114 - Merged 3D data cube (PREFIX_MERGE3D_DATA_OBJ_arm)\n\
115 - QC Traces of 3D data cube (PREFIX_MERGE3D_TRACE_OBJ_arm)\n\
116 - Order by order 3D data cube (PREFIX_ORDER3D_DATA_OBJ_arm)\n\
117 - Order by order 3D qual cube (IFU_CFG_COR_arm)\n\
118 - Order by order 3D qual cube (PREFIX_MERGE3D_DATA_SKY_arm)\n\
119 - where PREFIX is SCI, FLUX, TELL if input raw DPR.TYPE contains OBJECT or FLUX or TELLURIC\n";
120
121
122/*-----------------------------------------------------------------------------
123 Functions code
124 ----------------------------------------------------------------------------*/
125/*----------------------------------------------------------------------------*/
134/*----------------------------------------------------------------------------*/
135
136int cpl_plugin_get_info(cpl_pluginlist *list) {
137 cpl_recipe *recipe = NULL;
138 cpl_plugin *plugin = NULL;
139
140 recipe = cpl_calloc(1, sizeof(*recipe));
141 if ( recipe == NULL ){
142 return -1;
143 }
144
145 plugin = &recipe->interface ;
146
147 cpl_plugin_init(plugin,
148 CPL_PLUGIN_API, /* Plugin API */
149 XSH_BINARY_VERSION, /* Plugin version */
150 CPL_PLUGIN_TYPE_RECIPE, /* Plugin type */
151 RECIPE_ID, /* Plugin name */
153 xsh_scired_ifu_stare_description, /* Detailed help */
154 RECIPE_AUTHOR, /* Author name */
155 RECIPE_CONTACT, /* Contact address */
156 xsh_get_license(), /* Copyright */
160
161 cpl_pluginlist_append(list, plugin);
162
163 return (cpl_error_get_code() != CPL_ERROR_NONE);
164}
165
166/*----------------------------------------------------------------------------*/
176/*----------------------------------------------------------------------------*/
177
178static int xsh_scired_ifu_stare_create(cpl_plugin *plugin){
179 cpl_recipe *recipe = NULL;
180 xsh_clipping_param crh_clip_param = {5.0, 5, 0.7, 0,0.3};
181 /* First param (conv_kernel) should be initialized correctly ! */
182 xsh_rectify_param rectify = { "tanh",
183 CPL_KERNEL_DEFAULT, 2,
184 -1.,
185 -1.,
186 1, 0, 0 };
187 xsh_stack_param stack_param = {"median",5.,5.};
188 xsh_bary_corr_param bary_corr = {BARY_CORR_NONE };
189 /* 2nd and 3rd params should be initialized correctly */
190 /*
191 xsh_localize_obj_param loc_obj =
192 {10, 0.1, 1, 0, LOC_GAUSSIAN_METHOD, 0, 0.5, 2.0, 3};
193 */
194 /* Reset library state */
195 xsh_init();
196
197 /* Check input */
198 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
199
200 /* Get the recipe out of the plugin */
201 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
202 CPL_ERROR_TYPE_MISMATCH,
203 "Plugin is not a recipe");
204
205 recipe = (cpl_recipe *)plugin;
206
207 /* Create the parameter list in the cpl_recipe object */
208 recipe->parameters = cpl_parameterlist_new();
209 assure( recipe->parameters != NULL,
210 CPL_ERROR_ILLEGAL_OUTPUT,
211 "Memory allocation failed!");
212
213 /* Set generic parameters (common to all recipes) */
214 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
215 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
216 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
217 check(xsh_parameters_stack_create(RECIPE_ID,recipe->parameters,stack_param));
218 /* crh clipping params */
220 crh_clip_param));
221
222 /* subtract_background_params */
224
225 /* xsh_rectify */
227 rectify )) ;
228
229 /* xsh_localize_object
230 check(xsh_parameters_localize_obj_create(RECIPE_ID,recipe->parameters,
231 loc_obj )) ;
232 */
233
234 /* PIPE-10061 - barycentric correction param */
236 bary_corr)) ;
237
238 /* single rectify localization */
239 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
240 "compute-map", FALSE,
241 "if TRUE recompute (wave and slit) maps from the dispersion solution. If sky-subtract is set to TRUE this must be set to TRUE."));
242
243 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
244 "trace-obj", FALSE,
245 "if TRUE trace object position on each IFU slice. In this case order TAB edges is required"));
246
247
248 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
249 "check-afc", TRUE,
250 "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."));
251
252 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
253 "cut-uvb-spectrum", TRUE,
254 "TRUE if recipe cuts the UVB spectrum at 556 nm (dichroich)"));
255 cleanup:
256 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
257 xsh_error_dump(CPL_MSG_ERROR);
258 return 1;
259 }
260 else {
261 return 0;
262 }
263}
264/*--------------------------------------------------------------------------*/
272/*--------------------------------------------------------------------------*/
273
274static cpl_error_code
275xsh_params_bin_scale(cpl_frameset* raws,
277{
278
279 cpl_frame* frame=NULL;
280 const char* name=NULL;
281 cpl_propertylist* plist=NULL;
282 int binx=0;
283 int biny=0;
284
285 check(frame=cpl_frameset_get_frame(raws,0));
286 check(name=cpl_frame_get_filename(frame));
287 check(plist=cpl_propertylist_load(name,0));
290 xsh_free_propertylist(&plist);
291
292 if(biny>1) {
293
294 /*
295 backg->sampley=backg->sampley/biny;
296 Not bin dependent.
297 */
298
299 backg->radius_y=backg->radius_y/biny;
300 /*
301 if(backg->smooth_y>0) {
302 backg->smooth_y=backg->smooth_y/biny;
303 }
304 Smoothing radius' half size in y direction
305 For the moment not bin dependent, but for optimal results probably yes
306 */
307
308 /*
309 rectify_par->rectif_radius=rectify_par->rectif_radius/biny;
310 Rectify Interpolation radius.
311 For the moment not bin dependent, but for optimal results probably yes
312 */
313
314 /*
315 rectify_par->rectif_bin_lambda=rectify_par->rectif_bin_lambda/biny;
316 Rectify Wavelength Step.
317 For the moment not bin dependent, but for optimal results probably yes
318 */
319
320
321 }
322
323
324 if(binx>1) {
325
326 backg->radius_x=backg->radius_x/binx;
327 /*
328 if(backg->smooth_x>0) {
329 backg->smooth_x=backg->smooth_x/binx;
330 }
331 Smoothing radius' half size in x direction
332 For the moment not bin dependent, but for optimal results probably yes
333 */
334
335 /*
336 rectify_par->rectif_bin_space=rectify_par->rectif_bin_space/binx;
337 Rectify Position Step.
338 For the moment not bin dependent, but for optimal results probably yes
339 */
340
341 }
342
343 cleanup:
344 xsh_free_propertylist(&plist);
345 return cpl_error_get_code();
346
347}
348
349/*----------------------------------------------------------------------------*/
355/*----------------------------------------------------------------------------*/
356
357static int xsh_scired_ifu_stare_exec(cpl_plugin *plugin) {
358 cpl_recipe *recipe = NULL;
359
360 /* Check parameter */
361
362 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
363
364 /* Get the recipe out of the plugin */
365 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
366 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
367
368 recipe = (cpl_recipe *)plugin;
369
370 /* Check recipe */
371 xsh_scired_ifu_stare(recipe->parameters, recipe->frames);
372
373 cleanup:
374 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
375 xsh_error_dump(CPL_MSG_ERROR);
377 return 1;
378 }
379 else {
380 return 0;
381 }
382}
383
384/*----------------------------------------------------------------------------*/
390/*----------------------------------------------------------------------------*/
391static int xsh_scired_ifu_stare_destroy(cpl_plugin *plugin)
392{
393 cpl_recipe *recipe = NULL;
394
395 /* reset error state before detroying recipe */
397 /* Check parameter */
398 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
399
400 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
401 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
402
403 recipe = (cpl_recipe *)plugin;
404
405 xsh_free_parameterlist(&recipe->parameters);
406
407 cleanup:
408 if (cpl_error_get_code() != CPL_ERROR_NONE)
409 {
410 return 1;
411 }
412 else
413 {
414 return 0;
415 }
416}
417static cpl_error_code
419 xsh_rectify_param * rectify_par)
420{
421
422
423 xsh_msg_dbg_low("bkg params: sampley=%d radius_y=%d",
424 backg->sampley,backg->radius_y);
425
426 xsh_msg_dbg_low("bkg params: radius_x=%d",
427 backg->radius_x);
428
429 xsh_msg_dbg_low("rectify params: radius=%g bin_lambda=%g bin_space=%g",
430 rectify_par->rectif_radius,rectify_par->rectif_bin_lambda,
431 rectify_par->rectif_bin_space);
432
433 return cpl_error_get_code();
434
435}
436
437/*----------------------------------------------------------------------------*/
445/*----------------------------------------------------------------------------*/
446static void xsh_scired_ifu_stare(cpl_parameterlist* parameters,
447 cpl_frameset* frameset)
448{
449
450 const char* recipe_tags[4] = {XSH_OBJECT_IFU_STARE,XSH_SKY_IFU,
453
454 int recipe_tags_size = 4;
455
456 /* Input frames */
457 cpl_frameset *raws = NULL;
458 cpl_frameset *calib = NULL;
459
460 /* Beware, do not "free" the following input frames, they are part
461 of the input frameset */
462 cpl_frame *spectral_format = NULL;
463 cpl_frame *ifu_cfg_tab_frame = NULL ;
464 cpl_frame *ifu_cfg_cor_frame = NULL ;
465
466
467 /* Beware, do not "free" the following input frames, they are part
468 of the input frameset */
469 cpl_frame *bpmap = NULL;
470 cpl_frame *master_bias = NULL;
471 cpl_frame *master_dark = NULL;
472 cpl_frame *master_flat = NULL;
473 cpl_frame *order_tab_edges = NULL;
474
475 cpl_frame *model_config_frame = NULL ;
476 cpl_frame *wavemap = NULL ;
477 cpl_frame *slitmap = NULL ;
478 cpl_frame *disp_tab_frame = NULL;
479
480 /* Parameters */
481 xsh_background_param *backg_par = NULL;
482 xsh_rectify_param *rectify_par = NULL ;
483 xsh_stack_param* stack_par=NULL;
484 xsh_bary_corr_param * bary_par = NULL ;
485
486 int do_compute_map = 0;
487
488 int recipe_use_model = FALSE;
489 int check_afc = TRUE;
490 int do_trace_obj = 0;
491
493 int nb_raw_frames;
494
495 /* Intermediate frames */
496 cpl_frame * crhm_frame = NULL ;
497 cpl_frame * rmbias = NULL;
498 cpl_frame * rmdark = NULL;
499 cpl_frame * rmbkg = NULL ;
500 cpl_frame *div_frame = NULL ;
502 /* Output Frames (results)*/
503 cpl_frame* grid_backg=NULL;
504 cpl_frame* frame_backg=NULL;
505
506 const char* ftag=NULL;
507 char rec_prefix[256];
508 //cpl_image* crh_ima=NULL;
509 //cpl_frame* crh_frm=NULL;
510 char tag[256];
511 char name[256];
512 cpl_frame* wavesol=NULL;
513 cpl_frame* order_tab_edges_frame=NULL;
514
515 char wave_map_tag[256];
516 char slit_map_tag[256];
517 char* prefix=NULL;
518 int pre_overscan_corr=0;
519 cpl_frame* ifu_sky_map=NULL;
520 /**************************************************************************/
521 /* DFS management */
522 /**************************************************************************/
523 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
524 recipe_tags, recipe_tags_size,RECIPE_ID, XSH_BINARY_VERSION,
526
527 assure( instrument->mode == XSH_MODE_IFU, CPL_ERROR_ILLEGAL_INPUT,
528 "Instrument NOT in IFU Mode");
529
531 /**************************************************************************/
532 /* Recipe frames */
533 /**************************************************************************/
534
535 /* One should have 1 or >=3 input frames. 2 is not permitted */
536 check( nb_raw_frames = cpl_frameset_get_size( raws ) ) ;
537 XSH_ASSURE_NOT_ILLEGAL( nb_raw_frames == 1 || nb_raw_frames >= 3 ) ;
538
539 if(nb_raw_frames>1) {
541 }
542
543 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
544 "pre-overscan-corr"));
545
546
547 prefix=xsh_set_recipe_file_prefix(raws,"xsh_scired_ifu_stare");
548 check(strcpy(rec_prefix,(const char*)prefix));
549 XSH_FREE(prefix);
550 xsh_msg("ok1");
551 check(xsh_ifu_stare_get_calibs(calib, instrument, &spectral_format, &master_bias,
552 &master_dark, &master_flat, &order_tab_edges,
553 &model_config_frame, &bpmap, &wavemap, &slitmap,
554 &ifu_cfg_tab_frame, &ifu_cfg_cor_frame, &wavesol,
555 RECIPE_ID, &recipe_use_model, pre_overscan_corr));
556
557
558 xsh_msg("ok2");
559 /**************************************************************************/
560 /* Recipe parameters */
561 /**************************************************************************/
562 recipe_use_model = ( model_config_frame != NULL);
563
564 check( stack_par = xsh_stack_frames_get( RECIPE_ID, parameters));
565
567 parameters));
568
569
571 parameters));
572 rectify_par->conserve_flux=FALSE;
573
574 check( do_compute_map = xsh_parameters_get_boolean( parameters, RECIPE_ID,
575 "compute-map"));
576
577 check( check_afc = xsh_parameters_get_boolean( parameters, RECIPE_ID,
578 "check-afc"));
579
580 check( do_trace_obj = xsh_parameters_get_boolean( parameters, RECIPE_ID,
581 "trace-obj"));
582
583 if ( do_compute_map && recipe_use_model==FALSE){
584 check( disp_tab_frame = xsh_find_disp_tab( calib, instrument));
585 }
587
588 /* adjust relevant parameter to binning */
590 check(xsh_params_bin_scale(raws,backg_par));
591 }
592 check(xsh_params_monitor(backg_par,rectify_par));
593
594 // PIPE-10061 - get barycentric corr param
595 check(bary_par = xsh_parameters_bary_corr_get( RECIPE_ID, parameters)) ;
596
597
598 /**************************************************************************/
599 /* Recipe code */
600 /**************************************************************************/
601 /* prepare RAW frames in XSH format */
602 xsh_msg( "---Prepare raws frames");
603 check( xsh_prepare( raws, bpmap, master_bias, XSH_OBJECT_IFU_STARE,
604 instrument,pre_overscan_corr,CPL_TRUE));
605
606 /* Removing Cosmic Rays (if more than 2 frames)
607 Output frame in PRE format */
608 if ( nb_raw_frames >= 3 ) {
609 xsh_msg( "---Remove cosmics");
610
612 check_msg( crhm_frame = xsh_remove_crh_multiple( raws,
613 ftag,stack_par,NULL,
614 instrument, NULL,NULL,0 ),
615 "Error in xsh_remove_crh" ) ;
616 }
617 else {
618 /* Only one frame in raws frameset, get it (it's first of course !) */
619 check( crhm_frame = cpl_frame_duplicate(cpl_frameset_get_frame( raws,0 )));
620 }
621 xsh_msg( "created %s", cpl_frame_get_filename( crhm_frame));
622
623
624 if (recipe_use_model){
625 int found_temp=true;
626 xsh_msg("correct for temperature");
627 check(xsh_model_temperature_update_frame(&model_config_frame,crhm_frame,
628 instrument,&found_temp));
629 }
630
631 if ( do_compute_map){
633
634 if (recipe_use_model){
635
636
637 sprintf(wave_map_tag,"%s_%s",rec_prefix,XSH_WAVE_MAP_MODEL);
638 sprintf(slit_map_tag,"%s_%s",rec_prefix,XSH_SLIT_MAP_MODEL);
639 check( xsh_create_model_map( model_config_frame, instrument,
640 wave_map_tag,slit_map_tag,
641 &wavemap, &slitmap,0));
642
643 }
644 else{
645 xsh_msg( "Compute the wave map and the slit map");
646 check( xsh_create_map( disp_tab_frame, order_tab_edges,
647 crhm_frame, instrument,
648 &wavemap, &slitmap,rec_prefix));
649 }
650 cpl_frameset_insert( calib, wavemap);
651 cpl_frameset_insert( calib, slitmap);
652 }
653 else{
654 check( wavemap = xsh_find_wavemap( calib, instrument));
655 slitmap = xsh_find_slitmap(calib, instrument);
656 }
657
658 /* NIR arm */
659 check( rmbias = xsh_check_subtract_bias( crhm_frame, master_bias,
660 instrument, rec_prefix,
661 pre_overscan_corr,0));
662
663 xsh_add_temporary_file(cpl_frame_get_filename(rmbias));
664 /**************************************************************************/
665 /* Check that SCI IFU frame and AFC corrected CFG are proper */
666 /**************************************************************************/
667
668 if(check_afc) {
669 if(model_config_frame!=NULL) {
672 rmbias,instrument));
673 } else {
676 rmbias,instrument));
677 }
678 }
679
680 /* Subtract Dark */
681 if ( master_dark != NULL ) {
682 xsh_msg( "---Subtract_dark");
683 sprintf(name, "%s_DARK_%s.fits",
685 check( rmdark = xsh_subtract_dark(rmbias, master_dark,
686 name,instrument));
687 }
688 else {
689 xsh_msg( "No Master Dark" ) ;
690 check( rmdark = cpl_frame_duplicate( rmbias ) ) ;
691 }
692 xsh_free_frame(&rmbias);
693
694
695 /* subtract background */
696 xsh_msg("---Subtract_background");
697 check( rmbkg = xsh_subtract_background( rmdark,
698 order_tab_edges, backg_par, instrument, rec_prefix,&grid_backg,
699 &frame_backg,0,0,0 ));
700 xsh_free_frame(&rmdark);
701
702 /* divide by */
703 xsh_msg("---Do flatfielding");
704 sprintf( tag, "%s_FF_%s",
706 sprintf(name,"%s.fits",tag);
707 check( div_frame = xsh_divide_flat( rmbkg, master_flat,
708 tag, instrument));
710
711 xsh_free_frame( &rmbkg);
712
713 if(do_trace_obj && do_compute_map) {
715 check(order_tab_edges_frame = xsh_find_order_tab_edges(calib,instrument));
717 check(xsh_ifu_trace_object_calibrate(cpl_frame_get_filename(div_frame),
718 cpl_frame_get_filename(order_tab_edges_frame),
719 cpl_frame_get_filename(slitmap),
720 cpl_frame_get_filename(wavemap)));
721 }
722
723 check(xsh_build_ifu_cube(div_frame,ifu_cfg_tab_frame,ifu_cfg_cor_frame,
724 spectral_format,
725 model_config_frame,
726 wavesol,
728 frameset,
729 parameters,rectify_par,RECIPE_ID,rec_prefix,1));
730
731 if(do_compute_map) {
732 check(ifu_sky_map=xsh_build_ifu_map(div_frame,wavemap,slitmap,instrument));
733 check( xsh_add_product_image( ifu_sky_map, frameset,parameters, RECIPE_ID, instrument,NULL));
734 }
735 cleanup:
736
737 xsh_end( RECIPE_ID, frameset, parameters );
739 xsh_free_frameset( &raws);
740 xsh_free_frameset( &calib);
741
742 xsh_free_frame( &crhm_frame);
743 xsh_free_frame(&rmbias);
744 xsh_free_frame(&div_frame);
745 xsh_free_frame(&rmdark);
746 xsh_free_frame( &rmbkg);
747 xsh_free_frame( &grid_backg);
748 xsh_free_frame( &frame_backg);
749
750 XSH_FREE(stack_par);
751 XSH_FREE(backg_par);
752 XSH_FREE(rectify_par);
753 XSH_FREE( bary_par);
754
755 //xsh_free(&model_config);
756 return;
757}
758
static xsh_instrument * instrument
int binx
int biny
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
Definition: xsh_2dmap.c:151
cpl_frame * xsh_divide_flat(cpl_frame *frame, cpl_frame *flat, const char *tag, xsh_instrument *instr)
divide PRE frame with the master FLAT frame
Definition: xsh_divide.c:75
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 ...
Definition: xsh_prepare.c:122
#define XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#define assure(CONDITION, ERROR_CODE,...)
Definition: xsh_error.h:54
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define check_msg(COMMAND,...)
Definition: xsh_error.h:62
#define xsh_error_reset()
Definition: xsh_error.h:87
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
void xsh_mode_set(xsh_instrument *instrument, XSH_MODE mode)
set the instrument mode as user specifies
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(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_low(...)
Definition: xsh_msg.h:48
int xsh_pfits_get_binx(const cpl_propertylist *plist)
find out the BINX value
Definition: xsh_pfits.c:289
int xsh_pfits_get_biny(const cpl_propertylist *plist)
find out the BINY value
Definition: xsh_pfits.c:306
cpl_frame * xsh_remove_crh_multiple(cpl_frameset *rawFrames, const char *name, xsh_stack_param *stack_param, xsh_clipping_param *crh_clipping, xsh_instrument *inst, cpl_imagelist **, cpl_image **, const int save_tmp)
#define RECIPE_CONTACT
static cpl_error_code xsh_params_monitor(xsh_background_param *backg, xsh_rectify_param *rectify_par)
static char xsh_scired_ifu_stare_description[]
static char xsh_scired_ifu_stare_description_short[]
#define RECIPE_ID
#define RECIPE_AUTHOR
cpl_frame * xsh_subtract_background(cpl_frame *frame, cpl_frame *ordertable, xsh_background_param *bckg, xsh_instrument *instr, const char *prefix, cpl_frame **grid_frame, cpl_frame **frame_backg, const int save_bkg, const int save_grid, const int save_sub_bkg)
Subtract the inter-order background from PRE frame.
Definition: xsh_subtract.c:947
cpl_frame * xsh_subtract_dark(cpl_frame *frame, cpl_frame *dark, const char *filename, xsh_instrument *instr)
subtract the master dark frame from PRE frame
Definition: xsh_subtract.c:247
void xsh_free_parameterlist(cpl_parameterlist **p)
Deallocate a parameter list and set the pointer to NULL.
Definition: xsh_utils.c:2224
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
Definition: xsh_utils.c:2269
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
Definition: xsh_utils.c:2254
char * xsh_set_recipe_file_prefix(cpl_frameset *raw, const char *recipe)
Set recipe frames prefix.
Definition: xsh_utils.c:601
const char * xsh_get_license(void)
Get the pipeline copyright and license.
Definition: xsh_utils.c:1193
void xsh_init(void)
Reset library state.
Definition: xsh_utils.c:1160
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.
Definition: xsh_utils.c:1244
cpl_error_code xsh_rectify_params_set_defaults(cpl_parameterlist *pars, const char *rec_id, xsh_instrument *inst, xsh_rectify_param *rectify_par)
Definition: xsh_utils.c:6681
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
Definition: xsh_utils.c:2179
cpl_error_code xsh_end(const char *recipe_id, cpl_frameset *frames, cpl_parameterlist *parameters)
Recipe termination.
Definition: xsh_utils.c:1519
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
Definition: xsh_utils.c:1432
void xsh_create_map(cpl_frame *dispsol_frame, cpl_frame *ordertab_frame, cpl_frame *pre_frame, xsh_instrument *instrument, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame, const char *rec_prefix)
void xsh_create_model_map(cpl_frame *model_frame, xsh_instrument *instrument, const char *wtag, const char *stag, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame, const int save_tmp)
@ XSH_ARM_NIR
@ XSH_MODE_SLIT
@ XSH_MODE_IFU
cpl_frame * xsh_find_wavemap(cpl_frameset *frames, xsh_instrument *instr)
Find Wave Map frame. The frame returned should not be free by the caller.
Definition: xsh_dfs.c:3983
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.
Definition: xsh_dfs.c:4066
cpl_frame * xsh_find_order_tab_edges(cpl_frameset *frames, xsh_instrument *instr)
Find an order tab EDGES.
Definition: xsh_dfs.c:3595
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)
Definition: xsh_dfs.c:2965
cpl_frame * xsh_find_slitmap(cpl_frameset *frames, xsh_instrument *instr)
Find a slit map.
Definition: xsh_dfs.c:3673
cpl_error_code xsh_frameset_check_uniform_exptime(cpl_frameset *raws, xsh_instrument *inst)
Definition: xsh_dfs.c:5119
#define XSH_STD_FLUX_IFU_STARE
Definition: xsh_dfs.h:455
#define XSH_SLIT_STARE_REMOVE_CRH
Definition: xsh_dfs.h:156
#define XSH_SLIT_MAP_MODEL
Definition: xsh_dfs.h:146
#define XSH_SKY_IFU
Definition: xsh_dfs.h:234
#define XSH_STD_TELL_IFU_STARE
Definition: xsh_dfs.h:469
#define XSH_OBJECT_IFU_STARE
Definition: xsh_dfs.h:230
#define XSH_WAVE_MAP_MODEL
Definition: xsh_dfs.h:923
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
Definition: xsh_dfs.h:1548
cpl_frame * xsh_check_subtract_bias(cpl_frame *crhm_frame, cpl_frame *master_bias, xsh_instrument *instrument, const char *prefix, const int pre_overscan_corr, const int save_tmp)
Check function to subtract bias.
cpl_error_code xsh_model_temperature_update_frame(cpl_frame **model_config_frame, cpl_frame *ref_frame, xsh_instrument *instrument, int *found_temp)
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_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)
void xsh_parameters_background_create(const char *recipe_id, cpl_parameterlist *list)
create the subtract background parameters in a parameters list
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
int xsh_parameters_get_int(const cpl_parameterlist *list, const char *recipe_id, const char *name)
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)
xsh_background_param * xsh_parameters_background_get(const char *recipe_id, cpl_parameterlist *list)
get the background parameters in a parameters list
@ BARY_CORR_NONE
static int xsh_scired_ifu_stare_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static int xsh_scired_ifu_stare_create(cpl_plugin *)
Setup the recipe options.
static int xsh_scired_ifu_stare_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static cpl_error_code xsh_params_bin_scale(cpl_frameset *raws, xsh_background_param *backg)
Rescale input parameters for binning.
static void xsh_scired_ifu_stare(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
#define XSH_FREE(POINTER)
Definition: xsh_utils.h:92
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_error_code xsh_frame_check_model_cfg_is_proper_for_sci(cpl_frame *model_config_frame, cpl_frame *sci_frame, xsh_instrument *instrument)
Check if a model configuration frame has been corrected for flexures.
cpl_error_code xsh_frame_check_model_cfg_is_afc_corrected(cpl_frame *model_config_frame)
utility to check if a frame has been corrected for flexures
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_error_code xsh_ifu_trace_object_calibrate(const char *ifu_object_ff_name, const char *order_tab_edges_ifu_name, const char *slit_map_name, const char *wave_map_name)
Function to calibrate object traces in IFU mode.
cpl_error_code xsh_ifu_stare_get_calibs(cpl_frameset *calib, xsh_instrument *inst, cpl_frame **spectral_format, cpl_frame **mbias, cpl_frame **mdark, cpl_frame **mflat, cpl_frame **otab_edges, cpl_frame **model_cfg, cpl_frame **bpmap, cpl_frame **wmap, cpl_frame **smap, cpl_frame **ifu_cfg_tab, cpl_frame **ifu_cfg_cor, cpl_frame **wavesol, const char *rec_id, int *recipe_use_model, int pscan)