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_order.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 XSH_FLOAT_PRECISION 0.000001
00059 #define MODULE_ID "XSH_SUBTRACT_SKY_NOD"
00060
00061 #define SYNTAX "Test xsh_subtract_sky_nod\n"\
00062 "usage : ./test_xsh_subtract_sky_nod [<o[tions>] <raw_file1> <raw_file2> ... \n"\
00063 " Subtract noded files 2 by 2).\n"\
00064 "<raw_files> the list of raw files, 2 by 2\n"\
00065
00066 #if 0
00067 static const char * Options = "?" ;
00068
00069 enum {
00070 POINT_OPT, SIZE_OPT, STEP_OPT, C_COLOR_OPT
00071 } ;
00072
00073 static struct option LongOptions[] = {
00074 {"point", required_argument, 0, POINT_OPT},
00075 {"size", required_argument, 0, SIZE_OPT},
00076 {"step", required_argument, 0, STEP_OPT},
00077 {"c-color", required_argument, 0, C_COLOR_OPT},
00078 {NULL, 0, 0, 0}
00079 } ;
00080
00081 static char PointType[16] ;
00082 static char PointSize[8] ;
00083 static int PointStep = 8 ;
00084 static char CentralColor[32] ;
00085 #endif
00086
00087
00088
00089
00090 #if 0
00091 static void HandleOptions( int argc, char ** argv )
00092 {
00093 int opt ;
00094 int option_index = 0;
00095
00096
00097 strcpy( PointType, "cross" ) ;
00098 strcpy( PointSize, "" ) ;
00099 strcpy( CentralColor, "green" ) ;
00100
00101 while( (opt = getopt_long( argc, argv, Options,
00102 LongOptions, &option_index )) != EOF )
00103 switch( opt ) {
00104 case POINT_OPT:
00105 strcpy( PointType, optarg ) ;
00106 break ;
00107 case SIZE_OPT:
00108 strcpy( PointSize, optarg ) ;
00109 break ;
00110 case STEP_OPT:
00111 sscanf( optarg, "%d", &PointStep ) ;
00112 break ;
00113 case C_COLOR_OPT:
00114 strcpy( CentralColor, optarg ) ;
00115 break ;
00116 default:
00117 printf( SYNTAX ) ;
00118 exit( 0 ) ;
00119 }
00120 }
00121 #endif
00122
00123
00131
00132 int main(int argc, char** argv)
00133 {
00134 int ret = 1;
00135 xsh_instrument * instrument = NULL ;
00136 cpl_frameset *set = NULL;
00137 cpl_frameset *ord_set = NULL;
00138 int nb_raw_frames , raw_modulo;
00139 cpl_frameset * pairs = NULL ;
00140 int mode=0;
00141
00142
00143 TESTS_INIT(MODULE_ID);
00144 cpl_msg_set_level(CPL_MSG_DEBUG);
00145 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM) ;
00146 #if 0
00147 HandleOptions( argc, argv );
00148 #endif
00149
00150
00151 if ( argc < 2 ) {
00152 printf(SYNTAX);
00153 TEST_END();
00154 return 0;
00155 }
00156 else {
00157
00158 int iarg = 1 ;
00159
00160 check( set = cpl_frameset_new() ) ;
00161 nb_raw_frames = 0 ;
00162
00163 for( iarg = 1 ; iarg < argc ; iarg++ ) {
00164 cpl_frame * input_frame = NULL ;
00165
00166 check( input_frame = cpl_frame_new() ) ;
00167 check(cpl_frame_set_filename( input_frame, argv[iarg] ) );
00168 check(cpl_frame_set_tag(input_frame, "OBJECT_SLIT_NOD_VIS" ) ) ;
00169 check(cpl_frame_set_group( input_frame, CPL_FRAME_GROUP_RAW ) ) ;
00170 check(cpl_frameset_insert( set, input_frame ) ) ;
00171 nb_raw_frames++ ;
00172 }
00173 }
00174 xsh_msg( "Nb of frames: %d", nb_raw_frames ) ;
00175
00176 instrument = xsh_instrument_new() ;
00177 XSH_ASSURE_NOT_NULL( instrument);
00178 xsh_instrument_set_mode( instrument, XSH_MODE_SLIT );
00179 xsh_instrument_set_arm( instrument, XSH_ARM_VIS);
00180
00181
00182 XSH_ASSURE_NOT_NULL( set );
00183
00184 raw_modulo = nb_raw_frames % 2;
00185 XSH_ASSURE_NOT_ILLEGAL( raw_modulo == 0);
00186
00187 check(xsh_prepare( set, NULL, (cpl_frame *)-1, XSH_OBJECT_SLIT_NOD,
00188 instrument,0));
00189 xsh_msg( "Now call xsh_subtract_sky_nod with %d raw frames",
00190 nb_raw_frames ) ;
00191
00192 check( pairs = xsh_subtract_sky_nod( set,
00193 instrument, mode)) ;
00194 ret = 0 ;
00195
00196 cleanup:
00197 xsh_instrument_free( &instrument);
00198 xsh_free_frameset( &pairs);
00199 xsh_free_frameset( &set);
00200 xsh_free_frameset( &ord_set);
00201
00202 if ( cpl_error_get_code() != CPL_ERROR_NONE){
00203 ret = 1;
00204 }
00205 TEST_END();
00206 return ret ;
00207 }
00208