visir_parameter.c

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

Generated on Thu Mar 24 11:59:39 2011 for VISIR Pipeline Reference Manual by  doxygen 1.5.8