X-shooter Pipeline Reference Manual 3.8.15
test-telluric_sampling.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/*--------------------------------------------------------------------------*/
62int main( int argc, char** argv)
63{
64 int ret = 0;
65
67 cpl_msg_set_level( CPL_MSG_DEBUG);
69
70 char name1[256];
71 char name2[256];
72
73 cpl_table* tab1=NULL;
74 cpl_table* tab2=NULL;
75 cpl_table* tabo=NULL;
76 cpl_propertylist* plist=NULL;
77
78 int nrows;
79 double* pratio=NULL;
80 double* praw1=NULL;
81 double* praw2=NULL;
82 float* pwav1=NULL;
83 double* pwavo=NULL;
84 double mean=0;
85 double rms=0;
86 double median=0;
87 double min=0;
88 double max=0;
89 int i=0;
90 xsh_msg("argc=%d",argc);
91 if((size_t)argc != 3){
92 xsh_msg_error("Provide two inputs: resp1, resp2 tables");
93 } else {
94 sprintf(name1,argv[1]);
95 sprintf(name2,argv[2]);
96 }
97
98 tab1=cpl_table_load(name1, 1, 1);
99 tab2=cpl_table_load(name1, 1, 1);
100 nrows=cpl_table_get_nrow(tab1);
101
102 tabo=cpl_table_new(nrows);
103 cpl_table_new_column(tabo,"wave",CPL_TYPE_DOUBLE);
104 cpl_table_new_column(tabo,"ratio",CPL_TYPE_DOUBLE);
105
106 cpl_table_fill_column_window_double(tabo, "ratio", 0, nrows, 0);
107 cpl_table_fill_column_window_double(tabo, "wave", 0, nrows, 0);
108 pratio=cpl_table_get_data_double(tabo,"ratio");
109 praw1=cpl_table_get_data_double(tab1,"REF_DIV_OBS");
110
111 praw2=cpl_table_get_data_double(tab2,"REF_DIV_OBS");
112 pwav1=cpl_table_get_data_float(tab1,"LAMBDA");
113 pwavo=cpl_table_get_data_double(tabo,"wave");
114 for(i=0;i<nrows;i++) {
115 pwavo[i]=(double)pwav1[i];
116 pratio[i]=praw1[i]/praw2[i];
117 }
118
119 mean=cpl_table_get_column_mean(tabo,"ratio");
120 median=cpl_table_get_column_median(tabo,"ratio");
121 min=cpl_table_get_column_min(tabo,"ratio");
122 max=cpl_table_get_column_max(tabo,"ratio");
123 rms=cpl_table_get_column_stdev(tabo,"ratio");
124
125 plist=cpl_propertylist_new();
126 cpl_propertylist_append_double(plist,"MEAN",mean);
127 cpl_propertylist_append_double(plist,"MEDIAN",median);
128 cpl_propertylist_append_double(plist,"RMS",rms);
129 cpl_propertylist_append_double(plist,"MIN",min);
130 cpl_propertylist_append_double(plist,"MAX",max);
131
132 cpl_table_save(tabo,plist,NULL,"ratio.fits",CPL_IO_DEFAULT);
133
134 cpl_table_delete(tab1);
135 cpl_table_delete(tab2);
136 cpl_table_delete(tabo);
137 cpl_propertylist_delete(plist);
138 xsh_msg_warning("statistic: mean: %g median: %g rms: %g min: %g max: %g",
139 mean,median,rms,min,max);
140 cleanup:
141 if (cpl_error_get_code() != CPL_ERROR_NONE) {
142 xsh_error_dump(CPL_MSG_ERROR);
143 ret = 1;
144 }
145 return ret;
146}
147
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_error(...)
Print an error message.
Definition: xsh_msg.h:62
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define MODULE_ID
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
#define max(a, b)
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138