39 #include "sinfo_objnod_ini_by_cpl.h"
40 #include "sinfo_pro_types.h"
41 #include "sinfo_hidden.h"
42 #include "sinfo_globals.h"
43 #include "sinfo_functions.h"
45 #include "sinfo_file_handling.h"
51 parse_section_frames(object_config *,cpl_frameset* sof,
52 cpl_frameset** stk,
int* status);
53 static void parse_section_jittering(object_config *,
54 cpl_parameterlist * cpl_cfg);
55 static void parse_section_resampling(object_config *,
56 cpl_parameterlist * cpl_cfg);
57 static void parse_section_calibration(object_config *);
58 static void parse_section_cubecreation(object_config *,
59 cpl_parameterlist * cpl_cfg);
60 static void parse_section_finetuning(object_config *,
61 cpl_parameterlist * cpl_cfg);
62 static void parse_section_skyextraction(object_config *,
63 cpl_parameterlist * cpl_cfg);
87 sinfo_parse_cpl_input_objnod(cpl_parameterlist * cpl_cfg,cpl_frameset* sof,
90 object_config * cfg = sinfo_object_cfg_create();
98 parse_section_resampling (cfg, cpl_cfg);
99 parse_section_calibration (cfg);
100 parse_section_cubecreation (cfg, cpl_cfg);
101 parse_section_finetuning (cfg, cpl_cfg);
102 parse_section_skyextraction(cfg, cpl_cfg);
103 parse_section_jittering (cfg, cpl_cfg);
104 parse_section_frames (cfg, sof,stk,&status);
107 sinfo_objnod_free(&cfg);
116 parse_section_frames(object_config * cfg,
127 cpl_frame* frame = NULL;
130 char spat_res[FILE_NAME_SZ];
131 char lamp_status[FILE_NAME_SZ];
132 char band[FILE_NAME_SZ];
137 sinfo_contains_frames_type(sof,stk,PRO_NODDING_STACKED);
138 nstk = cpl_frameset_get_size(*stk);
141 sinfo_contains_frames_type(sof,stk,PRO_PSF_CALIBRATOR_STACKED);
142 nstk = cpl_frameset_get_size(*stk);
145 sinfo_contains_frames_type(sof,stk,PRO_PUPIL_LAMP_STACKED);
146 nstk = cpl_frameset_get_size(*stk);
157 nraw = cpl_frameset_get_size(*stk);
160 sinfo_msg_error(
"Cannot find input stacked frames in the input list") ;
165 nraw = cpl_frameset_get_size(*stk);
173 cfg->framelist = cpl_malloc(nraw *
sizeof(
char*));
176 for (i=0 ; i<nraw ; i++) {
177 frame = cpl_frameset_get_frame(*stk,i);
178 if(sinfo_file_exists((
char*)cpl_frame_get_filename(frame))==1)
180 cfg->framelist[i]=cpl_strdup(cpl_frame_get_filename(frame));
193 cfg->nframes = nraw ;
195 strcpy(cfg -> outName, OBJNOD_OUT_FILENAME);
196 strcpy(cfg -> maskname, OBJNOD_OUT_BPMAP);
197 strcpy(cfg -> med_cube_name, OBJNOD_OUT_MED_CUBE);
200 frame = cpl_frameset_get_frame(*stk,0);
202 sinfo_get_spatial_res(frame,spat_res);
203 switch(sinfo_frame_is_on(frame))
207 strcpy(lamp_status,
"on");
210 strcpy(lamp_status,
"off");
213 strcpy(lamp_status,
"undefined");
216 strcpy(lamp_status,
"undefined");
219 sinfo_get_band(frame,band);
220 sinfo_msg(
"Spatial resolution: %s lamp_status: %s band: %s",
221 spat_res, lamp_status, band);
224 sinfo_get_ins_set(band,&ins_set);
226 if(NULL != cpl_frameset_find(sof,PRO_WAVE_MAP)) {
227 frame = cpl_frameset_find(sof,PRO_WAVE_MAP);
228 strcpy(cfg -> wavemap, cpl_frame_get_filename(frame));
230 sinfo_msg(
"Frame %s not found!", PRO_WAVE_MAP);
236 if(NULL != cpl_frameset_find(sof,PRO_MASTER_FLAT_LAMP)) {
237 frame = cpl_frameset_find(sof,PRO_MASTER_FLAT_LAMP);
238 strcpy(cfg -> mflat, cpl_frame_get_filename(frame));
240 sinfo_msg(
"Frame %s not found!", PRO_MASTER_FLAT_LAMP);
246 if(NULL != cpl_frameset_find(sof,PRO_STACK_SKY_DIST)) {
247 frame = cpl_frameset_find(sof,PRO_STACK_SKY_DIST);
248 strcpy(cfg -> sky_dist, cpl_frame_get_filename(frame));
251 strcpy(cfg -> sky_dist,
"no_sky");
254 if(NULL != cpl_frameset_find(sof,PRO_STACK_MFLAT_DIST)) {
255 frame = cpl_frameset_find(sof,PRO_STACK_MFLAT_DIST);
256 strcpy(cfg -> mflat_dist, cpl_frame_get_filename(frame));
258 strcpy(cfg -> mflat_dist,
"not_found");
259 sinfo_msg(
"Frame %s not found!", PRO_STACK_MFLAT_DIST);
263 if(NULL != cpl_frameset_find(sof,PRO_STACK_MFLAT_DITHER_DIST)) {
264 frame = cpl_frameset_find(sof,PRO_STACK_MFLAT_DITHER_DIST);
265 strcpy(cfg -> mflat_dither_dist, cpl_frame_get_filename(frame));
267 strcpy(cfg -> mflat_dither_dist,
"not_found");
268 sinfo_msg(
"Frame %s not found!", PRO_STACK_MFLAT_DITHER_DIST);
272 if(cfg -> northsouthInd) {
274 if(NULL != cpl_frameset_find(sof,PRO_SLITLETS_DISTANCE)) {
275 frame = cpl_frameset_find(sof,PRO_SLITLETS_DISTANCE);
276 strcpy(cfg -> distlist, cpl_frame_get_filename(frame));
278 sinfo_msg(
"Frame %s not found!", PRO_SLITLETS_DISTANCE);
285 if(NULL != cpl_frameset_find(sof,PRO_SLIT_POS)) {
286 frame = cpl_frameset_find(sof,PRO_SLIT_POS);
287 strcpy(cfg -> poslist, cpl_frame_get_filename(frame));
289 sinfo_msg(
"Frame %s not found!", PRO_SLIT_POS);
295 if(cfg -> halocorrectInd) {
296 if(NULL != cpl_frameset_find(sof,PRO_HALO_SPECT)) {
297 frame = cpl_frameset_find(sof,PRO_HALO_SPECT);
298 strcpy(cfg -> halospectrum, cpl_frame_get_filename(frame));
300 sinfo_msg(
"Frame %s not found!", PRO_HALO_SPECT);
306 if(NULL != cpl_frameset_find(sof, PRO_REF_ATM_REF_CORR))
308 frame = cpl_frameset_find(sof, PRO_REF_ATM_REF_CORR);
309 strcpy(cfg->polyshiftname, cpl_frame_get_filename(frame));
312 sinfo_msg(
"Frame %s not found, shift due atmospheric refraction "
313 "would not be applied!", PRO_REF_ATM_REF_CORR);
314 cfg->polyshiftname[0] = 0;
327 parse_section_jittering(object_config * cfg,cpl_parameterlist * cpl_cfg)
331 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.jitter_index");
332 cfg -> jitterind = cpl_parameter_get_bool(p);
334 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.size_x");
335 cfg -> size_x = cpl_parameter_get_int(p);
337 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.size_y");
338 cfg -> size_y = cpl_parameter_get_int(p);
340 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.kernel_type");
341 strcpy(cfg -> kernel_type, cpl_parameter_get_string(p));
346 parse_section_resampling(object_config * cfg,cpl_parameterlist* cpl_cfg)
350 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.n_coeffs");
351 cfg -> ncoeffs = cpl_parameter_get_int(p);
353 cfg -> nrows = SINFO_RESAMP_NROWS;
358 parse_section_calibration(object_config * cfg)
360 cfg -> halocorrectInd=0;
366 parse_section_cubecreation(object_config * cfg,cpl_parameterlist* cpl_cfg)
369 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.nord_south_index");
370 cfg -> northsouthInd = cpl_parameter_get_bool(p);
371 cfg -> nslits = NSLITLETS;
377 parse_section_finetuning(object_config * cfg,cpl_parameterlist* cpl_cfg)
381 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.fine_tuning_method");
382 strcpy(cfg -> method, cpl_parameter_get_string(p));
384 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.order");
385 cfg -> order = cpl_parameter_get_int(p);
390 parse_section_skyextraction(object_config * cfg,cpl_parameterlist* cpl_cfg)
394 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.low_rejection");
395 cfg -> loReject = cpl_parameter_get_double(p);
397 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.high_rejection");
398 cfg -> hiReject = cpl_parameter_get_double(p);
400 p = cpl_parameterlist_find(cpl_cfg,
"sinfoni.objnod.tolerance");
401 cfg -> tolerance = cpl_parameter_get_int(p);
407 sinfo_objnod_free(object_config ** cfg) {
409 for(
int i=0;i<(*cfg)->nframes;i++) {
410 if((*cfg)->framelist[i]!=NULL) {
411 cpl_free((*cfg)->framelist[i]);
412 (*cfg)->framelist[i]=NULL;
415 if((*cfg)->framelist != NULL) {
416 cpl_free((*cfg)->framelist);
417 (*cfg)->framelist=NULL;
419 sinfo_object_cfg_destroy (*cfg);
#define sinfo_msg_error(...)
Print an error message.
#define sinfo_msg_warning(...)
Print an warning message.