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_atmos_ext.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_ATMOS_EXT"
00059
00060 #define SYNTAX "Test the atmos Extinction table\n"\
00061 "usage : test_xsh_data_atmos_ext atmos_ext \n"\
00062 "atmos_ext_table => the Atmos Ext table 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 * ext_tab_name = NULL;
00083 cpl_frame * ext_tab_frame = NULL;
00084 xsh_atmos_ext_list * ext_list = NULL ;
00085 double * plambda = NULL, *pK = NULL ;
00086 int ext_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 ext_tab_name = argv[optind] ;
00096 }
00097 else{
00098 printf(SYNTAX);
00099 return 0;
00100 }
00101
00102
00103 XSH_ASSURE_NOT_NULL( ext_tab_name);
00104 ext_tab_frame = cpl_frame_new();
00105 cpl_frame_set_filename( ext_tab_frame, ext_tab_name) ;
00106 cpl_frame_set_level( ext_tab_frame, CPL_FRAME_LEVEL_TEMPORARY);
00107 cpl_frame_set_group( ext_tab_frame, CPL_FRAME_GROUP_CALIB );
00108
00109 check( ext_list = xsh_atmos_ext_list_load( ext_tab_frame ) ) ;
00110 ext_tab_size = ext_list->size ;
00111 xsh_msg( "Atmos Ext Table size: %d", ext_tab_size ) ;
00112
00113
00114 plambda = ext_list->lambda ;
00115 pK = ext_list->K ;
00116
00117 for ( i = 0 ; i < ext_tab_size ; i++, plambda++, pK++ ) {
00118 xsh_msg( " %3d: %lf %lf", i, *plambda, *pK ) ;
00119 }
00120
00121 {
00122 FILE * fout ;
00123
00124 fout = fopen( "atmos_ext.dat", "w" ) ;
00125 plambda = ext_list->lambda ;
00126 pK = ext_list->K ;
00127 for ( i = 0 ; i < ext_tab_size ; i++, plambda++, pK++ )
00128 fprintf( fout, "%lf %lf\n", *plambda, *pK ) ;
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_atmos_ext_list_free( &ext_list);
00138
00139 return ret ;
00140 }
00141