X-shooter Pipeline Reference Manual 3.8.15
xsh_drl_check.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2013-01-30 10:34:01 $
23 * $Revision: 1.42 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39
40/*----------------------------------------------------------------------------
41 Includes
42 ----------------------------------------------------------------------------*/
43#include <xsh_drl.h>
44#include <xsh_drl_check.h>
45#include <xsh_pfits.h>
46#include <xsh_parameters.h>
47#include <xsh_model_utils.h>
48
49
50cpl_frame*
52 const char* rec_id) {
53 cpl_frame* bpmap = NULL;
54 cpl_frame* bpmap_nl = NULL;
55 cpl_frame* bpmap_rp = NULL;
56 cpl_frame* bp_nl_frame = NULL;
57 cpl_frame* frm = NULL;
58
59 cpl_propertylist* plist = NULL;
60 cpl_image* image = NULL;
61 cpl_frameset* set=NULL;
62
63 char tag_ou[256];
64 char name[256];
65 const char* bp_nl_name;
66
67 int naxis1 = 0;
68 int binx = 0;
69 int i=0;
70 int sz=0;
71 int is_pre=0;
72 int mode_or=1;
73 XSH_ARM the_arm = XSH_ARM_NIR;
74
75 /* define expected output frame tag with (coadded) BP map info */
76 sprintf(tag_ou, "%s_%s", XSH_BP_MAP, xsh_instrument_arm_tostring(inst));
77
78 /* define expected input frame tag that provides BP map info from 3rd extension
79 * REMOVED as 3rd extension of image frame should not contribute to BP map at this stage
80 if (strcmp(rec_id, "xsh_mbias") == 0) {
81 } else if (strcmp(rec_id, "xsh_mdark") == 0 ||
82 strcmp(rec_id, "xsh_predict") == 0 ||
83 strcmp(rec_id, "xsh_orderpos") == 0 ||
84 strcmp(rec_id, "xsh_mflat") == 0) {
85 if( the_arm != XSH_ARM_NIR ){
86 sprintf(tag_in, "%s_%s", XSH_MASTER_BIAS,
87 xsh_instrument_arm_tostring(inst));
88 }
89
90 } else {
91 sprintf(tag_in, "%s_%s", XSH_MASTER_FLAT,
92 xsh_instrument_arm_tostring(inst));
93 }
94 */
95
96 set=cpl_frameset_new();
97 /* search for reference pix BP map */
98 if ((bpmap_rp = xsh_find_frame_with_tag(calib, XSH_BP_MAP_RP, inst))
99 != NULL) {
100 xsh_msg("%s provided", XSH_BP_MAP_RP);
101 cpl_frameset_insert(set,cpl_frame_duplicate(bpmap_rp));
102 }
103
104 /* search for NL BP map */
105 if (NULL == (bp_nl_frame = xsh_find_frame_with_tag(calib, XSH_BP_MAP_NL, inst))) {
106 xsh_msg("%s not provided", XSH_BP_MAP_NL);
107 } else {
108 /* if BP_NL map comes from detmon recipe we may need to adjust its format */
109 bp_nl_name = cpl_frame_get_filename(bp_nl_frame);
110 plist = cpl_propertylist_load(bp_nl_name, 0);
111 naxis1 = xsh_pfits_get_naxis1(plist);
112 the_arm = xsh_instrument_get_arm(inst);
113
114 if (the_arm != XSH_ARM_NIR) {
115 binx = xsh_pfits_get_binx(plist);
116 }
117 if (the_arm == XSH_ARM_UVB) {
118 if ((naxis1 == 2144 && binx == 1) || (naxis1 == 1072 && binx == 2)) {
119 bpmap_nl = xsh_bpmap_2pre(bp_nl_frame, XSH_BP_MAP_NL, inst);
120 is_pre=1;
121 }
122 } else if (the_arm == XSH_ARM_VIS) {
123 if ((naxis1 == 2106 && binx == 1) || (naxis1 == 1053 && binx == 2)) {
124 bpmap_nl = xsh_bpmap_2pre(bp_nl_frame, XSH_BP_MAP_NL, inst);
125 is_pre=1;
126 }
127 } else if (the_arm == XSH_ARM_NIR) {
128 if (naxis1 == 2048) {
129 bpmap_nl = xsh_bpmap_2pre(bp_nl_frame, XSH_BP_MAP_NL, inst);
130 is_pre=1;
131 }
132 }
133 if(!is_pre){
134 bpmap_nl=cpl_frame_duplicate(bp_nl_frame);
135 }
136 cpl_frameset_insert(set,cpl_frame_duplicate(bpmap_nl));
137 xsh_free_frame(&bpmap_nl);
138 }
139
140 /* search for 3rd ext BP map
141 if (tag_in != NULL) {
142 if ((frm = cpl_frameset_find(calib, tag_in)) != NULL) {
143 xsh_msg("%s provided", tag_in);
144 frm_name = cpl_frame_get_filename(frm);
145 bpmap_ima = cpl_image_load(frm_name, CPL_TYPE_INT, 0, 3);
146 bpmap_3rd = cpl_frame_new();
147 sprintf(bpmap_name, "%s.fits", tag_ou);
148 cpl_image_save(bpmap_ima, bpmap_name, XSH_PRE_QUAL_BPP, plist, CPL_IO_DEFAULT);
149 cpl_frame_set_filename(bpmap_3rd, bpmap_name);
150 cpl_frame_set_type(bpmap_3rd, CPL_FRAME_TYPE_IMAGE);
151 cpl_frame_set_group(bpmap_3rd, CPL_FRAME_GROUP_CALIB);
152 cpl_frame_set_level(bpmap_3rd, CPL_FRAME_LEVEL_FINAL);
153 cpl_frameset_insert(set,cpl_frame_duplicate(bpmap_3rd));
154 }
155 }
156 */
157
158 /* now we combine all BP contributes */
159 sz=cpl_frameset_get_size(set);
160 if (sz > 0) {
161 bpmap = cpl_frame_duplicate(cpl_frameset_get_frame(set, 0));
162 for(i=1;i<sz;i++) {
163 frm=cpl_frameset_get_frame(set,i);
164 xsh_badpixelmap_coadd(bpmap, frm,mode_or);
165 }
166 }
167
168 /* save the result for QC */
169 if (bpmap != NULL) {
170 image = cpl_image_load(cpl_frame_get_filename(bpmap), CPL_TYPE_INT, 0, 0);
171 xsh_free_propertylist(&plist);
172 plist = cpl_propertylist_load(cpl_frame_get_filename(bpmap), 0);
173 sprintf(name, "%s.fits", tag_ou);
174 xsh_pfits_set_pcatg(plist, tag_ou);
175 cpl_image_save(image, name, XSH_PRE_DATA_BPP, plist, CPL_IO_DEFAULT);
176 cpl_frame_set_tag(bpmap, tag_ou);
177 cpl_frame_set_filename(bpmap, name);
179 }
180
181 xsh_free_image(&image);
182 xsh_free_propertylist(&plist);
183 xsh_free_frameset(&set);
184
185 return bpmap;
186}
187/*----------------------------------------------------------------------------*/
203/*----------------------------------------------------------------------------*/
204void xsh_check_get_map( cpl_frame *disp_tab_frame, cpl_frame *order_tab_edges,
205 cpl_frame *crhm_frame, cpl_frame *model_config_frame, cpl_frameset *calib,
206 xsh_instrument *instrument, int do_computemap, int recipe_use_model,
207 const char *rec_prefix,
208 cpl_frame **wavemap_frame, cpl_frame **slitmap_frame)
209{
210 char wave_map_tag[256];
211 char slit_map_tag[256];
212
213 if ( do_computemap){
214 if ( recipe_use_model){
215 int found_temp= CPL_TRUE;
216
217 xsh_msg( "Compute with MODEL the wave map and the slit map");
218 check( xsh_model_temperature_update_frame( &model_config_frame,
219 crhm_frame, instrument,&found_temp));
220 sprintf( wave_map_tag, "%s_%s_%s", rec_prefix, XSH_WAVE_MAP_MODEL,
222 sprintf( slit_map_tag, "%s_%s_%s", rec_prefix, XSH_SLIT_MAP_MODEL,
224 check( xsh_create_model_map( model_config_frame, instrument,
225 wave_map_tag,slit_map_tag, wavemap_frame, slitmap_frame,0));
226 }
227 else{
228 xsh_msg("Compute with POLY the wave map and the slit map");
229 check( xsh_create_map( disp_tab_frame, order_tab_edges,
230 crhm_frame, instrument,
231 wavemap_frame, slitmap_frame,rec_prefix));
232 }
233 }
234 else{
235 cpl_frame *tmp = NULL;
236
237 xsh_msg( "Get the wave map and the slit map");
238 tmp = xsh_find_slitmap( calib, instrument);
239 check_msg( *slitmap_frame = cpl_frame_duplicate( tmp),"If compute-map is set to FALSE you must provide a SLIT_MAP_ARM frame in input");
240 tmp = xsh_find_wavemap( calib, instrument);
241 check_msg( *wavemap_frame = cpl_frame_duplicate( tmp),"If compute-map is set to FALSE you must provide a SLIT_MAP_ARM frame in input");
242 }
243
244 cleanup:
245 return;
246}
247/*----------------------------------------------------------------------------*/
248
249/*----------------------------------------------------------------------------*/
260/*----------------------------------------------------------------------------*/
261cpl_frame* xsh_check_remove_crh_multiple( cpl_frameset* raws,
262 const char *ftag, xsh_stack_param* stack_par,xsh_clipping_param *crh_clipping_par,
263 xsh_instrument* instr,cpl_imagelist ** lista, cpl_image** listb)
264{
265 int size_raw_frameset =0;
266 cpl_frame *result = NULL;
267
268 XSH_ASSURE_NOT_NULL( ftag);
269
270 check( size_raw_frameset = cpl_frameset_get_size( raws));
271
272 if ( size_raw_frameset >= 2 ) {
273 xsh_msg( "---Remove crh (multiple frames)");
274 check_msg( result = xsh_remove_crh_multiple( raws,ftag, stack_par, crh_clipping_par,instr, lista, listb,1),
275 "Error in xsh_remove_crh");
276
277 }
278 else {
279 check( result = cpl_frame_duplicate(cpl_frameset_get_frame( raws,0)));
280 }
281 cleanup:
282 return result;
283}
284/*----------------------------------------------------------------------------*/
285
286/*----------------------------------------------------------------------------*/
296/*----------------------------------------------------------------------------*/
297cpl_frame* xsh_check_subtract_bias( cpl_frame *crhm_frame,
298 cpl_frame *master_bias,
300 const char* prefix,
301 const int pre_overscan_corr,const int save_tmp)
302{
303 cpl_frame *result = NULL;
304
305 XSH_ASSURE_NOT_NULL( crhm_frame);
307 XSH_ASSURE_NOT_NULL( prefix);
308
310 char rmbias_tag[256];
311
312 sprintf( rmbias_tag, "%s_%s_%s", prefix,"ON",
314 /* No bias for NIR */
315 check( result = cpl_frame_duplicate( crhm_frame));
316 cpl_frame_set_tag( result, rmbias_tag);
317 }
318 else {
319 /* UVB and VIS arm */
320 xsh_msg("---Subtract bias");
321 if( master_bias != NULL) {
322 /* subtract bias */
323 check( result = xsh_subtract_bias( crhm_frame, master_bias,
324 instrument, prefix,
325 pre_overscan_corr,save_tmp));
326 }
327 else {
328 result = cpl_frame_duplicate( crhm_frame);
329 }
330 }
331 cleanup:
332 return result;
333}
334/*----------------------------------------------------------------------------*/
335
336/*----------------------------------------------------------------------------*/
345/*----------------------------------------------------------------------------*/
346cpl_frame* xsh_check_subtract_dark( cpl_frame *rmbias_frame,
347 cpl_frame *master_dark, xsh_instrument *instrument, const char* prefix)
348{
349 cpl_frame *result = NULL;
350 char result_name[256];
351
352 XSH_ASSURE_NOT_NULL( rmbias_frame);
354 XSH_ASSURE_NOT_NULL( prefix);
355
356 if(master_dark != NULL) {
357 xsh_msg( "---Subtract dark");
358 sprintf( result_name, "%s_DARK.fits", prefix);
359 check( result = xsh_subtract_dark( rmbias_frame, master_dark,
360 result_name, instrument));
361 xsh_add_temporary_file(result_name);
362 }
363 else {
364 result = cpl_frame_duplicate( rmbias_frame);
365 }
366
367 cleanup:
368 return result;
369}
370/*----------------------------------------------------------------------------*/
371
372/*----------------------------------------------------------------------------*/
384/*----------------------------------------------------------------------------*/
385cpl_frame* xsh_check_divide_flat( int do_flatfield, cpl_frame *clean_frame,
386 cpl_frame *master_flat, xsh_instrument *instrument, const char* prefix)
387{
388 cpl_frame *result = NULL;
389 char result_tag[256];
390
391 XSH_ASSURE_NOT_NULL( clean_frame);
393 XSH_ASSURE_NOT_NULL( prefix);
394
395 if( do_flatfield == CPL_TRUE) {
396 xsh_msg( "---Divide flat");
397 sprintf( result_tag, "%s_DIVFF_%s", prefix,
399
400 check( result = xsh_divide_flat( clean_frame, master_flat,
401 result_tag, instrument));
402 }
403 else{
404 check( result = cpl_frame_duplicate( clean_frame));
405 }
406 cleanup:
407 return result;
408}
409/*----------------------------------------------------------------------------*/
410
411
412/*----------------------------------------------------------------------------*/
422/*----------------------------------------------------------------------------*/
423cpl_frame* xsh_check_remove_crh_single( int nb_raws_frame,
424 cpl_frame *subsky_frame, xsh_remove_crh_single_param *crh_single_par,
425 xsh_instrument *instrument, const char* prefix)
426{
427 char result_tag[256];
428 char result_name[256];
429 cpl_frame *result = NULL;
430
431 XSH_ASSURE_NOT_NULL( subsky_frame);
432 XSH_ASSURE_NOT_NULL( crh_single_par);
434 XSH_ASSURE_NOT_NULL( prefix);
435
436 if ( nb_raws_frame == 1 && crh_single_par->nb_iter > 0) {
437 xsh_msg( "---Remove crh (single frame)");
438 sprintf( result_tag, "%s_NOCRH_%s", prefix,
440 sprintf( result_name, "%s.fits",result_tag);
441 xsh_add_temporary_file(result_name);
442
443 check( result = xsh_remove_crh_single( subsky_frame,
444 instrument, NULL,crh_single_par, result_tag));
445 }
446 else {
447 check( result = cpl_frame_duplicate( subsky_frame));
448 }
449
450 cleanup:
451 return result;
452}
453/*----------------------------------------------------------------------------*/
454
455/*----------------------------------------------------------------------------*/
475/*----------------------------------------------------------------------------*/
476
477cpl_frame* xsh_check_subtract_sky_single( int do_subsky,
478 cpl_frame *src_frame,
479 cpl_frame *ordertabedges_frame,
480 cpl_frame *slitmap_frame,
481 cpl_frame *wavemap_frame,
482 cpl_frame *loctab_frame,
483 cpl_frame *definedbreakpoints_frame,
485 int nbkpts,
487 cpl_frame* ref_sky_list,
488 cpl_frame* sky_orders_chunks,
489 cpl_frame **sky_spectrum,
490 cpl_frame **sky_spectrum_eso,
491 cpl_frame **sky_img,
492 const char *prefix,
493 const int clean_tmp)
494{
495 char result_tag[256];
496 char result_name[256];
497 cpl_frame *result = NULL;
498
499 XSH_ASSURE_NOT_NULL( src_frame);
500
501 if ( do_subsky == CPL_TRUE){
502 xsh_msg("---Sky subtraction (single frame)");
503 check( result = xsh_subtract_sky_single( src_frame, ordertabedges_frame,
504 slitmap_frame, wavemap_frame, loctab_frame,ref_sky_list,sky_orders_chunks,
505 definedbreakpoints_frame, instrument, nbkpts, sky_par, sky_spectrum,
506 sky_spectrum_eso, prefix,clean_tmp));
507 sprintf( result_tag,"%s_SKY_%s", prefix,
509 sprintf( result_name,"%s.fits", result_tag);
510 check( *sky_img = xsh_save_sky_model( src_frame, result, result_tag,
511 instrument));
512 if(strstr(result_name,"TMPSKY")!=NULL) {
513 xsh_add_temporary_file(result_name);
514 }
515 }
516 else{
517 xsh_msg("[No sky subtraction]");
518 check( result = cpl_frame_duplicate( src_frame));
519 }
520
521 if ( do_subsky == CPL_TRUE){
522
523 XSH_ASSURE_NOT_NULL_MSG( src_frame,"Required science frame is missing");
524 XSH_ASSURE_NOT_NULL_MSG( ordertabedges_frame,"Required order table frame is missing");
525 XSH_ASSURE_NOT_NULL_MSG( slitmap_frame, "Required slitmap frame is missing, provide it or set compute-map to TRUE");
526 XSH_ASSURE_NOT_NULL_MSG( wavemap_frame,"Required wavemap frame is missing");
527 XSH_ASSURE_NOT_NULL_MSG( instrument,"Instrument setting undefined");
528 XSH_ASSURE_NOT_ILLEGAL( nbkpts > 1);
529 XSH_ASSURE_NOT_NULL_MSG( sky_par,"Undefined input sky parameters");
530 //XSH_ASSURE_NOT_NULL_MSG(ref_sky_list,"Null input reference sky line list");
531 XSH_ASSURE_NOT_NULL( prefix);
532
533 xsh_msg("---Sky subtraction (single frame)");
534 xsh_free_frame(&result);
535 check( result = xsh_subtract_sky_single( src_frame, ordertabedges_frame,
536 slitmap_frame, wavemap_frame, loctab_frame,ref_sky_list,
537 sky_orders_chunks,
538 definedbreakpoints_frame, instrument, nbkpts, sky_par,
539 sky_spectrum, sky_spectrum_eso, prefix,clean_tmp));
540 sprintf( result_tag,"%s_SKY_%s", prefix,
542 sprintf( result_name,"%s.fits", result_tag);
543 xsh_free_frame(sky_img);
544 check( *sky_img = xsh_save_sky_model( src_frame, result, result_tag,
545 instrument));
546 if(strstr(result_name,"TMPSKY")!=NULL) {
547 xsh_add_temporary_file(result_name);
548 }
549 }
550 else{
551 xsh_msg("[No sky subtraction]");
552 xsh_free_frame(&result);
553 check( result = cpl_frame_duplicate( src_frame));
554 }
555
556 cleanup:
557 return result;
558}
559/*----------------------------------------------------------------------------*/
560
561
562/*----------------------------------------------------------------------------*/
573/*----------------------------------------------------------------------------*/
574void xsh_check_afc( int check_flag, cpl_frame *model_frame,
575 cpl_frame *sci_frame, cpl_frameset *wave_frameset,
576 cpl_frame *order_tab_frame, cpl_frame *disp_tab_frame,
578{
579 int i;
580
581 if (check_flag) {
582 if( model_frame!=NULL) {
585 sci_frame,instrument));
586 }
587 else {
588 for(i=0; i< 3; i++){
589 cpl_frame *wavesol_frame = NULL;
590
591 wavesol_frame = cpl_frameset_get_frame( wave_frameset, i);
594 sci_frame,instrument));
595 }
598 sci_frame,instrument));
599 if ( disp_tab_frame != NULL){
602 sci_frame,instrument));
603 }
604 }
605 }
606 cleanup:
607 return;
608}
609/*----------------------------------------------------------------------------*/
610
611#if 0
612void xsh_check_localize_and_nocrh( int nb_frames, loc_obj_par
613 /* Create the localization */
614 if (loc_obj_par->method == LOC_MANUAL_METHOD){
615 check( loc_table_frame = xsh_localize_obj( NULL,
616 instrument, loc_obj_par, NULL, NULL));
617 }
618 if( (loc_obj_par->method != LOC_MANUAL_METHOD) ||
619 (nb_raw_frames == 1 && crh_single_par->nb_iter > 0)){
620 xsh_msg("Preliminary sky subtraction for CRH single or localize auto");
621 xsh_msg("Sky will be put back later");
622
623 sprintf(sky_tag,"%s_TMP_SKY_%s",rec_prefix,
624 xsh_instrument_arm_tostring(instrument));
625
626 check( sub_sky_frame = xsh_subtract_sky_single( rmbkg, order_tab_edges,
627 slitmap_frame, wavemap_frame,
628 NULL,
629 single_frame_sky_sub_tab_frame,
630 instrument,
631 sub_sky_nbkpts1, sky_par,
632 &sky_frame,
633 &sky_frame_eso,
634 sky_tag));
635
636
637
638
639
640 /* to monitor quality of SKY model
641 we subtract to object before sky subtraction (flatfielded)
642 the frame after sky subtraction. This should give only the sky
643 (if the object is well masked)
644 */
645 sky_frame_ima=xsh_save_sky_model(rmbkg,sub_sky_frame,sky_tag,instrument,decode_bp);
646
647
648
649 if( loc_obj_par->method != LOC_MANUAL_METHOD){
650 xsh_msg("Localize auto");
651 sprintf(rec_name,"%s_%s_%s.fits",
652 rec_prefix,XSH_ORDER2D,
653 xsh_instrument_arm_tostring(instrument));
654
655 /* rectify */
656
657 check( rect_frame = xsh_rectify( sub_sky_frame, order_tab_edges,
658 wave_tab, model_config_frame,
659 instrument, rectify_par,
660 spectralformat_frame, disp_tab_frame,
661 rec_name, NULL, NULL,rec_prefix));
662
663 /* localize */
664 check( loc_table_frame = xsh_localize_obj( rect_frame, instrument,
665 loc_obj_par, NULL, NULL));
666 }
667 /* Remove COSMICS single */
668 check( clean_frame = xsh_check_remove_crh_single( nb_raw_frames, sub_sky_frame,
669 crh_single_par, wavemap_frame, instrument, rec_prefix));
670
671 /* We put back the SKY before doing flat field and
672 proper sky subtraction */
673 {
674 char * obj_nocrh_tag = NULL ;
675 char * obj_nocrh_name = NULL ;
676
677 obj_nocrh_tag = xsh_stringcat_any("OBJ_AND_SKY_NOCRH_",
679 (void*)NULL) ;
680 obj_nocrh_name = xsh_stringcat_any("OBJ_AND_SKY_NOCRH_",
682 ".fits",(void*)NULL) ;
683
684 check( pre_sci = xsh_pre_load( clean_frame, instrument));
685
686 strcpy(sky_name,cpl_frame_get_filename(sky_frame_ima));
687 check(sky_image=cpl_image_load(sky_name,CPL_TYPE_FLOAT,0,0));
688 check(cpl_image_add(pre_sci->data,sky_image));
689
690 check(clean_obj=xsh_pre_save(pre_sci, obj_nocrh_name, obj_nocrh_tag, 1));
691
692 XSH_FREE( obj_nocrh_tag ) ;
693 XSH_FREE( obj_nocrh_name ) ;
694 xsh_pre_free( &pre_sci);
695 }
696
697
698 } else {
699 /* LOcalize manual && no CRH SINGLE */
700 check( clean_obj=cpl_frame_duplicate(rmbkg));
701 }
702#endif
703
704
705
static xsh_instrument * instrument
int binx
cpl_error_code xsh_badpixelmap_coadd(cpl_frame *self, const cpl_frame *right, const int mode)
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
Definition: xsh_data_pre.c:849
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
Definition: xsh_data_pre.c:823
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
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
cpl_frame * xsh_bpmap_2pre(cpl_frame *bpmap, const char *prefix, xsh_instrument *inst)
This function transform a BP map from raw to pre format.
Definition: xsh_prepare.c:81
#define XSH_ASSURE_NOT_NULL_MSG(pointer, msg)
Definition: xsh_error.h:103
#define XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#define check(COMMAND)
Definition: xsh_error.h:71
#define check_msg(COMMAND,...)
Definition: xsh_error.h:62
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
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.
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
Definition: xsh_pfits.c:1008
int xsh_pfits_get_binx(const cpl_propertylist *plist)
find out the BINX value
Definition: xsh_pfits.c:289
int xsh_pfits_get_naxis1(const cpl_propertylist *plist)
find out the NAXIS1 value
Definition: xsh_pfits.c:227
cpl_frame * xsh_remove_crh_multiple(cpl_frameset *rawFrames, const char *name, xsh_stack_param *stack_param, xsh_clipping_param *crh_clipping, xsh_instrument *inst, cpl_imagelist **, cpl_image **, const int save_tmp)
cpl_frame * xsh_remove_crh_single(cpl_frame *sci_frame, xsh_instrument *instrument, cpl_mask *sky_map, xsh_remove_crh_single_param *single_par, const char *name)
Remove cosmic rays from a single frame.
cpl_frame * xsh_save_sky_model(cpl_frame *obj_frame, cpl_frame *sub_sky_frame, const char *sky_tag, xsh_instrument *instrument)
cpl_frame * xsh_subtract_sky_single(cpl_frame *sci_frame, cpl_frame *order_table_frame, cpl_frame *slitmap_frame, cpl_frame *wavemap_frame, cpl_frame *locTable_frame, cpl_frame *ref_sky_list, cpl_frame *sky_orders_chunks, cpl_frame *usr_defined_break_points_frame, xsh_instrument *instrument, int nbkpts, xsh_subtract_sky_single_param *sky_par, cpl_frame **sky_spectrum, cpl_frame **sky_spectrum_eso, const char *rec_prefix, const int clean_tmp)
Subtract the sky background for single frame. If sky_spectrum is NOT NULL it is saved as a product,...
cpl_frame * xsh_subtract_bias(cpl_frame *frame, cpl_frame *bias, xsh_instrument *instr, const char *type, const int pre_overscan_corr, const int save_tmp)
Subtract the master bias frame from PRE frame.
Definition: xsh_subtract.c:120
cpl_frame * xsh_subtract_dark(cpl_frame *frame, cpl_frame *dark, const char *filename, xsh_instrument *instr)
subtract the master dark frame from PRE frame
Definition: xsh_subtract.c:247
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
Definition: xsh_utils.c:2116
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_stringcat_any(const char *s,...)
Concatenate an arbitrary number of strings.
Definition: xsh_utils.c:1925
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
Definition: xsh_utils.c:2179
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
Definition: xsh_utils.c:1432
void xsh_create_map(cpl_frame *dispsol_frame, cpl_frame *ordertab_frame, cpl_frame *pre_frame, xsh_instrument *instrument, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame, const char *rec_prefix)
void xsh_create_model_map(cpl_frame *model_frame, xsh_instrument *instrument, const char *wtag, const char *stag, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame, const int save_tmp)
@ XSH_ARM_UVB
@ XSH_ARM_NIR
@ XSH_ARM_VIS
#define XSH_PRE_DATA_BPP
Definition: xsh_data_pre.h:43
cpl_frame * xsh_find_wavemap(cpl_frameset *frames, xsh_instrument *instr)
Find Wave Map frame. The frame returned should not be free by the caller.
Definition: xsh_dfs.c:3983
cpl_frame * xsh_find_slitmap(cpl_frameset *frames, xsh_instrument *instr)
Find a slit map.
Definition: xsh_dfs.c:3673
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_BP_MAP_RP
Definition: xsh_dfs.h:355
#define XSH_SLIT_MAP_MODEL
Definition: xsh_dfs.h:146
#define XSH_WAVE_MAP_MODEL
Definition: xsh_dfs.h:923
#define XSH_BP_MAP_NL
Definition: xsh_dfs.h:360
#define XSH_BP_MAP
Definition: xsh_dfs.h:338
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.
void xsh_check_afc(int check_flag, cpl_frame *model_frame, cpl_frame *sci_frame, cpl_frameset *wave_frameset, cpl_frame *order_tab_frame, cpl_frame *disp_tab_frame, xsh_instrument *instrument)
Check AFC frame.
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_frame * xsh_check_load_master_bpmap(cpl_frameset *calib, xsh_instrument *inst, const char *rec_id)
Definition: xsh_drl_check.c:51
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.
cpl_frame * xsh_check_remove_crh_single(int nb_raws_frame, cpl_frame *subsky_frame, xsh_remove_crh_single_param *crh_single_par, xsh_instrument *instrument, const char *prefix)
Check function.
cpl_error_code xsh_model_temperature_update_frame(cpl_frame **model_config_frame, cpl_frame *ref_frame, xsh_instrument *instrument, int *found_temp)
@ LOC_MANUAL_METHOD
#define XSH_FREE(POINTER)
Definition: xsh_utils.h:92
cpl_error_code xsh_frame_check_model_cfg_is_proper_for_sci(cpl_frame *model_config_frame, cpl_frame *sci_frame, xsh_instrument *instrument)
Check if a model configuration frame has been corrected for flexures.
cpl_error_code xsh_frame_check_model_cfg_is_afc_corrected(cpl_frame *model_config_frame)
utility to check if a frame has been corrected for flexures