IIINSTRUMENT Pipeline Reference Manual 4.5.1
visir_parameter.c
1/* $Id: visir_parameter.c,v 1.32 2013-02-27 11:06:35 jtaylor Exp $
2 *
3 * This file is part of the VISIR Pipeline
4 * Copyright (C) 2002,2003 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: jtaylor $
23 * $Date: 2013-02-27 11:06:35 $
24 * $Revision: 1.32 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32/*-----------------------------------------------------------------------------
33 Includes
34 -----------------------------------------------------------------------------*/
35
36#include <string.h>
37#include <math.h>
38#include <float.h>
39#include <assert.h>
40#include <cpl.h>
41
42#include "irplib_utils.h"
43
44#include "visir_parameter.h"
45#include "visir_dfs.h"
46#include "visir_pfits.h"
47
48/*-----------------------------------------------------------------------------
49 Define
50 -----------------------------------------------------------------------------*/
51
52#define visir_plot_manpage \
53 "The recipe can produce a number of predefined plots. " \
54 "Zero means that none of the plots are produced, while " \
55 "increasing values (e.g. 1 or 2) increases the number " \
56 "of plots produced. If the plotting fails a warning is " \
57 "produced, and the recipe continues. " \
58 "The default behaviour of the plotting is to use " \
59 "gnuplot (with option -persist). The recipe currently " \
60 "produces 1D-plots using gnuplot commands. The recipe " \
61 "user can control the actual plotting-command used by " \
62 "the recipe to create the plot by setting the " \
63 "environment variable CPL_PLOTTER. Currently, if " \
64 "CPL_PLOTTER " \
65 "is set it must contain the string 'gnuplot'. Setting " \
66 "it to 'cat > my_gnuplot_$$.txt' causes a number of " \
67 "ASCII-files to be created, which each produce a plot " \
68 "when given as standard input to gnuplot (e.g. later " \
69 "or on a different computer). A finer control of the " \
70 "plotting options can be obtained by writing an " \
71 "executable script, e.g. my_gnuplot.pl, that " \
72 "executes gnuplot after setting the desired gnuplot " \
73 "options (e.g. set terminal pslatex color) " \
74 "and then setting CPL_PLOTTER to my_gnuplot.pl. " \
75 "The predefined plots include plotting of images. " \
76 "Images can be plotted not only with gnuplot, but also " \
77 "using the pnm format. This is controlled with the " \
78 "environment variable CPL_IMAGER. If CPL_IMAGER " \
79 "is set to a string that does not contain the word " \
80 "gnuplot, the recipe will generate the plot in pnm " \
81 "format. E.g. setting CPL_IMAGER to " \
82 "'display - &' will produce a gray-scale image " \
83 "using the image viewer display."
84
85
86
87/* To be called from visir_parameter_set() */
88#define VISIR_PARAMETER_SET(MASK, VARNAME, TYPE, MAN, DEFAULT, SHORT) \
89if (bitmask & MASK) { \
90 char * paramname = cpl_sprintf(PACKAGE ".%s." VARNAME, recipe); \
91 \
92 p = cpl_parameter_new_value(paramname, TYPE, MAN, context, DEFAULT); \
93 cpl_free(paramname); \
94 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, SHORT); \
95 cpl_parameterlist_append(self, p); \
96 \
97 (void)cpl_error_set_where(cpl_func); /* Propagate error, if any */ \
98 \
99 bitmask ^= MASK; /* Reset bit. At the end bitmask must be zero */ \
100 \
101 /* Verify that each mask value is unique */ \
102 if (chkmask & MASK) \
103 (void)cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED); \
104 chkmask |= MASK; \
105}
106
107/* To be called from visir_parameterlist_get_bool() */
108#define VISIR_PARAMETER_GET_BOOL(MASK, VARNAME) \
109if (bitmask & MASK) { \
110 value = irplib_parameterlist_get_bool(self, PACKAGE, recipe, VARNAME); \
111 \
112 cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), \
113 return(CPL_FALSE), "mask=0x%llx", MASK); \
114 nbits++; /* Total number of bits must be one */ \
115 bitmask ^= MASK; /* - bitmask must be zero at the end */ \
116 \
117}
118
119/* To be called from visir_parameterlist_get_int() */
120#define VISIR_PARAMETER_GET_INT(MASK, VARNAME) \
121if (bitmask & MASK) { \
122 value = irplib_parameterlist_get_int(self, PACKAGE, recipe, VARNAME); \
123 \
124 cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(0), \
125 "mask=0x%llx", MASK); \
126 \
127 nbits++; /* Total number of bits must be one */ \
128 bitmask ^= MASK; /* - bitmask must be zero at the end */ \
129 \
130}
131
132/* To be called from visir_parameterlist_get_double() */
133#define VISIR_PARAMETER_GET_DOUBLE(MASK, VARNAME) \
134if (bitmask & MASK) { \
135 value = irplib_parameterlist_get_double(self, PACKAGE, recipe, VARNAME); \
136 \
137 cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(0.0), \
138 "mask=0x%llx", MASK); \
139 \
140 nbits++; /* Total number of bits must be one */ \
141 bitmask ^= MASK; /* - bitmask must be zero at the end */ \
142 \
143}
144
145/* To be called from visir_parameterlist_get_string() */
146#define VISIR_PARAMETER_GET_STRING(MASK, VARNAME) \
147if (bitmask & MASK) { \
148 value = irplib_parameterlist_get_string(self, PACKAGE, recipe, VARNAME); \
149 \
150 cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(NULL),\
151 "mask=0x%llx", MASK); \
152 \
153 nbits++; /* Total number of bits must be one */ \
154 bitmask ^= MASK; /* - bitmask must be zero at the end */ \
155 \
156}
157
158
159/*----------------------------------------------------------------------------*/
165/*----------------------------------------------------------------------------*/
166
170/*----------------------------------------------------------------------------*/
179/*----------------------------------------------------------------------------*/
180cpl_error_code visir_parameter_set(cpl_parameterlist * self,
181 const char * recipe,
182 visir_parameter bitmask)
183{
184
185 cpl_parameter * p;
186 char * context;
187 visir_parameter chkmask = 0; /* Verify that each mask value is unique */
188 cpl_boolean zerodist = CPL_FALSE;
189 cpl_boolean dostrip = CPL_TRUE;
190
191
192 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
193 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
194
195 context = cpl_sprintf(PACKAGE ".%s", recipe);
196
197 /* --nod */
198 VISIR_PARAMETER_SET(VISIR_PARAM_NODPOS, "nodding", CPL_TYPE_STRING,
199 "An optional ASCII specification of the nodding positions "
200 "(in case they are missing from the FITS-file). "
201 "The file must consist of one line per input FITS-file "
202 "and each line must consist of an integer (which is "
203 "ignored) followed by a 0 or 1 (to indicate object or sky). ",
204 VISIR_STR_PAR_EMPTY, "nod");
205
206 /* --auto_bpm */
207 VISIR_PARAMETER_SET(VISIR_PARAM_AUTOBPM, "auto_bpm", CPL_TYPE_BOOL,
208 "Automatic detection and correction of bad pixels",
209 TRUE, "auto_bpm");
210
211 /* --g */
212 VISIR_PARAMETER_SET(VISIR_PARAM_GLITCH, "rem_glitch", CPL_TYPE_BOOL,
213 "Automatic filtering of glitches", FALSE, "g");
214
215 /* --p */
216 VISIR_PARAMETER_SET(VISIR_PARAM_PURGE, "purge_bad", CPL_TYPE_BOOL,
217 "Automatic purging of half-cycle images whose median "
218 "deviates more than a factor three from the mean of "
219 "the medians of half-cycle images or whose standard "
220 "deviation deviates more than a factor three from the "
221 "mean of their standard deviations", FALSE, "p");
222
223 /* --union */
224 VISIR_PARAMETER_SET(VISIR_PARAM_UNION, "union", CPL_TYPE_BOOL,
225 "Combine images using their union, as opposed to their "
226 "intersection (deprecated and ignored, "
227 "see --combine_method)", TRUE, "union");
228
229 /* --rej */
230 VISIR_PARAMETER_SET(VISIR_PARAM_REJECT, "rej", CPL_TYPE_STRING,
231 "Each resulting pixel is the average of the "
232 "corresponding (interpolated) pixel value in each "
233 "jittered image. A positive value, n1, for the first "
234 "of the two integers specifies that for each pixel the "
235 "smallest n1 pixel values shall be ignored in the "
236 "averaging. Similarly, a positive value, n2, for the "
237 "second of the two integers specifies that for each "
238 "pixel the largest n2 pixel values shall be ignored in "
239 "the averaging.", "0-0", "rej");
240
241 VISIR_PARAMETER_SET(VISIR_PARAM_BKG_CORRECT, "bkgcorrect", CPL_TYPE_BOOL,
242 "Subtract the median from the spectral column before "
243 "extracting the wavelength. This is required when "
244 "the skylines do not correctly cancel due to gratting "
245 "oscillations", TRUE, "bkgcorrect");
246
247 /* --plot */
248 VISIR_PARAMETER_SET(VISIR_PARAM_PLOT, "plot", CPL_TYPE_INT,
249 visir_plot_manpage, 0, "plot");
250
251 if (bitmask & VISIR_PARAM_ZERODIST) {
252 bitmask ^= VISIR_PARAM_ZERODIST;
253 /* The is not a real option - its presence means that the default value
254 for the distortion correction parameters are all zero */
255 zerodist = CPL_TRUE;
256 }
257
258
259 /* TODO temporary aquarius parameters for commissioning, not very good */
260 /* --slit_skew */
261 /* The detector skew in pixels over the hole detector */
262 /* phi = atan(28.6/1024); */
263 VISIR_PARAMETER_SET(VISIR_PARAM_SLITSKEW, "phi", CPL_TYPE_DOUBLE,
264 "Distortion correction: Skew of slit (degrees) "
265 "(clockwise)", zerodist ? 0.0 : 0.52, "slit_skew");
266
267 /* --spectrum_skew */
268 /* The detector skew in pixels over the hole detector */
269 /* ksi = atan(12.5/1024); */
270 VISIR_PARAMETER_SET(VISIR_PARAM_SPECSKEW, "ksi", CPL_TYPE_DOUBLE,
271 "Distortion correction: LMR Skew of spectrum (degrees) "
272 "(counter-clockwise). Not used in High Resolution",
273 zerodist ? 0.0 : 1.73, "spectrum_skew");
274
275 /* --vert_arc */
276 /* LR eps = 0.052mm/0.050mm [pixel] (PXSPACE = 50 micron) */
277 VISIR_PARAMETER_SET(VISIR_PARAM_VERTARC, "eps", CPL_TYPE_DOUBLE,
278 "Distortion correction: LR Detector vertical curvature "
279 "(pixel). Reduced by a factor 4 in MR. Not used in HR "
280 "A-side. Increased by a factor 115/52 in HR B-side",
281 zerodist ? 0.0 : -0.8, "vert_arc");
282
283 /* --hori_arc */
284 /* delta = 0.004mm/0.050mm [pixel] (PXSPACE = 50 micron) */
285 VISIR_PARAMETER_SET(VISIR_PARAM_HORIARC, "delta", CPL_TYPE_DOUBLE,
286 "Distortion correction: LMR Detector horizontal "
287 "curvature (pixel). Increased by a factor 1.5 in HR "
288 "A-side. Reduced by a factor 2 in HR B-side",
289 zerodist ? 0.0 : 0, "hori_arc");
290
291 /* --orderoffset */
292 VISIR_PARAMETER_SET(VISIR_PARAM_ORDEROFF, "orderoffset", CPL_TYPE_INT,
293 "Echelle order offset. The offset is relative to the "
294 "main order. The allowed range of offsets depend on "
295 "the selected grism. The offset can never exceed +/-4. "
296 "If the main order is e.g. 8 an order offset of +1 "
297 "will cause the recipe to base the data reduction on "
298 "order 9. With a positive order offset the central "
299 "wavelength becomes smaller while for a negative "
300 "order offset the central wavelength becomes larger.", 0,
301 "orderoffset");
302
303 /* --off */
304 VISIR_PARAMETER_SET(VISIR_PARAM_OFFSETS, "offsets", CPL_TYPE_STRING,
305 "An optional ASCII specification of the offsets "
306 "in case those in FITS-headers are missing or wrong. "
307 "The file must consist of one line per input pair of "
308 "FITS-files, and each line must consist of two "
309 "numbers which represent the shift in pixels of that "
310 "image relative to the first image. The first line "
311 "should thus comprise two zeros. Correct FITS-header "
312 "offsets mean that the i'th X offset can be gotten "
313 "from Xoffset_0 - Xoffset_i, where Xoffset_i is the "
314 "value of " VISIR_PFITS_DOUBLE_CUMOFFSETX " and "
315 "likewise for Y.", VISIR_STR_PAR_EMPTY, "off");
316
317 VISIR_PARAMETER_SET(VISIR_PARAM_REFINE, "refine", CPL_TYPE_BOOL,
318 "User-defined refining of the image offsets. See "
319 "options objs and xcorr", FALSE, "ref");
320
321 VISIR_PARAMETER_SET(VISIR_PARAM_OBJECTS, "objects", CPL_TYPE_STRING,
322 "The shift and add of images needs anchor points that "
323 "typically are bright objects. These are normally "
324 "detected automatically but with user-defined refining "
325 "of offsets enabled, they must be provided by the user "
326 "through an ASCII file containing one line per anchor "
327 "point with each line consisting of its x and y "
328 "coordinate (in pixels). This file is ignored with "
329 "user-defined refining of offsets disabled.",
330 VISIR_STR_PAR_EMPTY, "objs");
331
332
333 /* --xcorr */
334 VISIR_PARAMETER_SET(VISIR_PARAM_XCORR, "xcorr", CPL_TYPE_STRING,
335 "If user-defined refining of offsets is enabled a "
336 "cross-correlation of the images is performed. In "
337 "order to speed up this process, this cross-"
338 "correlation is performed only on smaller rectangles "
339 "around the anchor points. The first two parameters "
340 "is the half-size of this rectangle in pixels. The "
341 "second pair is the maximum shift in x and y (pixels) "
342 "evaluated by the cross-correlation on the rectangle. "
343 "Used only if user-defined refining of offsets is enabled.",
344 "10-10-25-25", "xcorr");
345
346 /* --jy_val */
347 VISIR_PARAMETER_SET(VISIR_PARAM_JYVAL, "jy_val", CPL_TYPE_DOUBLE,
348 "The flux of the standard star in Jansky",
349 -999.0, "jy_val");
350
351 /* --radii */
352 VISIR_PARAMETER_SET(VISIR_PARAM_RADII, "radii", CPL_TYPE_STRING,
353 "Radii : star_max bg_int bg_ext. "
354 "If set to \"default\", "
355 "the value 20-20-30 is used for DRS data, "
356 "and 40-40-50 for Aquarius data.",
357 "default", "radii");
358
359 /* --low */
360 VISIR_PARAMETER_SET(VISIR_PARAM_LOWLIM, "low", CPL_TYPE_DOUBLE,
361 "Low threshold for the bad pixel map",
362 0.2, "low");
363
364 /* --high */
365 VISIR_PARAMETER_SET(VISIR_PARAM_HIGHLIM, "high", CPL_TYPE_DOUBLE,
366 "High threshold for the bad pixel map",
367 5.0, "high");
368
369 /* --fixcombi */
370 VISIR_PARAMETER_SET(VISIR_PARAM_FIXCOMBI, "fixcombi", CPL_TYPE_BOOL,
371 "Perform the distortion correction on the combined "
372 "image, and not on each of the jittered images. "
373 "This will reduce excution time and degrade the quality "
374 "of the combined image",
375 FALSE, "fixcombi");
376
377 /* --emis_tol */
378 VISIR_PARAMETER_SET(VISIR_PARAM_EMIS_TOL, "emis_tol", CPL_TYPE_DOUBLE,
379 "The computation of the mean and standard deviation "
380 "of the sensitivity is done for wavelengths with an "
381 "atmospheric emissivity of at most "
382 "emis_min + emis_tol * (emis_max - emis_min), where "
383 "emis_min is the minimum emissivity in the observed "
384 "wavelength range and emis_max is the ditto maximum. "
385 "Thus emis_tol = 1 means that all wavelengths are "
386 "included.",
387 1.0, "emis_tol");
388
389 /* --qeff */
390 VISIR_PARAMETER_SET(VISIR_PARAM_QEFF, "qeff", CPL_TYPE_DOUBLE,
391 "Ignored",
392 1.0, "qeff");
393
394 /* --r */
395 VISIR_PARAMETER_SET(VISIR_PARAM_REJBORD, "rej_bord", CPL_TYPE_STRING,
396 "Rejected left right bottom and top border (pixel)",
397 "50 50 50 50", "r");
398
399 /* --hot_t */
400 VISIR_PARAMETER_SET(VISIR_PARAM_HOT_LIM, "hot_threshold", CPL_TYPE_DOUBLE,
401 "Hot pixel map threshold", 10.0, "hot_t");
402
403 /* --cold_t */
404 VISIR_PARAMETER_SET(VISIR_PARAM_COLD_LIM, "cold_threshold", CPL_TYPE_DOUBLE,
405 "Cold pixel map threshold", 6.0, "cold_t");
406
407 /* --dev_t */
408 VISIR_PARAMETER_SET(VISIR_PARAM_DEV_LIM, "dev_threshold", CPL_TYPE_DOUBLE,
409 "Deviant pixel map threshold", 5.0, "dev_t");
410
411 /* --nsamples */
412 VISIR_PARAMETER_SET(VISIR_PARAM_NSAMPLES, "nsamples", CPL_TYPE_INT,
413 "Number of samples for Read-Out Noise (RON) computation",
414 100, "nsamples");
415
416 /* --hsize */
417 VISIR_PARAMETER_SET(VISIR_PARAM_HALFSIZE, "hsize", CPL_TYPE_INT,
418 "Half size of the window for Read-Out Noise (RON) "
419 "computation", 2, "hsize");
420
421 /* --comb_meth */
422 /* FIXME: Use cpl_parameter_new_enum() */
423 VISIR_PARAMETER_SET(VISIR_PARAM_COMBINE, "comb_meth", CPL_TYPE_STRING,
424 "Combine images using one of: 1) Onto the first image "
425 "(first); 2) Their union (union); 3) Their intersection"
426 " (inter). NB: Only the 'first'-method produces an "
427 "image product with WCS coordinates. A successful "
428 "'first'-method always produces a combined image with "
429 "dimensions equal to those of the input images. "
430 "For the 'union'-method the result image is at least "
431 "as large as the input images while for the 'inter'-"
432 "method the result image is at most as large as the "
433 "input images", "union", "combine_method");
434
435 if (bitmask & VISIR_PARAM_STRIPNON) {
436 bitmask ^= VISIR_PARAM_STRIPNON;
437 /* The is not a real option - its presence means that the default value
438 for the destriping iterations is zero */
439 dostrip = CPL_FALSE;
440 }
441
442 /* --nstripe */
443 VISIR_PARAMETER_SET(VISIR_PARAM_STRIPITE, "nstripe",
444 CPL_TYPE_INT, "Max number of destriping iterations "
445 "(0 to disable destriping). Horizontal destriping is "
446 "done first and if no horizontal striping is detected, "
447 "vertical destriping is performed", dostrip ? 15 : 0,
448 "destripe_iterations");
449
450 /* --mstripe */
451 VISIR_PARAMETER_SET(VISIR_PARAM_STRIPMOR, "mstripe", CPL_TYPE_BOOL,
452 "Destripe with morphological cleaning", FALSE,
453 "destripe_morpho");
454
455 /* --rl */
456 VISIR_PARAMETER_SET(VISIR_PARAM_REJLEFT, "reject_left", CPL_TYPE_INT,
457 "Reject leftmost columns in spectrum extraction, zero "
458 "means all columns on the left are used. In cross-"
459 "dispersion mode a (small) negative number may be used "
460 "(pixel)", 0, "rl");
461
462 /* --rr */
463 VISIR_PARAMETER_SET(VISIR_PARAM_REJRIGHT, "reject_right", CPL_TYPE_INT,
464 "Reject rightmost columns in spectrum extraction, zero "
465 "means all columns on the right are used. In cross-"
466 "dispersion mode a (small) negative number may be used "
467 "(pixel)", 0, "rr");
468
469 /* --apfile */
470 VISIR_PARAMETER_SET(VISIR_PARAM_APERT_FILE, "apfile", CPL_TYPE_STRING,
471 "An optional ASCII file specification of the aperture "
472 "definitions to use during spectral extraction. "
473 "Each line must contain either 3 fields for optimal "
474 "extraction, or an even number of fields greater than 5 "
475 "for aperture extraction. For optimal extraction, the "
476 "1st field should be 'O', and for aperture extraction "
477 "it should be 'A'. In both cases the next pair of fields "
478 "indicate the left & right edges of the source aperture "
479 "in pixel coordinates. For aperture extraction, fields "
480 "after the 3rd define the sky apertures coordinates, "
481 "with the 4th field indicating the method used to "
482 "determine the sky background [one of 'A' (average), "
483 "'F' (linear fit), or 'M' (median)] followed by at "
484 "least one pair of pixel coordinates representing the "
485 "left & right edge of a sky aperture. You may supply "
486 "more sky apertures by supplying additional pixel "
487 "coordinate pairs after the first. Multiple lines "
488 "targeting the same order are allowed.",
489 VISIR_STR_PAR_EMPTY, "apfile");
490
491 /* --ro_noise */
492 VISIR_PARAMETER_SET(VISIR_PARAM_RONOISE, "ron", CPL_TYPE_DOUBLE,
493 "Readout noise of the detector",
494 14.5, "ro_noise");
495
496 /* --eccmax */
497 VISIR_PARAMETER_SET(VISIR_PARAM_ECCMAX, "eccmax", CPL_TYPE_DOUBLE,
498 "The maximum eccentricity allowed in the combination "
499 "of the three (in parallel nod/chopping) or four (in "
500 "perpendicular nod/chopping) beams. In parallel mode, "
501 "three perfectly aligned points spaced with the "
502 "chopnod throw will have eccentricity 0, while in "
503 "perpedicular mode a square with the chopnod throw as "
504 "the side length will have eccentricity 0",
505 0.25, "eccmax");
506
507 /* --ox_sigma */
508 VISIR_PARAMETER_SET(VISIR_PARAM_OXSIGMA, "optex_sigma", CPL_TYPE_DOUBLE,
509 "Sigma to use for clipping in optimal extraction",
510 5.0, "ox_sigma");
511
512 /* --ox_niters */
513 VISIR_PARAMETER_SET(VISIR_PARAM_OXNITER, "optex_niters", CPL_TYPE_INT,
514 "Number of optimal extraction iterations to perform",
515 2, "ox_niters");
516
517 /* --ox_smooth */
518 VISIR_PARAMETER_SET(VISIR_PARAM_OXSMOOTH, "optex_smooth", CPL_TYPE_INT,
519 "Width of smoothing window to use along spectral "
520 "dimension during optimal extraction. A median filter "
521 "is used.",
522 31, "ox_smooth");
523
524 /* --gain */
525 VISIR_PARAMETER_SET(VISIR_PARAM_GAIN, "gain", CPL_TYPE_DOUBLE,
526 "Detector gain",
527 0.75, "gain");
528
529 /* --ox_kernel */
530 VISIR_PARAMETER_SET(VISIR_PARAM_OXKERNEL, "optex_kernel", CPL_TYPE_INT,
531 "Size of square smoothing kernel, in pixels, to apply "
532 "to science frame before optimal extraction (ignored "
533 "during aperture extraction). A median filter is used.",
534 3, "ox_kernel");
535
536 /* --respcal */
537 VISIR_PARAMETER_SET(VISIR_PARAM_RESPCAL, "respcal", CPL_TYPE_STRING,
538 "An optional path to a FITS file containing a 1-D "
539 "fringe model to be divided into the 1-D extracted "
540 "spectra in order to remove the fringes.",
541 VISIR_STR_PAR_EMPTY, "respcal");
542
543 cpl_free(context);
544
545 cpl_ensure_code(!cpl_error_get_code(), cpl_error_get_code());
546 cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
547
548 return CPL_ERROR_NONE;
549}
550
551/*----------------------------------------------------------------------------*/
561/*----------------------------------------------------------------------------*/
562cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist * self,
563 const char * recipe,
564 visir_parameter bitmask)
565{
566
567 int nbits = 0;
568 cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
569
570
571 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
572 cpl_ensure(self, CPL_ERROR_NULL_INPUT, CPL_FALSE);
573 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
574
575 /* --auto_bpm */
576 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_AUTOBPM, "auto_bpm");
577
578 /* --g */
579 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_GLITCH, "rem_glitch");
580
581 /* --p */
582 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_PURGE, "purge_bad");
583
584 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_REFINE, "refine");
585
586 /* --fixcombi */
587 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_FIXCOMBI, "fixcombi");
588
589 /* --mstripe */
590 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_STRIPMOR, "mstripe");
591
592 /* --bkgcorrect */
593 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_BKG_CORRECT, "bkgcorrect");
594
595
596 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
597 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
598
599 return value;
600
601}
602
603
604/*----------------------------------------------------------------------------*/
614/*----------------------------------------------------------------------------*/
615int visir_parameterlist_get_int(const cpl_parameterlist * self,
616 const char * recipe,
617 visir_parameter bitmask)
618{
619
620 int nbits = 0;
621 int value = 0; /* Avoid (false) uninit warning */
622
623
624 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
625 cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0);
626 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
627
628
629 /* --plot */
630 VISIR_PARAMETER_GET_INT(VISIR_PARAM_PLOT, "plot");
631
632 /* --orderoffset */
633 VISIR_PARAMETER_GET_INT(VISIR_PARAM_ORDEROFF, "orderoffset");
634
635 /* --nsamples */
636 VISIR_PARAMETER_GET_INT(VISIR_PARAM_NSAMPLES, "nsamples");
637
638 /* --hsize */
639 VISIR_PARAMETER_GET_INT(VISIR_PARAM_HALFSIZE, "hsize");
640
641 /* --nstripe */
642 VISIR_PARAMETER_GET_INT(VISIR_PARAM_STRIPITE, "nstripe");
643
644 /* --rl */
645 VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJLEFT, "reject_left");
646
647 /* --rr */
648 VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJRIGHT, "reject_right");
649
650 /* --ox_niters */
651 VISIR_PARAMETER_GET_INT(VISIR_PARAM_OXNITER, "optex_niters");
652
653 /* --ox_smooth */
654 VISIR_PARAMETER_GET_INT(VISIR_PARAM_OXSMOOTH, "optex_smooth");
655
656 /* --ox_kernel */
657 VISIR_PARAMETER_GET_INT(VISIR_PARAM_OXKERNEL, "optex_kernel");
658
659
660 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
661 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0);
662
663 return value;
664
665}
666
667/*----------------------------------------------------------------------------*/
677/*----------------------------------------------------------------------------*/
678double visir_parameterlist_get_double(const cpl_parameterlist * self,
679 const char * recipe,
680 visir_parameter bitmask)
681{
682
683 int nbits = 0;
684 double value = DBL_MAX; /* Avoid (false) uninit warning */
685
686
687 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
688 cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0.0);
689 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
690
691 /* --slit_skew */
692 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SLITSKEW, "phi");
693
694 /* --spectrum_skew */
695 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SPECSKEW, "ksi");
696
697 /* --vert_arc */
698 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_VERTARC, "eps");
699
700 /* --hori_arc */
701 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HORIARC, "delta");
702
703 /* --ro_noise */
704 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_RONOISE, "ron");
705
706 /* --jy_val */
707 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_JYVAL, "jy_val");
708
709 /* --low */
710 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_LOWLIM, "low");
711
712 /* --high */
713 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HIGHLIM, "high");
714
715 /* --emis_tol */
716 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_EMIS_TOL, "emis_tol");
717
718 /* --qeff */
719 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_QEFF, "qeff");
720
721 /* --hot_t */
722 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HOT_LIM, "hot_threshold");
723
724 /* --cold_t */
725 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_COLD_LIM, "cold_threshold");
726
727 /* --dev_t */
728 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_DEV_LIM, "dev_threshold");
729
730 /* --eccmax */
731 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_ECCMAX, "eccmax");
732
733 /* --ox_sigma */
734 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_OXSIGMA, "optex_sigma");
735
736 /* --gain */
737 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_GAIN, "gain");
738
739 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
740 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
741
742 return value;
743
744}
745
746
747
748/*----------------------------------------------------------------------------*/
757/*----------------------------------------------------------------------------*/
758const char * visir_parameterlist_get_string(const cpl_parameterlist * self,
759 const char * recipe,
760 visir_parameter bitmask)
761{
762
763 int nbits = 0;
764 const char * value = NULL; /* Avoid (false) uninit warning */
765 const cpl_boolean is_combine
766 = bitmask & VISIR_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
767
768 cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
769 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
770
771 /* --nod */
772 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_NODPOS, "nodding");
773
774 /* --rej */
775 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJECT, "rej");
776
777 /* --off */
778 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OFFSETS, "offsets");
779
780 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REFINE, "refine");
781
782 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OBJECTS, "objects");
783
784 /* --xcorr */
785 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_XCORR, "xcorr");
786
787 /* --radii */
788 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RADII, "radii");
789
790 /* --r */
791 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJBORD, "rej_bord");
792
793 /* --combine */
794 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_COMBINE, "comb_meth");
795
796 /* --apfile */
797 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_APERT_FILE, "apfile");
798
799 /* --apfile */
800 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RESPCAL, "respcal");
801
802 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
803 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
804
805 assert(value != NULL);
806
807 /* FIXME: This should be handled by the enum */
808 if (is_combine)
809 cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
810 strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
811 NULL);
812
813 return value;
814
815}
816
cpl_error_code visir_parameter_set(cpl_parameterlist *self, const char *recipe, visir_parameter bitmask)
Define the specified parameters.
int visir_parameterlist_get_int(const cpl_parameterlist *self, const char *recipe, visir_parameter bitmask)
Retrieve the value of a VISIR integer parameter.
const char * visir_parameterlist_get_string(const cpl_parameterlist *self, const char *recipe, visir_parameter bitmask)
Retrieve the value of a VISIR string parameter.
double visir_parameterlist_get_double(const cpl_parameterlist *self, const char *recipe, visir_parameter bitmask)
Retrieve the value of a VISIR parameter of type double.
cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist *self, const char *recipe, visir_parameter bitmask)
Retrieve the value of a VISIR boolean parameter.