naco_parameter.c

00001 /* $Id: naco_parameter.c,v 1.29 2009/11/18 19:19:48 llundin Exp $
00002  *
00003  * This file is part of the NACO 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/11/18 19:19:48 $
00024  * $Revision: 1.29 $
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_stdstar.h>
00043 
00044 #include "irplib_tools.h"
00045 #include "irplib_utils.h"
00046 /* Needed to define varius parameter settings */
00047 #include "irplib_plot.h"
00048 
00049 #include "naco_parameter.h"
00050 #include "naco_dfs.h"
00051 #include "naco_pfits.h"
00052 
00053 /*-----------------------------------------------------------------------------
00054                                    Define
00055  -----------------------------------------------------------------------------*/
00056 
00057 #define NACO_XCORR_SX            10
00058 #define NACO_XCORR_SY            10
00059 
00060 /* To be called from naco_parameter_set() */
00061 #define NACO_PARAMETER_SET(MASK, VARNAME, TYPE, MAN, DEFAULT, SHORT)           \
00062 if (bitmask & MASK) {                                                          \
00063     char * paramname = cpl_sprintf(PACKAGE ".%s." VARNAME, recipe);            \
00064                                                                                \
00065     p = cpl_parameter_new_value(paramname, TYPE, MAN, context, DEFAULT);       \
00066     cpl_free(paramname);                                                       \
00067     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, SHORT);                 \
00068     cpl_parameterlist_append(self, p);                                         \
00069                                                                                \
00070     if (cpl_error_get_code()) /* Propagate error */                            \
00071         (void)cpl_error_set_where(cpl_func);                                   \
00072                                                                                \
00073     bitmask ^= MASK; /* Reset bit. At the end bitmask must be zero */          \
00074                                                                                \
00075     /* Verify that each mask value is unique */                                \
00076     if (chkmask & MASK)                                                        \
00077         (void)cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED);                  \
00078     chkmask |= MASK;                                                           \
00079                                                                                \
00080 }
00081 
00082 /* To be called from naco_parameterlist_get_bool() */
00083 #define NACO_PARAMETER_GET_BOOL(MASK, VARNAME)                                 \
00084 if (bitmask & MASK) {                                                          \
00085     value = irplib_parameterlist_get_bool(self, PACKAGE, recipe, VARNAME);     \
00086                                                                                \
00087     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);        \
00088                                                                                \
00089     nbits++;         /* Total number of bits must be one  */                   \
00090     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00091                                                                                \
00092 }
00093 
00094 /* To be called from naco_parameterlist_get_int() */
00095 #define NACO_PARAMETER_GET_INT(MASK, VARNAME)                                  \
00096 if (bitmask & MASK) {                                                          \
00097     value = irplib_parameterlist_get_int(self, PACKAGE, recipe, VARNAME);      \
00098                                                                                \
00099     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);                \
00100                                                                                \
00101     nbits++;         /* Total number of bits must be one  */                   \
00102     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00103                                                                                \
00104 }
00105 
00106 /* To be called from naco_parameterlist_get_double() */
00107 #define NACO_PARAMETER_GET_DOUBLE(MASK, VARNAME)                               \
00108 if (bitmask & MASK) {                                                          \
00109     value = irplib_parameterlist_get_double(self, PACKAGE, recipe, VARNAME);   \
00110                                                                                \
00111     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);              \
00112                                                                                \
00113     nbits++;         /* Total number of bits must be one  */                   \
00114     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00115                                                                                \
00116 }
00117 
00118 /* To be called from naco_parameterlist_get_string() */
00119 #define NACO_PARAMETER_GET_STRING(MASK, VARNAME)                               \
00120 if (bitmask & MASK) {                                                          \
00121     value = irplib_parameterlist_get_string(self, PACKAGE, recipe, VARNAME);   \
00122                                                                                \
00123     cpl_ensure(value != NULL, cpl_error_get_code(), NULL);                     \
00124                                                                                \
00125     nbits++;         /* Total number of bits must be one  */                   \
00126     bitmask ^= MASK; /* - bitmask must be zero at the end */                   \
00127                                                                                \
00128 }
00129 
00130 
00131 /*----------------------------------------------------------------------------*/
00137 /*----------------------------------------------------------------------------*/
00138 
00142 /*----------------------------------------------------------------------------*/
00151 /*----------------------------------------------------------------------------*/
00152 cpl_error_code naco_parameter_set(cpl_parameterlist * self,
00153                                   const char * recipe,
00154                                   naco_parameter bitmask)
00155 {
00156 
00157     cpl_parameter * p;
00158     char * context;
00159     naco_parameter chkmask = 0; /* Verify that each mask value is unique */
00160 
00161 
00162     cpl_ensure_code(self,   CPL_ERROR_NULL_INPUT);
00163     cpl_ensure_code(recipe, CPL_ERROR_NULL_INPUT);
00164 
00165 
00166     context = cpl_sprintf(PACKAGE ".%s", recipe);
00167 
00168     /* --xtmax */
00169     NACO_PARAMETER_SET(NACO_PARAM_XTMAX, "extract_max", CPL_TYPE_INT,
00170                        "Stop the spectrum extraction at this column", 1024,
00171                        "xtmax");
00172 
00173     /* --xtmin */
00174     NACO_PARAMETER_SET(NACO_PARAM_XTMIN, "extract_min", CPL_TYPE_INT,
00175                        "Start the spectrum extraction at this column", 1,
00176                        "xtmin");
00177 
00178     /* --save */
00179     NACO_PARAMETER_SET(NACO_PARAM_SAVE, "save", CPL_TYPE_INT,
00180                        "A positive value causes additional, intermediate "
00181                        "products to be saved", 0, "save");
00182 
00183     /* --plot */
00184     NACO_PARAMETER_SET(NACO_PARAM_PLOT, "plot", CPL_TYPE_INT,
00185                        irplib_plot_manpage, 0, "plot");
00186 
00187     /* --star_r */
00188     NACO_PARAMETER_SET(NACO_PARAM_STAR_R, "star_r", CPL_TYPE_DOUBLE,
00189                        "The star radius [arcsecond]",
00190                        STREHL_STAR_RADIUS, "star_r");
00191 
00192     /* --bg_r1 */
00193     NACO_PARAMETER_SET(NACO_PARAM_BG_RINT, "bg_r1", CPL_TYPE_DOUBLE,
00194                        "The internal radius of the background [arcsecond]",
00195                        STREHL_BACKGROUND_R1, "bg_r1");
00196 
00197     /* --bg_r2 */
00198     NACO_PARAMETER_SET(NACO_PARAM_BG_REXT, "bg_r2", CPL_TYPE_DOUBLE,
00199                        "The external radius of the background [arcsecond]",
00200                        STREHL_BACKGROUND_R2, "bg_r2");
00201 
00202     /* --r */
00203     NACO_PARAMETER_SET(NACO_PARAM_REJBORD, "rej_bord", CPL_TYPE_STRING,
00204                        "Rejected left right bottom and top border [pixel]",
00205                        "200 200 200 200", "r");
00206 
00207     /* --hot_t */
00208     NACO_PARAMETER_SET(NACO_PARAM_HOT_LIM, "hot_threshold", CPL_TYPE_DOUBLE,
00209                        "Hot pixel map threshold", 10.0, "hot_t");
00210 
00211     /* --cold_t */
00212     NACO_PARAMETER_SET(NACO_PARAM_COLD_LIM, "cold_threshold", CPL_TYPE_DOUBLE,
00213                        "Cold pixel map threshold", 6.0, "cold_t");
00214 
00215     /* --dev_t */
00216     NACO_PARAMETER_SET(NACO_PARAM_DEV_LIM, "dev_threshold", CPL_TYPE_DOUBLE,
00217                        "Deviant pixel map threshold", 5.0, "dev_t");
00218 
00219     /* --nsamples */
00220     NACO_PARAMETER_SET(NACO_PARAM_NSAMPLES, "nsamples", CPL_TYPE_INT,
00221                        "Number of samples for RON computation", 100,
00222                        "nsamples");
00223 
00224     /* --hsize */
00225     NACO_PARAMETER_SET(NACO_PARAM_HALFSIZE, "hsize", CPL_TYPE_INT,
00226                        "Half size of the window for RON computation", 2,
00227                        "hsize");
00228 
00229     /* --force */
00230     NACO_PARAMETER_SET(NACO_PARAM_FORCE, "force", CPL_TYPE_BOOL,
00231                        "Force the computation", FALSE, "force");
00232 
00233     /* --slit_w */
00234     NACO_PARAMETER_SET(NACO_PARAM_SLIT_W, "slit_width", CPL_TYPE_INT,
00235                        "Slit width", 20, "slit_w");
00236 
00237     /* --t */
00238     NACO_PARAMETER_SET(NACO_PARAM_BPMTHRES, "thresholds", CPL_TYPE_STRING,
00239                        "Low and high thresholds for the Bad Pixel Map",
00240                        "0.5 2.0", "t");
00241 
00242     /* --prop */
00243     NACO_PARAMETER_SET(NACO_PARAM_PROPFIT, "proport", CPL_TYPE_BOOL,
00244                        "Use the proportional fit", FALSE, "prop");
00245 
00246     /* --bpm */
00247     NACO_PARAMETER_SET(NACO_PARAM_BPM, "bpm", CPL_TYPE_BOOL,
00248                        "Create the bad pixel map", FALSE, "bpm");
00249 
00250     /* --errmap */
00251     NACO_PARAMETER_SET(NACO_PARAM_ERRORMAP, "errmap", CPL_TYPE_BOOL,
00252                        "Create the error map", FALSE, "errmap");
00253 
00254     /* --intercept */
00255     NACO_PARAMETER_SET(NACO_PARAM_INTCEPT, "intercept", CPL_TYPE_BOOL,
00256             "Create the intercept image", FALSE, "intercept");
00257 
00258     /* --ra */
00259     NACO_PARAMETER_SET(NACO_PARAM_RA, "ra", CPL_TYPE_DOUBLE,
00260                        "Right Ascension [Degrees]", 999.0, "ra");
00261 
00262     /* --dec */
00263     NACO_PARAMETER_SET(NACO_PARAM_DEC, "dec", CPL_TYPE_DOUBLE,
00264                        "DEClination  [Degrees]", 999.0, "dec");
00265 
00266     /* --pscale */
00267     NACO_PARAMETER_SET(NACO_PARAM_PIXSCALE, "pscale", CPL_TYPE_DOUBLE,
00268                        "Pixel scale", -1.0, "pscale");
00269 
00270     /* --mag */
00271     NACO_PARAMETER_SET(NACO_PARAM_MAGNITD, "mag", CPL_TYPE_DOUBLE,
00272                        "Magnitude", IRPLIB_STDSTAR_NOMAG, "mag");
00273 
00274     /* --sx */
00275     NACO_PARAMETER_SET(NACO_PARAM_SX, "sx", CPL_TYPE_INT, 
00276                        "Size of the search window in X-direction [pixel]",
00277                        NACO_XCORR_SX, "sx");
00278 
00279     /* --sy */
00280     NACO_PARAMETER_SET(NACO_PARAM_SY, "sy", CPL_TYPE_INT, 
00281                        "Size of the search window in Y-direction [pixel]",
00282                        NACO_XCORR_SY, "sy");
00283 
00284     /* --check_im */
00285     NACO_PARAMETER_SET(NACO_PARAM_CHK_IMG, "check_im", CPL_TYPE_BOOL,
00286                        "Create the check image", FALSE, "check_im");
00287 
00288 
00289     /* --off */
00290     NACO_PARAMETER_SET(NACO_PARAM_OFFSETS, "offsets", CPL_TYPE_STRING,
00291                        "An optional ASCII specification of the offsets "
00292                        "in case those in FITS-headers are missing or wrong. "
00293                        "The file must consist of one line per object FITS-"
00294                        "file and each line must consist of two "
00295                        "numbers which represent the shift in pixels of that "
00296                        "image relative to the first image. The first line "
00297                        "should thus comprise two zeros. Correct FITS-header "
00298                        "offsets mean that the i'th X offset can be gotten "
00299                        "from Xoffset_0 - Xoffset_i, where Xoffset_i is the "
00300                        "value of " NACO_PFITS_DOUBLE_CUMOFFSETX " and "
00301                        "likewise for Y.", NULL, "off");
00302 
00303     /* --objs */
00304     NACO_PARAMETER_SET(NACO_PARAM_OBJECTS, "objects", CPL_TYPE_STRING,
00305                        "objects file", NULL, "objs");
00306 
00307     /* --oddeven */
00308     NACO_PARAMETER_SET(NACO_PARAM_ODDEVEN, "oddeven", CPL_TYPE_BOOL,
00309                        "Apply the odd-even correction. Warning: This flag "
00310                        "currently has no effect", CPL_FALSE, "oddeven");
00311 
00312     /* --xcorr */
00313     NACO_PARAMETER_SET(NACO_PARAM_XCORR, "xcorr", CPL_TYPE_STRING,
00314                        "Cross correlation search and measure sizes",
00315                        "40 40 65 65", "xcorr");
00316 
00317     /* --union */
00318     NACO_PARAMETER_SET(NACO_PARAM_UNION, "union", CPL_TYPE_BOOL,
00319                        "Combine images using their union, as opposed to their "
00320                        "intersection (deprecated and ignored, "
00321                        "see --combine_method)", TRUE, "union");
00322 
00323     /* --rej */
00324     NACO_PARAMETER_SET(NACO_PARAM_REJ_HILO, "rej", CPL_TYPE_STRING,
00325                        "Low and high number of rejected values", "2 2", "rej");
00326 
00327     /* --comb_meth */
00328     /* Copied from visir */
00329     /* FIXME: Use cpl_parameter_new_enum() */
00330     NACO_PARAMETER_SET(NACO_PARAM_COMBINE, "comb_meth", CPL_TYPE_STRING,
00331                        "Combine images using one of: 1) Onto the first image "
00332                        "(first); 2) Their union (union); 3) Their intersection"
00333                        " (inter). NB: Only the 'first'-method produces an "
00334                        "image product with WCS coordinates. A successful "
00335                        "'first'-method always produces a combined image with "
00336                        "dimensions equal to those of the input images. "
00337                        "For the 'union'-method the result image is at least "
00338                        "as large as the input images while for the 'inter'-"
00339                        "method the result image is at most as large as the "
00340                        "input images", "union", "combine_method");
00341 
00342     /* --sky_planes */
00343     NACO_PARAMETER_SET(NACO_PARAM_SKYPLANE, "sky_planes", CPL_TYPE_INT,
00344                        "Estimate the sky using the median of the last n planes "
00345                        "in the previous cube and the first n planes in the "
00346                        "following cube. If the cube has less than n planes "
00347                        "then use all planes. Zero means all. (Ignored for non-"
00348                        "cube data)", 25, "sky_planes");
00349 
00350     /* --cube_mode */
00351     NACO_PARAMETER_SET(NACO_PARAM_CUBEMODE, "cube_mode", CPL_TYPE_STRING,
00352                        "Collapse cube data using one of: 1) No recentering "
00353                        "(add); 2) Shift-and-Add (saa). (Ignored for non-"
00354                        "cube data)", "saa", "cube_mode");
00355 
00356     /* --lucky_strehl */
00357     NACO_PARAMETER_SET(NACO_PARAM_LUCK_STR, "lucky_strehl", CPL_TYPE_DOUBLE,
00358                        "In cube mode use only the frames with a strehl ratio "
00359                        "in the given top fraction. (Ignored for non-"
00360                        "cube data)", 1.0, "lucky");
00361 
00362     cpl_free(context);
00363 
00364     cpl_ensure_code(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE);
00365 
00366     /* Propagate error, if any */
00367     return cpl_error_set_where(cpl_func);
00368 }
00369 
00370 /*----------------------------------------------------------------------------*/
00380 /*----------------------------------------------------------------------------*/
00381 cpl_boolean naco_parameterlist_get_bool(const cpl_parameterlist * self,
00382                                         const char * recipe,
00383                                         naco_parameter bitmask)
00384 {
00385 
00386     int nbits = 0;
00387     cpl_boolean value = CPL_FALSE; /* Avoid (false) uninit warning */
00388 
00389 
00390     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), CPL_FALSE);
00391     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, CPL_FALSE);
00392     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, CPL_FALSE);
00393 
00394     /* --force */
00395     NACO_PARAMETER_GET_BOOL(NACO_PARAM_FORCE, "force");
00396 
00397     /* --prop */
00398     NACO_PARAMETER_GET_BOOL(NACO_PARAM_PROPFIT, "proport");
00399 
00400     /* --bpm */
00401     NACO_PARAMETER_GET_BOOL(NACO_PARAM_BPM, "bpm");
00402 
00403     /* --errmap */
00404     NACO_PARAMETER_GET_BOOL(NACO_PARAM_ERRORMAP, "errmap");
00405 
00406     /* --intercept */
00407     NACO_PARAMETER_GET_BOOL(NACO_PARAM_INTCEPT, "intercept");
00408 
00409     /* --check_im */
00410     NACO_PARAMETER_GET_BOOL(NACO_PARAM_CHK_IMG, "check_im");
00411 
00412     /* --oddeven */
00413     NACO_PARAMETER_GET_BOOL(NACO_PARAM_ODDEVEN, "oddeven");
00414 
00415     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, CPL_FALSE);
00416     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, CPL_FALSE);
00417 
00418     return value;
00419 
00420 }
00421 
00422 /*----------------------------------------------------------------------------*/
00432 /*----------------------------------------------------------------------------*/
00433 int naco_parameterlist_get_int(const cpl_parameterlist * self,
00434                                const char * recipe,
00435                                naco_parameter bitmask)
00436 {
00437 
00438     int nbits = 0;
00439     int value = 0; /* Avoid (false) uninit warning */
00440 
00441 
00442     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0);
00443     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, 0);
00444     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0);
00445 
00446 
00447     /* Must give the long name here */
00448 
00449     /* --xtmax */
00450     NACO_PARAMETER_GET_INT(NACO_PARAM_XTMAX, "extract_max");
00451 
00452     /* --xtmin */
00453     NACO_PARAMETER_GET_INT(NACO_PARAM_XTMIN, "extract_min");
00454 
00455     /* --save */
00456     NACO_PARAMETER_GET_INT(NACO_PARAM_SAVE, "save");
00457 
00458     /* --plot */
00459     NACO_PARAMETER_GET_INT(NACO_PARAM_PLOT, "plot");
00460 
00461     /* --nsamples */
00462     NACO_PARAMETER_GET_INT(NACO_PARAM_NSAMPLES, "nsamples");
00463 
00464     /* --hsize */
00465     NACO_PARAMETER_GET_INT(NACO_PARAM_HALFSIZE, "hsize");
00466 
00467     /* --sx */
00468     NACO_PARAMETER_GET_INT(NACO_PARAM_SX, "sx");
00469 
00470     /* --sy */
00471     NACO_PARAMETER_GET_INT(NACO_PARAM_SY, "sy");
00472 
00473     /* --slit_w */
00474     NACO_PARAMETER_GET_INT(NACO_PARAM_SLIT_W, "slit_width");
00475 
00476     /* --sky_planes */
00477     NACO_PARAMETER_GET_INT(NACO_PARAM_SKYPLANE, "sky_planes");
00478 
00479     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0);
00480     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, 0);
00481 
00482     return value;
00483 
00484 }
00485 
00486 /*----------------------------------------------------------------------------*/
00496 /*----------------------------------------------------------------------------*/
00497 double naco_parameterlist_get_double(const cpl_parameterlist * self,
00498                                      const char * recipe,
00499                                      naco_parameter bitmask)
00500 {
00501 
00502     int nbits = 0;
00503     double value = DBL_MAX; /* Avoid (false) uninit warning */
00504 
00505 
00506     cpl_ensure(!cpl_error_get_code(), cpl_error_get_code(), 0.0);
00507     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, 0.0);
00508     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, 0.0);
00509 
00510 
00511     /* --star_r */
00512     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_STAR_R, "star_r");
00513 
00514     /* --bg_r1 */
00515     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_BG_RINT, "bg_r1");
00516 
00517     /* --bg_r2 */
00518     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_BG_REXT, "bg_r2");
00519 
00520 
00521     /* --hot_t */
00522     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_HOT_LIM, "hot_threshold");
00523 
00524     /* --cold_t */
00525     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_COLD_LIM, "cold_threshold");
00526 
00527     /* --dev_t */
00528     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_DEV_LIM, "dev_threshold");
00529 
00530     /* --ra */
00531     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_RA, "ra");
00532 
00533     /* --dec */
00534     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_DEC, "dec");
00535 
00536     /* --pscale */
00537     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_PIXSCALE, "pscale");
00538 
00539     /* --mag */
00540     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_MAGNITD, "mag");
00541 
00542     /* --lucky_strehl */
00543     NACO_PARAMETER_GET_DOUBLE(NACO_PARAM_LUCK_STR, "lucky_strehl");
00544 
00545 
00546     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, 0.0);
00547     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, 0.0);
00548 
00549     return value;
00550 
00551 }
00552 
00553 /*----------------------------------------------------------------------------*/
00562 /*----------------------------------------------------------------------------*/
00563 const char * naco_parameterlist_get_string(const cpl_parameterlist * self,
00564                                            const char * recipe,
00565                                            naco_parameter bitmask)
00566 {
00567 
00568     int nbits = 0;
00569     const char * value = NULL; /* Avoid (false) uninit warning */
00570     const cpl_boolean is_combine
00571         = bitmask & NACO_PARAM_COMBINE ? CPL_TRUE : CPL_FALSE;
00572 
00573     cpl_ensure(self,   CPL_ERROR_NULL_INPUT, NULL);
00574     cpl_ensure(recipe, CPL_ERROR_NULL_INPUT, NULL);
00575 
00576 
00577     /* --r */
00578     NACO_PARAMETER_GET_STRING(NACO_PARAM_REJBORD, "rej_bord");
00579 
00580     /* --t */
00581     NACO_PARAMETER_GET_STRING(NACO_PARAM_BPMTHRES, "thresholds");
00582 
00583     /* --off */
00584     NACO_PARAMETER_GET_STRING(NACO_PARAM_OFFSETS, "offsets");
00585 
00586     /* --objs */
00587     NACO_PARAMETER_GET_STRING(NACO_PARAM_OBJECTS, "objects");
00588 
00589     /* --xcorr */
00590     NACO_PARAMETER_GET_STRING(NACO_PARAM_XCORR, "xcorr");
00591 
00592     /* --rej */
00593     NACO_PARAMETER_GET_STRING(NACO_PARAM_REJ_HILO, "rej");
00594 
00595     /* --combine */
00596     NACO_PARAMETER_GET_STRING(NACO_PARAM_COMBINE, "comb_meth");
00597 
00598     /* --cube_mode */
00599     NACO_PARAMETER_GET_STRING(NACO_PARAM_CUBEMODE, "cube_mode");
00600 
00601 
00602     cpl_ensure(bitmask == 0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
00603     cpl_ensure(nbits == 1,   CPL_ERROR_ILLEGAL_INPUT, NULL);
00604 
00605     assert(value != NULL);
00606 
00607     /* FIXME: This should be handled by the enum */
00608     if (is_combine)
00609         cpl_ensure(strcmp(value, "first") == 0 || strcmp(value, "union") == 0 ||
00610                    strcmp(value, "intersect") == 0, CPL_ERROR_UNSUPPORTED_MODE,
00611                    NULL);
00612 
00613     return value;
00614 }
00615 

Generated on Wed Mar 9 15:46:17 2011 for NACO Pipeline Reference Manual by  doxygen 1.5.8