X-shooter Pipeline Reference Manual 3.8.15
test-xsh_data_star_flux.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: 2009-09-27 10:35:23 $
23 * $Revision: 1.3 $
24 */
25#ifdef HAVE_CONFIG_H
26# include <config.h>
27#endif
28
29/*--------------------------------------------------------------------------*/
35/*--------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------
39 Includes
40 ---------------------------------------------------------------------------*/
41
42
43#include <xsh_data_star_flux.h>
44#include <xsh_error.h>
45#include <xsh_msg.h>
46#include <xsh_data_instrument.h>
47#include <xsh_dfs.h>
48#include <xsh_pfits.h>
49#include <tests.h>
50#include <xsh_utils_table.h>
51#include <cpl.h>
52#include <math.h>
53#include <getopt.h>
54
55/*---------------------------------------------------------------------------
56 Defines
57 ---------------------------------------------------------------------------*/
58#define MODULE_ID "XSH_DATA_STAR_FLUX"
59
60#define SYNTAX "Test the order table\n"\
61 "usage : test_xsh_data_star_flux std_star_flux_table \n"\
62 "std_star_flux_table => the Standard Star Flux tabe FITS file\n"
63
64
65/*--------------------------------------------------------------------------
66 Implementation
67 --------------------------------------------------------------------------*/
68
69/*--------------------------------------------------------------------------*/
77/*--------------------------------------------------------------------------*/
78int main(int argc, char** argv)
79{
80 int ret = 0;
81
82 char * star_tab_name = NULL;
83 cpl_frame * star_tab_frame = NULL;
84 xsh_star_flux_list * star_list = NULL ;
85 double * plambda = NULL, *pflux = NULL ;
86 int star_tab_size, i ;
87
88 /* Initialize libraries */
90 cpl_msg_set_level(CPL_MSG_DEBUG);
92
93 /* Analyse parameters */
94 if ( optind < argc ) {
95 star_tab_name = argv[optind] ;
96 }
97 else{
98 printf(SYNTAX);
99 return 0;
100 }
101
102 /* Create frames */
103 XSH_ASSURE_NOT_NULL( star_tab_name);
104 star_tab_frame = cpl_frame_new();
105 cpl_frame_set_filename( star_tab_frame, star_tab_name) ;
106 cpl_frame_set_level( star_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
107 cpl_frame_set_group( star_tab_frame, CPL_FRAME_GROUP_CALIB );
108
109 check( star_list = xsh_star_flux_list_load( star_tab_frame ) ) ;
110 star_tab_size = star_list->size ;
111 xsh_msg( "Star Table size: %d", star_tab_size ) ;
112
113 /* Dump star data */
114 plambda = star_list->lambda ;
115 pflux = star_list->flux ;
116
117 for ( i = 0 ; i < star_tab_size ; i++, plambda++, pflux++ ) {
118 xsh_msg( " %3d: %lf %lf", i, *plambda, *pflux ) ;
119 }
120 /* dump to file */
121 {
122 FILE * fout ;
123
124 fout = fopen( "star_flux.dat", "w" ) ;
125 plambda = star_list->lambda ;
126 pflux = star_list->flux ;
127 for ( i = 0 ; i < star_tab_size ; i++, plambda++, pflux++ )
128 fprintf( fout, "%lf %lf\n", *plambda, *pflux ) ;
129 fclose( fout ) ;
130 }
131
132 cleanup:
133 if (cpl_error_get_code() != CPL_ERROR_NONE) {
134 xsh_error_dump(CPL_MSG_ERROR);
135 ret = 1;
136 }
137 xsh_star_flux_list_free( &star_list);
138
139 return ret ;
140}
141
int main()
Unit test of xsh_bspline_interpol.
#define MODULE_ID
#define SYNTAX
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
void xsh_star_flux_list_free(xsh_star_flux_list **list)
xsh_star_flux_list * xsh_star_flux_list_load(cpl_frame *star_frame)
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138