38 #include "sinfo_wavecal_ini_by_cpl.h"
39 #include "sinfo_raw_types.h"
40 #include "sinfo_pro_types.h"
41 #include "sinfo_ref_types.h"
42 #include "sinfo_hidden.h"
43 #include "sinfo_functions.h"
44 #include "sinfo_utils.h"
50 parse_section_frames ( wave_config *, cpl_parameterlist* cpl_cfg, cpl_frameset* sof,
51 cpl_frameset** raw,
int* status );
54 parse_section_findlines ( wave_config *, cpl_parameterlist* cpl_cfg );
56 parse_section_wavecalib ( wave_config *, cpl_parameterlist* cpl_cfg );
58 parse_section_wavemap ( wave_config *, cpl_parameterlist* cpl_cfg );
60 parse_section_qclog ( wave_config *, cpl_parameterlist* cpl_cfg );
62 parse_section_fitslits ( wave_config *, cpl_parameterlist* cpl_cfg );
110 sinfo_parse_cpl_input_wave ( cpl_parameterlist* cpl_cfg,
111 cpl_frameset* sof, cpl_frameset** raw )
115 wave_config * cfg= sinfo_wave_cfg_create();
121 parse_section_findlines ( cfg, cpl_cfg );
122 parse_section_wavecalib ( cfg, cpl_cfg );
123 parse_section_wavemap ( cfg, cpl_cfg );
124 parse_section_fitslits ( cfg, cpl_cfg );
125 parse_section_qclog ( cfg, cpl_cfg );
126 parse_section_frames ( cfg, cpl_cfg, sof, raw, &status );
131 sinfo_wave_cfg_destroy ( cfg );
160 parse_section_frames ( wave_config * cfg,cpl_parameterlist* cpl_cfg, cpl_frameset* sof,
161 cpl_frameset** raw,
int* status )
163 cpl_frame* frame = NULL;
164 char spat_res[FILE_NAME_SZ];
165 char lamp_status[FILE_NAME_SZ];
166 char band[FILE_NAME_SZ];
169 cpl_parameter* p=NULL;
170 cpl_table* drs_tab=NULL;
171 wcal* w=sinfo_wcal_new();
174 sinfo_extract_raw_frames_type ( sof,raw,PRO_WAVE_LAMP_STACKED );
175 nraw=cpl_frameset_get_size ( *raw );
178 sinfo_extract_raw_frames_type ( sof,raw,PRO_WAVE_NS_STACKED );
180 nraw=cpl_frameset_get_size ( *raw );
183 sinfo_extract_raw_frames_type ( sof,raw,PRO_WAVE_SLITPOS_STACKED );
186 nraw=cpl_frameset_get_size ( *raw );
189 sinfo_msg (
"Frame %s or %s or %s not found!",
190 PRO_WAVE_LAMP_STACKED,PRO_WAVE_NS_STACKED,PRO_WAVE_SLITPOS_STACKED );
195 frame = cpl_frameset_get_frame ( *raw,0 );
196 sinfo_get_spatial_res ( frame,spat_res );
198 switch ( sinfo_frame_is_on ( frame ) )
201 strcpy ( lamp_status,
"on" );
204 strcpy ( lamp_status,
"off" );
207 strcpy ( lamp_status,
"undefined" );
210 strcpy ( lamp_status,
"undefined" );
216 sinfo_get_band ( frame,band );
217 sinfo_msg (
"Spatial resolution: %s lamp status: %s band: %s \n",
218 spat_res, lamp_status, band );
221 sinfo_get_ins_set ( band,&ins_set );
222 if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_LAMP_STACKED ) )
224 frame = cpl_frameset_find ( sof,PRO_WAVE_LAMP_STACKED );
225 strcpy ( cfg -> inFrame,cpl_frame_get_filename ( frame ) );
227 else if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_NS_STACKED ) )
229 frame = cpl_frameset_find ( sof,PRO_WAVE_NS_STACKED );
230 strcpy ( cfg -> inFrame,cpl_frame_get_filename ( frame ) );
232 else if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_SLITPOS_STACKED ) )
234 frame = cpl_frameset_find ( sof,PRO_WAVE_SLITPOS_STACKED );
235 strcpy ( cfg -> inFrame,cpl_frame_get_filename ( frame ) );
240 PRO_WAVE_LAMP_STACKED,PRO_WAVE_NS_STACKED );
246 if ( NULL != cpl_frameset_find ( sof,DRS_SETUP_WAVE ) )
248 frame = cpl_frameset_find ( sof,DRS_SETUP_WAVE );
249 strcpy ( cfg -> drs_setup,cpl_frame_get_filename ( frame ) );
250 drs_tab = cpl_table_load ( cfg->drs_setup,1,0 );
251 w->wstart=cpl_table_get_double ( drs_tab,
"W_START",ins_set,&check );
252 w->wgdisp1=cpl_table_get_double ( drs_tab,
"W_DISP1",ins_set,&check );
253 w->wgdisp2=cpl_table_get_double ( drs_tab,
"W_DISP2",ins_set,&check );
254 w->hw=cpl_table_get_int ( drs_tab,
"W_HW",ins_set,&check );
255 w->fwhm=cpl_table_get_double ( drs_tab,
"W_FWHM",ins_set,&check );
256 w->min_amp=cpl_table_get_double ( drs_tab,
"W_MIN_AMP",ins_set,&check );
264 w->low_pos=cpl_table_get_int ( drs_tab,
"W_LOW_POS",ins_set,&check );
265 w->hig_pos=cpl_table_get_int ( drs_tab,
"W_HI_POS",ins_set,&check );
267 cfg -> guessBeginWavelength = w->wstart;
268 cfg -> guessDispersion1 = w->wgdisp1;
269 cfg -> guessDispersion2 = w->wgdisp2;
270 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.half_width" );
271 if ( sinfo_parameter_get_default_flag ( p ) == 0 )
274 cfg -> halfWidth = w->hw;
281 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fwhm" );
282 if ( sinfo_parameter_get_default_flag ( p ) == 0 )
284 cfg -> fwhm = w->fwhm;
291 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.min_amplitude" );
292 if ( sinfo_parameter_get_default_flag ( p ) == 0 )
294 cfg -> minAmplitude = w->min_amp;
308 cfg -> loPos = w->low_pos;
309 cfg -> hiPos = w->hig_pos;
327 sinfo_wcal_delete ( w );
328 cpl_table_delete ( drs_tab );
329 if ( -1 == sinfo_check_rec_status ( 0 ) )
344 if ( NULL != cpl_frameset_find ( sof,REF_LINE_OH ) )
346 frame = cpl_frameset_find ( sof,REF_LINE_OH );
347 strcpy ( cfg -> lineList,cpl_frame_get_filename ( frame ) );
349 else if ( NULL != cpl_frameset_find ( sof,REF_LINE_ARC ) )
351 frame = cpl_frameset_find ( sof,REF_LINE_ARC );
352 strcpy ( cfg -> lineList,cpl_frame_get_filename ( frame ) );
362 if ( NULL != cpl_frameset_find ( sof,PRO_SLIT_POS_GUESS ) )
364 frame = cpl_frameset_find ( sof,PRO_SLIT_POS_GUESS );
365 strcpy ( cfg -> slitposGuessName,cpl_frame_get_filename ( frame ) );
369 sinfo_msg (
"Frame %s not found!", PRO_SLIT_POS_GUESS );
372 if ( cfg -> writeParInd ==0 )
374 if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_PAR_LIST ) )
376 frame = cpl_frameset_find ( sof,PRO_WAVE_PAR_LIST );
377 strcpy ( cfg -> paramsList,cpl_frame_get_filename ( frame ) );
381 sinfo_msg (
"Frame %s not found!", PRO_WAVE_PAR_LIST );
390 strcpy ( cfg -> paramsList, WAVECAL_FIT_PARAMS_OUT_FILENAME );
391 sinfo_msg (
"cfg -> paramsList %s not given\n",cfg -> paramsList );
397 if ( cfg -> calibIndicator == 0 )
399 if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_COEF_SLIT ) )
401 frame = cpl_frameset_find ( sof,PRO_WAVE_COEF_SLIT );
402 strcpy ( cfg -> coeffsName,cpl_frame_get_filename ( frame ) );
414 strcpy ( cfg -> coeffsName, WAVECAL_COEFF_SLIT_OUT_FILENAME );
415 sinfo_msg (
"cfg -> coeffsName %s not given\n",cfg -> coeffsName );
419 strcpy ( cfg -> outName, WAVECAL_OUT_FILENAME );
420 strcpy ( cfg -> slitposName, WAVECAL_SLIT_POS_OUT_FILENAME );
427 parse_section_findlines ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
432 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.calib_indicator" );
433 cfg -> calibIndicator = cpl_parameter_get_bool ( p );
435 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.min_diff" );
436 cfg -> mindiff = cpl_parameter_get_double ( p );
438 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.half_width" );
439 cfg -> halfWidth = cpl_parameter_get_int ( p );
441 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.sigma" );
442 cfg -> sigma = cpl_parameter_get_double ( p );
448 parse_section_wavecalib ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
452 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fwhm" );
453 cfg -> fwhm = cpl_parameter_get_double ( p );
455 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.min_amplitude" );
456 cfg -> minAmplitude = cpl_parameter_get_double ( p );
458 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.max_residual" );
459 cfg -> maxResidual = cpl_parameter_get_double ( p );
461 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.n_a_coefficients" );
462 cfg -> nrDispCoefficients = cpl_parameter_get_int ( p );
464 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.n_b_coefficients" );
465 cfg -> nrCoefCoefficients = cpl_parameter_get_int ( p );
467 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.sigma_factor" );
468 cfg -> sigmaFactor = cpl_parameter_get_double ( p );
470 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.write_coeffs_ind" );
471 cfg -> writeCoeffsInd = cpl_parameter_get_bool ( p );
473 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.write_par_ind" );
474 cfg -> writeParInd = cpl_parameter_get_bool ( p );
476 cfg -> nslitlets = NSLITLETS;
478 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.pixel_dist" );
479 cfg -> pixeldist = cpl_parameter_get_int ( p );
481 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.pixel_tol" );
482 cfg -> pixel_tolerance = cpl_parameter_get_double ( p );
487 parse_section_wavemap ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
491 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.wave_map_ind" );
492 cfg -> wavemapInd = cpl_parameter_get_bool ( p );
494 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.mag_factor" );
495 cfg -> magFactor = cpl_parameter_get_int ( p );
501 parse_section_fitslits ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
506 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.slit_pos_indicator" );
507 cfg -> slitposIndicator = cpl_parameter_get_bool ( p );
509 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fit_boltz_indicator" );
510 cfg -> fitBoltzIndicator = cpl_parameter_get_bool ( p );
512 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fit_edge_indicator" );
513 cfg -> fitEdgeIndicator = cpl_parameter_get_bool ( p );
515 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.estimate_indicator" );
516 cfg -> estimateIndicator = cpl_parameter_get_bool ( p );
521 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.box_length" );
522 cfg -> boxLength = cpl_parameter_get_int ( p );
524 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.y_box" );
525 cfg -> yBox = cpl_parameter_get_double ( p );
527 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.diff_tol" );
528 cfg -> diffTol = cpl_parameter_get_double ( p );
538 parse_section_qclog ( wave_config * cfg, cpl_parameterlist* cpl_cfg )
542 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.qc_thresh_min" );
543 cfg -> qc_thresh_min = cpl_parameter_get_int ( p );
546 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.qc_thresh_max" );
547 cfg -> qc_thresh_max = cpl_parameter_get_int ( p );
553 sinfo_wavecal_free ( wave_config ** cfg )
557 sinfo_wave_cfg_destroy ( *cfg );