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
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030
00036
00039
00040
00041
00042
00043 #include <tests.h>
00044
00045 #include <xsh_error.h>
00046 #include <xsh_msg.h>
00047 #include <xsh_drl.h>
00048 #include <cpl.h>
00049 #include <math.h>
00050
00051 #include <string.h>
00052 #include <getopt.h>
00053
00054
00055
00056
00057
00058 #define MODULE_ID "XSH_COMPUTE_ABSORP"
00059
00060 enum {
00061 FILTER_HSIZE_OPT, THRESH_OPT, HELP_OPT
00062 } ;
00063
00064 static struct option long_options[] = {
00065 {"filter-hsize", required_argument, 0, FILTER_HSIZE_OPT},
00066 {"threshold", required_argument, 0, THRESH_OPT},
00067 {"help", 0, 0, HELP_OPT},
00068 {0, 0, 0, 0}
00069 };
00070
00071 static void Help( void )
00072 {
00073 puts( "Unitary test of xsh_compute_absorp");
00074 puts( "Usage: test_xsh_compute_absorp [options] S1D TELLLIST");
00075
00076 puts( "Options" ) ;
00077 puts( " --help : What you see" ) ;
00078 puts( " --filter-hsize= : Half size of filter");
00079 puts( " --threshold= : Threshold");
00080 puts( "\nInput Files" ) ;
00081 puts( "S1D : 1D spectrum file");
00082 puts( "TELLLIST : tell line list");
00083 TEST_END();
00084 }
00085
00086
00087 static void HandleOptions( int argc, char **argv,
00088 int *filter_hsize, double *threshold)
00089 {
00090 int opt ;
00091 int option_index = 0;
00092
00093 while (( opt = getopt_long (argc, argv,
00094 "filter-hsize",
00095 long_options, &option_index)) != EOF ){
00096
00097 switch ( opt ) {
00098 case FILTER_HSIZE_OPT:
00099 *filter_hsize = atoi( optarg);
00100 break;
00101 case THRESH_OPT:
00102 *threshold = atof( optarg);
00103 break;
00104 default:
00105 Help(); exit(-1);
00106 }
00107 }
00108 return;
00109 }
00110
00111
00112 int main( int argc, char **argv)
00113 {
00114
00115 int ret = 0 ;
00116 int filter_hsize = 5;
00117 double threshold = 0.0;
00118 const char *s1d_name = NULL;
00119 cpl_frame *s1d_frame = NULL;
00120 const char *tell_name = NULL;
00121 cpl_frame *tell_frame = NULL;
00122 xsh_instrument *instr = NULL;
00123
00124
00125 TESTS_INIT(MODULE_ID);
00126
00127 cpl_msg_set_level(CPL_MSG_DEBUG);
00128 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM);
00129
00130
00131 HandleOptions( argc, argv, &filter_hsize, &threshold);
00132
00133 if ( (argc - optind) > 1 ) {
00134 s1d_name = argv[optind];
00135 tell_name = argv[optind+1];
00136 }
00137 else {
00138 Help();
00139 exit( 0);
00140 }
00141
00142 xsh_msg("---Input Files");
00143 xsh_msg("S1D File : %s ", s1d_name);
00144 xsh_msg("Telllist File : %s ", tell_name);
00145 xsh_msg("---Options");
00146 xsh_msg("Filter hsize : %d ", filter_hsize);
00147 xsh_msg("Threshold : %f ", threshold);
00148
00149 instr = xsh_instrument_new();
00150 xsh_instrument_set_arm( instr, XSH_ARM_UVB);
00151 TESTS_XSH_FRAME_CREATE( s1d_frame, "S1D", s1d_name);
00152 TESTS_XSH_FRAME_CREATE( tell_frame, "TELL_LINE_LIST", tell_name);
00153
00154 check( xsh_compute_absorp( s1d_frame, tell_frame, filter_hsize, threshold, instr));
00155
00156 cleanup:
00157 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00158 xsh_error_dump(CPL_MSG_ERROR);
00159 ret=1;
00160 }
00161 xsh_instrument_free( &instr);
00162 xsh_free_frame( &s1d_frame);
00163 xsh_free_frame( &tell_frame);
00164 TEST_END();
00165 return ret ;
00166 }
00167