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
00038
00041
00042
00043
00044
00045
00046 #include <xsh_data_pre.h>
00047 #include <xsh_error.h>
00048 #include <xsh_msg.h>
00049 #include <xsh_data_instrument.h>
00050 #include <xsh_dfs.h>
00051 #include <xsh_pfits.h>
00052 #include <tests.h>
00053 #include <cpl.h>
00054 #include <math.h>
00055 #include <string.h>
00056
00057
00058
00059
00060 #define MODULE_ID "PRODUCT_XSH_MASTER_BIAS"
00061 #define SYNTAX "Test the MASTER_BIAS\n"\
00062 "use : ./test-product_xsh_master_bias MASTER_BIAS\n"\
00063 "MASTER_BIAS => the master bias frame\n"
00064
00065
00066
00067
00068
00076
00077 int main( int argc, char** argv)
00078 {
00079 int res = 0;
00080 char* master_bias_name = NULL;
00081 const char* master_bias_pcatg = NULL;
00082 cpl_propertylist* master_bias_header = NULL;
00083 cpl_frame* master_bias_frame = NULL;
00084 xsh_pre* master_bias_pre = NULL;
00085 xsh_instrument* instrument = NULL;
00086 double mean =0.0, median=0.0, stdev=0.0, ron=0.0;
00087 double structx=0.0, structy=0.0;
00088
00089
00090 TESTS_INIT( MODULE_ID);
00091
00092 cpl_msg_set_level(CPL_MSG_DEBUG);
00093 xsh_debug_level_set(XSH_DEBUG_LEVEL_MEDIUM) ;
00094
00095
00096 if (argc > 1){
00097 master_bias_name = argv[1];
00098 }
00099 else{
00100 printf(SYNTAX);
00101 return 0;
00102 }
00103
00104
00105 XSH_ASSURE_NOT_NULL( master_bias_name);
00106 check( master_bias_header = cpl_propertylist_load( master_bias_name, 0 ));
00107 check( master_bias_pcatg = xsh_pfits_get_pcatg( master_bias_header));
00108
00109
00110 instrument = xsh_instrument_new();
00111 master_bias_frame = cpl_frame_new();
00112 cpl_frame_set_filename( master_bias_frame, master_bias_name);
00113
00114 if ( strstr(master_bias_pcatg, "MASTER_BIAS_UVB") != NULL){
00115 xsh_instrument_set_arm( instrument, XSH_ARM_UVB);
00116 cpl_frame_set_tag( master_bias_frame, "MASTER_BIAS_UVB");
00117 }
00118 else if ( strstr(master_bias_pcatg, "MASTER_BIAS_VIS") != NULL){
00119 xsh_instrument_set_arm( instrument, XSH_ARM_VIS);
00120 cpl_frame_set_tag( master_bias_frame, "MASTER_BIAS_VIS");
00121 }
00122 else {
00123 xsh_msg( "Invalid pcatg %s", master_bias_pcatg);
00124 XSH_ASSURE_NOT_ILLEGAL(1==0);
00125 }
00126
00127
00128 check( master_bias_pre = xsh_pre_load( master_bias_frame, instrument));
00129
00130
00131 check( mean = xsh_pfits_get_qc_mbiasavg ( master_bias_pre->data_header));
00132 check( median = xsh_pfits_get_qc_mbiasmed( master_bias_pre->data_header));
00133 check( stdev = xsh_pfits_get_qc_mbiasrms ( master_bias_pre->data_header));
00134 check( ron = xsh_pfits_get_qc_ron( master_bias_pre->data_header));
00135 check( structx = xsh_pfits_get_qc_structx( master_bias_pre->data_header));
00136 check( structy = xsh_pfits_get_qc_structy( master_bias_pre->data_header));
00137
00138 xsh_msg(" Given ron %f Compute ron %f",master_bias_pre->ron, ron);
00139 xsh_msg(" All is OK");
00140 cleanup:
00141 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00142 xsh_error_dump(CPL_MSG_ERROR);
00143 res = 1;
00144 }
00145 xsh_pre_free( &master_bias_pre);
00146 xsh_free_frame( &master_bias_frame);
00147 xsh_instrument_free(&instrument);
00148 return res;
00149 }
00150