X-shooter Pipeline Reference Manual 3.8.15
xsh_util_efficiency2d.c
Go to the documentation of this file.
1/* $Id: xsh_util_efficiency2d.c,v 1.19 2012-04-26 14:08:45 amodigli Exp $
2 *
3 * This file is part of the XSHOOTER Pipeline
4 * Copyright (C) 2002,2003 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22<<<<<<< xsh_util_efficiency2d.c
23 * $Author: amodigli $
24 * $Date: 2012-04-26 14:08:45 $
25 * $Revision: 1.19 $
26=======
27 * $Author: amodigli $
28 * $Date: 2012-04-26 14:08:45 $
29 * $Revision: 1.19 $
30>>>>>>> 1.15.2.1
31 * $Name: not supported by cvs2svn $
32 */
33
34#ifdef HAVE_CONFIG_H
35#include <config.h>
36#endif
37
38/*-----------------------------------------------------------------------------
39 Includes
40 ----------------------------------------------------------------------------*/
41#include <string.h>
42#include <math.h>
43
44/* cpl */
45#include <cpl.h>
46
47#include <xsh_dfs.h>
48#include <xsh_data_pre.h>
49#include <xsh_parameters.h>
50#include <xsh_drl.h>
51#include <xsh_msg.h>
52#include <xsh_pfits.h>
53#include <xsh_pfits_qc.h>
54#include <xsh_error.h>
55#include <xsh_utils_image.h>
56#include <xsh_data_atmos_ext.h>
57
58/*-----------------------------------------------------------------------------
59 Defines
60 ----------------------------------------------------------------------------*/
61
62#define RECIPE_ID "xsh_util_efficiency2d"
63#define RECIPE_AUTHOR "A.Modigliani"
64#define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
65#define PRO_IMA "PRO_IMA_UVB"
66#define KEY_VALUE_HPRO_DID "PRO-1.15"
67
68#define SPEED_LIGHT 2.99792458*1.E8 /* m s-1 */
69#define TEL_AREA 51.2e4 /* collecting area in cm2 */
70/*-----------------------------------------------------------------------------
71 Functions prototypes
72 ----------------------------------------------------------------------------*/
73
74static int xsh_util_efficiency2d_create(cpl_plugin *) ;
75static int xsh_util_efficiency2d_exec(cpl_plugin *) ;
76static int xsh_util_efficiency2d_destroy(cpl_plugin *) ;
77static int xsh_util_efficiency2d(cpl_parameterlist *, cpl_frameset *) ;
78
79/*-----------------------------------------------------------------------------
80 Static variables
81 ----------------------------------------------------------------------------*/
82
83static char
86"This recipe compute efficiency.\n"
87"The input files should be tagged as: \n"
88"input observed spectrum: RAW_IMA_SLIT_arm,\n"
89"input reference spectrum: FLUX_STD_TABLE_arm,\n"
90"input atmospheric extintion table: EXTCOEFF_TABLE_arm)\n"
91"The output is a table with efficiency as function of wavelength\n"
92"Information on relevant parameters can be found with\n"
93"esorex --params xsh_util_efficiency2d\n"
94"esorex --help xsh_util_efficiency2d\n"
95"\n";
96
97/*-----------------------------------------------------------------------------
98 Functions code
99 ----------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
108/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117int cpl_plugin_get_info(cpl_pluginlist * list)
118{
119 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
120 cpl_plugin * plugin = &recipe->interface ;
121
122 cpl_plugin_init(plugin,
123 CPL_PLUGIN_API,
124 XSH_BINARY_VERSION,
125 CPL_PLUGIN_TYPE_RECIPE,
126 RECIPE_ID,
135
136 cpl_pluginlist_append(list, plugin) ;
137
138 return 0;
139}
140
141/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151static int xsh_util_efficiency2d_create(cpl_plugin * plugin)
152{
153 cpl_recipe * recipe ;
154 cpl_parameter * p ;
155
156 /* Reset library state */
157 xsh_init();
158
159 /* Get the recipe out of the plugin */
160 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
161 recipe = (cpl_recipe *)plugin ;
162 else return -1 ;
163 cpl_error_reset();
164
165
166 /* Create the parameters list in the cpl_recipe object */
167 recipe->parameters = cpl_parameterlist_new() ;
168
169
170 /* Set generic parameters (common to all recipes) */
172 recipe->parameters ) ) ;
173 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
174 /* Fill the parameters list */
175 p = cpl_parameter_new_value("xsh.xsh_util_efficiency2d.sky1_lly",
176 CPL_TYPE_INT,
177 "Sky1 lly",
178 "xsh.xsh_util_efficiency2d",2);
179 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sky1_lly") ;
180 cpl_parameterlist_append(recipe->parameters, p) ;
181
182
183
184 /* Fill the parameters list */
185 p = cpl_parameter_new_value("xsh.xsh_util_efficiency2d.sky1_ury",
186 CPL_TYPE_INT,
187 "Sky1 ury",
188 "xsh.xsh_util_efficiency2d",20);
189 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sky1_ury") ;
190 cpl_parameterlist_append(recipe->parameters, p) ;
191
192
193
194
195 /* Fill the parameters list */
196 p = cpl_parameter_new_value("xsh.xsh_util_efficiency2d.sky2_lly",
197 CPL_TYPE_INT,
198 "Sky2 lly",
199 "xsh.xsh_util_efficiency2d",75);
200 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sky2_lly") ;
201 cpl_parameterlist_append(recipe->parameters, p) ;
202
203
204
205 /* Fill the parameters list */
206 p = cpl_parameter_new_value("xsh.xsh_util_efficiency2d.sky2_ury",
207 CPL_TYPE_INT,
208 "Sky ury",
209 "xsh.xsh_util_efficiency2d",100);
210 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sky2_ury") ;
211 cpl_parameterlist_append(recipe->parameters, p) ;
212
213
214
215
216
217 /* Fill the parameters list */
218 p = cpl_parameter_new_value("xsh.xsh_util_efficiency2d.obj_lly",
219 CPL_TYPE_INT,
220 "Sky2 lly",
221 "xsh.xsh_util_efficiency2d",22);
222 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "obj_lly") ;
223 cpl_parameterlist_append(recipe->parameters, p) ;
224
225
226
227 /* Fill the parameters list */
228 p = cpl_parameter_new_value("xsh.xsh_util_efficiency2d.obj_ury",
229 CPL_TYPE_INT,
230 "Sky ury",
231 "xsh.xsh_util_efficiency2d",70);
232 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "obj_ury") ;
233 cpl_parameterlist_append(recipe->parameters, p) ;
234
235
236
237
238 cleanup:
239
240 /* Return */
241 return 0;
242}
243
244/*---------------------------------------------------------------------------*/
250/*---------------------------------------------------------------------------*/
251static int xsh_util_efficiency2d_exec(cpl_plugin * plugin)
252{
253 cpl_recipe * recipe ;
254 int code=0;
255 cpl_errorstate initial_errorstate = cpl_errorstate_get();
256
257 /* Get the recipe out of the plugin */
258 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
259 recipe = (cpl_recipe *)plugin ;
260 else return -1 ;
261 cpl_error_reset();
262
263 code = xsh_util_efficiency2d(recipe->parameters, recipe->frames) ;
264
265
266 if (!cpl_errorstate_is_equal(initial_errorstate)) {
267 /* Dump the error history since recipe execution start.
268 At this point the recipe cannot recover from the error */
269 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
270 }
271
272 return code ;
273}
274
275/*---------------------------------------------------------------------------*/
281/*---------------------------------------------------------------------------*/
282static int xsh_util_efficiency2d_destroy(cpl_plugin * plugin)
283{
284 cpl_recipe * recipe ;
285
286 /* Get the recipe out of the plugin */
287 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
288 recipe = (cpl_recipe *)plugin ;
289 else return -1 ;
290
291 cpl_parameterlist_delete(recipe->parameters) ;
292 return 0 ;
293}
294
295static double
297 double wav,
298 const char* colx,
299 const char* coly)
300{
301
302 double y=0;
303 double w1=0;
304 double w2=0;
305 double pos_y1=0;
306 double pos_y2=0;
307 float* pe=NULL;
308 float* pw=NULL;
309 int nrow=0;
310 int i=0;
311
312
313 w1=cpl_table_get_column_min(tbl,colx);
314 w2=cpl_table_get_column_max(tbl,colx);
315 pos_y1=cpl_table_get_column_min(tbl,coly);
316 pos_y2=cpl_table_get_column_max(tbl,coly);
317
318
319 pw=cpl_table_get_data_float(tbl,colx);
320 pe=cpl_table_get_data_float(tbl,coly);
321 nrow=cpl_table_get_nrow(tbl);
322
323
324 for(i=0;i<nrow-1;i++) {
325 if(pw[i]<wav) {
326 w1=pw[i];
327 w2=pw[i+1];
328 pos_y1=pe[i];
329 pos_y2=pe[i+1];
330 }
331 }
332
333 y=pos_y1+(pos_y2-pos_y1)/(w2-w1)*(wav-w1);
334
335
336return y;
337
338}
339
340
341/*---------------------------------------------------------------------------*/
348/*---------------------------------------------------------------------------*/
349static int
350xsh_util_efficiency2d( cpl_parameterlist * parlist,
351 cpl_frameset * frames)
352{
353 const char* recipe_tags[1] = {XSH_RAW_IMA_SLIT};
354 int recipe_tags_size = 1;
355
357 cpl_parameter * param= NULL ;
358 cpl_frame* frm_sci=NULL;
359 cpl_frame* frm_ref=NULL;
360 cpl_frame* frm_atmext=NULL;
361
362 cpl_frameset* raws=NULL;
363 cpl_frameset* calib=NULL;
364
365 cpl_image* ima_sci=NULL;
366 cpl_table* tbl_ref=NULL;
367 cpl_table* tbl_ext=NULL;
368 cpl_table* tbl_atmext=NULL;
369
370 const char* name=NULL;
371 double ref_wmin=0;
372 double ref_wmax=0;
373 double ext_wmin=0;
374 double ext_wmax=0;
375
376 cpl_propertylist* plist=NULL;
377 double crval1=0;
378 double cdelt1=0;
379 int naxis1=0;
380 int nrow=0;
381 double* pext=NULL;
382 double* pcor=NULL;
383 double* pref=NULL;
384 double* peph=NULL;
385 double aimprim=1.446;
386
387
388 double exptime=600;
389 cpl_vector* rec_profile=NULL;
390 int i=0;
391 double airmass=0;
392 double airmass_start=0;
393 double airmass_end=0;
394
395 double nm2AA=10.; /* nm/AA */
396 int next=0;
397 int nord=0;
398 cpl_image* ima_ord=0;
399 cpl_image* ima_obj=0;
400 cpl_image* ima_sky1=0;
401 cpl_image* ima_sky2=0;
402 cpl_image* ima_sky=0;
403 int sx=0;
404 int obj_lly=37;//22; //18;
405 int obj_ury=85;//70; //80;
406
407 int sky1_lly=20;//2;//3;
408 int sky1_ury=35;//20;//15;
409
410
411 int sky2_lly=90;//75;//81;
412 int sky2_ury=105;//100;//100;
413 cpl_table* obj_tab=NULL;
414
415 double * pobj=NULL;
416 double * pw=NULL;
417 double * pf=NULL;
418 int * po=NULL;
419 int k=0;
420 int j=0;
421 double wav=0;
422 double gain=0;
423 cpl_table* tbl_sel=NULL;
424 int biny=1;
425
426 xsh_msg("Welcome to XSHOOTER Pipeline release %d.%d.%d",
427 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
428
429
430 check( xsh_begin( frames, parlist, &instrument, &raws, &calib,
431 recipe_tags, recipe_tags_size,
432 RECIPE_ID, XSH_BINARY_VERSION,
434
435
436
437 check(param=cpl_parameterlist_find(parlist,"xsh.xsh_util_efficiency2d.sky1_lly"));
438 check(sky1_lly=cpl_parameter_get_int(param));
439
440 check(param=cpl_parameterlist_find(parlist,"xsh.xsh_util_efficiency2d.sky1_ury"));
441 check(sky1_ury=cpl_parameter_get_int(param));
442
443
444 check(param=cpl_parameterlist_find(parlist,"xsh.xsh_util_efficiency2d.sky2_lly"));
445 check(sky2_lly=cpl_parameter_get_int(param));
446
447 check(param=cpl_parameterlist_find(parlist,"xsh.xsh_util_efficiency2d.sky2_ury"));
448 check(sky2_ury=cpl_parameter_get_int(param));
449
450
451
452
453 check(param=cpl_parameterlist_find(parlist,"xsh.xsh_util_efficiency2d.obj_lly"));
454 check(obj_lly=cpl_parameter_get_int(param));
455
456 check(param=cpl_parameterlist_find(parlist,"xsh.xsh_util_efficiency2d.obj_ury"));
457 check(obj_ury=cpl_parameter_get_int(param));
458 xsh_msg("Obj extraction window: %d %d",obj_lly,obj_ury);
459 xsh_msg("Sky1 extraction window: %d %d",sky1_lly,sky1_ury);
460 xsh_msg("Sky2 extraction window: %d %d",sky2_lly,sky2_ury);
461
462
463 /* HOW TO RETRIEVE INPUT PARAMETERS */
464 /* --stropt */
468 check(next = cpl_frame_get_nextensions(frm_sci));
469
470 xsh_msg("next=%d",next);
471 nord=(next+1)/3;
472 name=cpl_frame_get_filename(frm_sci);
473
474 check(plist=cpl_propertylist_load(name,0));
475 check(naxis1=xsh_pfits_get_naxis1(plist));
476 check(airmass_start=xsh_pfits_get_airm_start(plist));
477 check(airmass_end=xsh_pfits_get_airm_end(plist));
479 gain=2.12;
480 biny=1;
482 } else {
483 check(gain=xsh_pfits_get_conad(plist));
486 }
487
488 xsh_free_propertylist(&plist);
489 airmass=0.5*(airmass_start+airmass_end);
490
491 xsh_msg("gain=%g airm=%g exptime=%g",gain,airmass,exptime);
492
493 xsh_msg("name=%s",name);
494 nrow=naxis1*nord;
495 obj_tab=cpl_table_new(nrow);
496 cpl_table_new_column(obj_tab,"ORD",CPL_TYPE_INT);
497 cpl_table_new_column(obj_tab,"WAVELENGTH",CPL_TYPE_DOUBLE);
498 cpl_table_new_column(obj_tab,"FLUX",CPL_TYPE_DOUBLE);
499
500 check(po=cpl_table_get_data_int(obj_tab,"ORD"));
501 check(pw=cpl_table_get_data_double(obj_tab,"WAVELENGTH"));
502 check(pf=cpl_table_get_data_double(obj_tab,"FLUX"));
503
504 check(cpl_table_fill_column_window_int(obj_tab,"ORD",0,nrow,-1));
505 check(cpl_table_fill_column_window_double(obj_tab,"WAVELENGTH",0,nrow,-1));
506 check(cpl_table_fill_column_window_double(obj_tab,"FLUX",0,nrow,-1));
507
508 /* extract the object signal on a given slit
509 extract the sky signal on 2 given slits
510 computes the extracted sky per pixel on each sky window
511 average the two extracted sky
512 rescale the averaged sky to the object windows and
513 subtract it from the object
514 */
515 xsh_msg("extract object");
516 k=0;
517 for(i=0;i<next;i+=3) {
518 xsh_msg("processing extension %d",i);
519 check(ima_ord=cpl_image_load(name,CPL_TYPE_DOUBLE,0,i));
520 check(plist=cpl_propertylist_load(name,i));
521 check(sx=cpl_image_get_size_x(ima_ord));
522 check(ima_obj=cpl_image_collapse_window_create(ima_ord,1,obj_lly,
523 sx,obj_ury,0));
524 check(ima_sky1=cpl_image_collapse_window_create(ima_ord,1,sky1_lly,
525 sx,sky1_ury,0));
526 check(ima_sky2=cpl_image_collapse_window_create(ima_ord,1,sky2_lly,
527 sx,sky2_ury,0));
528 check(cpl_image_divide_scalar(ima_sky1,sky1_ury-sky1_lly+1));
529 check(cpl_image_divide_scalar(ima_sky2,sky2_ury-sky2_lly+1));
530
531
532 check(ima_sky=cpl_image_duplicate(ima_sky1));
533 check(cpl_image_add(ima_sky,ima_sky2));
534 check(cpl_image_divide_scalar(ima_sky,2));
535 check(cpl_image_multiply_scalar(ima_sky,obj_ury-obj_lly+1));
536 check(cpl_image_subtract(ima_obj,ima_sky));
537
538 check(pobj=cpl_image_get_data_double(ima_obj));
539 check(crval1=xsh_pfits_get_crval1(plist));
540 check(cdelt1=xsh_pfits_get_cdelt1(plist));
541 //pcor[i]=poh_pfits_get_cdelt1(plist));
542
543
544 for(j=0;j<naxis1;j++) {
545
546 wav=crval1+cdelt1*j;
547 pw[k+j]=wav;
548 po[k+j]=i/3;
550 ( (po[k+j]==3) ||(po[k+j]==8) ) ) {
551 pf[k+j]=0;
552 } else {
553 pf[k+j]=pobj[j];
554 }
555 }
556
557 k+=naxis1;
558 xsh_free_image(&ima_ord);
559 xsh_free_image(&ima_obj);
560 xsh_free_image(&ima_sky);
561 xsh_free_image(&ima_sky);
562 xsh_free_image(&ima_sky1);
563 xsh_free_image(&ima_sky2);
564 xsh_free_propertylist(&plist);
565
566
567 //pcor[i]=po
568 }
569 xsh_msg("Extracted spectrum sampling bin=%g [nm]",cdelt1);
570 check(name=cpl_frame_get_filename(frm_ref));
571 check(tbl_ref=cpl_table_load(name,1,0));
572 /* ref std spectrum wavelengh scale is in A units */
573 /* atm ext spectrum wavelengh scale in A units */
574 /* => we need to bring XSH spectrum to A */
575 /* In reference source the flux is in: erg/s/cm2/A */
576 /* In XSH the spectrum in in : erg/s/cm2/bin
577 we need to scale it to erg/s/cm2/A==> divide by bin/A */
578
579 /* express the extracted spectrum in AA units, same as reference */
580 cpl_table_multiply_scalar(obj_tab,"WAVELENGTH",nm2AA);
581
582
583 check(ref_wmin=cpl_table_get_column_min(tbl_ref,"WAVELENGTH"));
584 check(ref_wmax=cpl_table_get_column_max(tbl_ref,"WAVELENGTH"));
585 xsh_msg("Ref spectrum wmin=%g [A] wmax=%g [A]",ref_wmin,ref_wmax);
586
587 check(name=cpl_frame_get_filename(frm_atmext));
588 check(tbl_atmext=cpl_table_load(name,1,0));
589
590 //cpl_table_divide_scalar(tbl_atmext,"LAMBDA",10.);
591 check(ext_wmin=cpl_table_get_column_min(tbl_atmext,"LAMBDA"));
592 check(ext_wmax=cpl_table_get_column_max(tbl_atmext,"LAMBDA"));
593 xsh_msg("extinction wmin=%g [A] wmax=%g [A]",ext_wmin,ext_wmax);
594
595
596 check(cpl_table_new_column(obj_tab,"REF",CPL_TYPE_DOUBLE));
597 check(cpl_table_fill_column_window_double(obj_tab,"REF",0,nrow,-1));
598
599 check(cpl_table_new_column(obj_tab,"EXT",CPL_TYPE_DOUBLE));
600 check(cpl_table_fill_column_window_double(obj_tab,"EXT",0,nrow,-1));
601
602 check(cpl_table_new_column(obj_tab,"COR",CPL_TYPE_DOUBLE));
603 check(cpl_table_fill_column_window_double(obj_tab,"COR",0,nrow,-1));
604
605 check(cpl_table_new_column(obj_tab,"EPHOT",CPL_TYPE_DOUBLE));
606 check(cpl_table_fill_column_window_double(obj_tab,"EPHOT",0,nrow,-1));
607
608
609 check(pref=cpl_table_get_data_double(obj_tab,"REF"));
610 check(pext=cpl_table_get_data_double(obj_tab,"EXT"));
611 check(pcor=cpl_table_get_data_double(obj_tab,"COR"));
612 check(peph=cpl_table_get_data_double(obj_tab,"EPHOT"));
613
614 check(pw=cpl_table_get_data_double(obj_tab,"WAVELENGTH"));
615 check(pf=cpl_table_get_data_double(obj_tab,"FLUX"));
616 xsh_msg("Resample atmosphere and std star");
617 for(i=0;i<nrow;i++) {
618
619
620 check(pext[i]=xsh_table_get_interpolated(tbl_atmext,pw[i],"LAMBDA",
622
623 check(pref[i]=xsh_table_get_interpolated(tbl_ref,pw[i],
624 "WAVELENGTH","FLUX"));
625
626 pcor[i]=pow(10,(0.4*pext[i]*aimprim));
627 if(airmass != 0) pcor[i]/=pow(10,(0.4*pext[i]*airmass));
628 peph[i]=1.e7*1.986e-19/(pw[i]*1e-4);
629 /* ph energy: 1.986*10^-19(J.ph^-1)/lam(um) */
630
631 }
632 xsh_msg("apply corrections");
633 check(cpl_table_duplicate_column(obj_tab,"SRC_COR",obj_tab,"FLUX"));
634 check(cpl_table_multiply_columns(obj_tab,"SRC_COR","COR"));
635
636 /* correct flux by binning: divides by binsize in AA: cdelt1[nm]*nm2AA */
637 cpl_table_divide_scalar(obj_tab,"SRC_COR",nm2AA);
638 cpl_table_divide_scalar(obj_tab,"SRC_COR",cdelt1);
639 cpl_table_divide_scalar(obj_tab,"SRC_COR",biny);
640
641 check(cpl_table_duplicate_column(obj_tab,"EFF",obj_tab,"SRC_COR"));
642 //check(cpl_table_divide_scalar(obj_tab,"EFF",binsize));
643 check(cpl_table_multiply_scalar(obj_tab,"EFF",gain));
644 check(cpl_table_multiply_columns(obj_tab,"EFF","EPHOT"));
645 check(cpl_table_divide_scalar(obj_tab,"EFF",exptime));
646 check(cpl_table_divide_scalar(obj_tab,"EFF",TEL_AREA));
647 check(cpl_table_divide_columns(obj_tab,"EFF","REF"));
648
649
650 cpl_table_and_selected_double(obj_tab,"EFF",CPL_GREATER_THAN,1.e-5);
651 cpl_table_and_selected_double(obj_tab,"EFF",CPL_LESS_THAN,1.);
652 tbl_sel=cpl_table_extract_selected(obj_tab);
653
654
655 check( cpl_table_save(tbl_sel, NULL, NULL,"eff.fits", CPL_IO_DEFAULT));
656
657
658 xsh_free_table(&obj_tab);
659
660 cleanup:
661 xsh_free_table(&tbl_sel);
662 xsh_free_image(&ima_sci);
663 xsh_free_table(&obj_tab);
664 xsh_free_table(&tbl_ref);
665 xsh_free_table(&tbl_ext);
666 xsh_free_table(&tbl_atmext);
668
669 xsh_free_image(&ima_ord);
670 xsh_free_image(&ima_obj);
671 xsh_free_image(&ima_sky);
672 xsh_free_image(&ima_sky);
673 xsh_free_image(&ima_sky1);
674 xsh_free_image(&ima_sky2);
675 xsh_free_propertylist(&plist);
676 xsh_free_frameset(&raws);
677 xsh_free_frameset(&calib);
679
680 if (cpl_error_get_code()) {
681 return -1 ;
682 } else {
683 return 0 ;
684 }
685
686}
static double exptime
static xsh_instrument * instrument
int biny
#define check(COMMAND)
Definition: xsh_error.h:71
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
int * y
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
double xsh_pfits_get_conad(const cpl_propertylist *plist)
find out the CONAD value
Definition: xsh_pfits.c:692
double xsh_pfits_get_airm_end(const cpl_propertylist *plist)
find out the TEL AIRM END value
Definition: xsh_pfits.c:527
double xsh_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
Definition: xsh_pfits.c:1405
double xsh_pfits_get_win1_dit1(const cpl_propertylist *plist)
find out the DET WIN1 DIT1 value
Definition: xsh_pfits.c:1385
double xsh_pfits_get_cdelt1(const cpl_propertylist *plist)
find out the cdelt1
Definition: xsh_pfits.c:2196
int xsh_pfits_get_biny(const cpl_propertylist *plist)
find out the BINY value
Definition: xsh_pfits.c:306
int xsh_pfits_get_naxis1(const cpl_propertylist *plist)
find out the NAXIS1 value
Definition: xsh_pfits.c:227
double xsh_pfits_get_crval1(const cpl_propertylist *plist)
find out the crval1
Definition: xsh_pfits.c:1907
double xsh_pfits_get_airm_start(const cpl_propertylist *plist)
find out the TEL AIRM START value
Definition: xsh_pfits.c:496
static cpl_vector * rec_profile
Definition: xsh_rectify.c:80
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int xsh_util_efficiency2d_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static int xsh_util_efficiency2d(cpl_parameterlist *, cpl_frameset *)
Get the command line options and execute the data reduction.
static int xsh_util_efficiency2d_create(cpl_plugin *)
Setup the recipe options
static int xsh_util_efficiency2d_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static double xsh_table_get_interpolated(cpl_table *tbl, double wav, const char *colx, const char *coly)
void xsh_free_vector(cpl_vector **v)
Deallocate a vector and set the pointer to NULL.
Definition: xsh_utils.c:2284
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
Definition: xsh_utils.c:2116
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_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
Definition: xsh_utils.c:2133
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
Definition: xsh_utils.c:2179
#define XSH_ATMOS_EXT_LIST_COLNAME_K
@ XSH_ARM_NIR
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_EXTCOEFF_TAB
Definition: xsh_dfs.h:277
#define XSH_RAW_IMA_SLIT
Definition: xsh_dfs.h:241
#define XSH_FLUX_STD_TAB
Definition: xsh_dfs.h:266
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
#define RECIPE_CONTACT
static char xsh_util_efficiency2d_description[]
#define TEL_AREA
static char xsh_util_efficiency2d_description_short[]
#define RECIPE_ID
#define RECIPE_AUTHOR