X-shooter Pipeline Reference Manual 3.8.15
test-tell_catalog.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:13:14 $
23 * $Revision: 1.3 $
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_utils.h>
43#include <xsh_error.h>
44#include <xsh_msg.h>
45#include <tests.h>
46#include <cpl.h>
47#include <math.h>
48#include <time.h>
49#include <sys/time.h>
50/*---------------------------------------------------------------------------
51 Defines
52 ---------------------------------------------------------------------------*/
53#define MODULE_ID "CPL_IMAGE_FIT_GAUSSIAN"
54
55/*--------------------------------------------------------------------------*/
61/*--------------------------------------------------------------------------*/
63{
64 int ret = 0;
65
66 char namei[180];
67 char nameo[80];
68 cpl_table* tbl=NULL;
69 cpl_propertylist* plist=NULL;
70 int next=2; //72
71 int nrow;
72 double* wave=NULL;
73 double lambda=0;
74 double lambda2=0;
75 double lambda4=0;
76
77 double lam_c=0;
78 int i=0;
79 int j=0;
80 double um2angstrom=1.e4;
81
82 cpl_frame* frame=NULL;
83
84 sprintf(namei,"/home/amodigli/pipelines/workspace/xshoop/xsh/tests/telluric_model_catalog_vis.fits");
85 sprintf(nameo,"telluric_model_catalog_vis_new.fits");
86 frame=cpl_frame_new();
87 cpl_frame_set_filename(frame,namei);
88 cpl_frame_set_type(frame,CPL_FRAME_TYPE_TABLE);
89 cpl_frame_set_tag(frame,"TEST");
90 cpl_frame_set_group(frame,CPL_FRAME_GROUP_CALIB);
91 next=cpl_frame_get_nextensions(frame);
92
93 for(i=0;i<next;i++) {
94 xsh_msg_warning("process ext %d",i);
95 tbl=cpl_table_load(namei, i+1, 1);
96 plist=cpl_propertylist_load(namei,i);
97 nrow=cpl_table_get_nrow(tbl);
98 xsh_msg("nrow %d",nrow);
99 wave=cpl_table_get_data_double(tbl,"lam");
100 for(j=0;j<nrow;j++) {
101 /* the coefficient below refers to Angstrom units while the telluric
102 * model catalog has wavelengths expressed in um
103 */
104 lambda=1.e4*wave[j];
105 lambda2=lambda*lambda;
106 lambda4=lambda2*lambda2;
107 /* to come back to um we multiply by 10-4 */
108 lam_c=1.e-4*lambda/(1.0002735182+131.4182/lambda2+2.76249e8/lambda4);
109 wave[j]=lam_c;
110 }
111 xsh_msg("saving ext %d",i);
112 if(i==0) {
113 cpl_table_save(tbl,plist,NULL,nameo,CPL_IO_DEFAULT);
114 } else {
115 cpl_table_save(tbl,plist,NULL,nameo,CPL_IO_EXTEND);
116 }
117
118
119 xsh_msg("saved ext %d",i);
120 xsh_free_table(&tbl);
121 xsh_free_propertylist(&plist);
122 }
123 cpl_frame_delete(frame);
124
125 cleanup:
126 if (cpl_error_get_code() != CPL_ERROR_NONE) {
127 xsh_error_dump(CPL_MSG_ERROR);
128 ret = 1;
129 }
130 return ret;
131}
132
133
134int main(int argc, char* argv[])
135{
136
137 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
138 //test_catalog();
139
140
141 return cpl_test_end(0);
142}
143
144
int main()
Unit test of xsh_bspline_interpol.
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#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
int test_catalog()
Some test about performances.
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