VISIR Pipeline Reference Manual  4.1.0
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) \
89 if (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) \
109 if (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) \
121 if (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) \
134 if (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) \
147 if (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 /*----------------------------------------------------------------------------*/
180 cpl_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", FALSE, "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  /* --eccmax */
467  VISIR_PARAMETER_SET(VISIR_PARAM_ECCMAX, "eccmax", CPL_TYPE_DOUBLE,
468  "The maximum eccentricity allowed in the combination "
469  "of the three (in parallel nod/chopping) or four (in "
470  "perpendicular nod/chopping) beams. In parallel mode, "
471  "three perfectly aligned points spaced with the "
472  "chopnod throw will have eccentricity 0, while in "
473  "perpedicular mode a square with the chopnod throw as "
474  "the side length will have eccentricity 0",
475  0.25, "eccmax");
476 
477  cpl_free(context);
478 
479  cpl_ensure_code(!cpl_error_get_code(), cpl_error_get_code());
480  cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
481 
482  return CPL_ERROR_NONE;
483 }
484 
485 /*----------------------------------------------------------------------------*/
495 /*----------------------------------------------------------------------------*/
496 cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist * self,
497  const char * recipe,
498  visir_parameter bitmask)
499 {
500 
501  int nbits = 0;
502  cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
503 
504 
505  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
506  cpl_ensure(self, CPL_ERROR_NULL_INPUT, CPL_FALSE);
507  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
508 
509  /* --auto_bpm */
510  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_AUTOBPM, "auto_bpm");
511 
512  /* --g */
513  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_GLITCH, "rem_glitch");
514 
515  /* --p */
516  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_PURGE, "purge_bad");
517 
518  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_REFINE, "refine");
519 
520  /* --fixcombi */
521  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_FIXCOMBI, "fixcombi");
522 
523  /* --mstripe */
524  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_STRIPMOR, "mstripe");
525 
526  /* --bkgcorrect */
527  VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_BKG_CORRECT, "bkgcorrect");
528 
529 
530  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
531  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
532 
533  return value;
534 
535 }
536 
537 
538 /*----------------------------------------------------------------------------*/
548 /*----------------------------------------------------------------------------*/
549 int visir_parameterlist_get_int(const cpl_parameterlist * self,
550  const char * recipe,
551  visir_parameter bitmask)
552 {
553 
554  int nbits = 0;
555  int value = 0; /* Avoid (false) uninit warning */
556 
557 
558  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
559  cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0);
560  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
561 
562 
563  /* --plot */
564  VISIR_PARAMETER_GET_INT(VISIR_PARAM_PLOT, "plot");
565 
566  /* --orderoffset */
567  VISIR_PARAMETER_GET_INT(VISIR_PARAM_ORDEROFF, "orderoffset");
568 
569  /* --nsamples */
570  VISIR_PARAMETER_GET_INT(VISIR_PARAM_NSAMPLES, "nsamples");
571 
572  /* --hsize */
573  VISIR_PARAMETER_GET_INT(VISIR_PARAM_HALFSIZE, "hsize");
574 
575  /* --nstripe */
576  VISIR_PARAMETER_GET_INT(VISIR_PARAM_STRIPITE, "nstripe");
577 
578  /* --rl */
579  VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJLEFT, "reject_left");
580 
581  /* --rr */
582  VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJRIGHT, "reject_right");
583 
584 
585  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
586  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0);
587 
588  return value;
589 
590 }
591 
592 /*----------------------------------------------------------------------------*/
602 /*----------------------------------------------------------------------------*/
603 double visir_parameterlist_get_double(const cpl_parameterlist * self,
604  const char * recipe,
605  visir_parameter bitmask)
606 {
607 
608  int nbits = 0;
609  double value = DBL_MAX; /* Avoid (false) uninit warning */
610 
611 
612  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
613  cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0.0);
614  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
615 
616  /* --slit_skew */
617  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SLITSKEW, "phi");
618 
619  /* --spectrum_skew */
620  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SPECSKEW, "ksi");
621 
622  /* --vert_arc */
623  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_VERTARC, "eps");
624 
625  /* --hori_arc */
626  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HORIARC, "delta");
627 
628  /* --jy_val */
629  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_JYVAL, "jy_val");
630 
631  /* --low */
632  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_LOWLIM, "low");
633 
634  /* --high */
635  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HIGHLIM, "high");
636 
637  /* --emis_tol */
638  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_EMIS_TOL, "emis_tol");
639 
640  /* --qeff */
641  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_QEFF, "qeff");
642 
643  /* --hot_t */
644  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HOT_LIM, "hot_threshold");
645 
646  /* --cold_t */
647  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_COLD_LIM, "cold_threshold");
648 
649  /* --dev_t */
650  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_DEV_LIM, "dev_threshold");
651 
652  /* --eccmax */
653  VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_ECCMAX, "eccmax");
654 
655  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
656  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
657 
658  return value;
659 
660 }
661 
662 
663 
664 /*----------------------------------------------------------------------------*/
673 /*----------------------------------------------------------------------------*/
674 const char * visir_parameterlist_get_string(const cpl_parameterlist * self,
675  const char * recipe,
676  visir_parameter bitmask)
677 {
678 
679  int nbits = 0;
680  const char * value = NULL; /* Avoid (false) uninit warning */
681  const cpl_boolean is_combine
682  = bitmask & VISIR_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
683 
684  cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
685  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
686 
687  /* --nod */
688  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_NODPOS, "nodding");
689 
690  /* --rej */
691  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJECT, "rej");
692 
693  /* --off */
694  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OFFSETS, "offsets");
695 
696  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REFINE, "refine");
697 
698  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OBJECTS, "objects");
699 
700  /* --xcorr */
701  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_XCORR, "xcorr");
702 
703  /* --radii */
704  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RADII, "radii");
705 
706  /* --r */
707  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJBORD, "rej_bord");
708 
709  /* --combine */
710  VISIR_PARAMETER_GET_STRING(VISIR_PARAM_COMBINE, "comb_meth");
711 
712  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
713  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
714 
715  assert(value != NULL);
716 
717  /* FIXME: This should be handled by the enum */
718  if (is_combine)
719  cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
720  strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
721  NULL);
722 
723  return value;
724 
725 }
726 
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_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.
cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist *self, const char *recipe, visir_parameter bitmask)
Retrieve the value of a VISIR boolean 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.