X-shooter Pipeline Reference Manual 3.8.15
test-xsh_telluric_cor.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-05-14 07:02:49 $
23 * $Revision: 1.12 $
24 * $Name: not supported by cvs2svn $
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
36/*--------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------
40 Includes
41 ---------------------------------------------------------------------------*/
42#include <xsh_data_spectrum.h>
43#include <xsh_data_instrument.h>
44#include <xsh_utils_response.h>
45#include <xsh_msg.h>
46#include <xsh_error.h>
47#include <cpl.h>
48
49
50
51#include <xsh_utils.h>
52#include <tests.h>
53#include <math.h>
54#include <time.h>
55#include <sys/time.h>
56/*---------------------------------------------------------------------------
57 Defines
58 ---------------------------------------------------------------------------*/
59#define MODULE_ID "XSH_TELLURIC_COR"
60
61
62/*--------------------------------------------------------------------------*/
68/*--------------------------------------------------------------------------*/
69int main( int argc, char** argv)
70{
71 int ret = 0;
72 char *name_model = NULL;
73 char *name_spectrum = NULL;
74 xsh_spectrum* s=NULL;
75 cpl_frame* frame_s=NULL;
76 cpl_frame* frame_m=NULL;
77 //int i=0;
78
80 cpl_msg_set_level( CPL_MSG_DEBUG);
82
84 //int status=0;
85 //double model_mean=0;
86 //double model_rms=0;
87 cpl_size model_idx=0;
88
89 //double wstp=0;
90 cpl_table* tab_res=NULL;
91
92 if (argc > 1){
93 name_spectrum = argv[1];
94 name_model = argv[2];
95 }
96 else{
97 return 0;
98 }
99
102
103 frame_m=cpl_frame_new();
104 cpl_frame_set_filename(frame_m,name_model);
105 cpl_frame_set_type(frame_m,CPL_FRAME_TYPE_TABLE);
106
107 /* load input observed spectrum and convert it into a table
108 to easy to perform following corrections */
109 frame_s=cpl_frame_new();
110
111 cpl_frame_set_filename(frame_s,name_spectrum);
112 cpl_frame_set_type(frame_s,CPL_FRAME_TYPE_IMAGE);
113 //xsh_msg("no extension=%d",(int)cpl_frame_get_nextensions(frame));
114 check(s=xsh_spectrum_load(frame_s));
115
116 check(tab_res=xsh_telluric_model_eval(frame_m,s,instrument,&model_idx));
117
118 cleanup:
121 xsh_free_table(&tab_res);
122
123 if (cpl_error_get_code() != CPL_ERROR_NONE) {
124 xsh_error_dump(CPL_MSG_ERROR);
125 ret = 1;
126 }
127 return ret;
128}
129
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
xsh_spectrum * xsh_spectrum_load(cpl_frame *s1d_frame)
Load a 1D spectrum structure.
void xsh_spectrum_free(xsh_spectrum **s)
free memory associated to an 1D spectrum
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
static SimAnneal s
Definition: xsh_model_sa.c:99
cpl_table * xsh_telluric_model_eval(cpl_frame *frame_m, xsh_spectrum *s, xsh_instrument *instrument, cpl_size *model_idx)
#define MODULE_ID
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
Definition: xsh_utils.c:2133
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
@ XSH_ARM_NIR
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138