00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029
00035
00038
00039
00040
00041
00042
00043 #include <xsh_data_star_flux.h>
00044 #include <xsh_error.h>
00045 #include <xsh_msg.h>
00046 #include <xsh_data_instrument.h>
00047 #include <xsh_dfs.h>
00048 #include <xsh_pfits.h>
00049 #include <tests.h>
00050 #include <xsh_utils_table.h>
00051 #include <cpl.h>
00052 #include <math.h>
00053 #include <getopt.h>
00054
00055
00056
00057
00058 #define MODULE_ID "XSH_DATA_STAR_FLUX"
00059
00060 #define SYNTAX "Test the order table\n"\
00061 "usage : test_xsh_data_star_flux std_star_flux_table \n"\
00062 "std_star_flux_table => the Standard Star Flux tabe FITS file\n"
00063
00064
00065
00066
00067
00068
00069
00077
00078 int main(int argc, char** argv)
00079 {
00080 int ret = 0;
00081
00082 char * star_tab_name = NULL;
00083 cpl_frame * star_tab_frame = NULL;
00084 xsh_star_flux_list * star_list = NULL ;
00085 double * plambda = NULL, *pflux = NULL ;
00086 int star_tab_size, i ;
00087
00088
00089 TESTS_INIT(MODULE_ID);
00090 cpl_msg_set_level(CPL_MSG_DEBUG);
00091 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM) ;
00092
00093
00094 if ( optind < argc ) {
00095 star_tab_name = argv[optind] ;
00096 }
00097 else{
00098 printf(SYNTAX);
00099 return 0;
00100 }
00101
00102
00103 XSH_ASSURE_NOT_NULL( star_tab_name);
00104 star_tab_frame = cpl_frame_new();
00105 cpl_frame_set_filename( star_tab_frame, star_tab_name) ;
00106 cpl_frame_set_level( star_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
00107 cpl_frame_set_group( star_tab_frame, CPL_FRAME_GROUP_CALIB );
00108
00109 check( star_list = xsh_star_flux_list_load( star_tab_frame ) ) ;
00110 star_tab_size = star_list->size ;
00111 xsh_msg( "Star Table size: %d", star_tab_size ) ;
00112
00113
00114 plambda = star_list->lambda ;
00115 pflux = star_list->flux ;
00116
00117 for ( i = 0 ; i < star_tab_size ; i++, plambda++, pflux++ ) {
00118 xsh_msg( " %3d: %lf %lf", i, *plambda, *pflux ) ;
00119 }
00120
00121 {
00122 FILE * fout ;
00123
00124 fout = fopen( "star_flux.dat", "w" ) ;
00125 plambda = star_list->lambda ;
00126 pflux = star_list->flux ;
00127 for ( i = 0 ; i < star_tab_size ; i++, plambda++, pflux++ )
00128 fprintf( fout, "%lf %lf\n", *plambda, *pflux ) ;
00129 fclose( fout ) ;
00130 }
00131
00132 cleanup:
00133 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00134 xsh_error_dump(CPL_MSG_ERROR);
00135 ret = 1;
00136 }
00137 xsh_star_flux_list_free( &star_list);
00138
00139 return ret ;
00140 }
00141