32 #include "sinfo_flat_ini.h"
36 static void parse_section_general(dictionary *, flat_config *,
int *);
37 static void parse_section_frames(dictionary *, flat_config *,
int *);
38 static void parse_section_cleanmean(dictionary *, flat_config *,
int *);
39 static void parse_section_badpixel(dictionary *, flat_config *,
int *);
40 static void parse_section_badpix(dictionary *, flat_config *,
int *);
41 static void parse_section_thresh(dictionary *, flat_config *,
int *);
61 parse_flat_ini_file(
char * ini_name)
67 if (!sinfo_file_exists(ini_name)) {
71 sym = iniparser_load(ini_name) ;
77 cfg = sinfo_flat_cfg_create();
80 iniparser_freedict(sym) ;
90 parse_section_general (sym, cfg, &status);
91 parse_section_frames (sym, cfg, &status);
92 parse_section_cleanmean (sym, cfg, &status);
93 parse_section_badpixel (sym, cfg, &status);
94 parse_section_badpix (sym, cfg, &status);
95 parse_section_thresh (sym, cfg, &status);
97 iniparser_freedict(sym);
101 sinfo_flat_cfg_destroy(cfg);
129 static void parse_section_general(
141 cval = iniparser_getstr(sym,
"eclipse:versionnumber") ;
143 if (strcmp(cval, get_eclipse_version())) {
146 get_eclipse_version());
152 ival = iniparser_getint(sym,
"general:maximummemory", -1);
153 if (ival>0) sinfo_set_memory_parameter(
"max_ram", ival);
154 ival = iniparser_getint(sym,
"general:maximumswap", -1);
155 if (ival>0) sinfo_set_memory_parameter(
"max_swap", ival);
156 sinfo_set_verbose(iniparser_getboolean(sym,
"general:verbose", 0));
157 sinfo_set_debug(iniparser_getboolean(sym,
"general:debug", 0));
159 cval = iniparser_getstr(sym,
"general:tmpdirname");
161 sinfo_set_tmpdirname(cval);
163 sinfo_set_tmpdirname(
".");
166 ival = iniparser_getboolean(sym,
"general:logfile", 0);
168 cval = iniparser_getstr(sym,
"general:logfilename");
170 sinfo_set_logfile(1);
171 sinfo_set_logfilename(cval);
173 sinfo_set_logfile(0) ;
176 cval = iniparser_getstr(sym,
"general:outname");
178 strcpy (cfg -> outName , cval ) ;
184 if (sinfo_verbose_active())
185 sinfo_print_memory_parameters();
189 static void parse_section_frames(
200 int nval, nobj, noff ;
201 int nditherobj, nditheroff ;
206 int * frameposition ;
208 listname = iniparser_getstr(sym,
"general:infile");
209 if (sinfo_is_ascii_list(listname)!=1) {
216 charm = sinfo_charmatrix_read(listname);
225 for (j=0 ; j<charm->ly ; j++) {
227 name = charmatrix_elem(charm, 0, j);
228 if (sinfo_file_exists(name)!=1) {
236 sinfo_charmatrix_del(charm);
242 framelist = cpl_malloc(nval *
sizeof(
char*));
243 frametypes = cpl_malloc(nval *
sizeof(
int));
244 frameposition = cpl_malloc(nval *
sizeof(
int));
255 for (j=0 ; j<charm->ly ; j++)
257 name = charmatrix_elem(charm, 0, j);
258 if (sinfo_file_exists(name)==1)
261 framelist[i] = cpl_strdup(name);
266 type = charmatrix_elem(charm, 1, j);
269 if (strstr(type,
"sky")!=NULL || strstr(type,
"off") != NULL)
271 frametypes[i] = FRAME_OFF ;
274 if (strstr(type,
"2")!=NULL)
276 frameposition[i] = FRAME_POS2 ;
282 frameposition[i] = FRAME_POS1 ;
289 frametypes[i] = FRAME_ON ;
291 if (strstr(type,
"2")!=NULL)
293 frameposition[i] = FRAME_POS2 ;
299 frameposition[i] = FRAME_POS1 ;
307 frametypes[i] = FRAME_ON ;
309 frameposition[i] = FRAME_POS1 ;
315 sinfo_charmatrix_del(charm);
318 cfg->framelist = framelist ;
319 cfg->frametype = frametypes ;
320 cfg->frameposition = frameposition ;
321 cfg->nframes = nval ;
324 cfg->nditherobj = nditherobj ;
325 cfg->nditheroff = nditheroff ;
326 cfg->contains_sky = found_sky ;
327 cfg->contains_dither = found_dither ;
332 static void parse_section_cleanmean(
339 dval = iniparser_getdouble(sym,
"cleanmean:loreject", -1.) ;
342 cfg -> loReject = dval ;
349 dval = iniparser_getdouble(sym,
"cleanmean:hireject", -1.) ;
352 cfg -> hiReject = dval ;
362 static void parse_section_badpixel(
370 ival = iniparser_getboolean(sym,
"badpixel:interpolind", -1) ;
373 cfg -> interpolInd = ival ;
380 cval = iniparser_getstr(sym,
"badpixel:mask") ;
383 strcpy (cfg -> mask , cval) ;
390 ival = iniparser_getint(sym,
"badpixel:maxrad", -1) ;
393 cfg -> maxRad = ival ;
400 cval = iniparser_getstr(sym,
"badpixel:slitposlist") ;
403 strcpy (cfg -> slitposList , cval) ;
412 static void parse_section_badpix(
421 ival = iniparser_getboolean(sym,
"badpix:badind", -1) ;
424 cfg -> badInd = ival ;
431 cval = iniparser_getstr(sym,
"badpix:maskname") ;
434 strcpy (cfg -> maskname , cval) ;
441 dval = iniparser_getdouble(sym,
"badpix:sigmafactor", -1.) ;
444 cfg -> sigmaFactor = dval ;
451 dval = iniparser_getdouble(sym,
"badpix:factor", -1.) ;
454 cfg -> factor = dval ;
461 ival = iniparser_getint(sym,
"badpix:iterations", -1) ;
464 cfg -> iterations = ival ;
471 dval = iniparser_getdouble(sym,
"badpix:badloreject", -1.) ;
474 cfg -> badLoReject = dval ;
481 dval = iniparser_getdouble(sym,
"badpix:badhireject", -1.) ;
484 cfg -> badHiReject = dval ;
491 ival = iniparser_getint(sym,
"badpix:llx", -1) ;
501 ival = iniparser_getint(sym,
"badpix:lly", -1) ;
511 ival = iniparser_getint(sym,
"badpix:urx", -1) ;
521 ival = iniparser_getint(sym,
"badpix:ury", -1) ;
534 static void parse_section_thresh(
542 ival = iniparser_getboolean(sym,
"thresh:threshind", -1) ;
545 cfg -> threshInd = ival ;
552 dval = iniparser_getdouble(sym,
"thresh:meanfactor", -1.) ;
555 cfg -> meanfactor = dval ;
#define sinfo_msg_error(...)
Print an error message.
#define sinfo_msg_warning(...)
Print an warning message.