X-shooter Pipeline Reference Manual 3.8.15
xsh_ifu.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: 2011-12-02 14:15:28 $
23 * $Revision: 1.5 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
41/*-----------------------------------------------------------------------------
42 Includes
43 ----------------------------------------------------------------------------*/
44
45#include <xsh_data_shift_tab.h>
46#include <xsh_utils.h>
47#include <xsh_utils_table.h>
48#include <xsh_error.h>
49#include <xsh_msg.h>
50#include <xsh_pfits.h>
51#include <cpl.h>
52#include <xsh_drl.h>
53#include <math.h>
54
55/*----------------------------------------------------------------------------
56 Function implementation
57 ----------------------------------------------------------------------------*/
58
59/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71cpl_frameset* xsh_ifu_wavetab_create( cpl_frame *wavetab_frame,
72 cpl_frame *shifttab_frame, xsh_instrument *instr)
73{
74 cpl_frameset *result = NULL;
75 xsh_shift_tab *shift_tab = NULL;
76 xsh_wavesol *wavesol_cen = NULL;
77 xsh_wavesol *wavesol_up = NULL;
78 xsh_wavesol *wavesol_down = NULL;
79 char result_name[256];
80 const char *tag = NULL;
81 cpl_table *trace = NULL;
82 cpl_frame *down_frame = NULL;
83 cpl_frame *cen_frame = NULL;
84 cpl_frame *up_frame = NULL;
85
86 XSH_ASSURE_NOT_NULL( wavetab_frame);
87 XSH_ASSURE_NOT_NULL( instr);
88
89 check( wavesol_down = xsh_wavesol_load( wavetab_frame, instr));
90 check( wavesol_cen = xsh_wavesol_load( wavetab_frame, instr));
91 check( wavesol_up = xsh_wavesol_load( wavetab_frame, instr));
92
93 if ( shifttab_frame != NULL){
94 check( shift_tab = xsh_shift_tab_load( shifttab_frame, instr));
95 check( xsh_wavesol_apply_shift( wavesol_down, 0.0,
96 shift_tab->shift_y_down));
97 check( xsh_wavesol_apply_shift( wavesol_cen, 0.0,
98 shift_tab->shift_y_cen));
99 check( xsh_wavesol_apply_shift( wavesol_up, 0.0,
100 shift_tab->shift_y_up));
101 }
102 check( trace = cpl_table_new(1));
103
104 check( result = cpl_frameset_new());
105
107 sprintf( result_name, "%s.fits", tag);
108 check( down_frame = xsh_wavesol_save( wavesol_down,
109 trace, result_name, tag));
110 check( cpl_frameset_insert( result, down_frame));
111
113 sprintf( result_name, "%s.fits", tag);
114 check( cen_frame = xsh_wavesol_save( wavesol_cen,
115 trace, result_name, tag));
116 check( cpl_frameset_insert( result, cen_frame));
117
119 sprintf( result_name, "%s.fits", tag);
120 check( up_frame = xsh_wavesol_save( wavesol_up,
121 trace, result_name, tag));
122 check( cpl_frameset_insert( result, up_frame));
123
124 cleanup:
125 if ( cpl_error_get_code() != CPL_ERROR_NONE){
126 xsh_free_frameset( &result);
127 }
128 xsh_shift_tab_free( &shift_tab);
129 xsh_wavesol_free( &wavesol_down);
130 xsh_wavesol_free( &wavesol_cen);
131 xsh_wavesol_free( &wavesol_up);
132 xsh_free_table( &trace);
133 return result;
134}
135/*---------------------------------------------------------------------------*/
136
void xsh_shift_tab_free(xsh_shift_tab **tab)
Free memory associated to a the_arcline.
xsh_shift_tab * xsh_shift_tab_load(cpl_frame *frame, xsh_instrument *instr)
Load a shift table.
void xsh_wavesol_apply_shift(xsh_wavesol *wsol, float shift_x, float shift_y)
Apply a shift on X and Y to wave solution.
xsh_wavesol * xsh_wavesol_load(cpl_frame *frame, xsh_instrument *instrument)
load a wavelength solution
void xsh_wavesol_free(xsh_wavesol **w)
free wavelength solution structure
cpl_frame * xsh_wavesol_save(xsh_wavesol *w, cpl_table *trace, const char *filename, const char *tag)
save a wavelength solution
#define check(COMMAND)
Definition: xsh_error.h:71
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
cpl_frameset * xsh_ifu_wavetab_create(cpl_frame *wavetab_frame, cpl_frame *shifttab_frame, xsh_instrument *instr)
Create an IFU wave tab frame set.
Definition: xsh_ifu.c:71
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
Definition: xsh_utils.c:2254
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
Definition: xsh_utils.c:2133
#define XSH_WAVE_TAB_ARC_CEN_IFU
Definition: xsh_dfs.h:560
#define XSH_WAVE_TAB_ARC_DOWN_IFU
Definition: xsh_dfs.h:559
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
Definition: xsh_dfs.h:1548
#define XSH_WAVE_TAB_ARC_UP_IFU
Definition: xsh_dfs.h:561