IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 13, 2006, 5:14:07 PM (20 years ago)
Author:
Paul Price
Message:

Small hacks from updating psModule code for FPAs and concepts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageOptions.c

    r5858 r5976  
    1 # include "ppImage.h"
     1#include "ppImage.h"
    22
    33// XXX EAM : this needs signficant work to choose the detrend images based on the detrend database
    44
    5 bool ppImageOptions (ppData *data, ppOptions *options, ppConfig *config) {
     5bool ppImageOptions(ppData *data, ppOptions *options, ppConfig *config)
     6{
    67
    7     bool status;
    8 
    9     // default initial values
    10     options->doMask = false;            // Mask bad pixels
    11     options->doNonLin = false;          // Non-linearity correction
    12     options->doBias = false;            // Bias subtraction
    13     options->doDark = false;            // Dark subtraction
    14     options->doOverscan = false;        // Overscan subtraction
    15     options->doFlat = false;            // Flat-field normalisation
    16     options->doFringe = false;          // Fringe subtraction
    17     options->doSource = false;          // Source identification and photometry
    18     options->doAstrom = false;          // Astrometry
    19     options->overscanBins = 1;          // Number of pixels per bin for overscan
     8    // Flags for various activities
     9    options->doMask = false;            // Mask bad pixels
     10    options->doNonLin = false;          // Non-linearity correction
     11    options->doBias = false;            // Bias subtraction
     12    options->doDark = false;            // Dark subtraction
     13    options->doOverscan = false;        // Overscan subtraction
     14    options->doFlat = false;            // Flat-field normalisation
     15    options->doFringe = false;          // Fringe subtraction
     16    options->doSource = false;          // Source identification and photometry
     17    options->doAstrom = false;          // Astrometry
     18    // Overscan options
     19    options->overscanBins = 1;          // Number of pixels per bin for overscan
    2020    options->overscanStats = NULL;      // Statistics for overscan
    21     options->overscanFit = NULL;        // Overscan fit (polynomial or spline)
     21    options->overscanFit = NULL;        // Overscan fit (polynomial or spline)
    2222    options->overscanFitType = PM_FIT_NONE; // Fit type for overscan
    2323    options->overscanMode = PM_OVERSCAN_NONE; // Axis for overscan
     24    // Non-linearity options
     25    options->nonLinearType = 0;         // Type of non-linearity data (vector, string or metadata)
     26    options->nonLinearData = NULL;      // The non-linearity data
     27    options->nonLinearSource = NULL;    // If the non-linearity data is a menu, this provides the key
     28    // Various others
     29    options->imageLoadDepth = PP_LOAD_NONE; // No load depth specified yet
    2430
    25     options->doNonLin = false;
    26     options->nonLinearType = false;
    27     options->nonLinearData = NULL;
    28     options->nonLinearSource = NULL;
    29 
    30     options->imageLoadDepth = PP_LOAD_NONE;
    31     char *depth = psMetadataLookupPtr(NULL, config->recipe, "LOAD.DEPTH");
    32     if (depth == NULL) {
    33         psAbort ("phase2", "load depth not specified");
     31    bool mdStatus = false;              // Result of MD lookup
     32    const char *depth = psMetadataLookupStr(&mdStatus, config->recipe, "LOAD.DEPTH");
     33    if (! mdStatus || ! depth || strlen(depth) == 0) {
     34        psLogMsg("ppImage", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe.");
     35        exit(EXIT_FAILURE);
    3436    }
    3537    if (!strcasecmp(depth, "FPA")) {
    36         options->imageLoadDepth = PP_LOAD_FPA;
    37     }
    38     if (!strcasecmp(depth, "CHIP")) {
    39         options->imageLoadDepth = PP_LOAD_CHIP;
    40     }
    41     if (!strcasecmp(depth, "CELL")) {
    42         options->imageLoadDepth = PP_LOAD_CELL;
    43     }
    44     if (options->imageLoadDepth == PP_LOAD_NONE) {
    45         psAbort ("phase2", "load depth not specified");
     38        options->imageLoadDepth = PP_LOAD_FPA;
     39    } else if (!strcasecmp(depth, "CHIP")) {
     40        options->imageLoadDepth = PP_LOAD_CHIP;
     41    } else if (!strcasecmp(depth, "CELL")) {
     42        options->imageLoadDepth = PP_LOAD_CELL;
     43    } else {
     44        psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe is not FPA, CHIP or CELL.");
     45        exit(EXIT_FAILURE);
    4646    }
    4747
    48     // mask - recipe options
     48    // Mask recipe options
    4949    if (psMetadataLookupBool(NULL, config->recipe, "MASK")) {
    50         data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");
    51         if (strlen(data->mask->filename) > 0) {
     50        data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");
     51        if (data->mask->filename && strlen(data->mask->filename) > 0) {
    5252            options->doMask = true;
    5353        } else {
    54             psLogMsg("phase2", PS_LOG_WARN, "Masking is desired, but no mask was supplied"
    55                      " --- no masking will be performed.\n");
     54            psLogMsg(__func__, PS_LOG_WARN, "Masking is desired, but no mask was supplied"
     55                     " --- no masking will be performed.\n");
    5656        }
    5757    }
    5858
    59     // non-linear - recipe options
     59    // Non-linearity recipe options
    6060    if (psMetadataLookupBool(NULL, config->recipe, "NONLIN")) {
    61         psMetadataItem *dataItem = psMetadataLookup(config->recipe, "NONLIN.DATA");
    62         if (! dataItem) {
    63             psAbort("phase2", "Non-linearity correction desired, but unable to "
    64                      "find NONLIN.DATA in recipe");
    65         }
     61        psMetadataItem *dataItem = psMetadataLookup(config->recipe, "NONLIN.DATA");
     62        if (! dataItem) {
     63            psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
     64                     "find NONLIN.DATA in recipe.");
     65            exit(EXIT_FAILURE);
     66        }
    6667
    6768        options->doNonLin = true;
    68         options->nonLinearType = dataItem->type;
    69         options->nonLinearData = dataItem;
     69        options->nonLinearType = dataItem->type;
     70        options->nonLinearData = dataItem;
    7071
    71         switch (dataItem->type) {
    72           case PS_DATA_VECTOR:
    73           case PS_DATA_STRING:
    74             break;
     72        switch (dataItem->type) {
     73            // No immediate action required
     74          case PS_DATA_VECTOR:
     75          case PS_DATA_STRING:
     76            break;
    7577
    76           case PS_DATA_METADATA:
    77             // This is a menu
    78             options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE");
    79             if (! status || ! options->nonLinearSource) {
    80                 psAbort("phase2", "Non-linearity correction desired, but unable to "
    81                          "find NONLIN.SOURCE in recipe");
    82             }
    83             break;
    84 
    85           default:
    86             psAbort("phase2", "Non-linearity correction desired, but "
    87                     "NONLIN.DATA is of invalid type.");
    88         }
    89 
     78            // This is a menu; we need the key
     79          case PS_DATA_METADATA:
     80            {
     81                bool status;
     82                options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE");
     83                if (! status || ! options->nonLinearSource) {
     84                    psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
     85                            "find NONLIN.SOURCE in recipe");
     86                    exit(EXIT_FAILURE);
     87                }
     88            }
     89            break;
     90          default:
     91            psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but "
     92                    "NONLIN.DATA is of invalid type.");
     93            exit(EXIT_FAILURE);
     94        }
    9095    }
    9196
    92     // bias - recipe options
     97    // Bias recipe options
    9398    if (psMetadataLookupBool(NULL, config->recipe, "BIAS")) {
    94         data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias");
    95         if (strlen(data->bias->filename) > 0) {
     99        data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias");
     100        if (data->bias->filename && strlen(data->bias->filename) > 0) {
    96101            options->doBias = true;
    97102        } else {
    98             psLogMsg("phase2", PS_LOG_WARN, "Bias subtraction is desired, but no bias was supplied --- "
     103            psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired, but no bias was supplied --- "
    99104                     "no bias subtraction will be performed.\n");
    100105        }
    101106    }
    102107
    103     // dark - recipe options
     108    // Dark recipe options
    104109    if (psMetadataLookupBool(NULL, config->recipe, "DARK")) {
    105         data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark");
    106         if (strlen(data->dark->filename) > 0) {
     110        data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark");
     111        if (data->dark->filename && strlen(data->dark->filename) > 0) {
    107112            options->doDark = true;
    108113        } else {
    109             psLogMsg("phase2", PS_LOG_WARN, "Dark subtraction is desired, but no dark was supplied --- "
     114            psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired, but no dark was supplied --- "
    110115                     "no dark subtraction will be performed.\n");
    111116        }
    112117    }
    113118
    114     // overscan - recipe options
     119    // XXX PAP: The overscan stuff needs to be updated following the reworked API
     120
     121    // Overscan recipe options
    115122    // XXX EAM : we should abort on invalid options. default options?
    116123    if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) {
    117         // XXX EAM : does 'overscanMode = NONE' mean doOverscan = false?
     124        // XXX EAM : does 'overscanMode = NONE' mean doOverscan = false?
    118125        options->doOverscan = true;
    119126        psString mode = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.MODE");
     
    123130            options->overscanMode = PM_OVERSCAN_ALL;
    124131        } else if (strcasecmp(mode, "NONE")) {
    125             psLogMsg("phase2", PS_LOG_WARN, "OVERSCAN.MODE (%s) is not one of NONE, INDIVIDUAL, or ALL:"
     132            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.MODE (%s) is not one of NONE, INDIVIDUAL, or ALL:"
    126133                     " assuming NONE.\n", mode);
    127134        }
     
    135142            options->overscanFitType = PM_FIT_SPLINE;
    136143            // int order = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); // Order of polynomial fit
    137             // XXX : not in psLib yet : options->overscanFit = psSpline1DAlloc();
     144            // XXX : not in psLib yet : options->overscanFit = psSpline1DAlloc();
    138145        } else if (strcasecmp(fit, "NONE")) {
    139             psLogMsg("phase2", PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
     146            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
    140147                     " assuming NONE.\n", fit);
    141148        }
     
    158165    // flat-field - recipe options
    159166    if (psMetadataLookupBool(NULL, config->recipe, "FLAT")) {
    160         data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat");
     167        data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat");
    161168        if (strlen(data->flat->filename) > 0) {
    162169            options->doFlat = true;
    163170        } else {
    164             psLogMsg("phase2", PS_LOG_WARN, "Flat-fielding is desired, but no flat was supplied --- "
     171            psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired, but no flat was supplied --- "
    165172                     "no flat-fielding will be performed.\n");
    166173        }
Note: See TracChangeset for help on using the changeset viewer.