NACO Pipeline Reference Manual  4.4.0
naco_parameter.c
1 /* $Id: naco_parameter.c,v 1.31 2011-11-18 09:05:51 llundin Exp $
2  *
3  * This file is part of the NACO 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: llundin $
23  * $Date: 2011-11-18 09:05:51 $
24  * $Revision: 1.31 $
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_stdstar.h>
43 #include <irplib_strehl.h>
44 
45 #include "irplib_utils.h"
46 
47 #include "naco_parameter.h"
48 #include "naco_dfs.h"
49 #include "naco_pfits.h"
50 
51 /*-----------------------------------------------------------------------------
52  Define
53  -----------------------------------------------------------------------------*/
54 
55 #define naco_plot_manpage \
56  "The recipe can produce a number of predefined plots. " \
57  "Zero means that none of the plots are produced, while " \
58  "increasing values (e.g. 1 or 2) increases the number " \
59  "of plots produced. If the plotting fails a warning is " \
60  "produced, and the recipe continues. " \
61  "The default behaviour of the plotting is to use " \
62  "gnuplot (with option -persist). The recipe currently " \
63  "produces 1D-plots using gnuplot commands. The recipe " \
64  "user can control the actual plotting-command used by " \
65  "the recipe to create the plot by setting the " \
66  "environment variable CPL_PLOTTER. Currently, if " \
67  "CPL_PLOTTER " \
68  "is set it must contain the string 'gnuplot'. Setting " \
69  "it to 'cat > my_gnuplot_$$.txt' causes a number of " \
70  "ASCII-files to be created, which each produce a plot " \
71  "when given as standard input to gnuplot (e.g. later " \
72  "or on a different computer). A finer control of the " \
73  "plotting options can be obtained by writing an " \
74  "executable script, e.g. my_gnuplot.pl, that " \
75  "executes gnuplot after setting the desired gnuplot " \
76  "options (e.g. set terminal pslatex color) " \
77  "and then setting CPL_PLOTTER to my_gnuplot.pl. " \
78  "The predefined plots include plotting of images. " \
79  "Images can be plotted not only with gnuplot, but also " \
80  "using the pnm format. This is controlled with the " \
81  "environment variable CPL_IMAGER. If CPL_IMAGER " \
82  "is set to a string that does not contain the word " \
83  "gnuplot, the recipe will generate the plot in pnm " \
84  "format. E.g. setting CPL_IMAGER to " \
85  "'display - &' will produce a gray-scale image " \
86  "using the image viewer display."
87 
88 
89 #define NACO_XCORR_SX 10
90 #define NACO_XCORR_SY 10
91 
92 /* To be called from naco_parameter_set() */
93 #define NACO_PARAMETER_SET(MASK, VARNAME, TYPE, MAN, DEFAULT, SHORT) \
94 if (bitmask & MASK) { \
95  char * paramname = cpl_sprintf(PACKAGE ".%s." VARNAME, recipe); \
96  \
97  p = cpl_parameter_new_value(paramname, TYPE, MAN, context, DEFAULT); \
98  cpl_free(paramname); \
99  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, SHORT); \
100  cpl_parameterlist_append(self, p); \
101  \
102  if (cpl_error_get_code()) /* Propagate error */ \
103  (void)cpl_error_set_where(cpl_func); \
104  \
105  bitmask ^= MASK; /* Reset bit. At the end bitmask must be zero */ \
106  \
107  /* Verify that each mask value is unique */ \
108  if (chkmask & MASK) \
109  (void)cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED); \
110  chkmask |= MASK; \
111  \
112 }
113 
114 /* To be called from naco_parameterlist_get_bool() */
115 #define NACO_PARAMETER_GET_BOOL(MASK, VARNAME) \
116 if (bitmask & MASK) { \
117  value = irplib_parameterlist_get_bool(self, PACKAGE, recipe, VARNAME); \
118  \
119  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE); \
120  \
121  nbits++; /* Total number of bits must be one */ \
122  bitmask ^= MASK; /* - bitmask must be zero at the end */ \
123  \
124 }
125 
126 /* To be called from naco_parameterlist_get_int() */
127 #define NACO_PARAMETER_GET_INT(MASK, VARNAME) \
128 if (bitmask & MASK) { \
129  value = irplib_parameterlist_get_int(self, PACKAGE, recipe, VARNAME); \
130  \
131  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0); \
132  \
133  nbits++; /* Total number of bits must be one */ \
134  bitmask ^= MASK; /* - bitmask must be zero at the end */ \
135  \
136 }
137 
138 /* To be called from naco_parameterlist_get_double() */
139 #define NACO_PARAMETER_GET_DOUBLE(MASK, VARNAME) \
140 if (bitmask & MASK) { \
141  value = irplib_parameterlist_get_double(self, PACKAGE, recipe, VARNAME); \
142  \
143  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0); \
144  \
145  nbits++; /* Total number of bits must be one */ \
146  bitmask ^= MASK; /* - bitmask must be zero at the end */ \
147  \
148 }
149 
150 /* To be called from naco_parameterlist_get_string() */
151 #define NACO_PARAMETER_GET_STRING(MASK, VARNAME) \
152 if (bitmask & MASK) { \
153  value = irplib_parameterlist_get_string(self, PACKAGE, recipe, VARNAME); \
154  \
155  cpl_ensure(value != NULL, cpl_error_get_code(), NULL); \
156  \
157  nbits++; /* Total number of bits must be one */ \
158  bitmask ^= MASK; /* - bitmask must be zero at the end */ \
159  \
160 }
161 
162 
163 /*----------------------------------------------------------------------------*/
169 /*----------------------------------------------------------------------------*/
170 
174 /*----------------------------------------------------------------------------*/
183 /*----------------------------------------------------------------------------*/
184 cpl_error_code naco_parameter_set(cpl_parameterlist * self,
185  const char * recipe,
186  naco_parameter bitmask)
187 {
188 
189  cpl_parameter * p;
190  char * context;
191  naco_parameter chkmask = 0; /* Verify that each mask value is unique */
192 
193 
194  cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
195  cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
196 
197 
198  context = cpl_sprintf(PACKAGE ".%s", recipe);
199 
200  /* --xtmax */
201  NACO_PARAMETER_SET(NACO_PARAM_XTMAX, "extract_max", CPL_TYPE_INT,
202  "Stop the spectrum extraction at this column", 1024,
203  "xtmax");
204 
205  /* --xtmin */
206  NACO_PARAMETER_SET(NACO_PARAM_XTMIN, "extract_min", CPL_TYPE_INT,
207  "Start the spectrum extraction at this column", 1,
208  "xtmin");
209 
210  /* --save */
211  NACO_PARAMETER_SET(NACO_PARAM_SAVE, "save", CPL_TYPE_INT,
212  "A positive value causes additional, intermediate "
213  "products to be saved", 0, "save");
214 
215  /* --plot */
216  NACO_PARAMETER_SET(NACO_PARAM_PLOT, "plot", CPL_TYPE_INT,
217  naco_plot_manpage, 0, "plot");
218 
219  /* --star_r */
220  NACO_PARAMETER_SET(NACO_PARAM_STAR_R, "star_r", CPL_TYPE_DOUBLE,
221  "The star radius [arcsecond]",
222  IRPLIB_STREHL_STAR_RADIUS, "star_r");
223 
224  /* --bg_r1 */
225  NACO_PARAMETER_SET(NACO_PARAM_BG_RINT, "bg_r1", CPL_TYPE_DOUBLE,
226  "The internal radius of the background [arcsecond]",
227  IRPLIB_STREHL_BACKGROUND_R1, "bg_r1");
228 
229  /* --bg_r2 */
230  NACO_PARAMETER_SET(NACO_PARAM_BG_REXT, "bg_r2", CPL_TYPE_DOUBLE,
231  "The external radius of the background [arcsecond]",
232  IRPLIB_STREHL_BACKGROUND_R2, "bg_r2");
233 
234  /* --r */
235  NACO_PARAMETER_SET(NACO_PARAM_REJBORD, "rej_bord", CPL_TYPE_STRING,
236  "Rejected left right bottom and top border [pixel]",
237  "200 200 200 200", "r");
238 
239  /* --hot_t */
240  NACO_PARAMETER_SET(NACO_PARAM_HOT_LIM, "hot_threshold", CPL_TYPE_DOUBLE,
241  "Hot pixel map threshold", 10.0, "hot_t");
242 
243  /* --cold_t */
244  NACO_PARAMETER_SET(NACO_PARAM_COLD_LIM, "cold_threshold", CPL_TYPE_DOUBLE,
245  "Cold pixel map threshold", 6.0, "cold_t");
246 
247  /* --dev_t */
248  NACO_PARAMETER_SET(NACO_PARAM_DEV_LIM, "dev_threshold", CPL_TYPE_DOUBLE,
249  "Deviant pixel map threshold", 5.0, "dev_t");
250 
251  /* --nsamples */
252  NACO_PARAMETER_SET(NACO_PARAM_NSAMPLES, "nsamples", CPL_TYPE_INT,
253  "Number of samples for RON computation", 100,
254  "nsamples");
255 
256  /* --hsize */
257  NACO_PARAMETER_SET(NACO_PARAM_HALFSIZE, "hsize", CPL_TYPE_INT,
258  "Half size of the window for RON computation", 2,
259  "hsize");
260 
261  /* --force */
262  NACO_PARAMETER_SET(NACO_PARAM_FORCE, "force", CPL_TYPE_BOOL,
263  "Force the computation", FALSE, "force");
264 
265  /* --slit_w */
266  NACO_PARAMETER_SET(NACO_PARAM_SLIT_W, "slit_width", CPL_TYPE_INT,
267  "Slit width", 20, "slit_w");
268 
269  /* --t */
270  NACO_PARAMETER_SET(NACO_PARAM_BPMTHRES, "thresholds", CPL_TYPE_STRING,
271  "Low and high thresholds for the Bad Pixel Map",
272  "0.5 2.0", "t");
273 
274  /* --prop */
275  NACO_PARAMETER_SET(NACO_PARAM_PROPFIT, "proport", CPL_TYPE_BOOL,
276  "Use the proportional fit", FALSE, "prop");
277 
278  /* --bpm */
279  NACO_PARAMETER_SET(NACO_PARAM_BPM, "bpm", CPL_TYPE_BOOL,
280  "Create the bad pixel map", FALSE, "bpm");
281 
282  /* --errmap */
283  NACO_PARAMETER_SET(NACO_PARAM_ERRORMAP, "errmap", CPL_TYPE_BOOL,
284  "Create the error map", FALSE, "errmap");
285 
286  /* --intercept */
287  NACO_PARAMETER_SET(NACO_PARAM_INTCEPT, "intercept", CPL_TYPE_BOOL,
288  "Create the intercept image", FALSE, "intercept");
289 
290  /* --ra */
291  NACO_PARAMETER_SET(NACO_PARAM_RA, "ra", CPL_TYPE_DOUBLE,
292  "Right Ascension [Degrees]", 999.0, "ra");
293 
294  /* --dec */
295  NACO_PARAMETER_SET(NACO_PARAM_DEC, "dec", CPL_TYPE_DOUBLE,
296  "DEClination [Degrees]", 999.0, "dec");
297 
298  /* --pscale */
299  NACO_PARAMETER_SET(NACO_PARAM_PIXSCALE, "pscale", CPL_TYPE_DOUBLE,
300  "Pixel scale", -1.0, "pscale");
301 
302  /* --mag */
303  NACO_PARAMETER_SET(NACO_PARAM_MAGNITD, "mag", CPL_TYPE_DOUBLE,
304  "Magnitude", IRPLIB_STDSTAR_NOMAG, "mag");
305 
306  /* --sx */
307  NACO_PARAMETER_SET(NACO_PARAM_SX, "sx", CPL_TYPE_INT,
308  "Size of the search window in X-direction [pixel]",
309  NACO_XCORR_SX, "sx");
310 
311  /* --sy */
312  NACO_PARAMETER_SET(NACO_PARAM_SY, "sy", CPL_TYPE_INT,
313  "Size of the search window in Y-direction [pixel]",
314  NACO_XCORR_SY, "sy");
315 
316  /* --check_im */
317  NACO_PARAMETER_SET(NACO_PARAM_CHK_IMG, "check_im", CPL_TYPE_BOOL,
318  "Create the check image", FALSE, "check_im");
319 
320 
321  /* --off */
322  NACO_PARAMETER_SET(NACO_PARAM_OFFSETS, "offsets", CPL_TYPE_STRING,
323  "An optional ASCII specification of the offsets "
324  "in case those in FITS-headers are missing or wrong. "
325  "The file must consist of one line per object FITS-"
326  "file and each line must consist of two "
327  "numbers which represent the shift in pixels of that "
328  "image relative to the first image. The first line "
329  "should thus comprise two zeros. Correct FITS-header "
330  "offsets mean that the i'th X offset can be gotten "
331  "from Xoffset_0 - Xoffset_i, where Xoffset_i is the "
332  "value of " NACO_PFITS_DOUBLE_CUMOFFSETX " and "
333  "likewise for Y.", NULL, "off");
334 
335  /* --objs */
336  NACO_PARAMETER_SET(NACO_PARAM_OBJECTS, "objects", CPL_TYPE_STRING,
337  "objects file", NULL, "objs");
338 
339  /* --oddeven */
340  NACO_PARAMETER_SET(NACO_PARAM_ODDEVEN, "oddeven", CPL_TYPE_BOOL,
341  "Apply the odd-even correction. Warning: This flag "
342  "currently has no effect", CPL_FALSE, "oddeven");
343 
344  /* --xcorr */
345  NACO_PARAMETER_SET(NACO_PARAM_XCORR, "xcorr", CPL_TYPE_STRING,
346  "Cross correlation search and measure sizes",
347  "40 40 65 65", "xcorr");
348 
349  /* --union */
350  NACO_PARAMETER_SET(NACO_PARAM_UNION, "union", CPL_TYPE_BOOL,
351  "Combine images using their union, as opposed to their "
352  "intersection (deprecated and ignored, "
353  "see --combine_method)", TRUE, "union");
354 
355  /* --rej */
356  NACO_PARAMETER_SET(NACO_PARAM_REJ_HILO, "rej", CPL_TYPE_STRING,
357  "Low and high number of rejected values", "2 2", "rej");
358 
359  /* --comb_meth */
360  /* Copied from visir */
361  /* FIXME: Use cpl_parameter_new_enum() */
362  NACO_PARAMETER_SET(NACO_PARAM_COMBINE, "comb_meth", CPL_TYPE_STRING,
363  "Combine images using one of: 1) Onto the first image "
364  "(first); 2) Their union (union); 3) Their intersection"
365  " (inter). NB: Only the 'first'-method produces an "
366  "image product with WCS coordinates. A successful "
367  "'first'-method always produces a combined image with "
368  "dimensions equal to those of the input images. "
369  "For the 'union'-method the result image is at least "
370  "as large as the input images while for the 'inter'-"
371  "method the result image is at most as large as the "
372  "input images", "union", "combine_method");
373 
374  /* --sky_planes */
375  NACO_PARAMETER_SET(NACO_PARAM_SKYPLANE, "sky_planes", CPL_TYPE_INT,
376  "Estimate the sky using the median of the last n planes "
377  "in the previous cube and the first n planes in the "
378  "following cube. If the cube has less than n planes "
379  "then use all planes. Zero means all. (Ignored for non-"
380  "cube data)", 25, "sky_planes");
381 
382  /* --cube_mode */
383  NACO_PARAMETER_SET(NACO_PARAM_CUBEMODE, "cube_mode", CPL_TYPE_STRING,
384  "Collapse cube data using one of: 1) No recentering "
385  "(add); 2) Shift-and-Add (saa). (Ignored for non-"
386  "cube data)", "saa", "cube_mode");
387 
388  /* --lucky_strehl */
389  NACO_PARAMETER_SET(NACO_PARAM_LUCK_STR, "lucky_strehl", CPL_TYPE_DOUBLE,
390  "In cube mode use only the frames with a strehl ratio "
391  "in the given top fraction. (Ignored for non-"
392  "cube data)", 1.0, "lucky");
393 
394  /* --save_cube */
395  NACO_PARAMETER_SET(NACO_PARAM_SAVECUBE, "save_cube", CPL_TYPE_BOOL,
396  "Append the cube of corrected object images that are "
397  "shifted added together to the product", FALSE,
398  "save_cube");
399 
400  cpl_free(context);
401 
402  cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
403 
404  /* Propagate error, if any */
405  return cpl_error_set_where(cpl_func);
406 }
407 
408 /*----------------------------------------------------------------------------*/
418 /*----------------------------------------------------------------------------*/
419 cpl_boolean naco_parameterlist_get_bool(const cpl_parameterlist * self,
420  const char * recipe,
421  naco_parameter bitmask)
422 {
423 
424  int nbits = 0;
425  cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
426 
427 
428  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
429  cpl_ensure(self, CPL_ERROR_NULL_INPUT, CPL_FALSE);
430  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
431 
432  /* --force */
433  NACO_PARAMETER_GET_BOOL(NACO_PARAM_FORCE, "force");
434 
435  /* --prop */
436  NACO_PARAMETER_GET_BOOL(NACO_PARAM_PROPFIT, "proport");
437 
438  /* --bpm */
439  NACO_PARAMETER_GET_BOOL(NACO_PARAM_BPM, "bpm");
440 
441  /* --errmap */
442  NACO_PARAMETER_GET_BOOL(NACO_PARAM_ERRORMAP, "errmap");
443 
444  /* --intercept */
445  NACO_PARAMETER_GET_BOOL(NACO_PARAM_INTCEPT, "intercept");
446 
447  /* --check_im */
448  NACO_PARAMETER_GET_BOOL(NACO_PARAM_CHK_IMG, "check_im");
449 
450  /* --oddeven */
451  NACO_PARAMETER_GET_BOOL(NACO_PARAM_ODDEVEN, "oddeven");
452 
453  /* --save_cube */
454  NACO_PARAMETER_GET_BOOL(NACO_PARAM_SAVECUBE, "save_cube");
455 
456  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
457  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
458 
459  return value;
460 
461 }
462 
463 /*----------------------------------------------------------------------------*/
473 /*----------------------------------------------------------------------------*/
474 int naco_parameterlist_get_int(const cpl_parameterlist * self,
475  const char * recipe,
476  naco_parameter bitmask)
477 {
478 
479  int nbits = 0;
480  int value = 0; /* Avoid (false) uninit warning */
481 
482 
483  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
484  cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0);
485  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
486 
487 
488  /* Must give the long name here */
489 
490  /* --xtmax */
491  NACO_PARAMETER_GET_INT(NACO_PARAM_XTMAX, "extract_max");
492 
493  /* --xtmin */
494  NACO_PARAMETER_GET_INT(NACO_PARAM_XTMIN, "extract_min");
495 
496  /* --save */
497  NACO_PARAMETER_GET_INT(NACO_PARAM_SAVE, "save");
498 
499  /* --plot */
500  NACO_PARAMETER_GET_INT(NACO_PARAM_PLOT, "plot");
501 
502  /* --nsamples */
503  NACO_PARAMETER_GET_INT(NACO_PARAM_NSAMPLES, "nsamples");
504 
505  /* --hsize */
506  NACO_PARAMETER_GET_INT(NACO_PARAM_HALFSIZE, "hsize");
507 
508  /* --sx */
509  NACO_PARAMETER_GET_INT(NACO_PARAM_SX, "sx");
510 
511  /* --sy */
512  NACO_PARAMETER_GET_INT(NACO_PARAM_SY, "sy");
513 
514  /* --slit_w */
515  NACO_PARAMETER_GET_INT(NACO_PARAM_SLIT_W, "slit_width");
516 
517  /* --sky_planes */
518  NACO_PARAMETER_GET_INT(NACO_PARAM_SKYPLANE, "sky_planes");
519 
520  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
521  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0);
522 
523  return value;
524 
525 }
526 
527 /*----------------------------------------------------------------------------*/
537 /*----------------------------------------------------------------------------*/
538 double naco_parameterlist_get_double(const cpl_parameterlist * self,
539  const char * recipe,
540  naco_parameter bitmask)
541 {
542 
543  int nbits = 0;
544  double value = DBL_MAX; /* Avoid (false) uninit warning */
545 
546 
547  cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
548  cpl_ensure(self, CPL_ERROR_NULL_INPUT, 0.0);
549  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
550 
551 
552  /* --star_r */
553  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_STAR_R, "star_r");
554 
555  /* --bg_r1 */
556  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_BG_RINT, "bg_r1");
557 
558  /* --bg_r2 */
559  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_BG_REXT, "bg_r2");
560 
561 
562  /* --hot_t */
563  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_HOT_LIM, "hot_threshold");
564 
565  /* --cold_t */
566  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_COLD_LIM, "cold_threshold");
567 
568  /* --dev_t */
569  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_DEV_LIM, "dev_threshold");
570 
571  /* --ra */
572  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_RA, "ra");
573 
574  /* --dec */
575  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_DEC, "dec");
576 
577  /* --pscale */
578  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_PIXSCALE, "pscale");
579 
580  /* --mag */
581  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_MAGNITD, "mag");
582 
583  /* --lucky_strehl */
584  NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_LUCK_STR, "lucky_strehl");
585 
586 
587  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
588  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
589 
590  return value;
591 
592 }
593 
594 /*----------------------------------------------------------------------------*/
603 /*----------------------------------------------------------------------------*/
604 const char * naco_parameterlist_get_string(const cpl_parameterlist * self,
605  const char * recipe,
606  naco_parameter bitmask)
607 {
608 
609  int nbits = 0;
610  const char * value = NULL; /* Avoid (false) uninit warning */
611  const cpl_boolean is_combine
612  = bitmask & NACO_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
613 
614  cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
615  cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
616 
617 
618  /* --r */
619  NACO_PARAMETER_GET_STRING(NACO_PARAM_REJBORD, "rej_bord");
620 
621  /* --t */
622  NACO_PARAMETER_GET_STRING(NACO_PARAM_BPMTHRES, "thresholds");
623 
624  /* --off */
625  NACO_PARAMETER_GET_STRING(NACO_PARAM_OFFSETS, "offsets");
626 
627  /* --objs */
628  NACO_PARAMETER_GET_STRING(NACO_PARAM_OBJECTS, "objects");
629 
630  /* --xcorr */
631  NACO_PARAMETER_GET_STRING(NACO_PARAM_XCORR, "xcorr");
632 
633  /* --rej */
634  NACO_PARAMETER_GET_STRING(NACO_PARAM_REJ_HILO, "rej");
635 
636  /* --combine */
637  NACO_PARAMETER_GET_STRING(NACO_PARAM_COMBINE, "comb_meth");
638 
639  /* --cube_mode */
640  NACO_PARAMETER_GET_STRING(NACO_PARAM_CUBEMODE, "cube_mode");
641 
642 
643  cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
644  cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
645 
646  assert(value != NULL);
647 
648  /* FIXME: This should be handled by the enum */
649  if (is_combine)
650  cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
651  strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
652  NULL);
653 
654  return value;
655 }
656 
#define IRPLIB_STREHL_STAR_RADIUS
The radius of the star, [Arcseconds].
Definition: irplib_strehl.h:81
int naco_parameterlist_get_int(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO integer parameter.
double naco_parameterlist_get_double(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO parameter of type double.
cpl_boolean naco_parameterlist_get_bool(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO boolean parameter.
cpl_error_code naco_parameter_set(cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Define the specified parameters.
#define IRPLIB_STREHL_BACKGROUND_R2
The outer radius of the noise-estimation region, [Arcseconds].
Definition: irplib_strehl.h:99
#define IRPLIB_STREHL_BACKGROUND_R1
The inner radius of the noise-estimation region, [Arcseconds].
Definition: irplib_strehl.h:90
const char * naco_parameterlist_get_string(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO string parameter.