visir_parameter.c

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

Generated on Tue Jun 29 12:20:52 2010 for VISIR Pipeline Reference Manual by  doxygen 1.4.7