visir_parameter.c

00001 /* $Id: visir_parameter.c,v 1.20 2009/03/06 10:53:15 llundin 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: llundin $
00023  * $Date: 2009/03/06 10:53:15 $
00024  * $Revision: 1.20 $
00025  * $Name: visir-3_2_2 $
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 
00047 /*-----------------------------------------------------------------------------
00048                                    Define
00049  -----------------------------------------------------------------------------*/
00050 
00051 /* To be called from visir_parameter_set() */
00052 #define VISIR_PARAMETER_SET(MASK, VARNAME, TYPE, MAN, DEFAULT, SHORT)          \
00053 if (bitmask & MASK) {                                                          \
00054     char * paramname = irplib_sprintf(PACKAGE ".%s.%s", recipe, VARNAME);      \
00055     assert( paramname != NULL );                                               \
00056                                                                                \
00057     bitmask ^= MASK; /* Reset bit. At the end bitmask must be zero */          \
00058                                                                                \
00059     if (chkmask & MASK)                                                        \
00060         (void)cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED);                  \
00061     chkmask |= MASK;                                                           \
00062                                                                                \
00063     p = cpl_parameter_new_value(paramname, TYPE, MAN, context, DEFAULT);       \
00064     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, SHORT);                 \
00065     cpl_parameterlist_append(self, p);                                         \
00066                                                                                \
00067     cpl_free(paramname);                                                       \
00068                                                                                \
00069 }
00070 
00071 /* To be called from visir_parameterlist_get_bool() */
00072 #define VISIR_PARAMETER_GET_BOOL(MASK, VARNAME)                                \
00073 if (bitmask & MASK) {                                                          \
00074     value = irplib_parameterlist_get_bool(self, PACKAGE, recipe, VARNAME);     \
00075                                                                                \
00076     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(),              \
00077                     return(CPL_FALSE), "mask=%llu", MASK);                     \
00078                                                                                \
00079     nbits++;         /* Total number of bits must be one  */                   \
00080     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00081                                                                                \
00082 }
00083 
00084 /* To be called from visir_parameterlist_get_int() */
00085 #define VISIR_PARAMETER_GET_INT(MASK, VARNAME)                                 \
00086 if (bitmask & MASK) {                                                          \
00087     value = irplib_parameterlist_get_int(self, PACKAGE, recipe, VARNAME);      \
00088                                                                                \
00089     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(0),   \
00090                      "mask=%llu", MASK);                                       \
00091                                                                                \
00092     nbits++;         /* Total number of bits must be one  */                   \
00093     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00094                                                                                \
00095 }
00096 
00097 /* To be called from visir_parameterlist_get_double() */
00098 #define VISIR_PARAMETER_GET_DOUBLE(MASK, VARNAME)                              \
00099 if (bitmask & MASK) {                                                          \
00100     value = irplib_parameterlist_get_double(self, PACKAGE, recipe, VARNAME);   \
00101                                                                                \
00102     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(0.0), \
00103                      "mask=%llu", MASK);                                       \
00104                                                                                \
00105     nbits++;         /* Total number of bits must be one  */                   \
00106     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00107                                                                                \
00108 }
00109 
00110 /* To be called from visir_parameterlist_get_string() */
00111 #define VISIR_PARAMETER_GET_STRING(MASK, VARNAME)                              \
00112 if (bitmask & MASK) {                                                          \
00113     value = irplib_parameterlist_get_string(self, PACKAGE, recipe, VARNAME);   \
00114                                                                                \
00115     cpl_error_ensure(!cpl_error_get_code(), cpl_error_get_code(), return(NULL),\
00116                      "mask=%llu", MASK);                                       \
00117                                                                                \
00118     nbits++;         /* Total number of bits must be one  */                   \
00119     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00120                                                                                \
00121 }
00122 
00123 
00124 /*----------------------------------------------------------------------------*/
00130 /*----------------------------------------------------------------------------*/
00131 
00135 /*----------------------------------------------------------------------------*/
00144 /*----------------------------------------------------------------------------*/
00145 cpl_error_code visir_parameter_set(cpl_parameterlist * self,
00146                                    const char * recipe,
00147                                    visir_parameter bitmask)
00148 {
00149 
00150     cpl_parameter * p;
00151     char          * context;
00152     visir_parameter chkmask  = 0;    /* Verify that each mask value is unique */
00153     cpl_boolean     zerodist = CPL_FALSE;
00154     cpl_boolean     dostrip  = CPL_TRUE;
00155 
00156 
00157     cpl_ensure_code(self,   CPL_ERROR_NULL_INPUT);
00158     cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
00159 
00160     context = irplib_sprintf(PACKAGE ".%s", recipe);
00161 
00162     /* --nod */
00163     VISIR_PARAMETER_SET(VISIR_PARAM_NODPOS, "nodding", CPL_TYPE_STRING,
00164                         "An optional ASCII specification of the nodding positions "
00165                         "(in case they are missing from the FITS-file). "
00166                         "The file must consist of one line per input FITS-file "
00167                         "and each line must consist of an integer (which is "
00168                         "ignored) followed by a 0 or 1 (to indicate object or sky). ",
00169                         "", "nod");
00170 
00171     /* --auto_bpm */
00172     VISIR_PARAMETER_SET(VISIR_PARAM_AUTOBPM, "auto_bpm", CPL_TYPE_BOOL,
00173                         "Automatic detection and correction of bad pixels",
00174                         TRUE, "auto_bpm");
00175 
00176     /* --g */
00177     VISIR_PARAMETER_SET(VISIR_PARAM_GLITCH, "rem_glitch", CPL_TYPE_BOOL,
00178                         "Automatic filtering of glitches", FALSE, "g");
00179 
00180     /* --p */
00181     VISIR_PARAMETER_SET(VISIR_PARAM_PURGE, "purge_bad", CPL_TYPE_BOOL,
00182                         "Automatic purging of half-cycle images whose median "
00183                         "deviates more than a factor three from the mean of "
00184                         "the medians of half-cycle images or whose standard "
00185                         "deviation deviates more than a factor three from the "
00186                         "mean of their standard deviations", FALSE, "p");
00187 
00188     /* --union */
00189     VISIR_PARAMETER_SET(VISIR_PARAM_UNION, "union", CPL_TYPE_BOOL,
00190                         "Combine images using their union, as opposed to their "
00191                         "intersection (deprecated and ignored, "
00192                         "see --combine_method)", TRUE, "union");
00193 
00194     /* --rej */
00195     VISIR_PARAMETER_SET(VISIR_PARAM_REJECT, "rej", CPL_TYPE_STRING,
00196                         "Each resulting pixel is the average of the "
00197                         "corresponding (interpolated) pixel value in each "
00198                         "jittered image. A positive value, n1, for the first "
00199                         "of the two integers specifies that for each pixel the "
00200                         "smallest n1 pixel values shall be ignored in the "
00201                         "averaging. Similarly, a positive value, n2, for the "
00202                         "second of the two integers specifies that for each "
00203                         "pixel the largest n2 pixel values shall be ignored in "
00204                         "the averaging.", "0 0", "rej");
00205 
00206     /* --plot */
00207     VISIR_PARAMETER_SET(VISIR_PARAM_PLOT, "plot", CPL_TYPE_INT,
00208                         "The recipe can produce a number of predefined plots. "
00209                         "Zero means that none of the plots are produced, while "
00210                         "increasing values (e.g. 1 or 2) increases the number "
00211                         "of plots produced. If the plotting fails a warning is "
00212                         "produced, and the recipe continues. "
00213                         "The default behaviour of the plotting is to use "
00214                         "gnuplot (with option -persist). The recipe currently "
00215                         "produces 1D-plots using gnuplot commands. The recipe "
00216                         "user can control the actual plotting-command used by "
00217                         "the recipe to create the plot by setting the "
00218                         "environment variable IRPLIB_PLOTTER. Currently, if "
00219                         "IRPLIB_PLOTTER "
00220                         "is set it must contain the string 'gnuplot'. Setting "
00221                         "it to 'cat > my_gnuplot_$$.txt' causes a number of "
00222                         "ASCII-files to be created, which each produce a plot "
00223                         "when given as standard input to gnuplot (e.g. later "
00224                         "or on a different computer). A finer control of the "
00225                         "plotting options can be obtained by writing an "
00226                         "executable script, e.g. my_gnuplot.pl, that "
00227                         "executes gnuplot after setting the desired gnuplot "
00228                         "options (e.g. set terminal pslatex color) "
00229                         "and then setting IRPLIB_PLOTTER to my_gnuplot.pl. "
00230                         "The predefined plots include plotting of images. "
00231                         "Images can be plotted not only with gnuplot, but also "
00232                         "using the pnm format. This is controlled with the "
00233                         "environment variable IRPLIB_IMAGER. If IRPLIB_IMAGER "
00234                         "is set to a string that does not contain the word "
00235                         "gnuplot, the recipe will generate the plot in pnm "
00236                         "format. E.g. setting IRPLIB_IMAGER to "
00237                         "'cat | display - &' will produce a gray-scale image "
00238                         "using the image viewer display.", 0, "plot");
00239 
00240     if (bitmask & VISIR_PARAM_ZERODIST) {
00241         bitmask ^= VISIR_PARAM_ZERODIST;
00242         /* The is not a real option - its presence means that the default value
00243            for the distortion correction parameters are all zero */
00244         zerodist = CPL_TRUE;
00245     }
00246 
00247 
00248     /* --slit_skew */
00249     /* The detector skew in pixels over the hole detector */
00250     /* phi = atan(28.6/1024); */
00251     VISIR_PARAMETER_SET(VISIR_PARAM_SLITSKEW, "phi", CPL_TYPE_DOUBLE,
00252                         "Distortion correction: Skew of slit [degrees] "
00253                         "(clockwise)", zerodist ? 0.0 : 1.6, "slit_skew");
00254 
00255     /* --spectrum_skew */
00256     /* The detector skew in pixels over the hole detector */
00257     /* ksi = atan(12.5/1024); */
00258     VISIR_PARAMETER_SET(VISIR_PARAM_SPECSKEW, "ksi", CPL_TYPE_DOUBLE,
00259                         "Distortion correction: LMR Skew of spectrum [degrees] "
00260                         "(counter-clockwise). Not used in High Resolution",
00261                         zerodist ? 0.0 : 0.7, "spectrum_skew");
00262 
00263     /* --vert_arc */
00264     /* LR eps = 0.052mm/0.050mm  [pixel] (PXSPACE = 50 micron) */
00265     VISIR_PARAMETER_SET(VISIR_PARAM_VERTARC, "eps", CPL_TYPE_DOUBLE,
00266                         "Distortion correction: LR Detector vertical curvature "
00267                         "[pixel]. Reduced by a factor 4 in MR. Not used in HR "
00268                         "A-side. Increased by a factor 115/52 in HR B-side",
00269                         zerodist ? 0.0 : 1.04, "vert_arc");
00270 
00271     /* --hori_arc */
00272     /* delta = 0.004mm/0.050mm [pixel] (PXSPACE = 50 micron) */
00273     VISIR_PARAMETER_SET(VISIR_PARAM_HORIARC, "delta", CPL_TYPE_DOUBLE,
00274                         "Distortion correction: LMR Detector horizontal "
00275                         "curvature [pixel]. Increased by a factor 1.5 in HR "
00276                         "A-side. Reduced by a factor 2 in HR B-side",
00277                         zerodist ? 0.0 : 0.08, "hori_arc");
00278 
00279     /* --orderoffset */
00280     VISIR_PARAMETER_SET(VISIR_PARAM_ORDEROFF, "orderoffset", CPL_TYPE_INT,
00281                         "Echelle order offset. The offset is relative to the "
00282                         "main order. The allowed range of offsets depend on "
00283                         "the selected grism. The offset can never exceed +/-4. "
00284                         "If the main order is e.g. 8 an order offset of +1 "
00285                         "will cause the recipe to base the data reduction on "
00286                         "order 9. With a positive order offset the central "
00287                         "wavelength becomes smaller while for a negative "
00288                         "order offset the central wavelength becomes larger.", 0,
00289                         "orderoffset");
00290 
00291     /* --off */
00292     VISIR_PARAMETER_SET(VISIR_PARAM_OFFSETS, "offsets",  CPL_TYPE_STRING,
00293                         "An optional ASCII specification of the offsets "
00294                         "in case they are missing from the FITS-file. "
00295                         "The file must consist of one line per input pair of "
00296                         "FITS-files, and each line must consist of two numbers, "
00297                         "which represent the shift in pixel of that image. "
00298                         "The reference point of the coordinates of the shift "
00299                         "may be chosen by the user. A convenient reference "
00300                         "point causes the offset of the first image to be (0,0) "
00301                         "and the other offsets to be relative to the first "
00302                         "image.", "", "off");
00303 
00304     VISIR_PARAMETER_SET(VISIR_PARAM_REFINE, "refine", CPL_TYPE_BOOL,
00305                         "User-defined refining of the image offsets. See options "
00306                         "objs and xcorr", FALSE, "ref");
00307 
00308     VISIR_PARAMETER_SET(VISIR_PARAM_OBJECTS, "objects", CPL_TYPE_STRING,
00309                         "The shift and add of images needs anchor points that "
00310                         "typically are bright objects. These are normally "
00311                         "detected automatically but with user-defined refining "
00312                         "of offsets enabled, they must be provided by the user "
00313                         "through an ASCII file containing one line per anchor "
00314                         "point with each line consisting of its x and y "
00315                         "coordinate (in pixels). This file is ignored with "
00316                         "user-defined refining of offsets disabled.",
00317                         "", "objs");
00318 
00319 
00320     /* --xcorr */
00321     VISIR_PARAMETER_SET(VISIR_PARAM_XCORR, "xcorr", CPL_TYPE_STRING,
00322                         "If user-defined refining of offsets is enabled a "
00323                         "cross-correlation of the images is performed. In "
00324                         "order to speed up this process, this cross-"
00325                         "correlation is performed only on smaller rectangles "
00326                         "around the anchor points. The first two parameters "
00327                         "is the half-size of this rectangle in pixels. The "
00328                         "second pair is the maximum shift in x and y (pixels) "
00329                         "evaluated by the cross-correlation on the rectangle. "
00330                         "Used only if user-defined refining of offsets is enabled.",
00331                         "10 10 25 25", "xcorr");
00332 
00333     /* --jy_val */
00334     VISIR_PARAMETER_SET(VISIR_PARAM_JYVAL, "jy_val", CPL_TYPE_DOUBLE,
00335                         "The flux of the standard star in Jansky",
00336                         -999.0, "jy_val");
00337 
00338     /* --radii */
00339     VISIR_PARAMETER_SET(VISIR_PARAM_RADII, "radii", CPL_TYPE_STRING,
00340                         "Radii : star_max bg_int bg_ext",
00341                         "20 20 30", "radii");
00342 
00343     /* --low */
00344     VISIR_PARAMETER_SET(VISIR_PARAM_LOWLIM, "low", CPL_TYPE_DOUBLE,
00345                         "Low threshold for the bad pixel map",
00346                         0.2, "low");
00347 
00348     /* --high */
00349     VISIR_PARAMETER_SET(VISIR_PARAM_HIGHLIM, "high", CPL_TYPE_DOUBLE,
00350                         "High threshold for the bad pixel map",
00351                         5.0, "high");
00352 
00353     /* --fixcombi */
00354     VISIR_PARAMETER_SET(VISIR_PARAM_FIXCOMBI, "fixcombi", CPL_TYPE_BOOL,
00355                         "Perform the distortion correction on the combined "
00356                         "image, and not on each of the jittered images. "
00357                         "This will reduce excution time and degrade the quality "
00358                         "of the combined image",
00359                         FALSE, "fixcombi");
00360 
00361     /* --emis_tol */
00362     VISIR_PARAMETER_SET(VISIR_PARAM_EMIS_TOL, "emis_tol", CPL_TYPE_DOUBLE,
00363                         "The computation of the mean and standard deviation "
00364                         "of the sensitivity is done for wavelengths with an "
00365                         "atmospheric emissivity of at most "
00366                         "emis_min + emis_tol * (emis_max - emis_min), where "
00367                         "emis_min is the minimum emissivity in the observed "
00368                         "wavelength range and emis_max is the ditto maximum. "
00369                         "Thus emis_tol = 1 means that all wavelengths are "
00370                         "included.",
00371                         1.0, "emis_tol");
00372 
00373     /* --qeff */
00374     VISIR_PARAMETER_SET(VISIR_PARAM_QEFF, "qeff", CPL_TYPE_DOUBLE,
00375                         "The overall Quantum-efficiency. The default value "
00376                         "comes from PH. Galdemard measurements. This option "
00377                         "is ignored for all but " VISIR_SPC_QEFF_ASCII
00378                         "-tagged files, while the efficiencies in such files "
00379                         "are multiplied by this overall efficiency",
00380                         0.72, "qeff");
00381 
00382     /* --r */
00383     VISIR_PARAMETER_SET(VISIR_PARAM_REJBORD, "rej_bord", CPL_TYPE_STRING,
00384                        "Rejected left right bottom and top border [pixel]",
00385                        "50 50 50 50", "r");
00386 
00387     /* --hot_t */
00388     VISIR_PARAMETER_SET(VISIR_PARAM_HOT_LIM, "hot_threshold", CPL_TYPE_DOUBLE,
00389                        "Hot pixel map threshold", 10.0, "hot_t");
00390 
00391     /* --cold_t */
00392     VISIR_PARAMETER_SET(VISIR_PARAM_COLD_LIM, "cold_threshold", CPL_TYPE_DOUBLE,
00393                        "Cold pixel map threshold", 6.0, "cold_t");
00394 
00395     /* --dev_t */
00396     VISIR_PARAMETER_SET(VISIR_PARAM_DEV_LIM, "dev_threshold", CPL_TYPE_DOUBLE,
00397                        "Deviant pixel map threshold", 5.0, "dev_t");
00398 
00399     /* --nsamples */
00400     VISIR_PARAMETER_SET(VISIR_PARAM_NSAMPLES, "nsamples", CPL_TYPE_INT,
00401                        "Number of samples for Read-Out Noise (RON) computation",
00402                        100, "nsamples");
00403 
00404     /* --hsize */
00405     VISIR_PARAMETER_SET(VISIR_PARAM_HALFSIZE, "hsize", CPL_TYPE_INT,
00406                        "Half size of the window for Read-Out Noise (RON) "
00407                         "computation", 2, "hsize");
00408 
00409     /* --comb_meth */
00410     /* FIXME: Use cpl_parameter_new_enum() */
00411     VISIR_PARAMETER_SET(VISIR_PARAM_COMBINE, "comb_meth", CPL_TYPE_STRING,
00412                         "Combine images using one of: 1) Onto the first image "
00413                         "(first); 2) Their union (union); 3) Their intersection"
00414                         " (inter). NB: Only the 'first'-method produces an "
00415                         "image product with WCS coordinates. A successful "
00416                         "'first'-method always produces a combined image with "
00417                         "dimensions equal to those of the input images. "
00418                         "For the 'union'-method the result image is at least "
00419                         "as large as the input images while for the 'inter'-"
00420                         "method the result image is at most as large as the "
00421                         "input images", "union", "combine_method");
00422 
00423     if (bitmask & VISIR_PARAM_STRIPNON) {
00424         bitmask ^= VISIR_PARAM_STRIPNON;
00425         /* The is not a real option - its presence means that the default value
00426            for the destriping iterations is zero */
00427         dostrip = CPL_FALSE;
00428     }
00429 
00430     /* --nstripe */
00431     VISIR_PARAMETER_SET(VISIR_PARAM_STRIPITE, "nstripe",
00432                         CPL_TYPE_INT, "Max number of destriping iterations "
00433                         "(0 to disable destriping). Horizontal destriping is "
00434                         "done first and if no horizontal striping is detected, "
00435                         "vertical destriping is performed", dostrip ? 15 : 0,
00436                         "destripe_iterations");
00437 
00438     /* --mstripe */
00439     VISIR_PARAMETER_SET(VISIR_PARAM_STRIPMOR, "mstripe", CPL_TYPE_BOOL,
00440                        "Destripe with morphological cleaning", FALSE,
00441                         "destripe_morpho");
00442 
00443     /* --rl */
00444     VISIR_PARAMETER_SET(VISIR_PARAM_REJLEFT, "reject_left", CPL_TYPE_INT,
00445                         "Reject leftmost columns in spectrum extraction, zero "
00446                         "means all columns on the left are used. In cross-"
00447                         "dispersion mode a (small) negative number may be used "
00448                         "[pixel]", 0, "rl");
00449 
00450     /* --rr */
00451     VISIR_PARAMETER_SET(VISIR_PARAM_REJRIGHT, "reject_right", CPL_TYPE_INT,
00452                         "Reject rightmost columns in spectrum extraction, zero "
00453                         "means all columns on the right are used. In cross-"
00454                         "dispersion mode a (small) negative number may be used "
00455                         "[pixel]", 0, "rr");
00456 
00457     cpl_free(context);
00458 
00459     cpl_ensure_code(!cpl_error_get_code(), cpl_error_get_code());
00460     cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
00461 
00462     return CPL_ERROR_NONE;
00463 }
00464 
00465 /*----------------------------------------------------------------------------*/
00475 /*----------------------------------------------------------------------------*/
00476 cpl_boolean visir_parameterlist_get_bool(const cpl_parameterlist * self,
00477                                          const char * recipe,
00478                                          visir_parameter bitmask)
00479 {
00480 
00481     int nbits = 0;
00482     cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
00483 
00484 
00485     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
00486     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, CPL_FALSE);
00487     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
00488 
00489     /* --auto_bpm */
00490     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_AUTOBPM, "auto_bpm");
00491 
00492     /* --g */
00493     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_GLITCH, "rem_glitch");
00494 
00495     /* --p */
00496     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_PURGE, "purge_bad");
00497 
00498     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_REFINE, "refine");
00499 
00500     /* --fixcombi */
00501     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_FIXCOMBI, "fixcombi");
00502 
00503     /* --mstripe */
00504     VISIR_PARAMETER_GET_BOOL(VISIR_PARAM_STRIPMOR, "mstripe");
00505 
00506 
00507     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
00508     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
00509 
00510     return value;
00511 
00512 }
00513 
00514 
00515 /*----------------------------------------------------------------------------*/
00525 /*----------------------------------------------------------------------------*/
00526 int visir_parameterlist_get_int(const cpl_parameterlist * self,
00527                                 const char * recipe,
00528                                 visir_parameter bitmask)
00529 {
00530 
00531     int nbits = 0;
00532     int value = 0; /* Avoid (false) uninit warning */
00533 
00534 
00535     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
00536     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, 0);
00537     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
00538 
00539 
00540     /* --plot */
00541     VISIR_PARAMETER_GET_INT(VISIR_PARAM_PLOT, "plot");
00542 
00543     /* --orderoffset */
00544     VISIR_PARAMETER_GET_INT(VISIR_PARAM_ORDEROFF, "orderoffset");
00545 
00546     /* --nsamples */
00547     VISIR_PARAMETER_GET_INT(VISIR_PARAM_NSAMPLES, "nsamples");
00548 
00549     /* --hsize */
00550     VISIR_PARAMETER_GET_INT(VISIR_PARAM_HALFSIZE, "hsize");
00551 
00552     /* --nstripe */
00553     VISIR_PARAMETER_GET_INT(VISIR_PARAM_STRIPITE, "nstripe");
00554 
00555     /* --rl */
00556     VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJLEFT, "reject_left");
00557 
00558     /* --rr */
00559     VISIR_PARAMETER_GET_INT(VISIR_PARAM_REJRIGHT, "reject_right");
00560 
00561 
00562     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
00563     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, 0);
00564 
00565     return value;
00566 
00567 }
00568 
00569 /*----------------------------------------------------------------------------*/
00579 /*----------------------------------------------------------------------------*/
00580 double visir_parameterlist_get_double(const cpl_parameterlist * self,
00581                                       const char * recipe,
00582                                       visir_parameter bitmask)
00583 {
00584 
00585     int nbits = 0;
00586     double value = DBL_MAX; /* Avoid (false) uninit warning */
00587 
00588 
00589     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
00590     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, 0.0);
00591     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
00592 
00593     /* --slit_skew */
00594     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SLITSKEW, "phi");
00595 
00596     /* --spectrum_skew */
00597     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_SPECSKEW, "ksi");
00598 
00599     /* --vert_arc */
00600     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_VERTARC, "eps");
00601 
00602     /* --hori_arc */
00603     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HORIARC, "delta");
00604 
00605     /* --jy_val */
00606     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_JYVAL, "jy_val");
00607 
00608     /* --low */
00609     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_LOWLIM, "low");
00610 
00611     /* --high */
00612     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HIGHLIM, "high");
00613 
00614     /* --emis_tol */
00615     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_EMIS_TOL, "emis_tol");
00616 
00617     /* --qeff */
00618     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_QEFF, "qeff");
00619 
00620     /* --hot_t */
00621     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_HOT_LIM, "hot_threshold");
00622 
00623     /* --cold_t */
00624     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_COLD_LIM, "cold_threshold");
00625 
00626     /* --dev_t */
00627     VISIR_PARAMETER_GET_DOUBLE(VISIR_PARAM_DEV_LIM, "dev_threshold");
00628 
00629     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
00630     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, 0.0);
00631 
00632     return value;
00633 
00634 }
00635 
00636 
00637 
00638 /*----------------------------------------------------------------------------*/
00647 /*----------------------------------------------------------------------------*/
00648 const char * visir_parameterlist_get_string(const cpl_parameterlist * self,
00649                                             const char * recipe,
00650                                             visir_parameter bitmask)
00651 {
00652 
00653     int nbits = 0;
00654     const char * value = NULL; /* Avoid (false) uninit warning */
00655     const cpl_boolean is_combine
00656         = bitmask & VISIR_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
00657 
00658     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, NULL);
00659     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
00660 
00661     /* --nod */
00662     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_NODPOS, "nodding");
00663 
00664     /* --rej */
00665     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJECT, "rej");
00666 
00667     /* --off */
00668     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OFFSETS, "offsets");
00669 
00670     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REFINE, "refine");
00671 
00672     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_OBJECTS, "objects");
00673 
00674     /* --xcorr */
00675     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_XCORR, "xcorr");
00676 
00677     /* --radii */
00678     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_RADII, "radii");
00679 
00680     /* --r */
00681     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_REJBORD, "rej_bord");
00682 
00683     /* --combine */
00684     VISIR_PARAMETER_GET_STRING(VISIR_PARAM_COMBINE, "comb_meth");
00685 
00686     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
00687     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, NULL);
00688 
00689     assert(value != NULL);
00690 
00691     /* FIXME: This should be handled by the enum */
00692     if (is_combine)
00693         cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
00694                    strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
00695                    NULL);
00696 
00697     return value;
00698 
00699 }
00700 

Generated on Fri Jul 3 11:15:23 2009 for VISIR Pipeline Reference Manual by  doxygen 1.5.8