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
00044 #include <xsh_data_pre.h>
00045 #include <xsh_error.h>
00046 #include <xsh_msg.h>
00047 #include <xsh_data_instrument.h>
00048 #include <xsh_dfs.h>
00049 #include <xsh_pfits.h>
00050 #include <tests.h>
00051 #include <cpl.h>
00052 #include <math.h>
00053 #include <getopt.h>
00054
00055
00056
00057 #define MODULE_ID "XSH_PREPARE"
00058
00059 #define SYNTAX \
00060 "Test the xsh_prepare function \n"\
00061 " transform RAW frames from a sof in PRE files\n"\
00062 "use : ./test_xsh_prepare SOF\n"\
00063 " SOF => the raw data FITS file\n"
00064
00065
00066
00067
00068
00069
00076
00077
00078 int main(int argc, char** argv)
00079 {
00080 xsh_instrument *instrument = NULL ;
00081 xsh_pre *pre = NULL;
00082 const char *sof_name = NULL;
00083 cpl_frame *master_bias_frame = NULL;
00084 cpl_frame *bp_map_frame = NULL;
00085 cpl_frameset *set = NULL;
00086 cpl_frameset *raws = NULL;
00087 cpl_frameset *calib = NULL;
00088 int ret=0;
00089
00090
00091 TESTS_INIT(MODULE_ID);
00092 cpl_msg_set_level(CPL_MSG_DEBUG);
00093 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM) ;
00094
00095
00096 if (argc > 1){
00097 sof_name = argv[1];
00098 }
00099 else{
00100 printf(SYNTAX);
00101 TEST_END();
00102 return 0;
00103 }
00104
00105 XSH_ASSURE_NOT_NULL( sof_name);
00106 check( set = sof_to_frameset( sof_name));
00107
00108
00109 check( instrument = xsh_dfs_set_groups( set));
00110 XSH_NEW_FRAMESET( raws);
00111 XSH_NEW_FRAMESET( calib);
00112 check( xsh_dfs_split_in_group( set, raws, calib));
00113 check( bp_map_frame = xsh_find_bpmap( calib));
00114 check( master_bias_frame = xsh_find_master_bias( calib, instrument));
00115
00116 #if 0
00117 for(i=0;i<3;i++){
00118 cpl_frame * frame = NULL;
00119 char framename[256];
00120
00121 sprintf(framename,"frame%d.fits",i);
00122 frame = xsh_test_create_frame(framename,10,10,
00123 XSH_BIAS_UVB,CPL_FRAME_GROUP_RAW, instrument);
00124 cpl_frameset_insert(set,frame);
00125 }
00126 #endif
00127
00128 check(xsh_prepare( raws, bp_map_frame, master_bias_frame,
00129 MODULE_ID, instrument,0,CPL_FALSE));
00130 #if 0
00131
00132 for(i=0;i<3;i++){
00133 cpl_frame * frame = NULL;
00134 frame = cpl_frameset_get_frame(set,i);
00135 check(pre = xsh_pre_load(frame,instrument));
00136 xsh_pre_free(&pre);
00137 }
00138 #endif
00139 xsh_msg("load all prepare frame success");
00140
00141 cleanup:
00142 xsh_free_frameset(&set);
00143 xsh_free_frameset( &raws);
00144 xsh_free_frameset( &calib);
00145 xsh_instrument_free(&instrument);
00146 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00147 xsh_pre_free(&pre);
00148 xsh_error_dump(CPL_MSG_ERROR);
00149 ret=1;
00150 }
00151 TEST_END();
00152 return ret;
00153 }
00154