32 #include "sinfo_lamp_ini.h"
37 parse_section_general(dictionary *, lamp_config *,
int *);
39 parse_section_resampling(dictionary *, lamp_config *,
int *);
41 parse_section_extractspectrum(dictionary *, lamp_config *,
int *);
69 generateLamp_ini_file(
char * ini_name,
char * name_i,
char * name_o,
74 if (sinfo_file_exists(ini_name)) {
77 if ((ini_file = fopen(ini_name,
"w")) == (FILE*) NULL ) {
84 "# Configuration file for the extraction of a halogen lamp spectrumn"
87 fprintf(ini_file,
"#\n\n[Eclipse]\n");
88 fprintf(ini_file,
"VersionNumber = %s\n\n", get_eclipse_version());
92 "# ----- [General] configures various software stuff\n"
94 "# This section is not mandatory. All eclipse routines\n"
95 "# should be set once for all in a .eclipse-rc file.\n"
96 "# If you choose to use the variables here, they will\n"
97 "# override the settings you have in the environment.\n"
98 "# See the eclipse installation manual to see what\n"
99 "# these variables refer to.\n"
103 "# MaximumMemory = 512 ; integer, maximum megs to allocate in RAM\n"
104 "# MaximumSwap = 2048 ; integer, maximum megs to allocate in swap\n"
105 "# TmpDirName = . ; path to temporary directory\n"
107 "Verbose = no ; verbose mode activation\n"
108 "Debug = no ; debug mode activation\n"
110 "# LogFile = yes ; activate message logging to a file\n"
111 "# LogFileName = /tmp/spiffi-log ; log file name\n"
116 "# the following are the names given in the argument of the python script\n"
119 fprintf(ini_file,
"InFrame = %s ; input file name\n"
120 "Wavemapim = %s ; file name of the wavelength map\n"
121 "OutName = %s ; name of output fits file\n", name_i,
126 "# [Resampling] resamples the spectra to a given pixel length\n"
127 "# ExtractSpectrum] takes the clean mean along the spatial pixels \n"
128 "# by avoiding the bad pixel positions and delivers the final \n"
129 "# halogen lamp\n" "# spectrum\n"
132 "Ncoeffs = 3 ; number of coefficients for the polynomial\n"
134 "Nrows = 2560 ; number of image rows in the resampled frame\n"
135 " (2560 for single frames, 5120 for dithered)\n"
136 "[ExtractSpectrum]\n"
137 "LoReject = 0.1 ; percentage of rejected low intensity pixels\n"
138 " before averaging\n"
139 "HiReject = 0.1 ; percentage of rejected high intensity pixels\n"
140 " before averaging\n"
141 "CountsToIntensity = 1. ; intensity conversion factor: counts per\n"
164 parse_lamp_ini_file(
char * ini_name)
170 if (!sinfo_file_exists(ini_name)) {
174 sym = iniparser_load(ini_name);
180 cfg = sinfo_lamp_cfg_create();
183 iniparser_freedict(sym);
193 parse_section_general(sym, cfg, &status);
194 parse_section_resampling(sym, cfg, &status);
195 parse_section_extractspectrum(sym, cfg, &status);
197 iniparser_freedict(sym);
201 sinfo_lamp_cfg_destroy(cfg);
225 parse_section_general(dictionary * sym, lamp_config * cfg,
int *status)
233 cval = iniparser_getstr(sym,
"eclipse:versionnumber");
235 if (strcmp(cval, get_eclipse_version())) {
238 get_eclipse_version());
245 ival = iniparser_getint(sym,
"general:maximummemory", -1);
247 sinfo_set_memory_parameter(
"max_ram", ival);
248 ival = iniparser_getint(sym,
"general:maximumswap", -1);
250 sinfo_set_memory_parameter(
"max_swap", ival);
251 sinfo_set_verbose(iniparser_getboolean(sym,
"general:verbose", 0));
252 sinfo_set_debug(iniparser_getboolean(sym,
"general:debug", 0));
254 cval = iniparser_getstr(sym,
"general:tmpdirname");
256 sinfo_set_tmpdirname(cval);
259 sinfo_set_tmpdirname(
".");
262 ival = iniparser_getboolean(sym,
"general:logfile", 0);
264 cval = iniparser_getstr(sym,
"general:logfilename");
266 sinfo_set_logfile(1);
267 sinfo_set_logfilename(cval);
270 sinfo_set_logfile(0);
273 cval = iniparser_getstr(sym,
"general:inframe");
275 strcpy(cfg->inFrame, cval);
281 cval = iniparser_getstr(sym,
"general:wavemapim");
283 strcpy(cfg->wavemapim, cval);
290 cval = iniparser_getstr(sym,
"general:outname");
292 strcpy(cfg->outName, cval);
299 if (sinfo_verbose_active())
300 sinfo_print_memory_parameters();
305 parse_section_resampling(dictionary * sym, lamp_config * cfg,
int *status)
309 ival = iniparser_getint(sym,
"resampling:ncoeffs", -1);
318 ival = iniparser_getint(sym,
"resampling:nrows", -1);
332 parse_section_extractspectrum(dictionary * sym, lamp_config * cfg,
int *status)
336 dval = iniparser_getdouble(sym,
"extractspectrum:loreject", -1.);
338 cfg->loReject = dval;
344 dval = iniparser_getdouble(sym,
"extractspectrum:hireject", -1.);
346 cfg->hiReject = dval;
352 dval = iniparser_getdouble(sym,
"extractspectrum:countstointensity", -1.);
354 cfg->countsToIntensity = dval;