63#define MODULE_ID "XSH_OPT_EXTRACT"
79 {
"niter", required_argument, 0,
NITER_OPT},
83 {
"debug", required_argument, 0,
DEBUG_OPT},
90 puts(
"Unitary test of xsh_opt_extract");
91 puts(
"Usage: test_xsh_opt_extract [options] <input_files>");
94 puts(
" --oversample=<n> : Oversample factor [5]" ) ;
95 puts(
" --box-hsize=<n> : Extract box half size [pixels] [10]" ) ;
96 puts(
" --chunk-size=<n> : Chunk size [pixels] [50]" ) ;
97 puts(
" --lambda-step=<n> : Step in wavelength [0.02]" );
98 puts(
" --clip-kappa=<nn> : Kappa for cosmics Ray hits rejection [3]" ) ;
99 puts(
" --clip-frac=<nn> : Maxium bad pixels fraction for cosmics Ray hits rejection [0.4]" );
100 puts(
" --clip-niter=<n> : Number of iterations for cosmics Ray hits rejection [2]" ) ;
101 puts(
" --niter=<n> : Number of iterations [1]" ) ;
102 puts(
" --method=<string> : Extraction method GAUSSIAN | GENERAL [GAUSSIAN]" ) ;
103 puts(
" --order-min=<n> : Minimum abs order" );
104 puts(
" --order-max=<n> : Maximum abs order" );
105 puts(
" --debug=<n> : Level of debug NONE | LOW | MEDIUM | HIGH [MEDIUM]" );
106 puts(
" --help : What you see" ) ;
107 puts(
"\nInput Files" ) ;
108 puts(
"The input files argument MUST be in this order:" ) ;
109 puts(
" 1. Science frame in PRE format sky subtracted" ) ;
110 puts(
" 2. Localization table" );
111 puts(
" 3. SOF [SPECTRAL_FORMAT, ORDER_TAB_EDGES,WAVE_TAB_2D, WAVEMAP, SLITMAP, MASTER_FLAT]\n" ) ;
119 int option_index = 0;
121 while (( opt = getopt_long (argc, argv,
"oversample:box-hsize:chunk-size",
129 opt_extract_par->
box_hsize = atoi( optarg);
141 opt_extract_par->
clip_frac = atof( optarg);
147 opt_extract_par->
niter = atoi( optarg);
158 sscanf( optarg,
"%64d", order_min);
161 sscanf( optarg,
"%64d", order_max);
164 if ( strcmp( optarg,
"LOW")==0){
167 else if ( strcmp( optarg,
"HIGH")==0){
170 else if ( strcmp( optarg,
"NONE")==0){
193int main(
int argc,
char **argv)
198 const char *sof_name = NULL;
199 cpl_frameset *set = NULL;
201 const char* sci_name = NULL;
202 const char* loc_name = NULL;
207 int rec_min_index = -1;
208 int rec_max_index = -1;
212 cpl_frame *sci_frame = NULL;
213 cpl_frame *loc_frame = NULL;
214 cpl_frame *orderlist_frame = NULL;
215 cpl_frame *wavesol_frame = NULL;
216 cpl_frame *model_frame = NULL;
217 cpl_frame *wavemap_frame = NULL;
218 cpl_frame *slitmap_frame = NULL;
219 cpl_frame *spectralformat_frame = NULL;
220 cpl_frame *masterflat_frame = NULL;
221 cpl_frame *orderext1d_frame = NULL;
222 cpl_frame *orderoxt1d_frame = NULL;
223 cpl_frame *orderoxt1d_eso_frame = NULL;
224 cpl_frame *qc_subex_frame = NULL;
225 cpl_frame *qc_s2ddiv1d_frame = NULL;
226 cpl_frame *qc_model_frame = NULL;
227 cpl_frame *qc_weight_frame = NULL;
229 cpl_frame *spectrumext1d_frame = NULL;
230 cpl_frame *spectrumoxt1d_frame = NULL;
231 const int decode_bp=2147483647;
235 cpl_msg_set_level( CPL_MSG_DEBUG);
245 opt_extract_par.
niter = 1;
249 HandleOptions( argc, argv, &opt_extract_par, &order_min, &order_max);
251 if ( (argc - optind) >= 3 ) {
252 sci_name = argv[optind];
253 loc_name = argv[optind+1];
254 sof_name = argv[optind+2];
282 if ( model_frame == NULL){
289 cpl_frame_get_filename( sci_frame));
291 cpl_frame_get_filename( loc_frame));
293 cpl_frame_get_filename( orderlist_frame));
294 if (model_frame != NULL){
299 cpl_frame_get_filename( model_frame));
303 cpl_frame_get_filename( wavesol_frame));
306 cpl_frame_get_filename( spectralformat_frame));
308 cpl_frame_get_filename( wavemap_frame));
310 cpl_frame_get_filename( slitmap_frame));
312 cpl_frame_get_filename( masterflat_frame));
327 if ( order_min != -1) {
330 xsh_msg(
"Order min %d => index %d", order_min, rec_min_index);
336 if ( order_max != -1) {
339 xsh_msg(
"Order max %d => index %d", order_max, rec_max_index);
342 rec_max_index = order_list->
size;
346 wavemap_frame, slitmap_frame, loc_frame, spectralformat_frame, masterflat_frame,
347 instrument, &opt_extract_par, rec_min_index, rec_max_index,
"TEST",
348 &orderext1d_frame, &orderoxt1d_frame,
349 &orderoxt1d_eso_frame, &qc_subex_frame, &qc_s2ddiv1d_frame,
350 &qc_model_frame, &qc_weight_frame));
356 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
cpl_frameset * sof_to_frameset(const char *sof_name)
int xsh_order_list_get_index_by_absorder(xsh_order_list *list, double absorder)
xsh_order_list * xsh_order_list_load(cpl_frame *frame, xsh_instrument *instr)
load an order list from a frame
void xsh_order_list_free(xsh_order_list **list)
free memory associated to an order_list
#define xsh_error_dump(level)
#define xsh_error_reset()
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
void xsh_instrument_set_decode_bp(xsh_instrument *i, const int decode_bp)
Set bad pixel code.
cpl_frame * xsh_merge_ord(cpl_frame *sci_frame, xsh_instrument *instrument, int merge, const char *rec_prefix)
Merge orders of the rectified frame using merge parameters.
#define xsh_msg(...)
Print a message on info level.
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_XSH_FRAME_CREATE(frame, tag, name)
#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.
cpl_frame * xsh_find_spectral_format(cpl_frameset *frames, xsh_instrument *instr)
Find spectral format frame.
cpl_frame * xsh_find_order_tab_edges(cpl_frameset *frames, xsh_instrument *instr)
Find an order tab EDGES.
cpl_frame * xsh_find_wave_tab_2d(cpl_frameset *frames, xsh_instrument *instr)
Find a wave tab 2D.
cpl_frame * xsh_find_slitmap(cpl_frameset *frames, xsh_instrument *instr)
Find a slit map.
xsh_instrument * xsh_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset and return the instrument detected.
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
cpl_frame * xsh_find_master_flat(cpl_frameset *frames, xsh_instrument *instr)
Find master flat frame.
#define XSH_MOD_CFG_OPT_2D
cpl_error_code xsh_model_temperature_update_frame(cpl_frame **model_config_frame, cpl_frame *ref_frame, xsh_instrument *instrument, int *found_temp)
#define OPTEXTRACT_METHOD_PRINT(method)