X-shooter Pipeline Reference Manual 3.8.15
xsh_wavecal.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.127 $
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>
52#include <xsh_model_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_drl.h>
59#include <xsh_drl_check.h>
60#include <xsh_data_instrument.h>
61#include <xsh_model_kernel.h>
63
64/* Library */
65#include <cpl.h>
66#include <math.h>
67
68/* Xsh Wavecal */
69
70/*-----------------------------------------------------------------------------
71 Defines
72 ----------------------------------------------------------------------------*/
73
74#define RECIPE_ID "xsh_wavecal"
75#define RECIPE_AUTHOR "L.Guglielmi"
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_wavecal_create(cpl_plugin *);
87static int xsh_wavecal_exec(cpl_plugin *);
88static int xsh_wavecal_destroy(cpl_plugin *);
89
90/* The actual executor function */
91static void xsh_wavecal(cpl_parameterlist *, cpl_frameset *);
92
93/*-----------------------------------------------------------------------------
94 Static variables
95 ----------------------------------------------------------------------------*/
97"Compute arclines tilt and instrument resolution";
98
100"This recipe detects and follow arc lines in a fully illuminated slit\n\
101frame.\n\
102Input Frames:\n\
103 Raw frame (Tag = ARC_SLIT_arm)\n\
104 Arc Line List (Tag = ARC_LINE_LIST_arm)\n\
105 Master Bias (Tag = MASTER_BIAS_arm)\n\
106 [OPTIONAL] Master Dark (Tag = MASTER_DARK_arm)\n\
107 Order Table (Tag = ORDER_TABLE_EDGES_arm)\n\
108 [poly mode] Wave Solution (Tag = WAVE_TAB_2D_arm)\n\
109 [poly mode] Theoretical Map (Tag = THEO_TAB_spec_arm, spec=SING/IFU)\n\
110 [physical model mode] Model cfg tab (Tag = XSH_MOD_CFG_TAB_arm)\n\
111 - [OPTIONAL] A non-linear badpixel map (Tag = BP_MAP_NL_arm)\n\
112 - [OPTIONAL] A reference badpixel map (Tag = BP_MAP_RP_arm)\n\
113 [OPTIONAL-To compute spectral resolution] Dispersion Table Frame (Tag = DISP_TAB_arm)\n\
114Prepare PRE structures.\n\
115Subtract the master Dark (UVB, VIS and NIR)\n\
116Substract the master Bias (UVB and VIS)\n\
117Divide by Flat.\n\
118Detect and follow arc lines.\n\
119Products:\n\
120 Wavelength solution, PRO.CATG = WAVE_TAB_ARC_SLIT_arm [if poly mode]\n\
121 Linetilt list, PRO.CATG = TILT_TAB_SLIT_arm\n\
122 Residuals table, PRO.CATG = RESID_TAB_GOOD_LINES_arm\n\
123 Wave Map, PRO.CATG = WAVE_MAP_arm [if model-wavemap-compute=TRUE]\n\
124 In case of IFU mode cdata previous producs repat for each IFU slices\n\
125 Arc frame, Bias subtracted in PRE format, PRO.CATG = ARC_BIAS_SUBTRACT_arm\n\
126 If arm=UVB/VIS and PRO.CATG=ARC_NIR_ON if arm=NIR\n\
127 Arc frame, Bias subtracted, FLAT-FIELDED, PRO.CATG = WAVECAL_FLATFIELDED_arm";
128
129
130/*-----------------------------------------------------------------------------
131 Functions code
132 ----------------------------------------------------------------------------*/
133/*----------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144int cpl_plugin_get_info(cpl_pluginlist *list) {
145 cpl_recipe *recipe = NULL;
146 cpl_plugin *plugin = NULL;
147
148 recipe = cpl_calloc(1, sizeof(*recipe));
149 if ( recipe == NULL ){
150 return -1;
151 }
152
153 plugin = &recipe->interface ;
154
155 cpl_plugin_init(plugin,
156 CPL_PLUGIN_API, /* Plugin API */
157 XSH_BINARY_VERSION, /* Plugin version */
158 CPL_PLUGIN_TYPE_RECIPE, /* Plugin type */
159 RECIPE_ID, /* Plugin name */
160 xsh_wavecal_description_short, /* Short help */
161 xsh_wavecal_description, /* Detailed help */
162 RECIPE_AUTHOR, /* Author name */
163 RECIPE_CONTACT, /* Contact address */
164 xsh_get_license(), /* Copyright */
168
169 cpl_pluginlist_append(list, plugin);
170
171 return (cpl_error_get_code() != CPL_ERROR_NONE);
172}
173
174/*----------------------------------------------------------------------------*/
184/*----------------------------------------------------------------------------*/
185
186static int xsh_wavecal_create(cpl_plugin *plugin)
187{
188 cpl_recipe *recipe = NULL;
189 //char paramname[256];
190 //cpl_parameter* p=NULL;
191
192 /* Reset library state */
193 xsh_init();
194
195 /* Check input */
196 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
197
198 /* Get the recipe out of the plugin */
199 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
200 CPL_ERROR_TYPE_MISMATCH,
201 "Plugin is not a recipe");
202
203 recipe = (cpl_recipe *)plugin;
204
205 /* Create the parameter list in the cpl_recipe object */
206 recipe->parameters = cpl_parameterlist_new();
207 assure( recipe->parameters != NULL,
208 CPL_ERROR_ILLEGAL_OUTPUT,
209 "Memory allocation failed!");
210
211 /* Set generic parameters (common to all recipes) */
212 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
213 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
214 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
215
216 /* Window for gaussian fits (at each pixel) */
218 recipe->parameters));
219
221 recipe->parameters));
222
224 recipe->parameters));
225
227 recipe->parameters ) ) ;
228
230 recipe->parameters ) ) ;
231
232 cleanup:
233 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
234 xsh_error_dump(CPL_MSG_ERROR);
235 return 1;
236 }
237 else {
238 return 0;
239 }
240}
241
242/*----------------------------------------------------------------------------*/
248/*----------------------------------------------------------------------------*/
249
250static int xsh_wavecal_exec(cpl_plugin *plugin)
251{
252 cpl_recipe *recipe = NULL;
253
254 /* Check parameter */
255 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
256
257 /* Get the recipe out of the plugin */
258 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
259 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
260
261 recipe = (cpl_recipe *)plugin;
262
263 /* Check recipe */
264 xsh_wavecal(recipe->parameters, recipe->frames);
265
266 cleanup:
267 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
268 xsh_error_dump(CPL_MSG_ERROR);
269 /* RESTORE the error context */
270 cpl_error_reset();
271 return 1;
272 }
273 else {
274 return 0;
275 }
276}
277
278/*----------------------------------------------------------------------------*/
284/*----------------------------------------------------------------------------*/
285static int xsh_wavecal_destroy(cpl_plugin *plugin)
286{
287 cpl_recipe *recipe = NULL;
288
289 /* Check parameter */
290 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
291
292 /* Get the recipe out of the plugin */
293 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
294 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
295
296 recipe = (cpl_recipe *)plugin;
297
298 xsh_free_parameterlist(&recipe->parameters);
299
300 cleanup:
301 if (cpl_error_get_code() != CPL_ERROR_NONE)
302 {
303 return 1;
304 }
305 else
306 {
307 return 0;
308 }
309}
310
311static void xsh_wavecal_get_parameters( cpl_parameterlist* parameters,
313{
315 parameters));
317 parameters));
319 parameters));
321 parameters));
323 parameters));
324 cleanup:
325 return ;
326}
327
328
329
330
331
332
333
334
335static cpl_error_code
337{
338 xsh_msg_dbg_low("follow arclines: range=%d margin=%d",
339 follow_param.range,follow_param.margin);
340
341 return cpl_error_get_code();
342
343}
344
345
346
347
348static cpl_error_code
349xsh_params_set_defaults(cpl_parameterlist* pars,
350 xsh_instrument* inst)
351{
352 cpl_parameter* p=NULL;
353 check(p=xsh_parameters_find(pars,RECIPE_ID,"followarclines-min-sn"));
354 if(cpl_parameter_get_double(p) <= 0) {
356 cpl_parameter_set_double(p,6);
357 } else {
358 cpl_parameter_set_double(p,15);
359 }
360 }
361
362
363 cleanup:
364
365 return cpl_error_get_code();
366
367}
368
369
370
371
372/*--------------------------------------------------------------------------*/
380/*--------------------------------------------------------------------------*/
381
382static cpl_error_code
383xsh_params_bin_scale(cpl_frameset* raws,
384 xsh_follow_arclines_param follow_param)
385{
386
387 cpl_frame* frame=NULL;
388 const char* name=NULL;
389 cpl_propertylist* plist=NULL;
390 int binx=0;
391 int biny=0;
392
393 check(frame=cpl_frameset_get_frame(raws,0));
394 check(name=cpl_frame_get_filename(frame));
395 check(plist=cpl_propertylist_load(name,0));
398
399 if(biny>1) {
400
401 follow_param.range=follow_param.range/biny;
402
403 }
404
405
406 if(binx>1) {
407
408 follow_param.margin=follow_param.margin/binx;
409
410 }
411
412 cleanup:
413 xsh_free_propertylist(&plist);
414 return cpl_error_get_code();
415
416}
417
418/*----------------------------------------------------------------------------*/
426/*----------------------------------------------------------------------------*/
427static void xsh_wavecal(cpl_parameterlist* parameters,
428 cpl_frameset* frameset)
429{
430 const char* recipe_tags[1] = {XSH_WAVECAL};
431 int recipe_tags_size = 1;
432
433 const char *prefix = "ARC_";
434 /* Intermediate frames */
435 cpl_frameset* raws = NULL;
436 cpl_frameset* calib = NULL;
437 cpl_frameset* on = NULL;
438 cpl_frameset* off = NULL;
439 cpl_frameset* on_off = NULL;
440
441 cpl_frame * raw_frame = NULL ;
442 cpl_frame * bpmap = NULL;
443 cpl_frame * order_tab_edges = NULL ;
444 cpl_frame * arc_line_list = NULL ;
445 cpl_frame * model_config_frame = NULL;
446 cpl_frame * spectralformat_frame = NULL;
447 cpl_frame * wave_tab_2d = NULL ;
448 cpl_frame * master_bias = NULL ;
449 cpl_frame * master_dark = NULL ;
450 cpl_frame * rmbias = NULL ;
451 cpl_frame * intFrame = NULL ;
452 cpl_frame * resFrame = NULL ;
453 cpl_frame *wavemap_frame = NULL;
454 cpl_frame *disptab_frame = NULL;
455 cpl_frame *slitmap_frame = NULL;
456
457 /* Product frames (SLIT mode) */
458 cpl_frame * shiftFrame = NULL ;
459 cpl_frame * tilt_list = NULL ;
460
461 /* Product frames (IFU mode) */
462 cpl_frameset * tilt_set = NULL ;
463
464 /* Other */
466 xsh_follow_arclines_param follow_param;
467 int follow_param_init=false;
468 //char fname[256];
469 //char tag[256];
470
471 //char * prefix = NULL ;
472 /* used for annealing: but we do not anneal in wavecal
473 cpl_frame * opt_model_config_frame = NULL;
474 int maxit=200;
475 double ann_fac=1.0;
476 int scenario=-1;
477 char paramname[256];
478 cpl_parameter * p =NULL;
479 */
480 char file_prefix[10];
481 char tag[40];
482 //int resid_size=0;
483 int pre_overscan_corr=0;
484
485 const char* rec_prefix ="xsh_wavecal";
486
487 /**************************************************************************/
488 /* DFS management */
489 /**************************************************************************/
490 xsh_begin( frameset, parameters, &instrument, &raws, &calib,
491 recipe_tags, recipe_tags_size,
492 RECIPE_ID, XSH_BINARY_VERSION, xsh_wavecal_description_short );
493
494
496 /**************************************************************************/
497 /* Recipe frames */
498 /**************************************************************************/
500 check(order_tab_edges = xsh_find_order_tab_edges(calib,instrument));
501 spectralformat_frame = xsh_find_spectral_format( calib, instrument);
503 if((model_config_frame = xsh_find_frame_with_tag(calib,
505 instrument)) == NULL) {
506
508
509 if ((model_config_frame = xsh_find_frame_with_tag(calib,XSH_MOD_CFG_TAB,
510 instrument)) == NULL) {
512 }
513
514 }
515
517 check(arc_line_list = xsh_find_frame_with_tag(calib,
519 instrument));
520
521 check(wave_tab_2d = xsh_find_wave_tab_2d( calib, instrument ));
522
523 check( wavemap_frame = xsh_find_wavemap( calib, instrument));
524 if (wavemap_frame){
525 wavemap_frame = cpl_frame_duplicate( wavemap_frame);
526 }
527 check( slitmap_frame = xsh_find_slitmap( calib, instrument));
528 if ( slitmap_frame){
529 slitmap_frame = cpl_frame_duplicate( slitmap_frame);
530 }
531
532 if( NULL==(disptab_frame = xsh_find_disp_tab( calib, instrument))) {
533 xsh_msg_warning("No input DISP_TAB_ARM provided. Spectral Resolution will not be computed");
534 }
535
536
537 /* In UVB and VIS mode */
539 /* RAWS frameset must have only one file */
540 XSH_ASSURE_NOT_ILLEGAL_MSG(cpl_frameset_get_size(raws) == 1,
541 "UVB,VIS arm provide one slit,arc lamp frame");
542
543 if((master_bias = xsh_find_frame_with_tag(calib,XSH_MASTER_BIAS,
544 instrument)) == NULL) {
545
546 xsh_msg_warning("Frame %s not provided",XSH_MASTER_BIAS);
548 }
549
550 //if((master_dark = xsh_find_frame_with_tag(calib,XSH_MASTER_DARK,
551 // instrument)) == NULL){
552 if ( (master_dark = xsh_find_master_dark(calib,instrument)) == NULL ) {
553 xsh_msg_warning("Frame %s not provided",XSH_MASTER_DARK);
555 }
556 else xsh_msg( "Frame %s Found", XSH_MASTER_DARK ) ;
557 }
558 /* IN NIR mode */
559 else {
560 /* split on and off files */
561 check(xsh_dfs_split_nir(raws,&on,&off));
562 XSH_ASSURE_NOT_ILLEGAL_MSG(cpl_frameset_get_size(on) == 1,
563 "NIR arm provide one slit,arc lamp on frame");
564 XSH_ASSURE_NOT_ILLEGAL_MSG(cpl_frameset_get_size(off) == 1,
565 "NIR arm provide one slit,arc lamp off frame");
566 }
568 spectralformat_frame));
569
570
571 /**************************************************************************/
572 /* Recipe parameters */
573 /**************************************************************************/
575 check(xsh_wavecal_get_parameters( parameters, &follow_param ));
576 follow_param_init=true;
577 xsh_msg_dbg_low( "Parameters: Y range = %d, X Margin = %d", follow_param.range,
578 follow_param.margin ) ;
579 xsh_msg_dbg_low( "Clipping Tilt Parameters: sigma = %.2lf, Niter = %d, Frac = %.2lf",
580 follow_param.tilt_clipping->sigma,
581 follow_param.tilt_clipping->niter,
582 follow_param.tilt_clipping->frac ) ;
583
584 /* adjust relevant parameter to binning */
586 check(xsh_params_monitor(follow_param));
587 check(xsh_params_bin_scale(raws,follow_param));
588 }
589 check(xsh_params_monitor(follow_param));
590
591
592 /**************************************************************************/
593 /* Recipe code */
594 /**************************************************************************/
595
596 /* In UVB and VIS mode */
598 check(xsh_prepare( raws, bpmap, master_bias, XSH_WAVECAL, instrument,pre_overscan_corr,CPL_TRUE));
599 check(raw_frame = cpl_frameset_get_frame(raws,0));
600
601 /* Subtract bias if necessary */
602 if(master_bias != NULL) {
603 xsh_msg( "Subtract bias" );
604 sprintf(file_prefix,"ARC_%s_",xsh_instrument_mode_tostring(instrument));
605 check(rmbias = xsh_subtract_bias( raw_frame, master_bias, instrument,file_prefix,pre_overscan_corr,0));
606 } else {
607 rmbias=cpl_frame_duplicate(raw_frame);
608 }
609
610
611 /* Subtract Dark if necessary */
612 check( intFrame = xsh_check_subtract_dark( rmbias, master_dark,
613 instrument, prefix));
614 }
615 else{
616 /* do ON - OFF */
617 check(xsh_prepare(on, bpmap, NULL, "ON", instrument,pre_overscan_corr,CPL_TRUE));
618 check(xsh_prepare(off,bpmap, NULL, "OFF", instrument,pre_overscan_corr,CPL_TRUE));
619
620 xsh_msg( "Subtract ON-OFF" ) ;
621 check( on_off = xsh_subtract_nir_on_off(on, off, instrument));
622 XSH_ASSURE_NOT_ILLEGAL(cpl_frameset_get_size(on_off) == 1);
623 check( intFrame = cpl_frame_duplicate( cpl_frameset_get_frame( on_off,0)));
624 }
625
626
627
628 /* generate wavemap if necessary */
629 if ( model_config_frame != NULL && wavemap_frame == NULL){
630 char wave_map_tag[256];
631 char slit_map_tag[256];
632 int found_temp=true;
633
634 xsh_free_frame( &slitmap_frame);
635 sprintf(wave_map_tag,"%s_%s_%s",rec_prefix,XSH_WAVE_MAP_MODEL,
637 sprintf(slit_map_tag,"%s_%s_%s",rec_prefix,XSH_SLIT_MAP_MODEL,
639
640
641 check(xsh_model_temperature_update_frame(&model_config_frame,intFrame,
642 instrument,&found_temp));
643
644 check( xsh_create_model_map( model_config_frame, instrument,
645 wave_map_tag,slit_map_tag,
646 &wavemap_frame, &slitmap_frame,1));
647 }
648
649
650/* check( resFrame = xsh_check_divide_flat( CPL_TRUE, intFrame, master_flat,
651 instrument, prefix));
652*/
653
654 /* xsh_follow_arclines */
655 /* Separate SLIT and IFU handling */
657 xsh_msg( "Call xsh_follow_arclines, SLIT mode" );
658 check( xsh_follow_arclines_slit( intFrame, arc_line_list,
659 wave_tab_2d, order_tab_edges,
660 spectralformat_frame, model_config_frame,
661 wavemap_frame, slitmap_frame,
662 disptab_frame,
663 &follow_param, instrument,
664 &tilt_list,
665 &shiftFrame));
666
667 /*********************************************************************/
668 /* Products SLIT mode */
669 /*********************************************************************/
670 xsh_msg("Saving products, SLIT mode");
671
672 XSH_ASSURE_NOT_NULL( tilt_list);
673 xsh_msg_dbg_low( "Tilt List Product from '%s'",
674 cpl_frame_get_filename(tilt_list));
675 check( xsh_add_product_table( tilt_list, frameset, parameters, RECIPE_ID,
676 instrument,NULL));
677 }
678 else {
679 int i ;
680
681 xsh_msg( "Call xsh_follow_arclines, IFU mode" ) ;
682 check( tilt_set = cpl_frameset_new() ) ;
683 check( xsh_follow_arclines_ifu( intFrame, arc_line_list,
684 wave_tab_2d, order_tab_edges,
685 spectralformat_frame, model_config_frame,
686 wavemap_frame, slitmap_frame, disptab_frame,
687 &follow_param, instrument,
688 tilt_set, &shiftFrame));
689 /*********************************************************************/
690 /* Products IFU mode */
691 /*********************************************************************/
692 xsh_msg("Saving products, IFU mode");
693 /* In IFU mode we have 3 products per slitlet */
694 for( i = 0 ; i<3 ; i++ ) {
695 //const char * wname = NULL ;
696 cpl_frame *tilt_frame = NULL;
697
698 check( tilt_frame = cpl_frameset_get_frame( tilt_set, i));
699 xsh_msg_dbg_low( "Product from '%s'",
700 cpl_frame_get_filename( tilt_frame));
701 check( xsh_add_product_table( tilt_frame, frameset, parameters,
702 RECIPE_ID, instrument,NULL));
703 }
704 }
705
706 /*********************************************************************/
707 /* Others Products */
708 /*********************************************************************/
710 sprintf(tag,"ARC_SLIT_ON");
711 } else {
712 sprintf(tag,"ARC_IFU_ON");
713 }
715 xsh_msg_dbg_low( "Product from '%s'",
716 cpl_frame_get_filename( rmbias));
717
718 check(xsh_add_product_image(rmbias,frameset,parameters,
719 RECIPE_ID,instrument,tag));
720 /*
721 check(xsh_add_product_pre(rmbias,frameset,parameters,
722 RECIPE_ID,instrument));
723 */
724 } else {
725 xsh_msg_dbg_low( "Product from '%s'",
726 cpl_frame_get_filename( intFrame));
727 check(xsh_add_product_image(intFrame,frameset,parameters,
728 RECIPE_ID,instrument,tag));
729 /*
730 check(xsh_add_product_pre(intFrame,frameset,parameters,
731 RECIPE_ID,instrument));
732 */
733 }
734
735 xsh_msg_dbg_low( "Product from '%s'",
736 cpl_frame_get_filename( shiftFrame));
737 check( xsh_add_product_table( shiftFrame, frameset,parameters, RECIPE_ID,
738 instrument,NULL));
739
740 cleanup:
741 xsh_end( RECIPE_ID, frameset, parameters);
743 xsh_free_frameset( &raws);
744 xsh_free_frameset( &calib);
745 xsh_free_frame( &wavemap_frame);
746 xsh_free_frame( &slitmap_frame);
747 xsh_free_frame( &rmbias);
748 xsh_free_frame( &intFrame);
749 xsh_free_frameset( &on);
750 xsh_free_frameset( &off);
751 xsh_free_frameset( &on_off);
752 xsh_free_frame( &resFrame);
753 xsh_free_frame( &shiftFrame);
754 if(follow_param_init) {
755 XSH_FREE( follow_param.tilt_clipping);
756 XSH_FREE( follow_param.specres_clipping);
757 }
758 xsh_free_frame( &tilt_list);
759 xsh_free_frameset( &tilt_set);
760
761 return;
762}
static xsh_instrument * instrument
int binx
int biny
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
Definition: xsh_prepare.c:122
#define XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#define assure(CONDITION, ERROR_CODE,...)
Definition: xsh_error.h:54
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define xsh_error_reset()
Definition: xsh_error.h:87
#define XSH_ASSURE_NOT_ILLEGAL_MSG(cond, msg)
Definition: xsh_error.h:111
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
void xsh_follow_arclines_slit(cpl_frame *inframe, cpl_frame *arclines, cpl_frame *wavesol, cpl_frame *order_table, cpl_frame *spectralformat_frame, cpl_frame *model_config_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, cpl_frame *disptab_frame, xsh_follow_arclines_param *param, xsh_instrument *instrument, cpl_frame **tilt_list, cpl_frame **shift_frame)
void xsh_follow_arclines_ifu(cpl_frame *inframe, cpl_frame *arclines, cpl_frame *wavesol, cpl_frame *order_table, cpl_frame *spectralformat_frame, cpl_frame *model_config_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, cpl_frame *disptab_frame, xsh_follow_arclines_param *follow_param, xsh_instrument *instrument, cpl_frameset *tilt_set, cpl_frame **shift_frame)
Detect and follow arc lines. Computes center, width and tilt parameters. The position of the center o...
const char * xsh_instrument_mode_tostring(xsh_instrument *i)
Get the string associated with a mode.
void xsh_instrument_update_from_spectralformat(xsh_instrument *i, cpl_frame *spectralformat_frame)
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
XSH_MODE xsh_instrument_get_mode(xsh_instrument *i)
Get a mode on instrument structure.
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
#define xsh_msg_warning(...)
Print an warning message.
Definition: xsh_msg.h:88
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_low(...)
Definition: xsh_msg.h:48
int xsh_pfits_get_binx(const cpl_propertylist *plist)
find out the BINX value
Definition: xsh_pfits.c:289
int xsh_pfits_get_biny(const cpl_propertylist *plist)
find out the BINY value
Definition: xsh_pfits.c:306
cpl_frameset * xsh_subtract_nir_on_off(cpl_frameset *on, cpl_frameset *off, xsh_instrument *instr)
(NIR only) subtract the OFF set of files from the On set of files
Definition: xsh_subtract.c:194
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
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
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
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
#define RECIPE_CONTACT
Definition: xsh_wavecal.c:76
static char xsh_wavecal_description_short[]
Definition: xsh_wavecal.c:96
static void xsh_wavecal(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
Definition: xsh_wavecal.c:427
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
Definition: xsh_wavecal.c:144
static char xsh_wavecal_description[]
Definition: xsh_wavecal.c:99
static int xsh_wavecal_create(cpl_plugin *)
Setup the recipe options.
Definition: xsh_wavecal.c:186
static cpl_error_code xsh_params_monitor(xsh_follow_arclines_param follow_param)
Definition: xsh_wavecal.c:336
static int xsh_wavecal_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
Definition: xsh_wavecal.c:250
static int xsh_wavecal_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
Definition: xsh_wavecal.c:285
#define RECIPE_ID
Definition: xsh_wavecal.c:74
#define RECIPE_AUTHOR
Definition: xsh_wavecal.c:75
static void xsh_wavecal_get_parameters(cpl_parameterlist *parameters, xsh_follow_arclines_param *par)
Definition: xsh_wavecal.c:311
static cpl_error_code xsh_params_bin_scale(cpl_frameset *raws, xsh_follow_arclines_param follow_param)
Scale input parameters.
Definition: xsh_wavecal.c:383
static cpl_error_code xsh_params_set_defaults(cpl_parameterlist *pars, xsh_instrument *inst)
Definition: xsh_wavecal.c:349
xsh_clipping_param * tilt_clipping
xsh_clipping_param * specres_clipping
void xsh_create_model_map(cpl_frame *model_frame, xsh_instrument *instrument, const char *wtag, const char *stag, cpl_frame **wavemap_frame, cpl_frame **slitmap_frame, const int save_tmp)
@ XSH_ARM_NIR
@ XSH_MODE_SLIT
@ XSH_MODE_IFU
cpl_frame * xsh_find_wavemap(cpl_frameset *frames, xsh_instrument *instr)
Find Wave Map frame. The frame returned should not be free by the caller.
Definition: xsh_dfs.c:3983
cpl_frame * xsh_find_master_dark(cpl_frameset *frames, xsh_instrument *instr)
Find master dark frame.
Definition: xsh_dfs.c:3404
cpl_frame * xsh_find_spectral_format(cpl_frameset *frames, xsh_instrument *instr)
Find spectral format frame.
Definition: xsh_dfs.c:4318
cpl_frame * xsh_find_disp_tab(cpl_frameset *frames, xsh_instrument *instr)
Find Dispersol tab frame. The frame returned should not be free by the caller.
Definition: xsh_dfs.c:4066
cpl_frame * xsh_find_order_tab_edges(cpl_frameset *frames, xsh_instrument *instr)
Find an order tab EDGES.
Definition: xsh_dfs.c:3595
cpl_frame * xsh_find_wave_tab_2d(cpl_frameset *frames, xsh_instrument *instr)
Find a wave tab 2D.
Definition: xsh_dfs.c:3650
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_dfs_split_nir(cpl_frameset *input, cpl_frameset **on, cpl_frameset **off)
split input RAW NIR sof in ON and OFF
Definition: xsh_dfs.c:1297
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_MASTER_BIAS
Definition: xsh_dfs.h:549
#define XSH_MOD_CFG_OPT_2D
Definition: xsh_dfs.h:1233
#define XSH_MASTER_DARK
Definition: xsh_dfs.h:550
#define XSH_MOD_CFG_TAB
Definition: xsh_dfs.h:1251
#define XSH_SLIT_MAP_MODEL
Definition: xsh_dfs.h:146
#define XSH_WAVECAL
Definition: xsh_dfs.h:224
#define XSH_WAVE_MAP_MODEL
Definition: xsh_dfs.h:923
#define XSH_ARC_LINE_LIST
Definition: xsh_dfs.h:955
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
cpl_error_code xsh_model_temperature_update_frame(cpl_frame **model_config_frame, cpl_frame *ref_frame, xsh_instrument *instrument, int *found_temp)
double xsh_parameters_wavecal_s_n_get(const char *recipe_id, cpl_parameterlist *list)
cpl_parameter * xsh_parameters_find(cpl_parameterlist *list, const char *recipe_id, const char *name)
find a parameter
void xsh_parameters_pre_overscan(const char *recipe_id, cpl_parameterlist *plist)
void xsh_parameters_wavecal_s_n_create(const char *recipe_id, cpl_parameterlist *list)
void xsh_parameters_clipping_tilt_create(const char *recipe_id, cpl_parameterlist *list)
create the xsh_wavecal (function follow_arclines) clipping parameters in a parameters list
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
xsh_clipping_param * xsh_parameters_clipping_tilt_get(const char *recipe_id, cpl_parameterlist *list)
get the xsh_wavecal (follow_arclines) clipping parameters in a parameters list
void xsh_parameters_wavecal_range_create(const char *recipe_id, cpl_parameterlist *list)
xsh_clipping_param * xsh_parameters_clipping_specres_get(const char *recipe_id, cpl_parameterlist *list)
get the xsh_wavecal (follow_arclines) clipping parameters in a parameters list
int xsh_parameters_wavecal_range_get(const char *recipe_id, cpl_parameterlist *list)
int xsh_parameters_wavecal_margin_get(const char *recipe_id, cpl_parameterlist *list)
void xsh_parameters_clipping_specres_create(const char *recipe_id, cpl_parameterlist *list)
create the xsh_wavecal (function follow_arclines) clipping parameters in a parameters list
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
cpl_error_code xsh_recipe_params_check(cpl_parameterlist *parameters, xsh_instrument *instrument, const char *rec_id)
void xsh_parameters_wavecal_margin_create(const char *recipe_id, cpl_parameterlist *list)
#define XSH_FREE(POINTER)
Definition: xsh_utils.h:92