IIINSTRUMENT Pipeline Reference Manual 4.4.3
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 "20-20-30", "radii");
355
356 /* --low */
357 VISIR_PARAMETER_SET(VISIR_PARAM_LOWLIM, "low", CPL_TYPE_DOUBLE,
358 "Low threshold for the bad pixel map",
359 0.2, "low");
360
361 /* --high */
362 VISIR_PARAMETER_SET(VISIR_PARAM_HIGHLIM, "high", CPL_TYPE_DOUBLE,
363 "High threshold for the bad pixel map",
364 5.0, "high");
365
366 /* --fixcombi */
367 VISIR_PARAMETER_SET(VISIR_PARAM_FIXCOMBI, "fixcombi", CPL_TYPE_BOOL,
368 "Perform the distortion correction on the combined "
369 "image, and not on each of the jittered images. "
370 "This will reduce excution time and degrade the quality "
371 "of the combined image",
372 FALSE, "fixcombi");
373
374 /* --emis_tol */
375 VISIR_PARAMETER_SET(VISIR_PARAM_EMIS_TOL, "emis_tol", CPL_TYPE_DOUBLE,
376 "The computation of the mean and standard deviation "
377 "of the sensitivity is done for wavelengths with an "
378 "atmospheric emissivity of at most "
379 "emis_min + emis_tol * (emis_max - emis_min), where "
380 "emis_min is the minimum emissivity in the observed "
381 "wavelength range and emis_max is the ditto maximum. "
382 "Thus emis_tol = 1 means that all wavelengths are "
383 "included.",
384 1.0, "emis_tol");
385
386 /* --qeff */
387 VISIR_PARAMETER_SET(VISIR_PARAM_QEFF, "qeff", CPL_TYPE_DOUBLE,
388 "Ignored",
389 1.0, "qeff");
390
391 /* --r */
392 VISIR_PARAMETER_SET(VISIR_PARAM_REJBORD, "rej_bord", CPL_TYPE_STRING,
393 "Rejected left right bottom and top border (pixel)",
394 "50 50 50 50", "r");
395
396 /* --hot_t */
397 VISIR_PARAMETER_SET(VISIR_PARAM_HOT_LIM, "hot_threshold", CPL_TYPE_DOUBLE,
398 "Hot pixel map threshold", 10.0, "hot_t");
399
400 /* --cold_t */
401 VISIR_PARAMETER_SET(VISIR_PARAM_COLD_LIM, "cold_threshold", CPL_TYPE_DOUBLE,
402 "Cold pixel map threshold", 6.0, "cold_t");
403
404 /* --dev_t */
405 VISIR_PARAMETER_SET(VISIR_PARAM_DEV_LIM, "dev_threshold", CPL_TYPE_DOUBLE,
406 "Deviant pixel map threshold", 5.0, "dev_t");
407
408 /* --nsamples */
409 VISIR_PARAMETER_SET(VISIR_PARAM_NSAMPLES, "nsamples", CPL_TYPE_INT,
410 "Number of samples for Read-Out Noise (RON) computation",
411 100, "nsamples");
412
413 /* --hsize */
414 VISIR_PARAMETER_SET(VISIR_PARAM_HALFSIZE, "hsize", CPL_TYPE_INT,
415 "Half size of the window for Read-Out Noise (RON) "
416 "computation", 2, "hsize");
417
418 /* --comb_meth */
419 /* FIXME: Use cpl_parameter_new_enum() */
420 VISIR_PARAMETER_SET(VISIR_PARAM_COMBINE, "comb_meth", CPL_TYPE_STRING,
421 "Combine images using one of: 1) Onto the first image "
422 "(first); 2) Their union (union); 3) Their intersection"
423 " (inter). NB: Only the 'first'-method produces an "
424 "image product with WCS coordinates. A successful "
425 "'first'-method always produces a combined image with "
426 "dimensions equal to those of the input images. "
427 "For the 'union'-method the result image is at least "
428 "as large as the input images while for the 'inter'-"
429 "method the result image is at most as large as the "
430 "input images", "union", "combine_method");
431
432 if (bitmask & VISIR_PARAM_STRIPNON) {
433 bitmask ^= VISIR_PARAM_STRIPNON;
434 /* The is not a real option - its presence means that the default value
435 for the destriping iterations is zero */
436 dostrip = CPL_FALSE;
437 }
438
439 /* --nstripe */
440 VISIR_PARAMETER_SET(VISIR_PARAM_STRIPITE, "nstripe",
441 CPL_TYPE_INT, "Max number of destriping iterations "
442 "(0 to disable destriping). Horizontal destriping is "
443 "done first and if no horizontal striping is detected, "
444 "vertical destriping is performed", dostrip ? 15 : 0,
445 "destripe_iterations");
446
447 /* --mstripe */
448 VISIR_PARAMETER_SET(VISIR_PARAM_STRIPMOR, "mstripe", CPL_TYPE_BOOL,
449 "Destripe with morphological cleaning", FALSE,
450 "destripe_morpho");
451
452 /* --rl */
453 VISIR_PARAMETER_SET(VISIR_PARAM_REJLEFT, "reject_left", CPL_TYPE_INT,
454 "Reject leftmost columns in spectrum extraction, zero "
455 "means all columns on the left are used. In cross-"
456 "dispersion mode a (small) negative number may be used "
457 "(pixel)", 0, "rl");
458
459 /* --rr */
460 VISIR_PARAMETER_SET(VISIR_PARAM_REJRIGHT, "reject_right", CPL_TYPE_INT,
461 "Reject rightmost columns in spectrum extraction, zero "
462 "means all columns on the right are used. In cross-"
463 "dispersion mode a (small) negative number may be used "
464 "(pixel)", 0, "rr");
465
466 /* --apfile */
467 VISIR_PARAMETER_SET(VISIR_PARAM_APERT_FILE, "apfile", CPL_TYPE_STRING,
468 "An optional ASCII file specification of the aperture "
469 "definitions to use during spectral extraction. "
470 "Each line must contain either 3 fields for optimal "
471 "extraction, or an even number of fields greater than 5 "
472 "for aperture extraction. For optimal extraction, the "
473 "1st field should be 'O', and for aperture extraction "
474 "it should be 'A'. In both cases the next pair of fields "
475 "indicate the left & right edges of the source aperture "
476 "in pixel coordinates. For aperture extraction, fields "
477 "after the 3rd define the sky apertures coordinates, "
478 "with the 4th field indicating the method used to "
479 "determine the sky background [one of 'A' (average), "
480 "'F' (linear fit), or 'M' (median)] followed by at "
481 "least one pair of pixel coordinates representing the "
482 "left & right edge of a sky aperture. You may supply "
483 "more sky apertures by supplying additional pixel "
484 "coordinate pairs after the first. Multiple lines "
485 "targeting the same order are allowed.",
486 VISIR_STR_PAR_EMPTY, "apfile");
487
488 /* --ro_noise */
489 VISIR_PARAMETER_SET(VISIR_PARAM_RONOISE, "ron", CPL_TYPE_DOUBLE,
490 "Readout noise of the detector",
491 14.5, "ro_noise");
492
493 /* --eccmax */
494 VISIR_PARAMETER_SET(VISIR_PARAM_ECCMAX, "eccmax", CPL_TYPE_DOUBLE,
495 "The maximum eccentricity allowed in the combination "
496 "of the three (in parallel nod/chopping) or four (in "
497 "perpendicular nod/chopping) beams. In parallel mode, "
498 "three perfectly aligned points spaced with the "
499 "chopnod throw will have eccentricity 0, while in "
500 "perpedicular mode a square with the chopnod throw as "
501 "the side length will have eccentricity 0",
502 0.25, "eccmax");
503
504 /* --ox_sigma */
505 VISIR_PARAMETER_SET(VISIR_PARAM_OXSIGMA, "optex_sigma", CPL_TYPE_DOUBLE,
506 "Sigma to use for clipping in optimal extraction",
507 5.0, "ox_sigma");
508
509 /* --ox_niters */
510 VISIR_PARAMETER_SET(VISIR_PARAM_OXNITER, "optex_niters", CPL_TYPE_INT,
511 "Number of optimal extraction iterations to perform",
512 2, "ox_niters");
513
514 /* --ox_smooth */
515 VISIR_PARAMETER_SET(VISIR_PARAM_OXSMOOTH, "optex_smooth", CPL_TYPE_INT,
516 "Width of smoothing window to use along spectral "
517 "dimension during optimal extraction. A median filter "
518 "is used.",
519 31, "ox_smooth");
520
521 /* --gain */
522 VISIR_PARAMETER_SET(VISIR_PARAM_GAIN, "gain", CPL_TYPE_DOUBLE,
523 "Detector gain",
524 0.75, "gain");
525
526 /* --ox_kernel */
527 VISIR_PARAMETER_SET(VISIR_PARAM_OXKERNEL, "optex_kernel", CPL_TYPE_INT,
528 "Size of square smoothing kernel, in pixels, to apply "
529 "to science frame before optimal extraction (ignored "
530 "during aperture extraction). A median filter is used.",
531 3, "ox_kernel");
532
533 /* --respcal */
534 VISIR_PARAMETER_SET(VISIR_PARAM_RESPCAL, "respcal", CPL_TYPE_STRING,
535 "An optional path to a FITS file containing a 1-D "
536 "fringe model to be divided into the 1-D extracted "
537 "spectra in order to remove the fringes.",
538 VISIR_STR_PAR_EMPTY, "respcal");
539
540 cpl_free(context);
541
542 cpl_ensure_code(!cpl_error_get_code(), cpl_error_get_code());
543 cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
544
545 return CPL_ERROR_NONE;
546}
547
548/*----------------------------------------------------------------------------*/
558/*----------------------------------------------------------------------------*/
559cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist * self,
560 const char * recipe,
561 visir_parameter bitmask)
562{
563
564 int nbits = 0;
565 cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
566
567
568 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
569 cpl_ensure(self, CPL_ERROR_NULL_INPUT, CPL_FALSE);
570 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
571
572 /* --auto_bpm */
573 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_AUTOBPM, "auto_bpm");
574
575 /* --g */
576 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_GLITCH, "rem_glitch");
577
578 /* --p */
579 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_PURGE, "purge_bad");
580
581 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_REFINE, "refine");
582
583 /* --fixcombi */
584 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_FIXCOMBI, "fixcombi");
585
586 /* --mstripe */
587 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_STRIPMOR, "mstripe");
588
589 /* --bkgcorrect */
590 VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_BKG_CORRECT, "bkgcorrect");
591
592
593 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
594 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
595
596 return value;
597
598}
599
600
601/*----------------------------------------------------------------------------*/
611/*----------------------------------------------------------------------------*/
612int visir_parameterlist_get_int(const cpl_parameterlist * self,
613 const char * recipe,
614 visir_parameter bitmask)
615{
616
617 int nbits = 0;
618 int value = 0; /* Avoid (false) uninit warning */
619
620
621 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
622 cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0);
623 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
624
625
626 /* --plot */
627 VISIR_PARAMETER_GET_INT(VISIR_PARAM_PLOT, "plot");
628
629 /* --orderoffset */
630 VISIR_PARAMETER_GET_INT(VISIR_PARAM_ORDEROFF, "orderoffset");
631
632 /* --nsamples */
633 VISIR_PARAMETER_GET_INT(VISIR_PARAM_NSAMPLES, "nsamples");
634
635 /* --hsize */
636 VISIR_PARAMETER_GET_INT(VISIR_PARAM_HALFSIZE, "hsize");
637
638 /* --nstripe */
639 VISIR_PARAMETER_GET_INT(VISIR_PARAM_STRIPITE, "nstripe");
640
641 /* --rl */
642 VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJLEFT, "reject_left");
643
644 /* --rr */
645 VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJRIGHT, "reject_right");
646
647 /* --ox_niters */
648 VISIR_PARAMETER_GET_INT(VISIR_PARAM_OXNITER, "optex_niters");
649
650 /* --ox_smooth */
651 VISIR_PARAMETER_GET_INT(VISIR_PARAM_OXSMOOTH, "optex_smooth");
652
653 /* --ox_kernel */
654 VISIR_PARAMETER_GET_INT(VISIR_PARAM_OXKERNEL, "optex_kernel");
655
656
657 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
658 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0);
659
660 return value;
661
662}
663
664/*----------------------------------------------------------------------------*/
674/*----------------------------------------------------------------------------*/
675double visir_parameterlist_get_double(const cpl_parameterlist * self,
676 const char * recipe,
677 visir_parameter bitmask)
678{
679
680 int nbits = 0;
681 double value = DBL_MAX; /* Avoid (false) uninit warning */
682
683
684 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
685 cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0.0);
686 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
687
688 /* --slit_skew */
689 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SLITSKEW, "phi");
690
691 /* --spectrum_skew */
692 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SPECSKEW, "ksi");
693
694 /* --vert_arc */
695 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_VERTARC, "eps");
696
697 /* --hori_arc */
698 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HORIARC, "delta");
699
700 /* --ro_noise */
701 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_RONOISE, "ron");
702
703 /* --jy_val */
704 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_JYVAL, "jy_val");
705
706 /* --low */
707 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_LOWLIM, "low");
708
709 /* --high */
710 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HIGHLIM, "high");
711
712 /* --emis_tol */
713 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_EMIS_TOL, "emis_tol");
714
715 /* --qeff */
716 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_QEFF, "qeff");
717
718 /* --hot_t */
719 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HOT_LIM, "hot_threshold");
720
721 /* --cold_t */
722 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_COLD_LIM, "cold_threshold");
723
724 /* --dev_t */
725 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_DEV_LIM, "dev_threshold");
726
727 /* --eccmax */
728 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_ECCMAX, "eccmax");
729
730 /* --ox_sigma */
731 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_OXSIGMA, "optex_sigma");
732
733 /* --gain */
734 VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_GAIN, "gain");
735
736 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
737 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
738
739 return value;
740
741}
742
743
744
745/*----------------------------------------------------------------------------*/
754/*----------------------------------------------------------------------------*/
755const char * visir_parameterlist_get_string(const cpl_parameterlist * self,
756 const char * recipe,
757 visir_parameter bitmask)
758{
759
760 int nbits = 0;
761 const char * value = NULL; /* Avoid (false) uninit warning */
762 const cpl_boolean is_combine
763 = bitmask & VISIR_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
764
765 cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
766 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
767
768 /* --nod */
769 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_NODPOS, "nodding");
770
771 /* --rej */
772 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJECT, "rej");
773
774 /* --off */
775 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OFFSETS, "offsets");
776
777 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REFINE, "refine");
778
779 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OBJECTS, "objects");
780
781 /* --xcorr */
782 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_XCORR, "xcorr");
783
784 /* --radii */
785 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RADII, "radii");
786
787 /* --r */
788 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJBORD, "rej_bord");
789
790 /* --combine */
791 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_COMBINE, "comb_meth");
792
793 /* --apfile */
794 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_APERT_FILE, "apfile");
795
796 /* --apfile */
797 VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RESPCAL, "respcal");
798
799 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
800 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
801
802 assert(value != NULL);
803
804 /* FIXME: This should be handled by the enum */
805 if (is_combine)
806 cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
807 strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
808 NULL);
809
810 return value;
811
812}
813
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.