63#define MODULE_ID "XSH_REMOVE_CRH_SINGLE"
67 puts(
"Unitary test of xsh_remove_crh_single");
68 puts(
"Usage: test_xsh_remove_crh_single [options] <input_files>");
71 puts(
" --sigma_lim=<n> : Sigma limit (5.0]" ) ;
72 puts(
" --f_lim=<n> : F limit [2.0]" ) ;
73 puts(
" --iter=<n> : Number of iteration [4]" ) ;
74 puts(
" --frac_max=<n> : Maximum rejected fraction [0.1]");
75 puts(
" --debug=<n> : Level of debug LOW | MEDIUM | HIGH [MEDIUM]" );
76 puts(
" --help : What you see" ) ;
77 puts(
"\nInput Files" ) ;
78 puts(
"The input files argument MUST be in this order:" ) ;
79 puts(
" 1. Science frame in PRE format sky subtracted" ) ;
80 puts(
" 2. SOF [WAVE_MAP]\n" ) ;
96 {
"f_lim", required_argument, 0,
F_LIM_OPT},
97 {
"iter", required_argument, 0,
ITER_OPT},
99 {
"debug", required_argument, 0,
DEBUG_OPT},
108 int option_index = 0;
110 while (( opt = getopt_long (argc, argv,
"sigma_lim:f_lim",
117 single_par->
f_lim = atof(optarg);
123 sscanf( optarg,
"%64d", &single_par->
nb_iter ) ;
126 if ( strcmp( optarg,
"LOW")==0){
129 else if ( strcmp( optarg,
"HIGH")==0){
153int main(
int argc,
char **argv)
161 cpl_frameset* raw = NULL;
162 cpl_frameset *set = NULL;
163 cpl_frame* sciraw_frame = NULL;
164 cpl_frame* sci_frame = NULL;
165 cpl_frame* wavemap_frame = NULL;
166 cpl_frame* frame_rmcrh = NULL;
170 cpl_image* test_image = NULL;
171 cpl_propertylist * header = NULL ;
176 cpl_msg_set_level( CPL_MSG_DEBUG);
182 single_par.
f_lim = 2.0;
187 if (argc-optind > 1){
188 sprintf(name, argv[optind]);
189 sprintf( sof_name, argv[optind+1]);
200 xsh_msg(
"-------------------------------------------");
201 xsh_msg(
"Execute default test : do --help for option");
202 xsh_msg(
"-------------------------------------------");
211 test_image = cpl_image_fill_test_create(10,10);
212 sprintf(name,
"remove_crh_single_sci_UVB.fits");
213 header =
mkHeader( iconfig, 10, 10, 1.) ;
214 cpl_image_save(test_image, name, CPL_BPP_IEEE_DOUBLE, header,
216 sciraw_frame = cpl_frame_new();
217 cpl_frame_set_filename( sciraw_frame, name) ;
218 cpl_frame_set_tag( sciraw_frame,
"BIAS_UVB");
219 cpl_frame_set_level( sciraw_frame, CPL_FRAME_LEVEL_TEMPORARY);
220 cpl_frame_set_group( sciraw_frame, CPL_FRAME_GROUP_RAW);
222 raw = cpl_frameset_new();
223 check( cpl_frameset_insert( raw, sciraw_frame));
226 check( sci_frame = cpl_frame_duplicate( cpl_frameset_get_first( raw)));
230 xsh_msg(
"sky subtracted frame : %s", name);
231 if ( wavemap_frame != NULL){
232 xsh_msg(
"Wave map frame : %s", cpl_frame_get_filename( wavemap_frame));
242 sprintf( res_name,
"NOCRH_%s.fits",
261 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static void HandleOptions(int argc, char **argv, xsh_remove_crh_single_param *single_par)
static struct option long_options[]
static xsh_instrument * instrument
cpl_frameset * sof_to_frameset(const char *sof_name)
cpl_propertylist * mkHeader(XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
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 xsh_error_dump(level)
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
void xsh_instrument_set_recipe_id(xsh_instrument *instrument, const char *recipe_id)
Set the recipe_id into the instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
XSH_INSTRCONFIG * xsh_instrument_get_config(xsh_instrument *i)
Get the instrument default set of keywords.
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
#define xsh_msg(...)
Print a message on info level.
cpl_frame * xsh_remove_crh_single(cpl_frame *sci_frame, xsh_instrument *instrument, cpl_mask *sky_map, xsh_remove_crh_single_param *single_par, const char *name)
Remove cosmic rays from a single frame.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
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
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
#define TESTS_CLEAN_WORKSPACE(DRL_ID)
#define TESTS_XSH_FRAME_CREATE(frame, tag, name)
#define TESTS_INIT_WORKSPACE(DRL_ID)
#define TESTS_INIT(DRL_ID)
cpl_frame * xsh_find_wavemap(cpl_frameset *frames, xsh_instrument *instr)
Find Wave Map frame. The frame returned should not be free by the caller.
xsh_instrument * xsh_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset and return the instrument detected.