58#define MODULE_ID "XSH_SUBTRACT_BIAS"
65 {
"debug", required_argument, 0,
DEBUG_OPT},
73 puts(
"Unitary test of xsh_subtract_bias");
74 puts(
"Usage: test_xsh_subtract_bias [options] <input_files>");
77 puts(
" --debug=<n> : Level of debug LOW | MEDIUM | HIGH [MEDIUM]" );
78 puts(
" --help : What you see" ) ;
79 puts(
"\nInput Files" ) ;
80 puts(
"The input files argument MUST be in this order:" ) ;
81 puts(
" 1. Science frame in PRE format" ) ;
82 puts(
" 2. SOF [MASTER_BIAS]");
95 while (( opt = getopt_long (argc, argv,
"debug:help",
100 if ( strcmp( optarg,
"LOW")==0){
103 else if ( strcmp( optarg,
"HIGH")==0){
129int main(
int argc,
char **argv)
132 cpl_frameset* set = NULL;
133 cpl_frame* frame = NULL;
134 cpl_frame* bias = NULL;
135 char* sci_name = NULL;
136 char* sof_name = NULL;
137 cpl_frame* temp = NULL;
142 float *data1 = NULL,*errs1 = NULL;
144 float *data2 = NULL,*errs2 = NULL;
146 float *data3 = NULL,*errs3 = NULL;
149 int pre_overscan_corr=0;
150 const int decode_bp=2147483647;
154 cpl_msg_set_level( CPL_MSG_DEBUG);
159 if ( (argc-optind) >= 2 ) {
160 sci_name = argv[optind];
161 sof_name = argv[optind+1];
172 xsh_msg(
"-------------------------------------------");
173 xsh_msg(
"Execute default test : do --help for option");
174 xsh_msg(
"-------------------------------------------");
183 set = cpl_frameset_new();
187 sprintf(framename,
"frame%d.fits",i);
190 cpl_frameset_insert(set,frame);
197 check( frame = cpl_frame_duplicate(cpl_frameset_get_frame(set,0)));
198 check( bias = cpl_frameset_get_frame(set,1));
203 cpl_frame_get_filename( frame));
205 cpl_frame_get_filename( bias));
215 data1 = cpl_image_get_data_float(pre1->
data);
216 data2 = cpl_image_get_data_float(pre2->
data);
217 data3 = cpl_image_get_data_float(pre3->
data);
218 errs1 = cpl_image_get_data_float(pre1->
errs);
219 errs2 = cpl_image_get_data_float(pre2->
errs);
220 errs3 = cpl_image_get_data_float(pre3->
errs);
221 qual1 = cpl_image_get_data_int(pre1->
qual);
222 qual2 = cpl_image_get_data_int(pre2->
qual);
223 qual3 = cpl_image_get_data_int(pre3->
qual);
227 CPL_ERROR_ILLEGAL_OUTPUT,
"Wrong data part");
228 assure(errs1[i] - (sqrt(errs2[i]*errs2[i]+errs3[i]*errs3[i])) <
230 assure(qual1[i] == (qual2[i] + qual3[i]),CPL_ERROR_ILLEGAL_OUTPUT,
244 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
static void HandleOptions(int argc, char **argv)
static struct option long_options[]
cpl_frameset * sof_to_frameset(const char *sof_name)
cpl_frame * xsh_test_create_frame(const char *name, int nx, int ny, const char *tag, cpl_frame_group group, xsh_instrument *instrument)
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
#define assure(CONDITION, ERROR_CODE,...)
#define xsh_error_dump(level)
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
void xsh_instrument_set_lamp(xsh_instrument *i, XSH_LAMP lamp)
Set a lamp on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
void xsh_instrument_set_decode_bp(xsh_instrument *i, const int decode_bp)
Set bad pixel code.
#define xsh_msg(...)
Print a message on info level.
cpl_frame * xsh_subtract_bias(cpl_frame *frame, cpl_frame *bias, xsh_instrument *instr, const char *type, const int pre_overscan_corr, const int save_tmp)
Subtract the master bias frame from PRE frame.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
int xsh_debug_level_set(int level)
set debug level
#define TESTS_CLEAN_WORKSPACE(DRL_ID)
#define TESTS_XSH_FRAME_CREATE(frame, tag, name)
#define TESTS_INIT_WORKSPACE(DRL_ID)
#define XSH_FLOAT_PRECISION
#define TESTS_INIT(DRL_ID)
cpl_frame * xsh_find_master_bias(cpl_frameset *frames, xsh_instrument *instr)
Find master bias frame.
xsh_instrument * xsh_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset and return the instrument detected.
#define XSH_LINEARITY_UVB