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_data_pre.h>
00046 #include <xsh_error.h>
00047 #include <xsh_msg.h>
00048 #include <xsh_data_instrument.h>
00049 #include <xsh_data_spectrum.h>
00050 #include <xsh_data_localization.h>
00051 #include <xsh_drl.h>
00052 #include <xsh_pfits.h>
00053 #include <xsh_parameters.h>
00054 #include <xsh_badpixelmap.h>
00055 #include <xsh_utils_ifu.h>
00056 #include <cpl.h>
00057 #include <math.h>
00058
00059 #include <string.h>
00060 #include <getopt.h>
00061
00062
00063
00064
00065
00066 #define MODULE_ID "XSH_COMPUTE_SHIFT_IFU"
00067
00068 enum {
00069 WAVEREF_OPT, WAVEREF_HSIZE_OPT, HELP_OPT
00070 } ;
00071
00072 static struct option long_options[] = {
00073 {"wave-ref", required_argument, 0, WAVEREF_OPT},
00074 {"wave-ref-hsize", required_argument, 0, WAVEREF_HSIZE_OPT},
00075 {"help", 0, 0, HELP_OPT},
00076 {0, 0, 0, 0}
00077 };
00078
00079 static void Help( void )
00080 {
00081 puts( "Unitary test of xsh_compute_shift_ifu");
00082 puts( "Usage: test_xsh_localize_ifu [options] OBJPOS_TAB SHIFTIFU_TAB");
00083
00084 puts( "Options" ) ;
00085 puts( " --help : What you see" ) ;
00086 puts( " --wave-ref= : Wavelength reference");
00087 puts( " --wave-ref-hsize= : Half size in nm for estimate wavelength reference [2.5]");
00088 puts( "\nInput Files" ) ;
00089 puts( "OBJPOS_TAB : OBJPOS frame");
00090 puts( "SHIFTIFU_TAB : [OPTIONAL] SHIFTIFU_TAB frame");
00091 TEST_END();
00092 }
00093
00094
00095 static void HandleOptions( int argc, char **argv,
00096 double *waveref, double *waveref_hsize)
00097 {
00098 int opt ;
00099 int option_index = 0;
00100
00101 while (( opt = getopt_long (argc, argv,
00102 "wave-ref",
00103 long_options, &option_index)) != EOF ){
00104
00105 switch ( opt ) {
00106 case WAVEREF_OPT:
00107 *waveref = atof(optarg);
00108 break;
00109 case WAVEREF_HSIZE_OPT:
00110 *waveref_hsize = atof(optarg);
00111 break;
00112
00113
00114 default:
00115 Help(); exit(-1);
00116 }
00117 }
00118 return;
00119 }
00120
00121
00122 int main( int argc, char **argv)
00123 {
00124
00125 int ret = 0 ;
00126 double waveref = 700;
00127 double waveref_hsize = 2.5;
00128 const char *objpos_name = NULL;
00129 const char *shiftifu_name = NULL;
00130 cpl_frame *objpos_frame = NULL;
00131 cpl_frame *shiftifu_frame = NULL;
00132 cpl_frame *result = NULL;
00133
00134
00135 TESTS_INIT(MODULE_ID);
00136
00137 cpl_msg_set_level(CPL_MSG_DEBUG);
00138 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM);
00139
00140
00141 HandleOptions( argc, argv, &waveref, &waveref_hsize);
00142
00143 if ( (argc - optind) > 0 ) {
00144 objpos_name = argv[optind];
00145 if ( (argc - optind) > 1 ) {
00146 shiftifu_name = argv[optind+1];
00147 }
00148 }
00149 else {
00150 Help();
00151 exit( 0);
00152 }
00153
00154 xsh_msg("---Input Files");
00155 xsh_msg("Objpos : %s ", objpos_name);
00156 xsh_msg("Shiftifu: %s ", shiftifu_name);
00157 xsh_msg("---Options");
00158 xsh_msg("Waveref : %f ", waveref);
00159 xsh_msg("Waveref_hsize : %f ", waveref_hsize);
00160
00161
00162 TESTS_XSH_FRAME_CREATE( objpos_frame, "OBJPOS_arm", objpos_name);
00163 if ( shiftifu_name != NULL){
00164 TESTS_XSH_FRAME_CREATE( shiftifu_frame, "SHIFTIFU_arm", shiftifu_name);
00165 }
00166
00167 check( result = xsh_compute_shift_ifu_slitlet( waveref, objpos_frame,
00168 shiftifu_frame, waveref_hsize, "shift.fits"));
00169
00170 cleanup:
00171 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00172 xsh_error_dump(CPL_MSG_ERROR);
00173 ret=1;
00174 }
00175 xsh_free_frame( &result);
00176 xsh_free_frame( &objpos_frame);
00177 xsh_free_frame( &shiftifu_frame);
00178 TEST_END();
00179 return ret ;
00180 }
00181