42 #include <irplib_stdstar.h>
43 #include <irplib_strehl.h>
45 #include "irplib_utils.h"
47 #include "naco_parameter.h"
49 #include "naco_pfits.h"
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 " \
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."
89 #define NACO_XCORR_SX 10
90 #define NACO_XCORR_SY 10
93 #define NACO_PARAMETER_SET(MASK, VARNAME, TYPE, MAN, DEFAULT, SHORT) \
94 if (bitmask & MASK) { \
95 char * paramname = cpl_sprintf(PACKAGE ".%s." VARNAME, recipe); \
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); \
102 if (cpl_error_get_code()) \
103 (void)cpl_error_set_where(cpl_func); \
108 if (chkmask & MASK) \
109 (void)cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED); \
115 #define NACO_PARAMETER_GET_BOOL(MASK, VARNAME) \
116 if (bitmask & MASK) { \
117 value = irplib_parameterlist_get_bool(self, PACKAGE, recipe, VARNAME); \
119 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE); \
127 #define NACO_PARAMETER_GET_INT(MASK, VARNAME) \
128 if (bitmask & MASK) { \
129 value = irplib_parameterlist_get_int(self, PACKAGE, recipe, VARNAME); \
131 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0); \
139 #define NACO_PARAMETER_GET_DOUBLE(MASK, VARNAME) \
140 if (bitmask & MASK) { \
141 value = irplib_parameterlist_get_double(self, PACKAGE, recipe, VARNAME); \
143 cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0); \
151 #define NACO_PARAMETER_GET_STRING(MASK, VARNAME) \
152 if (bitmask & MASK) { \
153 value = irplib_parameterlist_get_string(self, PACKAGE, recipe, VARNAME); \
155 cpl_ensure(value != NULL, cpl_error_get_code(), NULL); \
186 naco_parameter bitmask)
191 naco_parameter chkmask = 0;
194 cpl_ensure_code(
self, CPL_ERROR_NULL_INPUT);
195 cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
198 context = cpl_sprintf(PACKAGE
".%s", recipe);
201 NACO_PARAMETER_SET(NACO_PARAM_XTMAX,
"extract_max", CPL_TYPE_INT,
202 "Stop the spectrum extraction at this column", 1024,
206 NACO_PARAMETER_SET(NACO_PARAM_XTMIN,
"extract_min", CPL_TYPE_INT,
207 "Start the spectrum extraction at this column", 1,
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");
216 NACO_PARAMETER_SET(NACO_PARAM_PLOT,
"plot", CPL_TYPE_INT,
217 naco_plot_manpage, 0,
"plot");
220 NACO_PARAMETER_SET(NACO_PARAM_STAR_R,
"star_r", CPL_TYPE_DOUBLE,
221 "The star radius [arcsecond]",
225 NACO_PARAMETER_SET(NACO_PARAM_BG_RINT,
"bg_r1", CPL_TYPE_DOUBLE,
226 "The internal radius of the background [arcsecond]",
230 NACO_PARAMETER_SET(NACO_PARAM_BG_REXT,
"bg_r2", CPL_TYPE_DOUBLE,
231 "The external radius of the background [arcsecond]",
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");
240 NACO_PARAMETER_SET(NACO_PARAM_HOT_LIM,
"hot_threshold", CPL_TYPE_DOUBLE,
241 "Hot pixel map threshold", 10.0,
"hot_t");
244 NACO_PARAMETER_SET(NACO_PARAM_COLD_LIM,
"cold_threshold", CPL_TYPE_DOUBLE,
245 "Cold pixel map threshold", 6.0,
"cold_t");
248 NACO_PARAMETER_SET(NACO_PARAM_DEV_LIM,
"dev_threshold", CPL_TYPE_DOUBLE,
249 "Deviant pixel map threshold", 5.0,
"dev_t");
252 NACO_PARAMETER_SET(NACO_PARAM_NSAMPLES,
"nsamples", CPL_TYPE_INT,
253 "Number of samples for RON computation", 100,
257 NACO_PARAMETER_SET(NACO_PARAM_HALFSIZE,
"hsize", CPL_TYPE_INT,
258 "Half size of the window for RON computation", 2,
262 NACO_PARAMETER_SET(NACO_PARAM_FORCE,
"force", CPL_TYPE_BOOL,
263 "Force the computation", FALSE,
"force");
266 NACO_PARAMETER_SET(NACO_PARAM_SLIT_W,
"slit_width", CPL_TYPE_INT,
267 "Slit width", 20,
"slit_w");
270 NACO_PARAMETER_SET(NACO_PARAM_BPMTHRES,
"thresholds", CPL_TYPE_STRING,
271 "Low and high thresholds for the Bad Pixel Map",
275 NACO_PARAMETER_SET(NACO_PARAM_PROPFIT,
"proport", CPL_TYPE_BOOL,
276 "Use the proportional fit", FALSE,
"prop");
279 NACO_PARAMETER_SET(NACO_PARAM_BPM,
"bpm", CPL_TYPE_BOOL,
280 "Create the bad pixel map", FALSE,
"bpm");
283 NACO_PARAMETER_SET(NACO_PARAM_ERRORMAP,
"errmap", CPL_TYPE_BOOL,
284 "Create the error map", FALSE,
"errmap");
287 NACO_PARAMETER_SET(NACO_PARAM_INTCEPT,
"intercept", CPL_TYPE_BOOL,
288 "Create the intercept image", FALSE,
"intercept");
291 NACO_PARAMETER_SET(NACO_PARAM_RA,
"ra", CPL_TYPE_DOUBLE,
292 "Right Ascension [Degrees]", 999.0,
"ra");
295 NACO_PARAMETER_SET(NACO_PARAM_DEC,
"dec", CPL_TYPE_DOUBLE,
296 "DEClination [Degrees]", 999.0,
"dec");
299 NACO_PARAMETER_SET(NACO_PARAM_PIXSCALE,
"pscale", CPL_TYPE_DOUBLE,
300 "Pixel scale", -1.0,
"pscale");
303 NACO_PARAMETER_SET(NACO_PARAM_MAGNITD,
"mag", CPL_TYPE_DOUBLE,
304 "Magnitude", IRPLIB_STDSTAR_NOMAG,
"mag");
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");
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");
317 NACO_PARAMETER_SET(NACO_PARAM_CHK_IMG,
"check_im", CPL_TYPE_BOOL,
318 "Create the check image", FALSE,
"check_im");
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");
336 NACO_PARAMETER_SET(NACO_PARAM_OBJECTS,
"objects", CPL_TYPE_STRING,
337 "objects file", NULL,
"objs");
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");
345 NACO_PARAMETER_SET(NACO_PARAM_XCORR,
"xcorr", CPL_TYPE_STRING,
346 "Cross correlation search and measure sizes",
347 "40 40 65 65",
"xcorr");
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");
356 NACO_PARAMETER_SET(NACO_PARAM_REJ_HILO,
"rej", CPL_TYPE_STRING,
357 "Low and high number of rejected values",
"2 2",
"rej");
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");
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");
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");
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");
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,
402 cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
405 return cpl_error_set_where(cpl_func);
421 naco_parameter bitmask)
425 cpl_boolean value = CPL_FALSE;
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);
433 NACO_PARAMETER_GET_BOOL(NACO_PARAM_FORCE,
"force");
436 NACO_PARAMETER_GET_BOOL(NACO_PARAM_PROPFIT,
"proport");
439 NACO_PARAMETER_GET_BOOL(NACO_PARAM_BPM,
"bpm");
442 NACO_PARAMETER_GET_BOOL(NACO_PARAM_ERRORMAP,
"errmap");
445 NACO_PARAMETER_GET_BOOL(NACO_PARAM_INTCEPT,
"intercept");
448 NACO_PARAMETER_GET_BOOL(NACO_PARAM_CHK_IMG,
"check_im");
451 NACO_PARAMETER_GET_BOOL(NACO_PARAM_ODDEVEN,
"oddeven");
454 NACO_PARAMETER_GET_BOOL(NACO_PARAM_SAVECUBE,
"save_cube");
456 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
457 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
476 naco_parameter bitmask)
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);
491 NACO_PARAMETER_GET_INT(NACO_PARAM_XTMAX,
"extract_max");
494 NACO_PARAMETER_GET_INT(NACO_PARAM_XTMIN,
"extract_min");
497 NACO_PARAMETER_GET_INT(NACO_PARAM_SAVE,
"save");
500 NACO_PARAMETER_GET_INT(NACO_PARAM_PLOT,
"plot");
503 NACO_PARAMETER_GET_INT(NACO_PARAM_NSAMPLES,
"nsamples");
506 NACO_PARAMETER_GET_INT(NACO_PARAM_HALFSIZE,
"hsize");
509 NACO_PARAMETER_GET_INT(NACO_PARAM_SX,
"sx");
512 NACO_PARAMETER_GET_INT(NACO_PARAM_SY,
"sy");
515 NACO_PARAMETER_GET_INT(NACO_PARAM_SLIT_W,
"slit_width");
518 NACO_PARAMETER_GET_INT(NACO_PARAM_SKYPLANE,
"sky_planes");
520 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
521 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0);
540 naco_parameter bitmask)
544 double value = DBL_MAX;
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);
553 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_STAR_R,
"star_r");
556 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_BG_RINT,
"bg_r1");
559 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_BG_REXT,
"bg_r2");
563 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_HOT_LIM,
"hot_threshold");
566 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_COLD_LIM,
"cold_threshold");
569 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_DEV_LIM,
"dev_threshold");
572 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_RA,
"ra");
575 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_DEC,
"dec");
578 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_PIXSCALE,
"pscale");
581 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_MAGNITD,
"mag");
584 NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_LUCK_STR,
"lucky_strehl");
587 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
588 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
606 naco_parameter bitmask)
610 const char * value = NULL;
611 const cpl_boolean is_combine
612 = bitmask & NACO_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
614 cpl_ensure(
self, CPL_ERROR_NULL_INPUT, NULL);
615 cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
619 NACO_PARAMETER_GET_STRING(NACO_PARAM_REJBORD,
"rej_bord");
622 NACO_PARAMETER_GET_STRING(NACO_PARAM_BPMTHRES,
"thresholds");
625 NACO_PARAMETER_GET_STRING(NACO_PARAM_OFFSETS,
"offsets");
628 NACO_PARAMETER_GET_STRING(NACO_PARAM_OBJECTS,
"objects");
631 NACO_PARAMETER_GET_STRING(NACO_PARAM_XCORR,
"xcorr");
634 NACO_PARAMETER_GET_STRING(NACO_PARAM_REJ_HILO,
"rej");
637 NACO_PARAMETER_GET_STRING(NACO_PARAM_COMBINE,
"comb_meth");
640 NACO_PARAMETER_GET_STRING(NACO_PARAM_CUBEMODE,
"cube_mode");
643 cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
644 cpl_ensure(nbits == 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
646 assert(value != NULL);
650 cpl_ensure(strcmp(value,
"first") == 0 || strcmp(value,
"union") == 0 ||
651 strcmp(value,
"intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
#define IRPLIB_STREHL_STAR_RADIUS
The radius of the star, [Arcseconds].
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].
#define IRPLIB_STREHL_BACKGROUND_R1
The inner radius of the noise-estimation region, [Arcseconds].
const char * naco_parameterlist_get_string(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO string parameter.