visir_parameter.c

00001 /* $Id: visir_parameter.c,v 1.29 2012/02/02 10:30:05 jtaylor Exp $
00002  *
00003  * This file is part of the VISIR Pipeline
00004  * Copyright (C) 2002,2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: jtaylor $
00023  * $Date: 2012/02/02 10:30:05 $
00024  * $Revision: 1.29 $
00025  * $Name: visir-3_5_0 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                    Includes
00034  -----------------------------------------------------------------------------*/
00035 
00036 #include <string.h>
00037 #include <math.h>
00038 #include <float.h>
00039 #include <assert.h>
00040 #include <cpl.h>
00041 
00042 #include "irplib_utils.h"
00043 
00044 #include "visir_parameter.h"
00045 #include "visir_dfs.h"
00046 #include "visir_pfits.h"
00047 
00048 /*-----------------------------------------------------------------------------
00049                                    Define
00050  -----------------------------------------------------------------------------*/
00051 
00052 #define visir_plot_manpage                                      \
00053     "The recipe can produce a number of predefined plots. "     \
00054     "Zero means that none of the plots are produced, while "    \
00055     "increasing values (e.g. 1 or 2) increases the number "     \
00056     "of plots produced. If the plotting fails a warning is "    \
00057     "produced, and the recipe continues. "                      \
00058     "The default behaviour of the plotting is to use "          \
00059     "gnuplot (with option -persist). The recipe currently "     \
00060     "produces 1D-plots using gnuplot commands. The recipe "     \
00061     "user can control the actual plotting-command used by "     \
00062     "the recipe to create the plot by setting the "             \
00063     "environment variable CPL_PLOTTER. Currently, if "          \
00064     "CPL_PLOTTER "                                              \
00065     "is set it must contain the string 'gnuplot'. Setting "     \
00066     "it to 'cat > my_gnuplot_$$.txt' causes a number of "       \
00067     "ASCII-files to be created, which each produce a plot "     \
00068     "when given as standard input to gnuplot (e.g. later "      \
00069     "or on a different computer). A finer control of the "      \
00070     "plotting options can be obtained by writing an "           \
00071     "executable script, e.g. my_gnuplot.pl, that "              \
00072     "executes gnuplot after setting the desired gnuplot "       \
00073     "options (e.g. set terminal pslatex color) "                \
00074     "and then setting CPL_PLOTTER to my_gnuplot.pl. "           \
00075     "The predefined plots include plotting of images. "         \
00076     "Images can be plotted not only with gnuplot, but also "    \
00077     "using the pnm format. This is controlled with the "        \
00078     "environment variable CPL_IMAGER. If CPL_IMAGER "           \
00079     "is set to a string that does not contain the word "        \
00080     "gnuplot, the recipe will generate the plot in pnm "        \
00081     "format. E.g. setting CPL_IMAGER to "                       \
00082     "'display - &' will produce a gray-scale image "            \
00083     "using the image viewer display."
00084 
00085 
00086 
00087 /* To be called from visir_parameter_set() */
00088 #define VISIR_PARAMETER_SET(MASK, VARNAME, TYPE, MAN, DEFAULT, SHORT)          \
00089 if (bitmask & MASK) {                                                          \
00090     char * paramname = cpl_sprintf(PACKAGE ".%s." VARNAME, recipe);            \
00091                                                                                \
00092     p = cpl_parameter_new_value(paramname, TYPE, MAN, context, DEFAULT);       \
00093     cpl_free(paramname);                                                       \
00094     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, SHORT);                 \
00095     cpl_parameterlist_append(self, p);                                         \
00096                                                                                \
00097     (void)cpl_error_set_where(cpl_func); /* Propagate error, if any */         \
00098                                                                                \
00099     bitmask ^= MASK; /* Reset bit. At the end bitmask must be zero */          \
00100                                                                                \
00101     /* Verify that each mask value is unique */                                \
00102     if (chkmask & MASK)                                                        \
00103         (void)cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED);                  \
00104     chkmask |= MASK;                                                           \
00105 }
00106 
00107 /* To be called from visir_parameterlist_get_bool() */
00108 #define VISIR_PARAMETER_GET_BOOL(MASK, VARNAME)                                \
00109 if (bitmask & MASK) {                                                          \
00110     value = irplib_parameterlist_get_bool(self, PACKAGE, recipe, VARNAME);     \
00111                                                                                \
00112     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(),              \
00113                      return(CPL_FALSE), "mask=0x%llx", MASK);                  \
00114     nbits++;         /* Total number of bits must be one  */                   \
00115     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00116                                                                                \
00117 }
00118 
00119 /* To be called from visir_parameterlist_get_int() */
00120 #define VISIR_PARAMETER_GET_INT(MASK, VARNAME)                                 \
00121 if (bitmask & MASK) {                                                          \
00122     value = irplib_parameterlist_get_int(self, PACKAGE, recipe, VARNAME);      \
00123                                                                                \
00124     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(0),   \
00125                      "mask=0x%llx", MASK);                                     \
00126                                                                                \
00127     nbits++;         /* Total number of bits must be one  */                   \
00128     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00129                                                                                \
00130 }
00131 
00132 /* To be called from visir_parameterlist_get_double() */
00133 #define VISIR_PARAMETER_GET_DOUBLE(MASK, VARNAME)                              \
00134 if (bitmask & MASK) {                                                          \
00135     value = irplib_parameterlist_get_double(self, PACKAGE, recipe, VARNAME);   \
00136                                                                                \
00137     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(0.0), \
00138                      "mask=0x%llx", MASK);                                     \
00139                                                                                \
00140     nbits++;         /* Total number of bits must be one  */                   \
00141     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00142                                                                                \
00143 }
00144 
00145 /* To be called from visir_parameterlist_get_string() */
00146 #define VISIR_PARAMETER_GET_STRING(MASK, VARNAME)                              \
00147 if (bitmask & MASK) {                                                          \
00148     value = irplib_parameterlist_get_string(self, PACKAGE, recipe, VARNAME);   \
00149                                                                                \
00150     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(NULL),\
00151                      "mask=0x%llx", MASK);                                     \
00152                                                                                \
00153     nbits++;         /* Total number of bits must be one  */                   \
00154     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00155                                                                                \
00156 }
00157 
00158 
00159 /*----------------------------------------------------------------------------*/
00165 /*----------------------------------------------------------------------------*/
00166 
00170 /*----------------------------------------------------------------------------*/
00179 /*----------------------------------------------------------------------------*/
00180 cpl_error_code visir_parameter_set(cpl_parameterlist * self,
00181                                    const char * recipe,
00182                                    visir_parameter bitmask)
00183 {
00184 
00185     cpl_parameter * p;
00186     char          * context;
00187     visir_parameter chkmask  = 0;    /* Verify that each mask value is unique */
00188     cpl_boolean     zerodist = CPL_FALSE;
00189     cpl_boolean     dostrip  = CPL_TRUE;
00190 
00191 
00192     cpl_ensure_code(self,   CPL_ERROR_NULL_INPUT);
00193     cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
00194 
00195     context = cpl_sprintf(PACKAGE ".%s", recipe);
00196 
00197     /* --nod */
00198     VISIR_PARAMETER_SET(VISIR_PARAM_NODPOS, "nodding", CPL_TYPE_STRING,
00199                         "An optional ASCII specification of the nodding positions "
00200                         "(in case they are missing from the FITS-file). "
00201                         "The file must consist of one line per input FITS-file "
00202                         "and each line must consist of an integer (which is "
00203                         "ignored) followed by a 0 or 1 (to indicate object or sky). ",
00204                         "", "nod");
00205 
00206     /* --auto_bpm */
00207     VISIR_PARAMETER_SET(VISIR_PARAM_AUTOBPM, "auto_bpm", CPL_TYPE_BOOL,
00208                         "Automatic detection and correction of bad pixels",
00209                         TRUE, "auto_bpm");
00210 
00211     /* --g */
00212     VISIR_PARAMETER_SET(VISIR_PARAM_GLITCH, "rem_glitch", CPL_TYPE_BOOL,
00213                         "Automatic filtering of glitches", FALSE, "g");
00214 
00215     /* --p */
00216     VISIR_PARAMETER_SET(VISIR_PARAM_PURGE, "purge_bad", CPL_TYPE_BOOL,
00217                         "Automatic purging of half-cycle images whose median "
00218                         "deviates more than a factor three from the mean of "
00219                         "the medians of half-cycle images or whose standard "
00220                         "deviation deviates more than a factor three from the "
00221                         "mean of their standard deviations", FALSE, "p");
00222 
00223     /* --union */
00224     VISIR_PARAMETER_SET(VISIR_PARAM_UNION, "union", CPL_TYPE_BOOL,
00225                         "Combine images using their union, as opposed to their "
00226                         "intersection (deprecated and ignored, "
00227                         "see --combine_method)", TRUE, "union");
00228 
00229     /* --rej */
00230     VISIR_PARAMETER_SET(VISIR_PARAM_REJECT, "rej", CPL_TYPE_STRING,
00231                         "Each resulting pixel is the average of the "
00232                         "corresponding (interpolated) pixel value in each "
00233                         "jittered image. A positive value, n1, for the first "
00234                         "of the two integers specifies that for each pixel the "
00235                         "smallest n1 pixel values shall be ignored in the "
00236                         "averaging. Similarly, a positive value, n2, for the "
00237                         "second of the two integers specifies that for each "
00238                         "pixel the largest n2 pixel values shall be ignored in "
00239                         "the averaging.", "0-0", "rej");
00240 
00241     /* --plot */
00242     VISIR_PARAMETER_SET(VISIR_PARAM_PLOT, "plot", CPL_TYPE_INT,
00243                         visir_plot_manpage, 0, "plot");
00244 
00245     if (bitmask & VISIR_PARAM_ZERODIST) {
00246         bitmask ^= VISIR_PARAM_ZERODIST;
00247         /* The is not a real option - its presence means that the default value
00248            for the distortion correction parameters are all zero */
00249         zerodist = CPL_TRUE;
00250     }
00251 
00252 
00253     /* --slit_skew */
00254     /* The detector skew in pixels over the hole detector */
00255     /* phi = atan(28.6/1024); */
00256     VISIR_PARAMETER_SET(VISIR_PARAM_SLITSKEW, "phi", CPL_TYPE_DOUBLE,
00257                         "Distortion correction: Skew of slit (degrees) "
00258                         "(clockwise)", zerodist ? 0.0 : 1.6, "slit_skew");
00259 
00260     /* --spectrum_skew */
00261     /* The detector skew in pixels over the hole detector */
00262     /* ksi = atan(12.5/1024); */
00263     VISIR_PARAMETER_SET(VISIR_PARAM_SPECSKEW, "ksi", CPL_TYPE_DOUBLE,
00264                         "Distortion correction: LMR Skew of spectrum (degrees) "
00265                         "(counter-clockwise). Not used in High Resolution",
00266                         zerodist ? 0.0 : 0.7, "spectrum_skew");
00267 
00268     /* --vert_arc */
00269     /* LR eps = 0.052mm/0.050mm  [pixel] (PXSPACE = 50 micron) */
00270     VISIR_PARAMETER_SET(VISIR_PARAM_VERTARC, "eps", CPL_TYPE_DOUBLE,
00271                         "Distortion correction: LR Detector vertical curvature "
00272                         "(pixel). Reduced by a factor 4 in MR. Not used in HR "
00273                         "A-side. Increased by a factor 115/52 in HR B-side",
00274                         zerodist ? 0.0 : 1.04, "vert_arc");
00275 
00276     /* --hori_arc */
00277     /* delta = 0.004mm/0.050mm [pixel] (PXSPACE = 50 micron) */
00278     VISIR_PARAMETER_SET(VISIR_PARAM_HORIARC, "delta", CPL_TYPE_DOUBLE,
00279                         "Distortion correction: LMR Detector horizontal "
00280                         "curvature (pixel). Increased by a factor 1.5 in HR "
00281                         "A-side. Reduced by a factor 2 in HR B-side",
00282                         zerodist ? 0.0 : 0.08, "hori_arc");
00283 
00284     /* --orderoffset */
00285     VISIR_PARAMETER_SET(VISIR_PARAM_ORDEROFF, "orderoffset", CPL_TYPE_INT,
00286                         "Echelle order offset. The offset is relative to the "
00287                         "main order. The allowed range of offsets depend on "
00288                         "the selected grism. The offset can never exceed +/-4. "
00289                         "If the main order is e.g. 8 an order offset of +1 "
00290                         "will cause the recipe to base the data reduction on "
00291                         "order 9. With a positive order offset the central "
00292                         "wavelength becomes smaller while for a negative "
00293                         "order offset the central wavelength becomes larger.", 0,
00294                         "orderoffset");
00295 
00296     /* --off */
00297     VISIR_PARAMETER_SET(VISIR_PARAM_OFFSETS, "offsets",  CPL_TYPE_STRING,
00298                         "An optional ASCII specification of the offsets "
00299                         "in case those in FITS-headers are missing or wrong. "
00300                         "The file must consist of one line per input pair of "
00301                         "FITS-files, and each line must consist of two "
00302                         "numbers which represent the shift in pixels of that "
00303                         "image relative to the first image. The first line "
00304                         "should thus comprise two zeros. Correct FITS-header "
00305                         "offsets mean that the i'th X offset can be gotten "
00306                         "from Xoffset_0 - Xoffset_i, where Xoffset_i is the "
00307                         "value of " VISIR_PFITS_DOUBLE_CUMOFFSETX " and "
00308                         "likewise for Y.", "", "off");
00309 
00310     VISIR_PARAMETER_SET(VISIR_PARAM_REFINE, "refine", CPL_TYPE_BOOL,
00311                         "User-defined refining of the image offsets. See "
00312                         "options objs and xcorr", FALSE, "ref");
00313 
00314     VISIR_PARAMETER_SET(VISIR_PARAM_OBJECTS, "objects", CPL_TYPE_STRING,
00315                         "The shift and add of images needs anchor points that "
00316                         "typically are bright objects. These are normally "
00317                         "detected automatically but with user-defined refining "
00318                         "of offsets enabled, they must be provided by the user "
00319                         "through an ASCII file containing one line per anchor "
00320                         "point with each line consisting of its x and y "
00321                         "coordinate (in pixels). This file is ignored with "
00322                         "user-defined refining of offsets disabled.",
00323                         "", "objs");
00324 
00325 
00326     /* --xcorr */
00327     VISIR_PARAMETER_SET(VISIR_PARAM_XCORR, "xcorr", CPL_TYPE_STRING,
00328                         "If user-defined refining of offsets is enabled a "
00329                         "cross-correlation of the images is performed. In "
00330                         "order to speed up this process, this cross-"
00331                         "correlation is performed only on smaller rectangles "
00332                         "around the anchor points. The first two parameters "
00333                         "is the half-size of this rectangle in pixels. The "
00334                         "second pair is the maximum shift in x and y (pixels) "
00335                         "evaluated by the cross-correlation on the rectangle. "
00336                         "Used only if user-defined refining of offsets is enabled.",
00337                         "10-10-25-25", "xcorr");
00338 
00339     /* --jy_val */
00340     VISIR_PARAMETER_SET(VISIR_PARAM_JYVAL, "jy_val", CPL_TYPE_DOUBLE,
00341                         "The flux of the standard star in Jansky",
00342                         -999.0, "jy_val");
00343 
00344     /* --radii */
00345     VISIR_PARAMETER_SET(VISIR_PARAM_RADII, "radii", CPL_TYPE_STRING,
00346                         "Radii : star_max bg_int bg_ext",
00347                         "20-20-30", "radii");
00348 
00349     /* --low */
00350     VISIR_PARAMETER_SET(VISIR_PARAM_LOWLIM, "low", CPL_TYPE_DOUBLE,
00351                         "Low threshold for the bad pixel map",
00352                         0.2, "low");
00353 
00354     /* --high */
00355     VISIR_PARAMETER_SET(VISIR_PARAM_HIGHLIM, "high", CPL_TYPE_DOUBLE,
00356                         "High threshold for the bad pixel map",
00357                         5.0, "high");
00358 
00359     /* --fixcombi */
00360     VISIR_PARAMETER_SET(VISIR_PARAM_FIXCOMBI, "fixcombi", CPL_TYPE_BOOL,
00361                         "Perform the distortion correction on the combined "
00362                         "image, and not on each of the jittered images. "
00363                         "This will reduce excution time and degrade the quality "
00364                         "of the combined image",
00365                         FALSE, "fixcombi");
00366 
00367     /* --emis_tol */
00368     VISIR_PARAMETER_SET(VISIR_PARAM_EMIS_TOL, "emis_tol", CPL_TYPE_DOUBLE,
00369                         "The computation of the mean and standard deviation "
00370                         "of the sensitivity is done for wavelengths with an "
00371                         "atmospheric emissivity of at most "
00372                         "emis_min + emis_tol * (emis_max - emis_min), where "
00373                         "emis_min is the minimum emissivity in the observed "
00374                         "wavelength range and emis_max is the ditto maximum. "
00375                         "Thus emis_tol = 1 means that all wavelengths are "
00376                         "included.",
00377                         1.0, "emis_tol");
00378 
00379     /* --qeff */
00380     VISIR_PARAMETER_SET(VISIR_PARAM_QEFF, "qeff", CPL_TYPE_DOUBLE,
00381                         "The overall Quantum-efficiency. The default value "
00382                         "comes from PH. Galdemard measurements. This option "
00383                         "is ignored for all but " VISIR_SPC_QEFF_ASCII
00384                         "-tagged files, while the efficiencies in such files "
00385                         "are multiplied by this overall efficiency",
00386                         0.72, "qeff");
00387 
00388     /* --r */
00389     VISIR_PARAMETER_SET(VISIR_PARAM_REJBORD, "rej_bord", CPL_TYPE_STRING,
00390                        "Rejected left right bottom and top border (pixel)",
00391                        "50 50 50 50", "r");
00392 
00393     /* --hot_t */
00394     VISIR_PARAMETER_SET(VISIR_PARAM_HOT_LIM, "hot_threshold", CPL_TYPE_DOUBLE,
00395                        "Hot pixel map threshold", 10.0, "hot_t");
00396 
00397     /* --cold_t */
00398     VISIR_PARAMETER_SET(VISIR_PARAM_COLD_LIM, "cold_threshold", CPL_TYPE_DOUBLE,
00399                        "Cold pixel map threshold", 6.0, "cold_t");
00400 
00401     /* --dev_t */
00402     VISIR_PARAMETER_SET(VISIR_PARAM_DEV_LIM, "dev_threshold", CPL_TYPE_DOUBLE,
00403                        "Deviant pixel map threshold", 5.0, "dev_t");
00404 
00405     /* --nsamples */
00406     VISIR_PARAMETER_SET(VISIR_PARAM_NSAMPLES, "nsamples", CPL_TYPE_INT,
00407                        "Number of samples for Read-Out Noise (RON) computation",
00408                        100, "nsamples");
00409 
00410     /* --hsize */
00411     VISIR_PARAMETER_SET(VISIR_PARAM_HALFSIZE, "hsize", CPL_TYPE_INT,
00412                        "Half size of the window for Read-Out Noise (RON) "
00413                         "computation", 2, "hsize");
00414 
00415     /* --comb_meth */
00416     /* FIXME: Use cpl_parameter_new_enum() */
00417     VISIR_PARAMETER_SET(VISIR_PARAM_COMBINE, "comb_meth", CPL_TYPE_STRING,
00418                         "Combine images using one of: 1) Onto the first image "
00419                         "(first); 2) Their union (union); 3) Their intersection"
00420                         " (inter). NB: Only the 'first'-method produces an "
00421                         "image product with WCS coordinates. A successful "
00422                         "'first'-method always produces a combined image with "
00423                         "dimensions equal to those of the input images. "
00424                         "For the 'union'-method the result image is at least "
00425                         "as large as the input images while for the 'inter'-"
00426                         "method the result image is at most as large as the "
00427                         "input images", "union", "combine_method");
00428 
00429     if (bitmask & VISIR_PARAM_STRIPNON) {
00430         bitmask ^= VISIR_PARAM_STRIPNON;
00431         /* The is not a real option - its presence means that the default value
00432            for the destriping iterations is zero */
00433         dostrip = CPL_FALSE;
00434     }
00435 
00436     /* --nstripe */
00437     VISIR_PARAMETER_SET(VISIR_PARAM_STRIPITE, "nstripe",
00438                         CPL_TYPE_INT, "Max number of destriping iterations "
00439                         "(0 to disable destriping). Horizontal destriping is "
00440                         "done first and if no horizontal striping is detected, "
00441                         "vertical destriping is performed", dostrip ? 15 : 0,
00442                         "destripe_iterations");
00443 
00444     /* --mstripe */
00445     VISIR_PARAMETER_SET(VISIR_PARAM_STRIPMOR, "mstripe", CPL_TYPE_BOOL,
00446                        "Destripe with morphological cleaning", FALSE,
00447                         "destripe_morpho");
00448 
00449     /* --rl */
00450     VISIR_PARAMETER_SET(VISIR_PARAM_REJLEFT, "reject_left", CPL_TYPE_INT,
00451                         "Reject leftmost columns in spectrum extraction, zero "
00452                         "means all columns on the left are used. In cross-"
00453                         "dispersion mode a (small) negative number may be used "
00454                         "(pixel)", 0, "rl");
00455 
00456     /* --rr */
00457     VISIR_PARAMETER_SET(VISIR_PARAM_REJRIGHT, "reject_right", CPL_TYPE_INT,
00458                         "Reject rightmost columns in spectrum extraction, zero "
00459                         "means all columns on the right are used. In cross-"
00460                         "dispersion mode a (small) negative number may be used "
00461                         "(pixel)", 0, "rr");
00462 
00463     /* --eccmax */
00464     VISIR_PARAMETER_SET(VISIR_PARAM_ECCMAX, "eccmax", CPL_TYPE_DOUBLE,
00465                        "The maximum eccentricity allowed in the combination "
00466                         "of the three (in parallel nod/chopping) or four (in "
00467                         "perpendicular nod/chopping) beams. In parallel mode, "
00468                         "three perfectly aligned points spaced with the "
00469                         "chopnod throw will have eccentricity 0, while in "
00470                         "perpedicular mode a square with the chopnod throw as "
00471                         "the side length will have eccentricity 0",
00472                         0.25, "eccmax");
00473 
00474     cpl_free(context);
00475 
00476     cpl_ensure_code(!cpl_error_get_code(), cpl_error_get_code());
00477     cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
00478 
00479     return CPL_ERROR_NONE;
00480 }
00481 
00482 /*----------------------------------------------------------------------------*/
00492 /*----------------------------------------------------------------------------*/
00493 cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist * self,
00494                                          const char * recipe,
00495                                          visir_parameter bitmask)
00496 {
00497 
00498     int nbits = 0;
00499     cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
00500 
00501 
00502     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
00503     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, CPL_FALSE);
00504     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
00505 
00506     /* --auto_bpm */
00507     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_AUTOBPM, "auto_bpm");
00508 
00509     /* --g */
00510     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_GLITCH, "rem_glitch");
00511 
00512     /* --p */
00513     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_PURGE, "purge_bad");
00514 
00515     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_REFINE, "refine");
00516 
00517     /* --fixcombi */
00518     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_FIXCOMBI, "fixcombi");
00519 
00520     /* --mstripe */
00521     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_STRIPMOR, "mstripe");
00522 
00523 
00524     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
00525     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
00526 
00527     return value;
00528 
00529 }
00530 
00531 
00532 /*----------------------------------------------------------------------------*/
00542 /*----------------------------------------------------------------------------*/
00543 int visir_parameterlist_get_int(const cpl_parameterlist * self,
00544                                 const char * recipe,
00545                                 visir_parameter bitmask)
00546 {
00547 
00548     int nbits = 0;
00549     int value = 0; /* Avoid (false) uninit warning */
00550 
00551 
00552     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
00553     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, 0);
00554     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
00555 
00556 
00557     /* --plot */
00558     VISIR_PARAMETER_GET_INT(VISIR_PARAM_PLOT, "plot");
00559 
00560     /* --orderoffset */
00561     VISIR_PARAMETER_GET_INT(VISIR_PARAM_ORDEROFF, "orderoffset");
00562 
00563     /* --nsamples */
00564     VISIR_PARAMETER_GET_INT(VISIR_PARAM_NSAMPLES, "nsamples");
00565 
00566     /* --hsize */
00567     VISIR_PARAMETER_GET_INT(VISIR_PARAM_HALFSIZE, "hsize");
00568 
00569     /* --nstripe */
00570     VISIR_PARAMETER_GET_INT(VISIR_PARAM_STRIPITE, "nstripe");
00571 
00572     /* --rl */
00573     VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJLEFT, "reject_left");
00574 
00575     /* --rr */
00576     VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJRIGHT, "reject_right");
00577 
00578 
00579     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
00580     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, 0);
00581 
00582     return value;
00583 
00584 }
00585 
00586 /*----------------------------------------------------------------------------*/
00596 /*----------------------------------------------------------------------------*/
00597 double visir_parameterlist_get_double(const cpl_parameterlist * self,
00598                                       const char * recipe,
00599                                       visir_parameter bitmask)
00600 {
00601 
00602     int nbits = 0;
00603     double value = DBL_MAX; /* Avoid (false) uninit warning */
00604 
00605 
00606     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
00607     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, 0.0);
00608     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
00609 
00610     /* --slit_skew */
00611     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SLITSKEW, "phi");
00612 
00613     /* --spectrum_skew */
00614     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SPECSKEW, "ksi");
00615 
00616     /* --vert_arc */
00617     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_VERTARC, "eps");
00618 
00619     /* --hori_arc */
00620     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HORIARC, "delta");
00621 
00622     /* --jy_val */
00623     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_JYVAL, "jy_val");
00624 
00625     /* --low */
00626     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_LOWLIM, "low");
00627 
00628     /* --high */
00629     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HIGHLIM, "high");
00630 
00631     /* --emis_tol */
00632     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_EMIS_TOL, "emis_tol");
00633 
00634     /* --qeff */
00635     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_QEFF, "qeff");
00636 
00637     /* --hot_t */
00638     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HOT_LIM, "hot_threshold");
00639 
00640     /* --cold_t */
00641     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_COLD_LIM, "cold_threshold");
00642 
00643     /* --dev_t */
00644     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_DEV_LIM, "dev_threshold");
00645 
00646     /* --eccmax */
00647     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_ECCMAX, "eccmax");
00648 
00649     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
00650     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, 0.0);
00651 
00652     return value;
00653 
00654 }
00655 
00656 
00657 
00658 /*----------------------------------------------------------------------------*/
00667 /*----------------------------------------------------------------------------*/
00668 const char * visir_parameterlist_get_string(const cpl_parameterlist * self,
00669                                             const char * recipe,
00670                                             visir_parameter bitmask)
00671 {
00672 
00673     int nbits = 0;
00674     const char * value = NULL; /* Avoid (false) uninit warning */
00675     const cpl_boolean is_combine
00676         = bitmask & VISIR_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
00677 
00678     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, NULL);
00679     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
00680 
00681     /* --nod */
00682     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_NODPOS, "nodding");
00683 
00684     /* --rej */
00685     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJECT, "rej");
00686 
00687     /* --off */
00688     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OFFSETS, "offsets");
00689 
00690     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REFINE, "refine");
00691 
00692     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OBJECTS, "objects");
00693 
00694     /* --xcorr */
00695     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_XCORR, "xcorr");
00696 
00697     /* --radii */
00698     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RADII, "radii");
00699 
00700     /* --r */
00701     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJBORD, "rej_bord");
00702 
00703     /* --combine */
00704     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_COMBINE, "comb_meth");
00705 
00706     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
00707     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, NULL);
00708 
00709     assert(value != NULL);
00710 
00711     /* FIXME: This should be handled by the enum */
00712     if (is_combine)
00713         cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
00714                    strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
00715                    NULL);
00716 
00717     return value;
00718 
00719 }
00720 

Generated on Mon Feb 6 15:23:49 2012 for VISIR Pipeline Reference Manual by  doxygen 1.5.8