X-shooter Pipeline Reference Manual 3.8.15
xsh_absorp.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: 2012-12-18 14:12:51 $
23 * $Revision: 1.13 $
24*/
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29
30/*----------------------------------------------------------------------------*/
38/*----------------------------------------------------------------------------*/
41/*-----------------------------------------------------------------------------
42 Includes
43 ----------------------------------------------------------------------------*/
44
45
46/* DRL steps */
47
48/* Error handling */
49#include <xsh_error.h>
50/* Utility fonctions */
51#include <xsh_utils.h>
53#include <xsh_msg.h>
54/* DFS functions */
55#include <xsh_dfs.h>
56#include <xsh_pfits.h>
57/* DRL functions */
58#include <xsh_utils_image.h>
60#include <xsh_data_instrument.h>
61#include <xsh_data_spectrum1D.h>
62#include <xsh_drl_check.h>
63#include <xsh_drl.h>
64#include <xsh_model_utils.h>
65/* Library */
66#include <cpl.h>
67/* CRH Remove */
68
69/*-----------------------------------------------------------------------------
70 Defines
71 ----------------------------------------------------------------------------*/
72
73#define RECIPE_ID "xsh_absorp"
74#define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer, A. Modigliani"
75#define RECIPE_CONTACT "regis.haigron@obspm.fr,amodigli@eso.org"
76
77/*-----------------------------------------------------------------------------
78 Functions prototypes
79 ----------------------------------------------------------------------------*/
80
81/*
82 * Plugin initalization, execute and cleanup handlers
83 */
84
85
86static int xsh_absorp_create(cpl_plugin *);
87static int xsh_absorp_exec(cpl_plugin *);
88static int xsh_absorp_destroy(cpl_plugin *);
89
90/* The actual executor function */
91static cpl_error_code xsh_absorp(cpl_parameterlist *, cpl_frameset *);
92
93/*-----------------------------------------------------------------------------
94 Static variables
95 ----------------------------------------------------------------------------*/
97"Create a telluric absorption mask";
98
100"This recipe creates a mask corresponding to the positions of telluric absorption\n\
101Input Frames : \n\
102 - A set of n Science frames ( n == 1 or >=3, Tag = STD_TELL_SLIT_STARE_arm)\n\
103 - A spectral format table (Tag = SPECTRAL_FORMAT_TAB_arm)\n\
104 - [UVB,VIS] A master bias frame (Tag = MASTER_BIAS_arm)\n\
105 - [OPTIONAL]A master dark frame (Tag = MASTER_DARK_arm)\n\
106 - A master flat frame (Tag = MASTER_FLAT_SLIT_arm)\n\
107 - An order table frame(Tag = ORDER_TAB_EDGES_SLIT_arm)\n\
108 - [OPTIONAL] A table with dispersion coefficients (Tag = DISP_TAB_arm,\n\
109 required if rectify-conserve-flux=TRUE or do_wavemap=TRUE and poly mode\n\
110 - [poly mode] A wave solution frame(Tag = WAVE_TAB_2D_arm)\n\
111 - [physical model mode] A model cfg table (Format = TABLE, Tag = XSH_MOD_CFG_TAB_arm)\n\
112 - [OPTIONAL] A table specifying multiplying factor for break points \n\
113 (Tag = SKY_SUB_BKPTS_arm) to generate\n\
114 - [OPTIONAL] A badpixel map (Tag = BADPIXEL_MAP_arm)\n\
115 - [OPTIONAL,physmod mode] A table listing sky line positions (Tag = SKY_LINE_LIST_arm)\n\
116 this is used to be able to control quality of sky subtraction, for example\n\
117 projecting guess positions on the product SCI_SLIT_STARE_SUB_SKY_arm\n\
118Products : \n\
119 - TELL_MASK_arm telluric mask\n\
120 - PREFIX_ORDER2D_arm extracted spectrum, order-by-order, 2D\n\
121 - PREFIX_ORDER1D_arm extracted spectrum, order-by-order, 1D\n\
122 - PREFIX_MERGE2D_arm merged spectrum, 2D\n\
123 - PREFIX_MERGE1D_arm merged spectrum, 1D\n\
124 - PREFIX_ON_arm bias (dark) subtracted sci frame\n\
125 - PREFIX_SUB_BACK_SLIT_arm sci frame bias, (dark), inter-order bkg subtracted\n\
126 - PREFIX_NOCRH_arm sci frame corrected from cosmic ray hits\n\
127 - [OPTIONAL,-compute-map=TRUE] PREFIX_WAVE_MAP_arm, wave map image\n\
128 - [OPTIONAL,-compute-map=TRUE] PREFIX_SLIT_MAP_arm, slit map image\n\
129 - PREFIX_DIVFF_arm as PREFIX_SUB_BACK_SLIT_arm, flat fielded\n\
130 - PREFIX_SUB_SKY_arm, as PREFIX_DIVFF_arm, sky subtracted\n\
131 - PREFIX_SKY_arm, 2D sky frame\n\
132 - PREFIX_SKY_ORD1D_arm, 1D sky image (order-by-order)\n\
133 - PREFIX_SCI_SLIT_STARE_BACK_SLIT_arm, inter-order background image\n\
134 - OBJECT_SLIT_STARE_arm, sci frame in PRE format\n\
135 - where PREFIX is SCI, FLUX, TELL if input raw DPR.TYPE contains OBJECT or FLUX or TELLURIC";
136
137/*-----------------------------------------------------------------------------
138 Functions code
139 ----------------------------------------------------------------------------*/
140/*----------------------------------------------------------------------------*/
149/*----------------------------------------------------------------------------*/
150
151int cpl_plugin_get_info(cpl_pluginlist *list) {
152 cpl_recipe *recipe = NULL;
153 cpl_plugin *plugin = NULL;
154
155 recipe = cpl_calloc(1, sizeof(*recipe));
156 if ( recipe == NULL ){
157 return -1;
158 }
159
160 plugin = &recipe->interface ;
161
162 cpl_plugin_init(plugin,
163 CPL_PLUGIN_API, /* Plugin API */
164 XSH_BINARY_VERSION, /* Plugin version */
165 CPL_PLUGIN_TYPE_RECIPE, /* Plugin type */
166 RECIPE_ID, /* Plugin name */
167 xsh_absorp_description_short, /* Short help */
168 xsh_absorp_description, /* Detailed help */
169 RECIPE_AUTHOR, /* Author name */
170 RECIPE_CONTACT, /* Contact address */
171 xsh_get_license(), /* Copyright */
175
176 cpl_pluginlist_append(list, plugin);
177
178 return (cpl_error_get_code() != CPL_ERROR_NONE);
179}
180
181/*----------------------------------------------------------------------------*/
191/*----------------------------------------------------------------------------*/
192
193static int xsh_absorp_create(cpl_plugin *plugin){
194 cpl_recipe *recipe = NULL;
195 cpl_parameter* p=NULL;
196
197 xsh_clipping_param crh_clip_param = {5.0, 5, 0.7, 0, 0.3};
198 /* First param (conv_kernel) should be initialized correctly ! */
199 xsh_remove_crh_single_param crh_single = { 0.1, 5, 2.0, 4} ;
200 xsh_rectify_param rectify = { "default",
201 CPL_KERNEL_DEFAULT,
202 4,
205 1,
206 0, 0. };
207
208 xsh_subtract_sky_single_param sky_single = {3000, 3000,7,20, 5., -1, -1,
209 BSPLINE_METHOD, FINE,7, 1.5,
210 0.0, 0.0,
211 0.0, 0.0} ;
212 xsh_stack_param stack_param = {"median",5.,5.,5};
213 /* 2nd and 3rd params should be initialized correctly */
214 xsh_localize_obj_param loc_obj =
215 {10, 0.1, 0, 0, LOC_MANUAL_METHOD, 0, 2.0,3,3, FALSE};
216 xsh_extract_param extract_par =
218
219 xsh_opt_extract_param opt_extract_par =
220 { 5, 10, 10, 0.01, 10.0, 1., 2, 2, GAUSS_METHOD };
221
222 /* Parameters init */
223 opt_extract_par.oversample = 5;
224 opt_extract_par.box_hsize = 10;
225 opt_extract_par.chunk_size = 50;
226 opt_extract_par.lambda_step = 0.02;
227 opt_extract_par.clip_kappa = 3;
228 opt_extract_par.clip_frac = 0.4;
229 opt_extract_par.clip_niter = 2;
230 opt_extract_par.niter = 1;
231 opt_extract_par.method = GAUSS_METHOD;
232 /* Reset library state */
233 xsh_init();
234
235 /* Check input */
236 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
237
238 /* Get the recipe out of the plugin */
239 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
240 CPL_ERROR_TYPE_MISMATCH,
241 "Plugin is not a recipe");
242
243 recipe = (cpl_recipe *)plugin;
244
245 /* Create the parameter list in the cpl_recipe object */
246 recipe->parameters = cpl_parameterlist_new();
247 assure( recipe->parameters != NULL,
248 CPL_ERROR_ILLEGAL_OUTPUT,
249 "Memory allocation failed!");
250
251 /* Set generic parameters (common to all recipes) */
252 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
253 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
254 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
255 check(xsh_parameters_stack_create(RECIPE_ID,recipe->parameters,stack_param));
256
257 /* crh clipping params */
259 crh_clip_param));
260
261 /* subtract_background_params */
263
264
265 check(p=xsh_parameters_find(recipe->parameters,RECIPE_ID,"background-method"));
266 cpl_parameter_set_default_string(p,"poly");
267
268
269 /* remove_crh_single */
271 crh_single )) ;
272
273 /* xsh_rectify */
275 rectify )) ;
276
277 /* xsh_localize_object */
279 loc_obj )) ;
280
281 /* xsh_remove_sky_single */
283 sky_single )) ;
284
285 /* trivial extract (Just temporary) */
287 recipe->parameters,
288 extract_par,LOCALIZATION_METHOD )) ;
289
290 /* optimal extract */
291 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
292 "do-optextract", FALSE,
293 "TRUE if we do the optimal extraction"));
294
296 opt_extract_par));
297
298 /* absorp parameters */
299 check( xsh_parameters_new_int( recipe->parameters, RECIPE_ID,
300 "absorp-filter-hsize", 5,
301 "Half size of median filter use to detect tellurics"));
302 check( xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
303 "absorp-threshold", 0.02,
304 "Threshold use to detect tellurics"));
305
306 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
307 "do-flatfield", TRUE,
308 "TRUE if we do the flatfielding"));
309
310 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
311 "compute-map", TRUE,
312 "if TRUE recompute (wave and slit) maps from the dispersion solution. If sky-subtract is set to TRUE this must be set to TRUE."));
313
314 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
315 "trace-obj", FALSE,
316 "if TRUE compute object position trace via Gaussian fit."));
317
318
319 cleanup:
320 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
321 xsh_error_dump(CPL_MSG_ERROR);
322 return 1;
323 }
324 else {
325 return 0;
326 }
327}
328
329/*----------------------------------------------------------------------------*/
335/*----------------------------------------------------------------------------*/
336
337static int xsh_absorp_exec(cpl_plugin *plugin) {
338 cpl_recipe *recipe = NULL;
339
340 /* Check parameter */
341
342 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
343
344 /* Get the recipe out of the plugin */
345 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
346 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
347
348 recipe = (cpl_recipe *)plugin;
349
350 /* Check recipe */
351 xsh_absorp(recipe->parameters, recipe->frames);
352
353 cleanup:
354 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
355 xsh_error_dump(CPL_MSG_ERROR);
357 return 1;
358 }
359 else {
360 return 0;
361 }
362}
363
364/*----------------------------------------------------------------------------*/
370/*----------------------------------------------------------------------------*/
371static int xsh_absorp_destroy(cpl_plugin *plugin)
372{
373 cpl_recipe *recipe = NULL;
374
375 /* reset error state before detroying recipe */
377 /* Check parameter */
378 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
379
380 /* Get the recipe out of the plugin */
381 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
382 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
383
384 recipe = (cpl_recipe *)plugin;
385
386 xsh_free_parameterlist(&recipe->parameters);
387
388 cleanup:
389 if (cpl_error_get_code() != CPL_ERROR_NONE)
390 {
391 return 1;
392 }
393 else
394 {
395 return 0;
396 }
397}
398
399static cpl_error_code
400xsh_params_set_defaults(cpl_parameterlist* pars,
401 const char* rec_id,
402 xsh_instrument* inst,
403 xsh_rectify_param * rectify_par,
405{
406
407 cpl_parameter* p=NULL;
408 check(p=xsh_parameters_find(pars,RECIPE_ID,"background-radius-x"));
409 if(cpl_parameter_get_int(p) <= 0) {
411 backg->radius_x=1;
412 } else {
413 backg->radius_x=2;
414 }
415 }
416
417 check(xsh_rectify_params_set_defaults(pars,rec_id,inst,rectify_par));
418
419 cleanup:
420
421 return cpl_error_get_code();
422
423}
424
425
426static cpl_error_code
428 xsh_rectify_param * rectify_par,
429 xsh_localize_obj_param * loc_obj_par,
430 xsh_opt_extract_param *opt_extract_par,
431 int sub_sky_nbkpts1,
432 int sub_sky_nbkpts2)
433{
434
435
436 xsh_msg_dbg_low("bkg params: sampley=%d radius_y=%d smooth_y=%d",
437 backg->sampley,backg->radius_y,backg->smooth_y);
438
439 xsh_msg_dbg_low("bkg params: radius_x=%d smooth_x=%d",
440 backg->radius_x,backg->smooth_x);
441
442 xsh_msg_dbg_low("rectify params: radius=%g bin_lambda=%g bin_space=%g",
443 rectify_par->rectif_radius,rectify_par->rectif_bin_lambda,
444 rectify_par->rectif_bin_space);
445
446 xsh_msg_dbg_low("localize params: chunk_nb=%d nod_step=%g",
447 loc_obj_par->loc_chunk_nb,loc_obj_par->nod_step);
448
449 xsh_msg_dbg_low("opt extract params: chunk_size=%d lambda_step=%g box_hsize=%d",
450 opt_extract_par->chunk_size,opt_extract_par->lambda_step,
451 opt_extract_par->box_hsize);
452
453 xsh_msg_dbg_low("sky params: nbkpts1=%d nbkpts2=%d",
454 sub_sky_nbkpts1,sub_sky_nbkpts2);
455
456 return cpl_error_get_code();
457
458}
459/*--------------------------------------------------------------------------*/
467/*--------------------------------------------------------------------------*/
468
469static cpl_error_code
470xsh_params_bin_scale(cpl_frameset* raws,
472 xsh_opt_extract_param *opt_extract_par,
473 int* sub_sky_nbkpts1,
474 int* sub_sky_nbkpts2)
475{
476
477 cpl_frame* frame=NULL;
478 const char* name=NULL;
479 cpl_propertylist *plist=NULL;
480 int binx=0;
481 int biny=0;
482
483 check(frame=cpl_frameset_get_first(raws));
484 check(name=cpl_frame_get_filename(frame));
485 check(plist=cpl_propertylist_load(name,0));
488 xsh_free_propertylist( &plist);
489
490 if(biny>1) {
491
492 /* backg->sampley=backg->sampley/biny;
493 number of points of the grid in y direction.
494 Not to be bin dependent
495 */
496
497 backg->radius_y=backg->radius_y/biny;
498
499 /* bin dependent */
500 *sub_sky_nbkpts1*=0.75*biny;
501 *sub_sky_nbkpts2*=0.75*biny;
502
503 /*
504 if(backg->smooth_y>0) {
505 backg->smooth_y=backg->smooth_y/biny;
506 }
507 Smoothing radius' half size in x direction.
508 For the moment not bin dependent, but for optimal results probably yes
509 */
510 /*
511 rectify_par->rectif_radius=rectify_par->rectif_radius/biny;
512 Rectify Interpolation radius
513 For the moment not bin dependent, but for optimal results probably yes
514 */
515
516 /*
517 rectify_par->rectif_bin_lambda=rectify_par->rectif_bin_lambda/biny;
518 Rectify Wavelength Step
519 For the moment not bin dependent, but for optimal results probably yes
520 */
521
522 /*
523 loc_obj_par->loc_chunk_nb=loc_obj_par->loc_chunk_nb/biny;
524 Localization Nb of chunks
525 Not bin dependent
526 */
527
528 /*
529 opt_extract_par->chunk_size=opt_extract_par->chunk_size/biny;
530 Chunk size.
531 */
532
533 /*
534 opt_extract_par->lambda_step=opt_extract_par->lambda_step/biny;
535 Lambda step.
536 For the moment not bin dependent, but for optimal results probably yes
537 */
538
539
540 }
541
542
543 if(binx>1) {
544
545 backg->radius_x=backg->radius_x/binx;
546
547 /*
548 if(backg->smooth_x>0) {
549 backg->smooth_x=backg->smooth_x/binx;
550 }
551 Smoothing radius' half size in x direction
552 For the moment not bin dependent, but for optimal results probably yes
553 */
554
555 /*
556 rectify_par->rectif_bin_space=rectify_par->rectif_bin_space/binx;
557 Rectify Position Step
558 For the moment not bin dependent, but for optimal results probably yes
559 */
560
561 /*
562 loc_obj_par->nod_step=loc_obj_par->nod_step/binx;
563 Step (arcsec) between A and B images in nodding mode
564 Not bin dependent
565 */
566
567 opt_extract_par->box_hsize=opt_extract_par->box_hsize/binx;
568
569 }
570
571 cleanup:
572 xsh_free_propertylist(&plist);
573 return cpl_error_get_code();
574
575}
576
577/*----------------------------------------------------------------------------*/
585/*----------------------------------------------------------------------------*/
586static cpl_error_code
587xsh_absorp(cpl_parameterlist* parameters,
588 cpl_frameset* frameset)
589{
590 const char* recipe_tags[1] = {XSH_STD_TELL_SLIT_STARE};
591 int recipe_tags_size = 1;
592
593 /* Input frames */
594 cpl_frameset *raws = NULL;
595 cpl_frameset *calib = NULL;
596 /* Beware, do not "free" the following input frames, they are part
597 of the input frameset */
598 cpl_frame *bpmap = NULL;
599 cpl_frame *master_bias = NULL;
600 cpl_frame *master_dark = NULL;
601 cpl_frame *master_flat = NULL;
602 cpl_frame *order_tab_edges = NULL;
603 cpl_frame *wave_tab = NULL ;
604 cpl_frame *model_config_frame = NULL ;
605 cpl_frame *wavemap_frame = NULL ;
606 cpl_frame *slitmap_frame = NULL ;
607 cpl_frame *disp_tab_frame = NULL;
608 cpl_frame *spectralformat_frame = NULL ;
609 cpl_frame *tell_list_frame = NULL;
610 /* Parameters */
611 xsh_clipping_param* crh_clipping_par = NULL;
612 xsh_background_param* backg_par = NULL;
613 xsh_remove_crh_single_param * crh_single_par = NULL ;
614 xsh_rectify_param * rectify_par = NULL ;
615 xsh_localize_obj_param * loc_obj_par = NULL ;
616 int sub_sky_nbkpts1 = SUBTRACT_SKY_SINGLE_NBKPTS ;
619 int sub_sky_nbkpts2 = SUBTRACT_SKY_SINGLE_NBKPTS ;
622 int do_sub_sky = FALSE;
623 int recipe_use_model = 0;
624 int do_optextract = 0;
625 int do_flatfield = 0;
626 int do_compute_map = 0;
627 int do_trace_obj = 0;
628
629 int merge_par = 0;
630 xsh_extract_param *extract_par = NULL ;
631 xsh_opt_extract_param *opt_extract_par = NULL;
632 xsh_subtract_sky_single_param *sky_par = NULL;
633
635 int nb_raw_frames ;
636 char rec_name[256];
637
638 /* Intermediate frames */
639#if 0
640 cpl_frameset * on = NULL, * off = NULL ;
641#endif
642 cpl_frame * crhm_frame = NULL ;
643 cpl_frame * rmbias = NULL;
644 cpl_frame * rmdark = NULL;
645 cpl_frame * rmbkg = NULL ;
646 cpl_frame * div_frame = NULL ;
647 cpl_frame * sub_sky_frame = NULL ;
648 cpl_frame * sub_sky2_frame = NULL ;
650 cpl_frame * rect_frame = NULL ;
651 cpl_frame * loc_table_frame = NULL ;
652 cpl_frame * clean_frame = NULL ;
653 cpl_frame * rect2_frame = NULL ;
654 cpl_frame * rect2_frame_eso = NULL ;
655 cpl_frame * rect2_frame_tab = NULL ;
656
657 /* Output Frames (results)*/
658 cpl_frame * sky_frame = NULL ;
659 cpl_frame * sky_frame_eso = NULL ;
660 cpl_frame * res_1D_frame = NULL ;
661 cpl_frame * res_2D_frame = NULL ;
662 cpl_frame * fluxcal_rect_1D_frame = NULL ;
663 cpl_frame * fluxcal_rect_2D_frame = NULL ;
664 cpl_frame * fluxcal_1D_frame = NULL ;
665 cpl_frame * fluxcal_2D_frame = NULL ;
666
667 cpl_frame * ext_frame = NULL ;
668 cpl_frame * ext_frame_eso = NULL ;
669
670 cpl_frame *orderoxt1d_eso_frame = NULL;
671 cpl_frame *orderext1d_frame = NULL;
672 cpl_frame *orderoxt1d_frame = NULL;
673 cpl_frame *mergeext1d_frame = NULL;
674 cpl_frame *mergeoxt1d_frame = NULL;
675
676 cpl_frame* grid_backg=NULL;
677 cpl_frame* frame_backg=NULL;
678 cpl_frame* sky_frame_ima=NULL;
679 char prefix[256];
680 const char* ftag=NULL;
681
682 cpl_frame* single_frame_sky_sub_tab_frame=NULL;
683/*
684 char sky_name[256];
685 xsh_pre* pre_sci=NULL;
686 cpl_image* sky_image=NULL;
687*/
688 cpl_frame* clean_obj=NULL;
689 char *rec_prefix = NULL;
690 cpl_frame* sky_list_frame=NULL;
691 cpl_frame* qc_sky_frame=NULL;
692 cpl_propertylist* plist=NULL;
693 cpl_frame* qc_obj_trace_ord=NULL;
694 cpl_frame* qc_obj_trace_mer=NULL;
695
696 const char* name=NULL;
697 int pre_overscan_corr=0;
698 /* absorp */
699 cpl_frame *tell_mask_frame = NULL;
700 int absorp_filter_hsize = 5;
701 double absorp_thresh = 0.0;
702 cpl_frame *qc_subex_frame = NULL;
703 cpl_frame *qc_s2ddiv1d_frame = NULL;
704 cpl_frame *qc_model_frame = NULL;
705 cpl_frame *qc_weight_frame = NULL;
706
707 xsh_stack_param* stack_par=NULL;
708
709 /**************************************************************************/
710 /* DFS management */
711 /**************************************************************************/
712 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
713 recipe_tags, recipe_tags_size,
714 RECIPE_ID, XSH_BINARY_VERSION,
716
717 /*
718 assure( instrument->mode == XSH_MODE_SLIT, CPL_ERROR_ILLEGAL_INPUT,
719 "Instrument NOT in Slit Mode" ) ;
720 */
722 if(instrument->arm == XSH_ARM_NIR) {
724 }
725 /**************************************************************************/
726 /* Recipe frames */
727 /**************************************************************************/
728 /* One should have 1 or >=3 input frames. 2 is not permitted */
729 check( nb_raw_frames = cpl_frameset_get_size( raws ) ) ;
730 xsh_msg_dbg_low("nb_raw_frames=%d",nb_raw_frames);
731 XSH_ASSURE_NOT_ILLEGAL_MSG( nb_raw_frames == 1 || nb_raw_frames >= 3,
732 "This recipes accepts either one or at least 3 input frames" ) ;
733 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
734 "pre-overscan-corr"));
735 check(xsh_slit_stare_get_calibs(calib,instrument, &spectralformat_frame,
736 &master_bias,&master_dark,&master_flat,
737 &order_tab_edges,&model_config_frame,
738 &wave_tab,&sky_list_frame,&qc_sky_frame,
739 &bpmap,&single_frame_sky_sub_tab_frame,
740 &wavemap_frame,&slitmap_frame,RECIPE_ID,
741 &recipe_use_model,pre_overscan_corr));
742
743 /* tell line list */
744 check( tell_list_frame = xsh_find_frame_with_tag(calib,XSH_TELL_LINE_LIST,
745 instrument));
746 if ( tell_list_frame == NULL){
747 xsh_msg_error("Provide telluric line list frame");
748 return CPL_ERROR_DATA_NOT_FOUND;
749 }
750
751 /**************************************************************************/
752 /* Recipe parameters */
753 /**************************************************************************/
754
755 check(xsh_slit_stare_get_params(parameters,RECIPE_ID, &pre_overscan_corr,
756 &crh_clipping_par,&backg_par,&loc_obj_par,
757 &rectify_par,&crh_single_par,&sub_sky_nbkpts1,
758 &do_flatfield,&sub_sky_nbkpts2,&sky_par,
759 &extract_par,&do_optextract,
760 &opt_extract_par,&do_trace_obj));
761
762 check( absorp_filter_hsize = xsh_parameters_get_int( parameters, RECIPE_ID,
763 "absorp-filter-hsize"));
764 check( absorp_thresh = xsh_parameters_get_double( parameters, RECIPE_ID,
765 "absorp-threshold"));
766 check(xsh_params_set_defaults(parameters,RECIPE_ID,instrument,rectify_par,
767 backg_par));
768 /* special parameters */
769 check( xsh_parameters_dosky_get( RECIPE_ID, parameters,&do_sub_sky));
770
771 /* adjust relevant parameter to binning */
773 check(xsh_params_bin_scale(raws,backg_par,
774 opt_extract_par,
775 &sub_sky_nbkpts1,&sub_sky_nbkpts2));
776 }
777
778 /* parameters dependent input */
779 check( stack_par = xsh_stack_frames_get( RECIPE_ID, parameters));
780 if ( rectify_par->conserve_flux){
781 check_msg(disp_tab_frame = xsh_find_disp_tab( calib, instrument),
782 "rectify-conserve-flux=TRUE, you must give a DISP_TAB_ARM input");
783 }
784 if ( do_compute_map && recipe_use_model==FALSE){
785 check_msg(disp_tab_frame = xsh_find_disp_tab( calib, instrument),
786 "compute-map=TRUE, physmodel mode, you must give a DISP_TAB_ARM input");
787 }
788 check(xsh_params_monitor(backg_par,rectify_par,loc_obj_par,opt_extract_par,
789 sub_sky_nbkpts1,sub_sky_nbkpts2));
790
791 /**************************************************************************/
792 /* Recipe code */
793 /**************************************************************************/
794
795 /* prepare RAW frames in XSH format */
796 check(xsh_prepare(raws, bpmap, master_bias, XSH_OBJECT_SLIT_STARE,
797 instrument,pre_overscan_corr,CPL_TRUE));
798 check( rec_prefix = xsh_set_recipe_file_prefix( raws,
799 "xsh_absorp"));
800
801 /* pre CRH removal (method multi) as scired may have more than 2 in frames */
803 check( crhm_frame = xsh_check_remove_crh_multiple( raws, ftag,stack_par,
804 crh_clipping_par, instrument, NULL, NULL));
805
806
808 do_compute_map,recipe_use_model,rec_prefix,
809 instrument,model_config_frame,crhm_frame,
810 disp_tab_frame,order_tab_edges,
811 &wavemap_frame, &slitmap_frame));
812
813 sprintf(prefix,"%s_",rec_prefix);
814 /* Subtract bias if necessary */
815 /* AMO here one should check is pre-overscan was corrected */
816 check( rmbias = xsh_check_subtract_bias( crhm_frame, master_bias,
817 instrument, prefix,
818 pre_overscan_corr,0));
819
820 /* Subtract Dark if necessary */
821 check( rmdark = xsh_check_subtract_dark( rmbias, master_dark,
822 instrument, rec_prefix));
823
824 /* subtract inter-order background */
825 xsh_msg("Subtract inter-order background");
826 check(rmbkg = xsh_subtract_background( rmdark,
827 order_tab_edges,
828 backg_par, instrument,rec_prefix,
829 &grid_backg,&frame_backg,0));
830
831 /* In case CRH single or localize auto do preliminar sky subtraction */
832 xsh_slit_stare_correct_crh_and_sky(loc_obj_par,crh_single_par,rectify_par,
833 do_sub_sky,rec_prefix,rmbkg,
834 order_tab_edges, slitmap_frame,
835 wavemap_frame,model_config_frame,
836 single_frame_sky_sub_tab_frame,instrument,
837 sub_sky_nbkpts1, sky_par,
838 &sky_frame,&sky_frame_eso,&sky_frame_ima,
839 wave_tab,disp_tab_frame,
840 spectralformat_frame,nb_raw_frames,
841 &loc_table_frame,&clean_frame,&clean_obj);
842
843
844
845 /* now we divide by the flat for proper sky subtraction */
846 check( div_frame = xsh_check_divide_flat( do_flatfield, clean_obj,
847 master_flat, instrument, rec_prefix));
848
849
850 check( sub_sky2_frame = xsh_check_subtract_sky_single( do_sub_sky, div_frame,
851 order_tab_edges, slitmap_frame, wavemap_frame, loc_table_frame,
852 single_frame_sky_sub_tab_frame, instrument, sub_sky_nbkpts2, sky_par,
853 &sky_frame, &sky_frame_eso, &sky_frame_ima, rec_prefix,0));
854
855 xsh_msg( "Prepare S2D products" ) ;
856 xsh_msg( "Rectify") ;
857 sprintf(rec_name,"%s_%s_%s.fits",rec_prefix,XSH_ORDER2D,
859
860 check( rect2_frame = xsh_rectify( sub_sky2_frame, order_tab_edges,
861 wave_tab, model_config_frame, instrument,
862 rectify_par,spectralformat_frame,
863 disp_tab_frame,rec_name,
864 &rect2_frame_eso,&rect2_frame_tab,
865 rec_prefix));
866 xsh_msg( "Extract" ) ;
867 check(ext_frame=xsh_extract(rect2_frame, loc_table_frame,
868 instrument, extract_par,&ext_frame_eso,
869 rec_prefix)) ;
870
871 xsh_msg( "Merge orders with 1D frame" ) ;
872 check( res_1D_frame = xsh_merge_ord( ext_frame, instrument,
873 merge_par,rec_prefix ));
875
876 xsh_msg( "Calling xsh_merge_ord with 2D frame" ) ;
877 check( res_2D_frame = xsh_merge_ord( rect2_frame, instrument,
878 merge_par,rec_prefix ));
879
880 xsh_msg("Prepare S1D products" ) ;
881 /* doing optimal extraction */
882 int hsize=0;
883 int naxis2=0;
884 if ( do_optextract){
885 xsh_msg( "Optimal extraction");
886 check( xsh_opt_extract( sub_sky2_frame, order_tab_edges,
887 wave_tab, model_config_frame, wavemap_frame,
888 slitmap_frame, loc_table_frame,
889 spectralformat_frame, master_flat, instrument,
890 opt_extract_par, rec_prefix,
891 &orderext1d_frame, &orderoxt1d_frame,
892 &orderoxt1d_eso_frame,
893 &qc_subex_frame,
894 &qc_s2ddiv1d_frame,
895 &qc_model_frame,
896 &qc_weight_frame));
897
898 check( mergeext1d_frame = xsh_merge_ord( orderext1d_frame, instrument,
899 merge_par,rec_prefix));
900 check( mergeoxt1d_frame = xsh_merge_ord( orderoxt1d_frame, instrument,
901 merge_par,rec_prefix));
902 }
903
904 if( do_trace_obj) {
905 name=cpl_frame_get_filename(res_2D_frame);
906 plist=cpl_propertylist_load(name,0);
907 naxis2=xsh_pfits_get_naxis2(plist);
908 xsh_free_propertylist(&plist);
909 hsize=naxis2/4;
910 check(qc_obj_trace_ord=xsh_frame_image_ext_qc_trace_window(rect2_frame_eso,
912 rec_prefix,
913 hsize,0));
914
915 check(qc_obj_trace_mer=xsh_frame_image_qc_trace_window(res_2D_frame,
917 rec_prefix,
918 hsize,0));
919 }
920
921 /* Produce telluric mask */
922 if ( mergeoxt1d_frame != NULL){
923 check( tell_mask_frame = xsh_compute_absorp( mergeoxt1d_frame, tell_list_frame,
924 absorp_filter_hsize, absorp_thresh, instrument));
925 }
926 else{
927 check( tell_mask_frame = xsh_compute_absorp( res_1D_frame, tell_list_frame,
928 absorp_filter_hsize, absorp_thresh, instrument));
929 }
930
931 /* saving products */
932
933 xsh_msg( "Saving products" ) ;
934
935 check( xsh_add_product_vector( tell_mask_frame, frameset, parameters,
937 cpl_frame_get_tag( tell_mask_frame)));
938
939
940
941 check( xsh_add_product_image(rect2_frame_eso, frameset, parameters,
943 cpl_frame_get_tag(rect2_frame_eso)));
944
945 check( xsh_add_product_image(ext_frame_eso, frameset, parameters,
947 cpl_frame_get_tag(ext_frame_eso)));
948
949 check( xsh_add_product_spectrum( res_2D_frame, frameset, parameters,
950 RECIPE_ID, instrument,NULL,NULL));
951
952
953 check( xsh_add_product_spectrum( res_1D_frame, frameset, parameters,
954 RECIPE_ID, instrument,NULL,NULL));
955
956 check( xsh_add_product_pre( rmbias, frameset, parameters,
957 RECIPE_ID, instrument,NULL));
958
959 check( xsh_add_product_image( rmbkg, frameset, parameters,
961 cpl_frame_get_tag(rmbkg)));
962
963 if ( do_sub_sky == 1 && nb_raw_frames == 1 && crh_single_par->nb_iter > 0){
964
965 check( xsh_add_product_image( clean_frame, frameset, parameters,
967 cpl_frame_get_tag(clean_frame)));
968
969 }
970 if (do_compute_map){
971 sprintf(prefix,"%s_WAVE_MAP_%s",rec_prefix,
973
974
975 check(xsh_add_product_image( wavemap_frame, frameset,
976 parameters, RECIPE_ID, instrument, prefix));
977
978 check(sprintf(prefix,"%s_SLIT_MAP_%s",rec_prefix,
980
981 check(xsh_add_product_image( slitmap_frame, frameset,
982 parameters, RECIPE_ID, instrument, prefix));
983 }
984 if(do_flatfield) {
985
986 check( xsh_add_product_image( div_frame, frameset, parameters,
988 cpl_frame_get_tag(div_frame)));
989 }
990
991 if ( do_optextract){
992 check( xsh_add_product_table( orderext1d_frame, frameset,
993 parameters, RECIPE_ID, instrument, NULL));
994 check( xsh_add_product_table( orderoxt1d_frame, frameset,
995 parameters, RECIPE_ID, instrument, NULL));
996 check( xsh_add_product_spectrum( mergeext1d_frame, frameset, parameters,
997 RECIPE_ID, instrument,NULL,NULL));
998 check( xsh_add_product_spectrum( mergeoxt1d_frame, frameset,
999 parameters, RECIPE_ID, instrument,NULL,NULL));
1000 check( xsh_add_product_image( qc_subex_frame, frameset, parameters,
1002 cpl_frame_get_tag(qc_subex_frame)));
1003 check( xsh_add_product_image( qc_s2ddiv1d_frame, frameset, parameters,
1005 cpl_frame_get_tag(qc_s2ddiv1d_frame)));
1006 check( xsh_add_product_image( qc_model_frame, frameset, parameters,
1008 cpl_frame_get_tag(qc_model_frame)));
1009 check( xsh_add_product_image( qc_weight_frame, frameset, parameters,
1011 cpl_frame_get_tag(qc_weight_frame)));
1012 }
1013 if ( do_sub_sky == 1 ) {
1014 check( xsh_add_product_pre( sub_sky2_frame, frameset, parameters,
1015 RECIPE_ID, instrument,NULL));
1016 check( xsh_add_product_image( sky_frame_ima, frameset, parameters,
1018 cpl_frame_get_tag(sky_frame_ima)));
1019 check( xsh_add_product_image( sky_frame_eso, frameset,
1020 parameters, RECIPE_ID, instrument,
1021 cpl_frame_get_tag(sky_frame_eso)));
1022 }
1023 check( xsh_add_product_image( frame_backg, frameset, parameters,
1025 cpl_frame_get_tag(frame_backg)));
1026
1027 if(crhm_frame != NULL) {
1028 check( xsh_add_product_image( crhm_frame, frameset, parameters,
1030 cpl_frame_get_tag(crhm_frame)));
1031
1032 }
1033
1034 if(qc_sky_frame != NULL) {
1035 check( xsh_add_product_table(qc_sky_frame, frameset,
1036 parameters, RECIPE_ID, instrument,NULL));
1037
1038 }
1039
1040 if(do_trace_obj) {
1041 check( xsh_add_product_table(qc_obj_trace_ord, frameset,
1042 parameters, RECIPE_ID, instrument, NULL));
1043
1044 check( xsh_add_product_table(qc_obj_trace_mer, frameset,
1045 parameters, RECIPE_ID, instrument, NULL));
1046 }
1047
1048
1049 cleanup:
1050 xsh_end( RECIPE_ID, frameset, parameters );
1051 XSH_FREE( rec_prefix);
1052 XSH_FREE( crh_clipping_par);
1053 XSH_FREE( backg_par);
1054 XSH_FREE( crh_single_par);
1055 XSH_FREE( rectify_par);
1056 XSH_FREE( sky_par);
1057 XSH_FREE( loc_obj_par);
1058 XSH_FREE( extract_par);
1059 XSH_FREE( opt_extract_par);
1061
1062 xsh_free_frameset(&raws);
1063 xsh_free_frameset(&calib);
1064 xsh_free_frame( &crhm_frame);
1065 xsh_free_frame( &qc_sky_frame);
1066
1067 xsh_free_frame( &wavemap_frame);
1068 xsh_free_frame( &slitmap_frame);
1069
1070 xsh_free_frame(&rmbias);
1071 xsh_free_frame(&rmdark);
1072 xsh_free_frame(&rmbkg);
1073 xsh_free_frame(&div_frame);
1074 xsh_free_frame(&sub_sky_frame);
1075
1076 xsh_free_frame(&sub_sky2_frame);
1077 xsh_free_frame(&sky_frame);
1078 xsh_free_frame(&sky_frame_eso);
1079 xsh_free_frame(&sky_frame_ima);
1080
1081 xsh_free_frame(&rect_frame) ;
1082 xsh_free_frame(&rect2_frame_eso) ;
1083 xsh_free_frame(&rect2_frame_tab) ;
1084
1085 xsh_free_frame( &orderext1d_frame);
1086 xsh_free_frame( &orderoxt1d_frame);
1087 xsh_free_frame( &mergeext1d_frame);
1088 xsh_free_frame( &mergeoxt1d_frame);
1089
1090 xsh_free_frame(&loc_table_frame) ;
1091 xsh_free_frame( &clean_frame);
1092 xsh_free_frame( &clean_obj);
1093 xsh_free_frame( &ext_frame);
1094 xsh_free_frame( &ext_frame_eso);
1095 xsh_free_frame(&res_1D_frame) ;
1096 xsh_free_frame(&res_2D_frame) ;
1097 xsh_free_frame(&fluxcal_rect_1D_frame) ;
1098 xsh_free_frame(&fluxcal_rect_2D_frame) ;
1099 xsh_free_frame(&fluxcal_1D_frame) ;
1100 xsh_free_frame(&fluxcal_2D_frame) ;
1101
1102 xsh_free_frame(&rect2_frame) ;
1103 xsh_free_frame(&grid_backg) ;
1104 xsh_free_frame(&frame_backg) ;
1105 xsh_free_frame( &tell_mask_frame);
1106 xsh_free_propertylist(&plist);
1107
1108 xsh_free_frame( &single_frame_sky_sub_tab_frame);
1109 xsh_free_frame( &qc_subex_frame);
1110 xsh_free_frame(&qc_s2ddiv1d_frame);
1111 xsh_free_frame(&qc_model_frame);
1112 xsh_free_frame(&qc_weight_frame);
1113
1114 return CPL_ERROR_NONE;
1115}
1116
static xsh_instrument * instrument
int binx
int biny
#define RECIPE_CONTACT
Definition: xsh_absorp.c:75
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
Definition: xsh_absorp.c:151
static char xsh_absorp_description[]
Definition: xsh_absorp.c:99
static cpl_error_code xsh_absorp(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
Definition: xsh_absorp.c:587
static int xsh_absorp_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
Definition: xsh_absorp.c:371
static cpl_error_code xsh_params_monitor(xsh_background_param *backg, xsh_rectify_param *rectify_par, xsh_localize_obj_param *loc_obj_par, xsh_opt_extract_param *opt_extract_par, int sub_sky_nbkpts1, int sub_sky_nbkpts2)
Definition: xsh_absorp.c:427
static int xsh_absorp_create(cpl_plugin *)
Setup the recipe options.
Definition: xsh_absorp.c:193
static int xsh_absorp_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
Definition: xsh_absorp.c:337
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.
Definition: xsh_absorp.c:470
#define RECIPE_ID
Definition: xsh_absorp.c:73
#define RECIPE_AUTHOR
Definition: xsh_absorp.c:74
static cpl_error_code xsh_params_set_defaults(cpl_parameterlist *pars, const char *rec_id, xsh_instrument *inst, xsh_rectify_param *rectify_par, xsh_background_param *backg)
Definition: xsh_absorp.c:400
static char xsh_absorp_description_short[]
Definition: xsh_absorp.c:96
cpl_frame * xsh_compute_absorp(cpl_frame *s1d_frame, cpl_frame *telllist_frame, int filter_hsize, double threshold, xsh_instrument *instr)
Compute the shift in slit between reference wavelength and others for all the slitlets.
cpl_error_code xsh_monitor_spectrum1D_flux(cpl_frame *in_frm, xsh_instrument *instrument)
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 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
#define XSH_ASSURE_NOT_ILLEGAL_MSG(cond, msg)
Definition: xsh_error.h:111
cpl_frame * xsh_extract(cpl_frame *rec_frame, cpl_frame *loc_frame, xsh_instrument *instrument, xsh_extract_param *extract_par, cpl_frame **res_frame_ext, const char *rec_prefix)
simple 1D extraction of point source like object
Definition: xsh_extract.c:808
cpl_error_code xsh_instrument_nir_corr_if_JH(cpl_frameset *raws, xsh_instrument *instr)
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
cpl_frame * xsh_merge_ord(cpl_frame *sci_frame, xsh_instrument *instrument, int merge, const char *rec_prefix)
Merge orders of the rectified frame using merge parameters.
#define xsh_msg_error(...)
Print an error message.
Definition: xsh_msg.h:62
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_low(...)
Definition: xsh_msg.h:48
void xsh_opt_extract(cpl_frame *sci_frame, cpl_frame *order_table_frame, cpl_frame *wavesol_frame, cpl_frame *model_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, cpl_frame *loc_frame, cpl_frame *spectralformat_frame, cpl_frame *masterflat_frame, xsh_instrument *instrument, xsh_opt_extract_param *opt_extract_par, const char *rec_prefix, cpl_frame **orderext1d_frame, cpl_frame **orderoxt1d_frame, cpl_frame **orderoxt1d_eso_frame, cpl_frame **qc_subextract_frame, cpl_frame **qc_s2ddiv1d_frame, cpl_frame **qc_model_frame, cpl_frame **qc_weight_frame)
Create a SPECTRUM 1D from a Science frame.
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
int xsh_pfits_get_naxis2(const cpl_propertylist *plist)
find out the NAXIS2 value
Definition: xsh_pfits.c:244
cpl_frame * xsh_rectify(cpl_frame *sci_frame, cpl_frame *order_table_frame, cpl_frame *wavesol_frame, cpl_frame *model_config_frame, xsh_instrument *instrument, xsh_rectify_param *rectify_par, cpl_frame *spectral_format, cpl_frame *disp_tab_frame, const char *fname, cpl_frame **res_frame_ext, cpl_frame **res_frame_tab, const char *prefix)
Create a grid in wavelength with the step in lambda and slit. Steps are defined in the parameters....
Definition: xsh_rectify.c:867
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
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
enum optextract_method method
@ XSH_ARM_NIR
void xsh_add_product_vector(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:1895
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
void xsh_add_product_pre(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instr, cpl_propertylist *qclist)
Add DFS keywords to a product frame.
Definition: xsh_dfs.c:2465
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
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)
Definition: xsh_dfs.c:3146
void xsh_add_product_spectrum(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instr, cpl_frame **result_frame, cpl_propertylist *qclist)
Definition: xsh_dfs.c:2067
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
Definition: xsh_dfs.c:3347
#define XSH_ORDER2D
Definition: xsh_dfs.h:588
#define XSH_STD_TELL_SLIT_STARE
Definition: xsh_dfs.h:462
#define XSH_SLIT_STARE_REMOVE_CRH
Definition: xsh_dfs.h:156
#define XSH_SLIT_BIN_SIZE_PIPE_NIR
Definition: xsh_dfs.h:101
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
Definition: xsh_dfs.h:1548
#define XSH_TELL_LINE_LIST
Definition: xsh_dfs.h:1139
#define XSH_WAVE_BIN_SIZE_PIPE_NIR
Definition: xsh_dfs.h:105
#define XSH_OBJECT_SLIT_STARE
Definition: xsh_dfs.h:226
cpl_frame * xsh_check_remove_crh_multiple(cpl_frameset *raws, const char *ftag, xsh_stack_param *stack_par, xsh_clipping_param *crh_clipping_par, xsh_instrument *instr, cpl_imagelist **lista, cpl_image **listb)
Check function.
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_frame * xsh_check_subtract_sky_single(int do_subsky, cpl_frame *src_frame, cpl_frame *ordertabedges_frame, cpl_frame *slitmap_frame, cpl_frame *wavemap_frame, cpl_frame *loctab_frame, cpl_frame *definedbreakpoints_frame, xsh_instrument *instrument, int nbkpts, xsh_subtract_sky_single_param *sky_par, cpl_frame *ref_sky_list, cpl_frame *sky_orders_chunks, cpl_frame **sky_spectrum, cpl_frame **sky_spectrum_eso, cpl_frame **sky_img, const char *prefix, const int clean_tmp)
Check function sky subtraction on single frame.
cpl_frame * xsh_check_divide_flat(int do_flatfield, cpl_frame *clean_frame, cpl_frame *master_flat, xsh_instrument *instrument, const char *prefix)
Check function.
cpl_frame * xsh_check_subtract_dark(cpl_frame *rmbias_frame, cpl_frame *master_dark, xsh_instrument *instrument, const char *prefix)
Check function for dark subtraction.
cpl_parameter * xsh_parameters_find(cpl_parameterlist *list, const char *recipe_id, const char *name)
find a parameter
void xsh_parameters_subtract_sky_single_create(const char *recipe_id, cpl_parameterlist *plist, xsh_subtract_sky_single_param p)
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
xsh_stack_param * xsh_stack_frames_get(const char *recipe_id, cpl_parameterlist *list)
get the detect arclines parameters in a parameters list
double xsh_parameters_get_double(const cpl_parameterlist *list, const char *recipe_id, const char *name)
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_new_double(cpl_parameterlist *list, const char *recipe_id, const char *name, double value, const char *comment)
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)
void xsh_parameters_background_create(const char *recipe_id, cpl_parameterlist *list)
create the subtract background parameters in a parameters list
void xsh_parameters_extract_create(const char *recipe_id, cpl_parameterlist *plist, xsh_extract_param p, enum extract_method method)
void xsh_parameters_remove_crh_single_create(const char *recipe_id, cpl_parameterlist *plist, xsh_remove_crh_single_param p)
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)
void xsh_parameters_new_int(cpl_parameterlist *list, const char *recipe_id, const char *name, int value, const char *comment)
void xsh_parameters_opt_extract_create(const char *recipe_id, cpl_parameterlist *list, xsh_opt_extract_param p)
Create the optimal extraction parameters in a parameters list.
@ FINE
#define SUBTRACT_SKY_SINGLE_NBKPTS
@ GAUSS_METHOD
@ BSPLINE_METHOD
@ LOC_MANUAL_METHOD
@ LOCALIZATION_METHOD
#define XSH_FREE(POINTER)
Definition: xsh_utils.h:92
cpl_frame * xsh_frame_image_qc_trace_window(cpl_frame *frm_ima, xsh_instrument *instrument, const char *suffix, const int hsize, const int method)
Trace object position in an image.
cpl_frame * xsh_frame_image_ext_qc_trace_window(cpl_frame *frm_ima, xsh_instrument *instrument, const char *suffix, const int hsize, const int method)
Trace object position in an image.
cpl_error_code xsh_slit_stare_get_params(cpl_parameterlist *parameters, const char *rec_id, int *pre_overscan_corr, xsh_background_param **backg_par, xsh_localize_obj_param **loc_obj_par, xsh_rectify_param **rectify_par, xsh_remove_crh_single_param **crh_single_par, int *sub_sky_nbkpts1, int *do_flatfield, int *sub_sky_nbkpts2, xsh_subtract_sky_single_param **sky_par, int *do_optextract, xsh_opt_extract_param **opt_extract_par, int *generate_sdp_format)
cpl_error_code xsh_slit_stare_get_maps(cpl_frameset *calib, int do_compute_map, int recipe_use_model, const char *rec_prefix, xsh_instrument *instrument, cpl_frame *model_config_frame, cpl_frame *crhm_frame, cpl_frame *disp_tab_frame, cpl_frame *order_tab_edges, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame)
cpl_error_code xsh_slit_stare_correct_crh_and_sky(xsh_localize_obj_param *loc_obj_par, xsh_remove_crh_single_param *crh_single_par, xsh_rectify_param *rectify_par, int do_sub_sky, const char *rec_prefix, cpl_frame *rmbkg, cpl_frame *order_tab_edges, cpl_frame *slitmap, cpl_frame *wavemap, cpl_frame *sky_map, cpl_frame *model_config, cpl_frame *single_frame_sky_sub_tab, xsh_instrument *instrument, int sub_sky_nbkpts1, xsh_subtract_sky_single_param *sky_par, cpl_frame *ref_sky_list, cpl_frame *sky_orders_chunks, cpl_frame **sky, cpl_frame **sky_eso, cpl_frame **sky_ima, cpl_frame *wave_tab, cpl_frame *disp_tab, cpl_frame *spectral_format, int nb_raw_frames, cpl_frame **loc_table, cpl_frame **clean, cpl_frame **clean_obj, const int clean_tmp)
correct CRH and sky lines (1st iteration)
cpl_error_code xsh_slit_stare_get_calibs(cpl_frameset *calib, xsh_instrument *instrument, cpl_frame **spectralformat, cpl_frame **mbias, cpl_frame **mdark, cpl_frame **mflat, cpl_frame **otab_edges, cpl_frame **model_cfg, cpl_frame **wave_tab, cpl_frame **sky_list, cpl_frame **sky_orders_chunks, cpl_frame **qc_sky, cpl_frame **bpmap, cpl_frame **sframe_sky_sub_tab, cpl_frame **wmap, cpl_frame **smap, const char *rec_id, int *recipe_use_model, int pscan)