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 #include <xsh_data_spectrum.h>
00043 #include <xsh_data_instrument.h>
00044 #include <xsh_utils_response.h>
00045 #include <xsh_msg.h>
00046 #include <xsh_error.h>
00047 #include <cpl.h>
00048
00049
00050
00051 #include <xsh_utils.h>
00052 #include <tests.h>
00053 #include <math.h>
00054 #include <time.h>
00055 #include <sys/time.h>
00056
00057
00058
00059 #define MODULE_ID "XSH_CPL_FIT"
00060
00061
00062
00068
00069 int main( int argc, char** argv)
00070 {
00071 int ret = 0;
00072 char *name_model = NULL;
00073 char *name_spectrum = NULL;
00074 xsh_spectrum* s=NULL;
00075 cpl_frame* frame_s=NULL;
00076 cpl_frame* frame_m=NULL;
00077
00078
00079 TESTS_INIT( MODULE_ID);
00080 cpl_msg_set_level( CPL_MSG_DEBUG);
00081 xsh_debug_level_set( XSH_DEBUG_LEVEL_MEDIUM) ;
00082
00083 xsh_instrument* instrument = NULL;
00084 int status=0;
00085 double model_mean=0;
00086 double model_rms=0;
00087 int model_idx=0;
00088
00089
00090 cpl_table* tab_res=NULL;
00091
00092 if (argc > 1){
00093 name_spectrum = argv[1];
00094 name_model = argv[2];
00095 }
00096 else{
00097 return 0;
00098 }
00099
00100 instrument = xsh_instrument_new();
00101 xsh_instrument_set_arm(instrument, XSH_ARM_NIR);
00102
00103 frame_m=cpl_frame_new();
00104 cpl_frame_set_filename(frame_m,name_model);
00105 cpl_frame_set_type(frame_m,CPL_FRAME_TYPE_TABLE);
00106
00107
00108
00109 frame_s=cpl_frame_new();
00110
00111 cpl_frame_set_filename(frame_s,name_spectrum);
00112 cpl_frame_set_type(frame_s,CPL_FRAME_TYPE_IMAGE);
00113
00114 check(s=xsh_spectrum_load(frame_s));
00115
00116 check(tab_res=xsh_telluric_model_eval(frame_m,s,instrument,&model_idx));
00117
00118 cleanup:
00119 xsh_instrument_free(&instrument);
00120 xsh_spectrum_free(&s);
00121 xsh_free_table(&tab_res);
00122
00123 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00124 xsh_error_dump(CPL_MSG_ERROR);
00125 ret = 1;
00126 }
00127 return ret;
00128 }
00129