X-shooter Pipeline Reference Manual 3.8.15
xsh_scired_slit_offset.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-08-29 10:49:42 $
23 * $Revision: 1.158 $
24 *
25*/
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*----------------------------------------------------------------------------*/
39/*----------------------------------------------------------------------------*/
42/*-----------------------------------------------------------------------------
43 Includes
44 ----------------------------------------------------------------------------*/
45
46/* DRL steps */
47
48/* Error handling */
49#include <xsh_error.h>
50#include <stdio.h>
51/* Utility fonctions */
52#include <xsh_utils.h>
54#include <xsh_data_spectrum.h>
55
56#include <xsh_msg.h>
57/* DFS functions */
58#include <xsh_dfs.h>
59#include <xsh_pfits.h>
60#include <xsh_data_spectrum1D.h>
62#include <xsh_utils_image.h>
63
64/* DRL functions */
65#include <xsh_drl.h>
66#include <xsh_drl_check.h>
67/* Library */
68#include <cpl.h>
69
70/*-----------------------------------------------------------------------------
71 Defines
72 ---------------------------------------------------------------------------*/
73
74#define RECIPE_ID "xsh_scired_slit_offset"
75#define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer, D. Bramich, A. Modigliani"
76#define RECIPE_CONTACT "amodigli@eso.org"
77
78/*-----------------------------------------------------------------------------
79 Functions prototypes
80 ----------------------------------------------------------------------------*/
81
82/*
83 * Plugin initalization, execute and cleanup handlers
84 */
85
86static int xsh_scired_slit_offset_create( cpl_plugin *);
87static int xsh_scired_slit_offset_exec( cpl_plugin *);
88static int xsh_scired_slit_offset_destroy( cpl_plugin *);
89
90/* The actual executor function */
91static void xsh_scired_slit_offset( cpl_parameterlist *, cpl_frameset *);
92
93/*-----------------------------------------------------------------------------
94 Static variables
95 ----------------------------------------------------------------------------*/
97"Reduce science exposure in SLIT configuration and on/off mode";
98
100"This recipe reduces science exposure in SLIT configuration and on/off mode\n\
101Input Frames : \n\
102 - A set of n Science frames and n corresponding Sky frames \
103 (excess frames will be dropped), \
104 Tag = STD_FLUX_SLIT_OFFSET_arm, SKY_SLIT_arm\n\
105 - Spectral format table (Tag = SPECTRAL_FORMAT_TAB_arm)\n\
106 - A master flat frame (Tag = MASTER_FLAT_SLIT_arm)\n\
107 - An order table frame(Tag = ORDER_TABLE_EDGES_SLIT_arm)\n\
108 - A wavelength calibration solution frame(Tag = WAVE_TAB_2D_arm)\n\
109 - [OPTIONAL] Table with dispersion coefficients (Tag = DISP_TAB_arm)\n\
110 It is required if -rectify-conserve-flux=TRUE\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\
113 - [OPTIONAL] The instrument response table (Tag = RESPONSE_MERGE1D_SLIT_arm)\n\
114 - [OPTIONAL] An atmospheric extinction table (Tag = ATMOS_EXT_arm)\n\
115 - [OPTIONAL] A telluric mask (Tag = TELL_MASK_arm)\n\
116 - [OPTIONAL] The instrument master response table (Tag = MRESPONSE_MERGE1D_SLIT_arm).\n\
117 If both master and individual response are provided the individual response is preferred.\n\
118Products : \n\
119 - PREFIX_ORDER2D_arm extracted spectrum, order-by-order, 2D\n\
120 - PREFIX_ORDER1D_arm extracted spectrum, order-by-order, 1D\n\
121 - PREFIX_MERGE2D_arm merged spectrum, 2D\n\
122 - PREFIX_MERGE1D_arm merged spectrum, 1D\n\
123 - PREFIX_SKY_arm, 2D sky frame\n\
124 - SKY_SLIT_ORDER2D_arm, 2D sky image (order-by-order)\n\
125 - SKY_SLIT_MERGE2D_arm, 2D sky image (merged)\n\
126 - PREFIX_WAVE_MAP_arm, wave map image\n\
127 - PREFIX_SLIT_MAP_arm, slit map image\n\
128 - where PREFIX is SCI, FLUX, TELL if input raw DPR.TYPE contains OBJECT or FLUX or TELLURIC\n\
129 - [OPTIONAL, if response and atm ext are provided] PREFIX_FLUX_ORDER2D_arm (2 dimension)\n\
130 - [OPTIONAL, if response and atm ext are provided] PREFIX_FLUX_ORDER1D_arm (1 dimension)\n\
131 - [OPTIONAL, if response and atm ext are provided] PREFIX_FLUX_MERGE2D_arm (2 dimension)\n\
132 - [OPTIONAL, if response and atm ext are provided] PREFIX_FLUX_MERGE1D_arm (1 dimension)\n";
133
134
135/*-----------------------------------------------------------------------------
136 Functions code
137 ----------------------------------------------------------------------------*/
138/*----------------------------------------------------------------------------*/
147/*----------------------------------------------------------------------------*/
148
149int cpl_plugin_get_info(cpl_pluginlist *list) {
150 cpl_recipe *recipe = NULL;
151 cpl_plugin *plugin = NULL;
152
153 recipe = cpl_calloc(1, sizeof(*recipe));
154 if ( recipe == NULL ){
155 return -1;
156 }
157
158 plugin = &recipe->interface ;
159
160 cpl_plugin_init(plugin,
161 CPL_PLUGIN_API, /* Plugin API */
162 XSH_BINARY_VERSION, /* Plugin version */
163 CPL_PLUGIN_TYPE_RECIPE, /* Plugin type */
164 RECIPE_ID, /* Plugin name */
166 xsh_scired_slit_offset_description, /* Detailed help */
167 RECIPE_AUTHOR, /* Author name */
168 RECIPE_CONTACT, /* Contact address */
169 xsh_get_license(), /* Copyright */
173
174 cpl_pluginlist_append(list, plugin);
175
176 return (cpl_error_get_code() != CPL_ERROR_NONE);
177}
178
179/*----------------------------------------------------------------------------*/
189/*----------------------------------------------------------------------------*/
190
191static int xsh_scired_slit_offset_create(cpl_plugin *plugin){
192 cpl_recipe *recipe = NULL;
193
194 /* First param (conv_kernel) should be initialized correctly ! */
195 xsh_remove_crh_single_param crh_single = { 0.1, 5.0, 2.0, -1} ;
196 xsh_rectify_param rectify = { "tanh",
197 CPL_KERNEL_DEFAULT,
198 2,
199 -1.0,
200 -1.0,
201 1,0,0.};
202 /* 2nd and 3rd params should be initialized correctly */
203 xsh_localize_obj_param loc_obj =
204 {10, 0.1, 0, 0, LOC_MANUAL_METHOD, 0, 2.0,3,3,FALSE};
205 //xsh_extract_param extract_par = { LOCALIZATION_METHOD};
206 xsh_combine_nod_param nod_param = { 5, TRUE, 5, 2, 0.1, "throwlist.asc", COMBINE_MEAN_METHOD } ;
207 xsh_interpolate_bp_param ipol_par = {30 };
208 xsh_bary_corr_param bary_corr = {BARY_CORR_NONE };
209 /* Reset library state */
210 xsh_init();
211
212 /* Check input */
213 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
214 /* Get the recipe out of the plugin */
215 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
216 CPL_ERROR_TYPE_MISMATCH,
217 "Plugin is not a recipe");
218
219 recipe = (cpl_recipe *)plugin;
220
221 /* Create the parameter list in the cpl_recipe object */
222 recipe->parameters = cpl_parameterlist_new();
223 assure( recipe->parameters != NULL,
224 CPL_ERROR_ILLEGAL_OUTPUT,
225 "Memory allocation failed!");
226
227 /* Set generic parameters (common to all recipes) */
228 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
229 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
230 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
231
232 /* remove_crh_single */
234 crh_single )) ;
235 /* xsh_rectify */
237 rectify )) ;
238 /* xsh_localize_object */
240 loc_obj )) ;
241 /* xsh_optimal_extract
242 check(xsh_parameters_optimal_extract_create(RECIPE_ID,
243 recipe->parameters,-1. )) ;
244 */
245 /* trivial extract (Just temporary)
246 check(xsh_parameters_extract_create(RECIPE_ID,
247 recipe->parameters,
248 extract_par,LOCALIZATION_METHOD )) ;
249 */
250
252 recipe->parameters,ipol_par)) ;
253
255 recipe->parameters,
256 nod_param )) ;
257 /*
258 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
259 "do-flatfield", TRUE,
260 "TRUE if we do the flatfielding"));
261*/
262
263 /* PIPE-10061 - barycentric correction param */
265 bary_corr)) ;
266
267 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
268 "gen-sky", TRUE,
269 "if TRUE a 2D sky frame, a 2D rectified, a 2D merged sky are generated"));
270
271 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
272 "cut-uvb-spectrum", TRUE,
273 "TRUE if recipe cuts the UVB spectrum at 556 nm (dichroich)"));
274
275 /*
276 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
277 "compute-map", TRUE,
278 "if TRUE recompute (wave and slit) maps from the dispersion solution. Use FALSE only if you are sure to have wave and slit maps better than what this recipe may compute."));
279 */
280
281 /* Flag for generation of data in SDP format. */
282 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
283 "generate-SDP-format", FALSE,
284 "TRUE if additional files should be generated in Science Data Product"
285 " (SDP) format."));
286
287 /* Flag for adding dummy ASSO[NCM]i keywords. */
288 check( xsh_parameters_new_int( recipe->parameters, RECIPE_ID,
289 "dummy-association-keys", 0,
290 "Sets the number of dummy (empty) ASSONi, ASSOCi and ASSOMi keywords to"
291 " create."));
292
293 cleanup:
294 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
295 xsh_error_dump(CPL_MSG_ERROR);
296 return 1;
297 }
298 else {
299 return 0;
300 }
301}
302
303/*----------------------------------------------------------------------------*/
309/*----------------------------------------------------------------------------*/
310
311static int xsh_scired_slit_offset_exec(cpl_plugin *plugin) {
312 cpl_recipe *recipe = NULL;
313
314 /* Check parameter */
315
316 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
317
318 /* Get the recipe out of the plugin */
319 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
320 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
321
322 recipe = (cpl_recipe *)plugin;
323
324 /* Check recipe */
325 xsh_scired_slit_offset(recipe->parameters, recipe->frames);
326
327 cleanup:
328 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
329 xsh_error_dump(CPL_MSG_ERROR);
331 return 1;
332 }
333 else {
334 return 0;
335 }
336}
337
338/*----------------------------------------------------------------------------*/
344/*----------------------------------------------------------------------------*/
345static int xsh_scired_slit_offset_destroy(cpl_plugin *plugin)
346{
347 cpl_recipe *recipe = NULL;
348
349 /* reset error state before detroying recipe */
351 /* Check parameter */
352 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
353
354 /* Get the recipe out of the plugin */
355 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
356 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
357
358 recipe = (cpl_recipe *)plugin;
359
360 xsh_free_parameterlist(&recipe->parameters);
361
362 cleanup:
363 if (cpl_error_get_code() != CPL_ERROR_NONE)
364 {
365 return 1;
366 }
367 else
368 {
369 return 0;
370 }
371}
372
373
374static cpl_error_code
376 xsh_localize_obj_param * loc_obj_par)
377{
378
379
380 xsh_msg_dbg_low("rectify params: radius=%g bin_lambda=%g bin_space=%g",
381 rectify_par->rectif_radius,rectify_par->rectif_bin_lambda,
382 rectify_par->rectif_bin_space);
383
384 xsh_msg_dbg_low("localize params: chunk_nb=%d nod_step=%g",
385 loc_obj_par->loc_chunk_nb,loc_obj_par->nod_step);
386
387 return cpl_error_get_code();
388
389}
390
391/*----------------------------------------------------------------------------*/
399/*----------------------------------------------------------------------------*/
400static void xsh_scired_slit_offset( cpl_parameterlist* parameters,
401 cpl_frameset* frameset)
402{
403 const char* recipe_tags[3] = {XSH_OBJECT_SLIT_OFFSET, XSH_STD_FLUX_SLIT_OFFSET, XSH_SKY_SLIT};
404 int recipe_tags_size = 3;
405
406 /* Input frames */
407 cpl_frameset* raws = NULL;
408
409 cpl_frameset * raw_object = NULL;
410 cpl_frameset * raw_sky = NULL;
411 cpl_frameset * calib = NULL;
412 cpl_frameset * usedframes = NULL;
413 int nobj=0;
414 int nsky=0;
415
416 int nb_sub_frames = 0;
417 /* Beware, do not "free" the following input frames, they are part
418 of the input frameset */
419 cpl_frame* bpmap = NULL;
420 cpl_frame* master_bias = NULL;
421 cpl_frame* master_dark = NULL;
422 cpl_frame* master_flat = NULL;
423 cpl_frame* order_tab_edges = NULL;
424 cpl_frame * wave_tab = NULL ;
425 cpl_frame * model_config_frame = NULL ;
426 cpl_frame * wavemap = NULL ;
427 cpl_frame * slitmap = NULL ;
428 cpl_frame *disp_tab_frame = NULL;
429 cpl_frame * spectral_format = NULL ;
430 cpl_frame *tellmask_frame = NULL;
431 /* Parameters */
432 xsh_remove_crh_single_param * crh_single_par = NULL ;
433 xsh_rectify_param * rectify_par = NULL ;
434 xsh_localize_obj_param * loc_obj_par = NULL ;
435 xsh_bary_corr_param * bary_par = NULL ;
436 xsh_extract_param * extract_par = NULL ;
437 xsh_combine_nod_param * combine_nod_param = NULL ;
438
440
441 /* Intermediate frames */
442
443 cpl_frame * loc_table_frame = NULL ;
444 cpl_frame * clean_frame = NULL ;
445 cpl_frameset * sub_frameset = NULL ;
446 cpl_frameset * clean_frameset = NULL ;
447 cpl_frameset * rect_frameset = NULL ;
448 cpl_frameset * rect2_frameset_tables = NULL ;
450 /* Output Frames (results)*/
451 cpl_frame * res1D_frame = NULL ;
452 cpl_frame * res2D_frame = NULL ;
453 cpl_frame * ext_frame = NULL ;
454 cpl_frame * ext_frame_eso = NULL ;
455 cpl_frame * comb_frame = NULL ;
456 cpl_frame * comb_frame_eso = NULL ;
457 cpl_frame* response_ord_frame=NULL;
458
459 char file_name[256];
460 char arm_str[16] ;
461 char file_tag[40];
462
463 int i ;
464 cpl_frame* grid_back=NULL;
465 cpl_frame* frame_backg=NULL;
466 int do_flatfield=1;
467 int gen_sky=0;
468 int generate_sdp_format=0;
469 char* rec_prefix=NULL;
470 char sky_prefix[256];
471 char sky_tag[256];
472 cpl_frame* avg_sky=NULL;
473 cpl_frame* rec_sky=NULL;
474 cpl_frame* rec_sky_eso=NULL;
475 cpl_frame* mer_sky=NULL;
476 cpl_frame * rectif_tab = NULL ;
477 cpl_frame * sky_divided = NULL ;
478 cpl_frameset* sky_bias=NULL;
479 cpl_frameset* sky_dark=NULL;
480 cpl_frame * fluxcal_rect_1D_frame = NULL ;
481 cpl_frame * fluxcal_rect_2D_frame = NULL ;
482 cpl_frame * fluxcal_1D_frame = NULL ;
483 cpl_frame * fluxcal_2D_frame = NULL ;
484 cpl_frame* frm_atmext=NULL;
485 cpl_frameset* crh_clean_obj = NULL;
486 cpl_frameset* crh_clean_sky = NULL;
487 cpl_frame* ext_sky_frame=NULL;
488 cpl_frame* ext_sky_frame_eso=NULL;
489 cpl_frame* res_1D_sky_frame=NULL;
490 cpl_frame * fluxframe = NULL;
491 cpl_frame * uncalframe = NULL;
492 cpl_frame* sky_map_frm = NULL;
493 int pre_overscan_corr=0;
494 int merge_par=0;
495 xsh_interpolate_bp_param *ipol_bp=NULL;
496 int do_computemap=1;
497 int use_model=0;
498 int cut_uvb_spectrum=0;
499 int scale_nod=0;
500 cpl_propertylist* qclist = cpl_propertylist_new();
501
502 /**************************************************************************/
503 /* DFS management */
504 /**************************************************************************/
505 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
506 recipe_tags, recipe_tags_size,
507 RECIPE_ID, XSH_BINARY_VERSION,
509
510 //get average airm, iwv and fwhm from raws; add keywords to qclist
512
514 assure( instrument->mode == XSH_MODE_SLIT, CPL_ERROR_ILLEGAL_INPUT,
515 "Instrument NOT in Slit Mode" ) ;
517 if(instrument->arm == XSH_ARM_NIR) {
519 }
520 /**************************************************************************/
521 /* Recipe frames */
522 /**************************************************************************/
523 check(xsh_slit_offset_get_calibs(calib,instrument,&bpmap,&master_bias,
524 &master_dark,&order_tab_edges,
525 &model_config_frame,&wave_tab,&master_flat,
526 &wavemap,&slitmap,&spectral_format,RECIPE_ID));
527
528 /* scired specifig input */
529 if((response_ord_frame=xsh_find_frame_with_tag(calib,XSH_RESPONSE_MERGE1D_SLIT,
530 instrument)) == NULL ) {
531 check( response_ord_frame = xsh_find_frame_with_tag(calib,
533 instrument));
534 }
535
536 if(response_ord_frame != NULL) {
538 if(frm_atmext==NULL) {
539 xsh_msg_error("Provide atmospheric extinction frame");
540 }
541 }
542
543 tellmask_frame = xsh_find_frame_with_tag(calib,XSH_TELL_MASK, instrument);
544 /**************************************************************************/
545 /* Recipe parameters */
546 /**************************************************************************/
547 cut_uvb_spectrum=xsh_parameters_cut_uvb_spectrum_get(RECIPE_ID,parameters);
549 &loc_obj_par,&rectify_par,&crh_single_par,
550 &extract_par,
551 &combine_nod_param,&do_flatfield,&gen_sky,
552 &generate_sdp_format));
553
555
557 rectify_par->conserve_flux=FALSE;
558
559 check(xsh_params_monitor(rectify_par,loc_obj_par));
560
561 if ( rectify_par->conserve_flux || model_config_frame == NULL){
562 check_msg( disp_tab_frame = xsh_find_disp_tab( calib, instrument),
563 "if rectify-conserve-flux=TRUE DISP_TAB_ARM is required input");
564 }
565 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
566 "pre-overscan-corr"));
567
568 /* PIPE-10665 */
570 instrument, crh_single_par));
571
572 // PIPE-10061 - get barycentric corr param
573 check(bary_par = xsh_parameters_bary_corr_get( RECIPE_ID, parameters)) ;
574
575 /**************************************************************************/
576 /* Recipe code */
577 /**************************************************************************/
578 /* prepare RAW frames in PRE format */
579 check(xsh_prepare(raws, bpmap, master_bias, XSH_OBJECT_SLIT_OFFSET,
580 instrument,pre_overscan_corr,CPL_TRUE));
581
582 /* make sure each input raw frame has the same exp time */
584
585 /* Separate OBJECT and SKY frames */
586 check( nb_sub_frames = xsh_dfs_split_offset( raws, XSH_OBJECT_SLIT_OFFSET,
587 XSH_SKY_SLIT, &raw_object,
588 &raw_sky ) );
589
590 nobj=cpl_frameset_get_size(raw_object);
591 nsky=cpl_frameset_get_size(raw_sky);
592 rec_prefix=xsh_set_recipe_file_prefix(raw_object,"xsh_scired_slit_offset");
593 sprintf(sky_prefix,xsh_set_recipe_sky_file_prefix(rec_prefix));
594
595 xsh_msg("cmap=%d wavemap=%p slitmap=%p",do_computemap,wavemap,slitmap);
596 if( (do_computemap == 1) &&
597 (wavemap ==NULL || slitmap ==NULL )
598 ) {
599 if (model_config_frame != NULL) {
600 use_model=1;
601 }
602
603 check( xsh_check_get_map( disp_tab_frame, order_tab_edges,
604 master_flat, model_config_frame, calib, instrument,
605 do_computemap, use_model, rec_prefix,
606 &wavemap, &slitmap));
607
608 }
609
610
611 if( nb_sub_frames==0 ) {
612 xsh_msg_error("nb_sub_frames=%d something wrong check your input raws",nb_sub_frames);
613 goto cleanup;
614
615 }
616
617
618 /* remove crh on each obj or sky frame */
619 sky_map_frm = xsh_find_frame_with_tag(calib,XSH_SKY_MAP, instrument);
620 crh_clean_obj = xsh_frameset_crh_single(raw_object, crh_single_par,
621 sky_map_frm,instrument,rec_prefix,"OBJ");
622 crh_clean_sky = xsh_frameset_crh_single(raw_sky, crh_single_par,
623 sky_map_frm, instrument,rec_prefix,"SKY");
624
625 check(
626 sub_frameset = xsh_subtract_sky_offset( crh_clean_obj, crh_clean_sky, nb_sub_frames,instrument));
627
629 "Nb of Subtracted Frames: %" CPL_SIZE_FORMAT "", cpl_frameset_get_size( sub_frameset ));
630
631 sprintf(arm_str, "%s", xsh_instrument_arm_tostring(instrument));
632
633 if (gen_sky) {
634 /* Not yet working.. */
635 if (master_bias != NULL && pre_overscan_corr == 0) {
636 check(
637 sky_bias=xsh_pre_frameset_subtract_frame(crh_clean_sky,master_bias,"MBIAS_",instrument));
638 } else {
639 sky_bias = cpl_frameset_duplicate(crh_clean_sky);
640 }
641 if (master_dark != NULL) {
642 check(
643 sky_dark=xsh_pre_frameset_subtract_frame(sky_bias,master_dark,"MDARK",instrument));
644 } else {
645 sky_dark = cpl_frameset_duplicate(sky_bias);
646 }
647 sprintf(sky_tag, "%s_SKY_%s", rec_prefix, arm_str);
648 check(avg_sky=xsh_frameset_average_pre(sky_dark,instrument,sky_tag));
649 if (do_flatfield == 1) {
650 sprintf(sky_tag, "%s_FF_SKY_%s", rec_prefix, arm_str);
651 check(
652 sky_divided = xsh_divide_flat( avg_sky,master_flat, sky_tag, instrument ));
653 } else {
654 sky_divided = cpl_frame_duplicate(avg_sky);
655 }
656 xsh_add_temporary_file(cpl_frame_get_filename(sky_divided));
657 }
658
659 if (do_flatfield == 1) {
660 clean_frameset=xsh_frameset_mflat_divide(sub_frameset,master_flat,instrument);
661 } else {
662 clean_frameset = cpl_frameset_duplicate(sub_frameset);
663 }
664 /* now we have duplicate sub_frameset we do not need it anymore */
665 xsh_free_frameset(&sub_frameset);
666
667 {
668 int clean_size ;
669
670 check( clean_size = cpl_frameset_get_size( clean_frameset ) ) ;
671 xsh_msg( "Nb of clean Frames: %d", clean_size ) ;
672 }
673
674
675 /* Now rectify each clean frame */
676 check( rect_frameset = cpl_frameset_new() ) ;
677 for( i = 0 ; i < nb_sub_frames ; i++ ) {
678 cpl_frame * rectif = NULL ;
679 cpl_frame * rectif_eso = NULL ;
680 cpl_frame * clean = NULL ;
681 char str[16] ;
682
683 sprintf( str, "%d", i ) ;
684 check( clean = cpl_frameset_get_frame( clean_frameset, i ) ) ;
685 xsh_msg( "Rectifying Frame '%s'", cpl_frame_get_filename( clean ) ) ;
686 sprintf(file_name,"RECTIFIED_SLIT_OFFSET_%s_%s.fits",arm_str,str) ;
687 check( rectif = xsh_rectify( clean, order_tab_edges, wave_tab,
688 model_config_frame, instrument,
689 rectify_par, spectral_format,
690 disp_tab_frame,
691 file_name,&rectif_eso,&rectif_tab,
692 rec_prefix) ) ;
693 xsh_add_temporary_file(file_name);
694 check( cpl_frameset_insert( rect_frameset, cpl_frame_duplicate(rectif) ) ) ;
695 check( cpl_frameset_insert( rect_frameset, cpl_frame_duplicate(rectif_eso) ) ) ;
696 xsh_free_frame(&rectif_tab);
697 xsh_free_frame(&rectif_eso);
698 xsh_free_frame(&rectif);
699 }
700
701
702 /* Combine rectified Frames */
703 sprintf(file_tag,"%s_%s_%s",rec_prefix,XSH_ORDER2D, arm_str) ;
704 check(rect2_frameset_tables=xsh_frameset_ext_table_frames(rect_frameset));
705 check( comb_frame = xsh_combine_nod(rect2_frameset_tables, combine_nod_param,
706 file_tag,instrument,&comb_frame_eso,scale_nod));
707 xsh_free_frameset(&rect2_frameset_tables);
708
709
710 if ( extract_par->method == LOCALIZATION_METHOD ||
711 extract_par->method == CLEAN_METHOD) {
712 xsh_msg( "Localize before extraction" ) ;
713 sprintf(file_name,"LOCALIZE_%s_ALL.fits",arm_str) ;
714 check( loc_table_frame = xsh_localize_obj( comb_frame, NULL,instrument,
715 loc_obj_par, NULL,
716 file_name) ) ;
717 xsh_add_temporary_file(file_name);
718 }
719
720
721
722 if(gen_sky) {
723 xsh_msg("rectify sky frame");
724 sprintf(file_name,"%s_RECTIFIED_SKY_%s.fits",sky_prefix,arm_str) ;
725 xsh_msg("file_name=%s",file_name);
726 check( rec_sky = xsh_rectify(sky_divided, order_tab_edges, wave_tab,
727 model_config_frame, instrument,
728 rectify_par, spectral_format,
729 disp_tab_frame,
730 file_name,&rec_sky_eso,&rectif_tab,
731 sky_prefix) ) ;
732
733 xsh_add_temporary_file(file_name);
734
735 xsh_msg("Merge 2D sky frame");
736 check( mer_sky = xsh_merge_ord( rec_sky, instrument,
737 merge_par,sky_prefix ));
738
739 check(ext_sky_frame = xsh_extract_clean(rec_sky, loc_table_frame,
740 instrument, extract_par,ipol_bp,
741 &ext_sky_frame_eso,rec_prefix )) ;
742
743 check( res_1D_sky_frame = xsh_merge_ord( ext_sky_frame, instrument,
744 merge_par,sky_prefix));
745 xsh_free_frame(&rectif_tab);
746 }
747
748
749 xsh_msg( "Calling xsh_extract" ) ;
750 check(ext_frame = xsh_extract_clean(comb_frame, loc_table_frame,
751 instrument, extract_par,ipol_bp, &ext_frame_eso,
752 rec_prefix )) ;
753 xsh_msg( "Calling xsh_merge_ord with 1D frame" ) ;
754 check( res1D_frame = xsh_merge_ord( ext_frame, instrument,
755 merge_par,rec_prefix ));
756 check( xsh_mark_tell( res1D_frame, tellmask_frame));
757 /* More todo here
758 mark_telluric
759 calibrate_flux
760 */
761
762
763 xsh_msg( "Calling xsh_merge_ord with 2D frame" ) ;
764 check( res2D_frame = xsh_merge_ord( comb_frame, instrument, merge_par,
765 rec_prefix) ) ;
766
767 cpl_boolean flux_available = CPL_FALSE;
768 if(response_ord_frame != NULL && frm_atmext != NULL) {
769 check(xsh_flux_calibrate(comb_frame_eso,ext_frame_eso,frm_atmext,
770 response_ord_frame,merge_par,instrument,rec_prefix,
771 &fluxcal_rect_2D_frame,&fluxcal_rect_1D_frame,
772 &fluxcal_2D_frame,&fluxcal_1D_frame));
773 flux_available = CPL_TRUE;
774
775 }
776 cpl_propertylist_append_bool(qclist,"ESO QC FLUX AVAILABLE",flux_available);
777
778
779 if(model_config_frame!=NULL && wavemap != NULL&& slitmap != NULL) {
780
781 check(xsh_compute_resampling_accuracy(wavemap,slitmap,order_tab_edges,model_config_frame,comb_frame_eso,instrument));
782 check(xsh_compute_resampling_accuracy(wavemap,slitmap,order_tab_edges,model_config_frame,res2D_frame,instrument));
783
784 check(xsh_compute_wavelength_resampling_accuracy(wavemap,order_tab_edges,model_config_frame,res1D_frame,instrument));
785 check(xsh_compute_wavelength_resampling_accuracy(wavemap,order_tab_edges,model_config_frame,ext_frame_eso,instrument));
786
787 xsh_add_afc_info(model_config_frame,wavemap);
788 xsh_add_afc_info(model_config_frame,slitmap);
789
790 if(fluxcal_rect_2D_frame != NULL) {
791
792 check(xsh_compute_resampling_accuracy(wavemap,slitmap,order_tab_edges,model_config_frame,fluxcal_rect_2D_frame,instrument));
793 check(xsh_compute_resampling_accuracy(wavemap,slitmap,order_tab_edges,model_config_frame,fluxcal_2D_frame,instrument));
794
795 check(xsh_compute_wavelength_resampling_accuracy(wavemap,order_tab_edges,model_config_frame,fluxcal_rect_1D_frame,instrument));
796 check(xsh_compute_wavelength_resampling_accuracy(wavemap,order_tab_edges,model_config_frame,fluxcal_1D_frame,instrument));
797
798 }
799
800 if(gen_sky) {
801 check(xsh_compute_resampling_accuracy(wavemap,slitmap,order_tab_edges,model_config_frame,rec_sky_eso,instrument));
802 check(xsh_compute_resampling_accuracy(wavemap,slitmap,order_tab_edges,model_config_frame,mer_sky,instrument));
803 }
804
805 }
806
807 if(cut_uvb_spectrum) {
808 if(instrument->arm == XSH_ARM_UVB) {
809 xsh_image_cut_dichroic_uvb(comb_frame_eso);
813
814 if(gen_sky) {
815
816 xsh_image_cut_dichroic_uvb(rec_sky_eso);
818 xsh_spectrum_cut_dichroic_uvb(res_1D_sky_frame);
819
820 }
821 if(fluxcal_rect_2D_frame != NULL) {
822
823 xsh_image_cut_dichroic_uvb(fluxcal_rect_2D_frame);
825 xsh_spectrum_cut_dichroic_uvb(fluxcal_2D_frame);
826 xsh_spectrum_cut_dichroic_uvb(fluxcal_1D_frame);
827
828 }
829 }
830 }
831
832
833 /* Save products */
834 xsh_msg( "Saving products" ) ;
835
836 usedframes = cpl_frameset_duplicate(frameset);
837
838 /* Removed as format not easy to read
839 check( xsh_add_product_table( comb_frame, frameset,
840 parameters, RECIPE_ID, instrument));
841 *
842 */
843
844 check( xsh_add_product_image( comb_frame_eso, frameset,
845 parameters, RECIPE_ID, instrument,NULL));
846
847 /* Removed as format not easy to read
848 check( xsh_add_product_table( ext_frame, frameset,
849 parameters, RECIPE_ID, instrument));
850 */
851
852 check( xsh_add_product_orders_spectrum( ext_frame_eso, frameset,
853 parameters, RECIPE_ID, instrument,NULL));
854
855 /* Calculate curvature QC params early */
856 cpl_image* itmp = cpl_image_load(cpl_frame_get_filename(res2D_frame),CPL_TYPE_DOUBLE,0,0);
857 calc_curve_qc(itmp,instrument,qclist);
858 cpl_image_delete(itmp);
859
860 check( xsh_add_product_spectrum( res2D_frame, frameset, parameters,
861 RECIPE_ID, instrument, NULL,qclist));
862
865 check( xsh_add_product_spectrum( res1D_frame, frameset, parameters,
866 RECIPE_ID, instrument, &uncalframe,qclist));
867
868
869 if(gen_sky) {
870 check( xsh_add_product_image( avg_sky, frameset, parameters,
871 RECIPE_ID, instrument,NULL));
872
873
874 sprintf(file_tag,"%s_%s_%s",sky_prefix,XSH_ORDER2D, arm_str) ;
875 check( xsh_add_product_image( rec_sky_eso, frameset, parameters,
876 RECIPE_ID, instrument,NULL));
877
878
879 sprintf(file_tag,"%s_%s_%s",sky_prefix,XSH_MERGE2D, arm_str) ;
880 check( xsh_add_product_image( mer_sky, frameset, parameters,
881 RECIPE_ID, instrument,NULL));
882
883 check( xsh_add_product_spectrum( res_1D_sky_frame, frameset, parameters,
884 RECIPE_ID, instrument, NULL,NULL));
885
886 }
887
888 if(fluxcal_rect_2D_frame != NULL) {
889 check( xsh_add_product_image(fluxcal_rect_2D_frame,frameset,parameters,
890 RECIPE_ID, instrument,NULL));
891
892 check( xsh_add_product_orders_spectrum(fluxcal_rect_1D_frame,frameset,parameters,
893 RECIPE_ID, instrument,NULL));
894
895 check( xsh_add_product_spectrum( fluxcal_2D_frame, frameset, parameters,
896 RECIPE_ID, instrument, NULL,qclist));
897 check(xsh_monitor_spectrum1D_extra_qc(fluxcal_1D_frame,instrument,qclist));
898 check( xsh_add_product_spectrum( fluxcal_1D_frame, frameset, parameters,
899 RECIPE_ID, instrument, &fluxframe,qclist));
900 }
901 if (do_computemap){
902 //sprintf(prefix,"%s_WAVE_MAP",rec_prefix);
903
904
905 check(xsh_add_product_image( wavemap, frameset,
906 parameters, RECIPE_ID, instrument, NULL));
907
908 //check(sprintf(prefix,"%s_SLIT_MAP",rec_prefix));
909
910 check(xsh_add_product_image( slitmap, frameset,
911 parameters, RECIPE_ID, instrument,NULL));
912 }
913
914 if (generate_sdp_format) {
915 cpl_frame * fluxframe_copy = fluxframe;
916 cpl_frame * uncalframe_copy = uncalframe;
917 if (fluxframe != NULL) {
918 check( cpl_frameset_insert(usedframes, fluxframe) );
919 fluxframe = NULL; /* prevent direct deletion in cleanup section,
920 will be deleted together with usedframes. */
921 }
922 if (uncalframe != NULL) {
923 check( cpl_frameset_insert(usedframes, uncalframe) );
924 uncalframe = NULL; /* prevent direct deletion in cleanup section,
925 will be deleted together with usedframes. */
926 }
927 check( xsh_add_sdp_product_spectrum(fluxframe_copy, uncalframe_copy,
928 frameset, usedframes, parameters, RECIPE_ID, instrument,qclist) );
929 /* Restore usedframes to what it was before in case we want to reuse it */
930 if (fluxframe_copy != NULL) {
931 check( cpl_frameset_erase_frame(usedframes, fluxframe_copy) );
932 }
933 if (uncalframe_copy != NULL) {
934 check( cpl_frameset_erase_frame(usedframes, uncalframe_copy) );
935 }
936 }
937
938 cleanup:
939 xsh_end( RECIPE_ID, frameset, parameters );
940 XSH_FREE( rec_prefix);
941 XSH_FREE( crh_single_par ) ;
942 XSH_FREE( rectify_par ) ;
943 XSH_FREE( loc_obj_par ) ;
944 XSH_FREE(extract_par);
945 XSH_FREE(ipol_bp);
946 XSH_FREE(combine_nod_param);
947 XSH_FREE( bary_par);
948
950 xsh_free_frameset(&rect2_frameset_tables);
951 xsh_free_frameset(&raws);
952
953 /* the following two frees are dangerous in case of failure (e.g. nsky=0) */
954 if(nobj>0) {
955 xsh_free_frameset( &raw_object);
956 }
957 if(nsky>0) {
958 xsh_free_frameset( &raw_sky);
959 }
960 xsh_free_frameset(&usedframes);
961 xsh_free_frameset(&calib);
962 xsh_free_frameset(&clean_frameset);
963 xsh_free_frameset(&crh_clean_obj);
964 xsh_free_frameset(&crh_clean_sky);
965
966 //this create seg fault
967 xsh_free_frameset(&rect_frameset);
968
969 xsh_free_frameset(&sky_bias);
970 xsh_free_frameset(&sky_dark);
971 xsh_free_frame(&bpmap);
972 xsh_free_frame(&wavemap) ;
973 xsh_free_frame(&slitmap) ;
974 xsh_free_frame(&loc_table_frame) ;
975 xsh_free_frame(&clean_frame) ;
976 xsh_free_frame(&res1D_frame) ;
977 xsh_free_frame(&res2D_frame) ;
978 xsh_free_frame( &comb_frame ) ;
979 xsh_free_frame( &comb_frame_eso ) ;
980 xsh_free_frame( &ext_frame ) ;
981 xsh_free_frame( &ext_frame_eso ) ;
982 xsh_free_frame( &ext_sky_frame);
983 xsh_free_frame( &ext_sky_frame_eso);
984
985 xsh_free_frame( &avg_sky ) ;
986 xsh_free_frame( &sky_divided ) ;
987 xsh_free_frame( &rec_sky ) ;
988 xsh_free_frame( &rec_sky_eso ) ;
989 xsh_free_frame( &mer_sky ) ;
990
991 xsh_free_frame( &frame_backg ) ;
992 xsh_free_frame( &grid_back ) ;
993 xsh_free_frame(&fluxcal_rect_1D_frame) ;
994 xsh_free_frame(&fluxcal_rect_2D_frame) ;
995 xsh_free_frame(&fluxcal_1D_frame) ;
996 xsh_free_frame(&fluxcal_2D_frame) ;
997 xsh_free_frame(&res_1D_sky_frame) ;
998
999 xsh_free_frame(&fluxframe);
1000 xsh_free_frame(&uncalframe);
1001
1002 return;
1003}
1004
static xsh_instrument * instrument
cpl_frame * xsh_combine_nod(cpl_frameset *nod_frames, xsh_combine_nod_param *nod_par, const char *tag, xsh_instrument *instrument, cpl_frame **res_frame_ext, const int scale_nod)
void xsh_mark_tell(cpl_frame *s1d_frame, cpl_frame *tellmask_frame)
Mark telluric in spectrum.
cpl_error_code xsh_monitor_spectrum1D_extra_qc(cpl_frame *in_frm, xsh_instrument *instrument, cpl_propertylist *qclist)
cpl_error_code xsh_monitor_spectrum1D_flux(cpl_frame *in_frm, xsh_instrument *instrument)
cpl_frame * xsh_frameset_average_pre(cpl_frameset *set, xsh_instrument *instr, const char *tag)
Average set of frames in PRE format.
cpl_frameset * xsh_pre_frameset_subtract_frame(cpl_frameset *set, cpl_frame *sub, const char *spec, xsh_instrument *instr)
Subtract 2 frames (in XSH_PRE format) Just loads the 2 frames, subtract (xsh_pre_subtract) and save r...
cpl_error_code xsh_spectrum_cut_dichroic_uvb(cpl_frame *frame1d)
cpl_error_code xsh_spectrum_orders_cut_dichroic_uvb(cpl_frame *frame1d, xsh_instrument *instr)
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 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
cpl_frame * xsh_extract_clean(cpl_frame *rec_frame, cpl_frame *loc_frame, xsh_instrument *instrument, xsh_extract_param *extract_par, xsh_interpolate_bp_param *ipol_bp, cpl_frame **res_frame_ext, const char *rec_prefix)
simple 1D extraction of point source like object
Definition: xsh_extract.c:836
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.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
cpl_frame * xsh_localize_obj(cpl_frame *sci_frame, cpl_frame *skymask_frame, xsh_instrument *instrument, xsh_localize_obj_param *loc_obj_par, xsh_slit_limit_param *slit_limit_param, const char *fname)
Build the localization table.
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
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
static cpl_error_code xsh_params_monitor(xsh_rectify_param *rectify_par, xsh_localize_obj_param *loc_obj_par)
static void xsh_scired_slit_offset(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
#define RECIPE_CONTACT
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int xsh_scired_slit_offset_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static char xsh_scired_slit_offset_description[]
static int xsh_scired_slit_offset_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static int xsh_scired_slit_offset_create(cpl_plugin *)
Setup the recipe options.
static char xsh_scired_slit_offset_description_short[]
#define RECIPE_ID
#define RECIPE_AUTHOR
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.
Definition: xsh_utils.c:2224
const char * xsh_set_recipe_sky_file_prefix(char *rec_prefix)
Set recipe sky frames prefix.
Definition: xsh_utils.c:576
cpl_error_code get_average_qc_from_raws(cpl_frameset *fset, xsh_instrument *instrument, cpl_propertylist *qclist)
Definition: xsh_utils.c:7216
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
cpl_error_code calc_curve_qc(cpl_image *im, xsh_instrument *instrument, cpl_propertylist *qclist)
Definition: xsh_utils.c:7322
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_remove_crh_single_params_set_defaults(cpl_parameterlist *pars, const char *rec_id, xsh_instrument *inst, xsh_remove_crh_single_param *crh_single_par)
Definition: xsh_utils.c:6723
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
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
enum extract_method method
@ XSH_ARM_UVB
@ XSH_ARM_NIR
@ XSH_MODE_SLIT
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
Definition: xsh_dfs.c:1357
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_frameset * xsh_frameset_ext_table_frames(cpl_frameset *set)
Extract frameset sub set containing only table frames.
Definition: xsh_dfs.c:207
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_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
void xsh_add_product_orders_spectrum(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instr, cpl_frame **result_frame)
Definition: xsh_dfs.c:2260
cpl_error_code xsh_add_afc_info(cpl_frame *frm_m, cpl_frame *frm_o)
Definition: xsh_dfs.c:5199
void xsh_add_sdp_product_spectrum(const cpl_frame *flux_cal_frame, const cpl_frame *uncal_frame, cpl_frameset *frameset, const cpl_frameset *usedframes, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, cpl_propertylist *qclist)
Creates a 1D spectrum product in the Science Data Product format.
Definition: xsh_dfs.c:6326
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)
Definition: xsh_dfs.c:352
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
cpl_error_code xsh_frameset_check_uniform_exptime(cpl_frameset *raws, xsh_instrument *inst)
Definition: xsh_dfs.c:5119
#define XSH_TELL_MASK
Definition: xsh_dfs.h:1183
#define XSH_ORDER2D
Definition: xsh_dfs.h:588
#define XSH_SKY_SLIT
Definition: xsh_dfs.h:233
#define XSH_OBJECT_SLIT_OFFSET
Definition: xsh_dfs.h:229
#define XSH_SKY_MAP
Definition: xsh_dfs.h:282
#define XSH_ATMOS_EXT
Definition: xsh_dfs.h:1191
#define XSH_STD_FLUX_SLIT_OFFSET
Definition: xsh_dfs.h:493
#define XSH_RESPONSE_MERGE1D_SLIT
Definition: xsh_dfs.h:1149
#define XSH_MERGE2D
Definition: xsh_dfs.h:594
#define XSH_MRESPONSE_MERGE1D_SLIT
Definition: xsh_dfs.h:1159
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)
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_combine_nod_create(const char *recipe_id, cpl_parameterlist *list, xsh_combine_nod_param p)
create the crh clipping parameters in a parameters list
void xsh_parameters_localize_obj_create(const char *recipe_id, cpl_parameterlist *plist, xsh_localize_obj_param p)
xsh_interpolate_bp_param * xsh_parameters_interpolate_bp_get(const char *recipe_id, cpl_parameterlist *list)
void xsh_parameters_rectify_create(const char *recipe_id, cpl_parameterlist *plist, xsh_rectify_param p)
void xsh_parameters_interpolate_bp_create(const char *recipe_id, cpl_parameterlist *plist, xsh_interpolate_bp_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
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)
int xsh_parameters_cut_uvb_spectrum_get(const char *recipe_id, const cpl_parameterlist *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)
void xsh_parameters_new_int(cpl_parameterlist *list, const char *recipe_id, const char *name, int value, const char *comment)
@ COMBINE_MEAN_METHOD
@ BARY_CORR_NONE
@ LOC_MANUAL_METHOD
@ LOCALIZATION_METHOD
@ CLEAN_METHOD
#define XSH_FREE(POINTER)
Definition: xsh_utils.h:92
cpl_error_code xsh_image_cut_dichroic_uvb(cpl_frame *frame1d)
cpl_error_code xsh_slit_offset_get_params(cpl_parameterlist *parameters, const char *rec_id, xsh_localize_obj_param **loc_obj_par, xsh_rectify_param **rectify_par, xsh_remove_crh_single_param **crh_single_par, xsh_extract_param **extract_par, xsh_combine_nod_param **combine_nod_param, int *do_flatfield, int *gen_sky, int *generate_sdp_format)
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_error_code xsh_flux_calibrate(cpl_frame *rect2D, cpl_frame *rect1D, cpl_frame *atmext, cpl_frame *response, int mpar, xsh_instrument *inst, const char *rec_prefix, cpl_frame **fcal_rect_2D, cpl_frame **fcal_rect_1D, cpl_frame **fcal_2D, cpl_frame **fcal_1D)
cpl_error_code xsh_compute_resampling_accuracy(cpl_frame *wavemap, cpl_frame *slitmap, cpl_frame *order_tab_edges, cpl_frame *model_config, cpl_frame *science, xsh_instrument *instrument)
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.
cpl_error_code xsh_compute_wavelength_resampling_accuracy(cpl_frame *wavemap, cpl_frame *order_tab_edges, cpl_frame *model_config, cpl_frame *science, xsh_instrument *instrument)
cpl_error_code xsh_slit_offset_get_calibs(cpl_frameset *calib, xsh_instrument *instrument, cpl_frame **bpmap, cpl_frame **mbias, cpl_frame **mdark, cpl_frame **otab_edges, cpl_frame **model_cfg, cpl_frame **wave_tab, cpl_frame **mflat, cpl_frame **wmap, cpl_frame **smap, cpl_frame **spectral_format, const char *rec_id)