58#define MODULE_ID "XSH_SUBTRACT_DARK"
65 {
"debug", required_argument, 0,
DEBUG_OPT},
72 puts(
"Unitary test of xsh_subtract_dark");
73 puts(
"Usage: test_xsh_subtract_dark [options] <input_files>");
76 puts(
" --debug=<n> : Level of debug LOW | MEDIUM | HIGH [MEDIUM]" );
77 puts(
" --help : What you see" ) ;
78 puts(
"\nInput Files" ) ;
79 puts(
"The input files argument MUST be in this order:" ) ;
80 puts(
" 1. Science frame in PRE format" ) ;
81 puts(
" 2. SOF [MASTER_DARK]");
91 while (( opt = getopt_long (argc, argv,
"debug:help",
96 if ( strcmp( optarg,
"LOW")==0){
99 else if ( strcmp( optarg,
"HIGH")==0){
128 cpl_frameset* set = NULL;
129 cpl_frame* frame = NULL;
130 cpl_frame* dark = NULL;
131 char* sci_name = NULL;
132 char* sof_name = NULL;
133 cpl_frame* temp = NULL;
138 float *data1 = NULL,*errs1 = NULL;
140 float *data2 = NULL,*errs2 = NULL;
142 float *data3 = NULL,*errs3 = NULL;
145 const int decode_bp=2147483647;
149 cpl_msg_set_level( CPL_MSG_DEBUG);
154 if ( (argc-optind) >= 2 ) {
155 sci_name = argv[optind];
156 sof_name = argv[optind+1];
167 xsh_msg(
"-------------------------------------------");
168 xsh_msg(
"Execute default test : do --help for option");
169 xsh_msg(
"-------------------------------------------");
177 set = cpl_frameset_new();
181 sprintf(framename,
"frame%d.fits",i);
184 cpl_frameset_insert(set,frame);
192 check( frame = cpl_frame_duplicate(cpl_frameset_get_frame(set,0)));
193 check( dark = cpl_frameset_get_frame(set,1));
197 cpl_frame_get_filename( frame));
200 cpl_frame_get_filename( dark));
208 data1 = cpl_image_get_data_float(pre1->
data);
209 data2 = cpl_image_get_data_float(pre2->
data);
210 data3 = cpl_image_get_data_float(pre3->
data);
211 errs1 = cpl_image_get_data_float(pre1->
errs);
212 errs2 = cpl_image_get_data_float(pre2->
errs);
213 errs3 = cpl_image_get_data_float(pre3->
errs);
214 qual1 = cpl_image_get_data_int(pre1->
qual);
215 qual2 = cpl_image_get_data_int(pre2->
qual);
216 qual3 = cpl_image_get_data_int(pre3->
qual);
222 CPL_ERROR_ILLEGAL_OUTPUT,
"Wrong data part");
223 assure(errs1[i] - (sqrt(errs2[i]*errs2[i]+errs3[i]*errs3[i]*pre2->
exptime*
226 assure(qual1[i] == (qual2[i] + qual3[i]),CPL_ERROR_ILLEGAL_OUTPUT,
240 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)
#define XSH_ASSURE_NOT_NULL(pointer)
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_dark(cpl_frame *frame, cpl_frame *dark, const char *filename, xsh_instrument *instr)
subtract the master dark 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_dark(cpl_frameset *frames, xsh_instrument *instr)
Find master dark 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