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];
170 wcal* w=sinfo_wcal_new();
173 sinfo_extract_raw_frames_type ( sof,raw,PRO_WAVE_LAMP_STACKED );
174 nraw=cpl_frameset_get_size ( *raw );
177 sinfo_extract_raw_frames_type ( sof,raw,PRO_WAVE_NS_STACKED );
179 nraw=cpl_frameset_get_size ( *raw );
182 sinfo_extract_raw_frames_type ( sof,raw,PRO_WAVE_SLITPOS_STACKED );
185 nraw=cpl_frameset_get_size ( *raw );
188 sinfo_msg (
"Frame %s or %s or %s not found!",
189 PRO_WAVE_LAMP_STACKED,PRO_WAVE_NS_STACKED,PRO_WAVE_SLITPOS_STACKED );
194 frame = cpl_frameset_get_frame ( *raw,0 );
195 sinfo_get_spatial_res ( frame,spat_res );
197 switch ( sinfo_frame_is_on ( frame ) )
200 strcpy ( lamp_status,
"on" );
203 strcpy ( lamp_status,
"off" );
206 strcpy ( lamp_status,
"undefined" );
209 strcpy ( lamp_status,
"undefined" );
215 sinfo_get_band ( frame,band );
216 sinfo_msg (
"Spatial resolution: %s lamp status: %s band: %s \n",
217 spat_res, lamp_status, band );
220 sinfo_get_ins_set ( band,&ins_set );
221 if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_LAMP_STACKED ) )
223 frame = cpl_frameset_find ( sof,PRO_WAVE_LAMP_STACKED );
224 strcpy ( cfg -> inFrame,cpl_frame_get_filename ( frame ) );
226 else if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_NS_STACKED ) )
228 frame = cpl_frameset_find ( sof,PRO_WAVE_NS_STACKED );
229 strcpy ( cfg -> inFrame,cpl_frame_get_filename ( frame ) );
231 else if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_SLITPOS_STACKED ) )
233 frame = cpl_frameset_find ( sof,PRO_WAVE_SLITPOS_STACKED );
234 strcpy ( cfg -> inFrame,cpl_frame_get_filename ( frame ) );
239 PRO_WAVE_LAMP_STACKED,PRO_WAVE_NS_STACKED );
245 if ( NULL != cpl_frameset_find ( sof,DRS_SETUP_WAVE ) )
247 frame = cpl_frameset_find ( sof,DRS_SETUP_WAVE );
248 strcpy ( cfg -> drs_setup,cpl_frame_get_filename ( frame ) );
249 cpl_table* drs_tab = cpl_table_load ( cfg->drs_setup,1,0 );
250 w->wstart=cpl_table_get_double ( drs_tab,
"W_START",ins_set,&check );
251 w->wgdisp1=cpl_table_get_double ( drs_tab,
"W_DISP1",ins_set,&check );
252 w->wgdisp2=cpl_table_get_double ( drs_tab,
"W_DISP2",ins_set,&check );
253 w->hw=cpl_table_get_int ( drs_tab,
"W_HW",ins_set,&check );
254 w->fwhm=cpl_table_get_double ( drs_tab,
"W_FWHM",ins_set,&check );
255 w->min_amp=cpl_table_get_double ( drs_tab,
"W_MIN_AMP",ins_set,&check );
263 w->low_pos=cpl_table_get_int ( drs_tab,
"W_LOW_POS",ins_set,&check );
264 w->hig_pos=cpl_table_get_int ( drs_tab,
"W_HI_POS",ins_set,&check );
266 cfg -> guessBeginWavelength = w->wstart;
267 cfg -> guessDispersion1 = w->wgdisp1;
268 cfg -> guessDispersion2 = w->wgdisp2;
269 cpl_parameter* p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.half_width" );
270 if ( sinfo_parameter_get_default_flag ( p ) == 0 )
273 cfg -> halfWidth = w->hw;
280 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fwhm" );
281 if ( sinfo_parameter_get_default_flag ( p ) == 0 )
283 cfg -> fwhm = w->fwhm;
290 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.min_amplitude" );
291 if ( sinfo_parameter_get_default_flag ( p ) == 0 )
293 cfg -> minAmplitude = w->min_amp;
307 cfg -> loPos = w->low_pos;
308 cfg -> hiPos = w->hig_pos;
326 sinfo_wcal_delete ( w );
327 cpl_table_delete ( drs_tab );
328 if ( -1 == sinfo_check_rec_status ( 0 ) )
343 if ( NULL != cpl_frameset_find ( sof,REF_LINE_OH ) )
345 frame = cpl_frameset_find ( sof,REF_LINE_OH );
346 strcpy ( cfg -> lineList,cpl_frame_get_filename ( frame ) );
348 else if ( NULL != cpl_frameset_find ( sof,REF_LINE_ARC ) )
350 frame = cpl_frameset_find ( sof,REF_LINE_ARC );
351 strcpy ( cfg -> lineList,cpl_frame_get_filename ( frame ) );
361 if ( NULL != cpl_frameset_find ( sof,PRO_SLIT_POS_GUESS ) )
363 frame = cpl_frameset_find ( sof,PRO_SLIT_POS_GUESS );
364 strcpy ( cfg -> slitposGuessName,cpl_frame_get_filename ( frame ) );
368 sinfo_msg (
"Frame %s not found!", PRO_SLIT_POS_GUESS );
371 if ( cfg -> writeParInd ==0 )
373 if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_PAR_LIST ) )
375 frame = cpl_frameset_find ( sof,PRO_WAVE_PAR_LIST );
376 strcpy ( cfg -> paramsList,cpl_frame_get_filename ( frame ) );
380 sinfo_msg (
"Frame %s not found!", PRO_WAVE_PAR_LIST );
389 strcpy ( cfg -> paramsList, WAVECAL_FIT_PARAMS_OUT_FILENAME );
390 sinfo_msg (
"cfg -> paramsList %s not given\n",cfg -> paramsList );
396 if ( cfg -> calibIndicator == 0 )
398 if ( NULL != cpl_frameset_find ( sof,PRO_WAVE_COEF_SLIT ) )
400 frame = cpl_frameset_find ( sof,PRO_WAVE_COEF_SLIT );
401 strcpy ( cfg -> coeffsName,cpl_frame_get_filename ( frame ) );
413 strcpy ( cfg -> coeffsName, WAVECAL_COEFF_SLIT_OUT_FILENAME );
414 sinfo_msg (
"cfg -> coeffsName %s not given\n",cfg -> coeffsName );
418 strcpy ( cfg -> outName, WAVECAL_OUT_FILENAME );
419 strcpy ( cfg -> slitposName, WAVECAL_SLIT_POS_OUT_FILENAME );
426 parse_section_findlines ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
431 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.calib_indicator" );
432 cfg -> calibIndicator = cpl_parameter_get_bool ( p );
434 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.min_diff" );
435 cfg -> mindiff = cpl_parameter_get_double ( p );
437 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.half_width" );
438 cfg -> halfWidth = cpl_parameter_get_int ( p );
440 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.sigma" );
441 cfg -> sigma = cpl_parameter_get_double ( p );
447 parse_section_wavecalib ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
451 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fwhm" );
452 cfg -> fwhm = cpl_parameter_get_double ( p );
454 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.min_amplitude" );
455 cfg -> minAmplitude = cpl_parameter_get_double ( p );
457 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.max_residual" );
458 cfg -> maxResidual = cpl_parameter_get_double ( p );
460 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.n_a_coefficients" );
461 cfg -> nrDispCoefficients = cpl_parameter_get_int ( p );
463 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.n_b_coefficients" );
464 cfg -> nrCoefCoefficients = cpl_parameter_get_int ( p );
466 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.sigma_factor" );
467 cfg -> sigmaFactor = cpl_parameter_get_double ( p );
469 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.write_coeffs_ind" );
470 cfg -> writeCoeffsInd = cpl_parameter_get_bool ( p );
472 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.write_par_ind" );
473 cfg -> writeParInd = cpl_parameter_get_bool ( p );
475 cfg -> nslitlets = NSLITLETS;
477 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.pixel_dist" );
478 cfg -> pixeldist = cpl_parameter_get_int ( p );
480 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.pixel_tol" );
481 cfg -> pixel_tolerance = cpl_parameter_get_double ( p );
486 parse_section_wavemap ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
490 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.wave_map_ind" );
491 cfg -> wavemapInd = cpl_parameter_get_bool ( p );
493 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.mag_factor" );
494 cfg -> magFactor = cpl_parameter_get_int ( p );
500 parse_section_fitslits ( wave_config * cfg,cpl_parameterlist* cpl_cfg )
505 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.slit_pos_indicator" );
506 cfg -> slitposIndicator = cpl_parameter_get_bool ( p );
508 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fit_boltz_indicator" );
509 cfg -> fitBoltzIndicator = cpl_parameter_get_bool ( p );
511 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.fit_edge_indicator" );
512 cfg -> fitEdgeIndicator = cpl_parameter_get_bool ( p );
514 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.estimate_indicator" );
515 cfg -> estimateIndicator = cpl_parameter_get_bool ( p );
520 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.box_length" );
521 cfg -> boxLength = cpl_parameter_get_int ( p );
523 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.y_box" );
524 cfg -> yBox = cpl_parameter_get_double ( p );
526 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.diff_tol" );
527 cfg -> diffTol = cpl_parameter_get_double ( p );
537 parse_section_qclog ( wave_config * cfg, cpl_parameterlist* cpl_cfg )
541 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.qc_thresh_min" );
542 cfg -> qc_thresh_min = cpl_parameter_get_int ( p );
545 p = cpl_parameterlist_find ( cpl_cfg,
"sinfoni.wavecal.qc_thresh_max" );
546 cfg -> qc_thresh_max = cpl_parameter_get_int ( p );
552 sinfo_wavecal_free ( wave_config ** cfg )
556 sinfo_wave_cfg_destroy ( *cfg );
#define sinfo_msg_error(...)
Print an error message.