IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2009, 12:08:50 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ppImage

  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageParseCamera.c

    r21364 r23352  
    99    bool status = false;
    1010
    11     // the input image defines the camera, and all recipes and options the follow
    12     pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT");
    13     if (!status || !input) {
    14         psError(PS_ERR_IO, false, "Failed to build FPA from PPIMAGE.INPUT");
    15         return NULL;
    16     }
    17     if (input->type != PM_FPA_FILE_IMAGE) {
    18         psError(PS_ERR_IO, true, "PPIMAGE.INPUT is not of type IMAGE");
    19         return NULL;
    20     }
    21 
    22     // if MASK or VARIANCE was supplied on command line, bind files to 'input'.
    23     // the mask and variance will be mosaicked with the image
    24     pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "PPIMAGE.INPUT.MASK");
    25     if (!status) {
    26         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    27         return NULL;
    28     }
    29     if (inputMask) {
    30       if (inputMask->type != PM_FPA_FILE_MASK) {
    31         psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK");
    32         return NULL;
    33       }
    34     }
    35 
    36     pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.VARIANCE", "PPIMAGE.INPUT.VARIANCE");
    37     if (!status) {
    38         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    39         return NULL;
    40     }
    41     if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) {
    42         psError(PS_ERR_IO, true, "PPIMAGE.INPUT.VARIANCE is not of type VARIANCE");
    43         return NULL;
    44     }
     11    if (!ppImageDefineFile(config, NULL, "PPIMAGE.INPUT", "INPUT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NONE)) {
     12        psError(PS_ERR_IO, false, "Can't find an input image source");
     13        return NULL;
     14    }
     15    pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.INPUT"); // Input file
     16    psAssert(input, "We just put it there!");
    4517
    4618    // add recipe options supplied on command line
    47     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, RECIPE_NAME);
     19    psMetadata *recipe  = psMetadataLookupPtr(&status, config->recipes, RECIPE_NAME);
    4820
    4921    // parse the options from the metadata format to the ppImageOptions structure
    50     ppImageOptions *options = ppImageOptionsParse (config);
     22    ppImageOptions *options = ppImageOptionsParse(config);
    5123
    5224    // the following are defined from the argument list, if given,
     
    5426    // not all input or output images are used in a given recipe
    5527    if (options->doBias) {
    56         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.BIAS", "BIAS", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) {
    57             psError (PS_ERR_IO, false, "Can't find a bias image source");
    58             psFree (options);
     28        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.BIAS", "BIAS",
     29                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) {
     30            psError(PS_ERR_IO, false, "Can't find a bias image source");
     31            psFree(options);
    5932            return NULL;
    6033        }
    6134    }
    6235    if (options->doDark) {
    63         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
    64             psError (PS_ERR_IO, false, "Can't find a dark image source");
    65             psFree (options);
     36        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.DARK", "DARK",
     37                               PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
     38            psError(PS_ERR_IO, false, "Can't find a dark image source");
     39            psFree(options);
    6640            return NULL;
    6741        }
    6842    }
    6943    if (options->doMask) {
    70 
    71         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
    72             psError (PS_ERR_IO, false, "Can't find a mask image source");
    73             psFree (options);
    74             return NULL;
    75         }
     44        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.MASK", "MASK",
     45                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
     46            psError(PS_ERR_IO, false, "Can't find a mask image source");
     47            psFree(options);
     48            return NULL;
     49        }
     50
     51#if 0
     52        // I think this is now done automatically in the pmFPAfileDefine and pmFPAfileIOChecks -- PAP.
     53
    7654        // XXX have ppImageDefineFile return the pmFPAfile?
    7755        pmFPAfile *mask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.MASK");
    78         psAssert (mask, "mask not defined?  not possible!");
     56        psAssert(mask, "Just defined the mask!");
    7957
    8058        // Need to read the names of bit masks from the mask header and set them in the
     
    8462            // XXX need to load the mask bit names from one of the headers
    8563            // this grabs the first available hdu : no guarantee that it will be valid, though
    86             pmHDU *hdu = pmHDUGetFirst (mask->fpa);
     64            pmHDU *hdu = pmHDUGetFirst(mask->fpa);
    8765            if (!hdu) {
    8866                psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK");
     
    9068            }
    9169            // XXX is this consistent with the pmConfigMaskReadHeader call above?
    92             if (!pmConfigMaskReadHeader (config, hdu->header)) {
     70            if (!pmConfigMaskReadHeader(config, hdu->header)) {
    9371                psError(PS_ERR_IO, false, "error in mask bits");
    9472                return NULL;
    9573            }
    9674        }
     75#endif
    9776    }
    9877    if (options->doShutter) {
    99         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) {
    100             psError (PS_ERR_IO, false, "Can't find a shutter image source");
    101             psFree (options);
     78        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER",
     79                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) {
     80            psError(PS_ERR_IO, false, "Can't find a shutter image source");
     81            psFree(options);
    10282            return NULL;
    10383        }
     
    10585
    10686    if (options->doFlat) {
    107         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FLAT", "FLAT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) {
    108             psError (PS_ERR_IO, false, "Can't find a flat image source");
    109             psFree (options);
    110             return NULL;
    111         }
    112     }
    113 
    114     int nThreads = psMetadataLookupS32 (&status, config->arguments, "NTHREADS");
     87        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FLAT", "FLAT",
     88                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) {
     89            psError(PS_ERR_IO, false, "Can't find a flat image source");
     90            psFree(options);
     91            return NULL;
     92        }
     93    }
     94
     95    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS");
    11596    if (nThreads > 0) {
    116         int nScanRows = psMetadataLookupS32 (&status, recipe, "SCAN.ROWS");
    117         pmDetrendSetThreadTasks (nScanRows);
     97        int nScanRows = psMetadataLookupS32(&status, recipe, "SCAN.ROWS");
     98        pmDetrendSetThreadTasks(nScanRows);
    11899    }
    119100
     
    166147skip_fringe:
    167148    if (options->doFringe) {
    168         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) {
     149        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FRINGE", "FRINGE",
     150                               PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) {
    169151            psError (PS_ERR_IO, false, "Can't find a fringe image source");
    170152            return NULL;
     
    283265        // define associated psphot input/output files
    284266        if (!psphotDefineFiles (config, psphotInput)) {
    285             psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");
     267            psError(PSPHOT_ERR_CONFIG, false,
     268                    "Trouble defining the additional input/output files for psphot");
    286269            return false;
    287270        }
     
    291274    if (options->doAstromChip || options->doAstromMosaic) {
    292275        if (!options->doPhotom) {
    293             psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry");
     276            psError(PSASTRO_ERR_CONFIG, false,
     277                    "Photometry mode is not selected; it is required for astrometry");
    294278            return false;
    295279        }
    296280
    297         pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
    298         PS_ASSERT (psphotOutput, false);
    299 
    300         pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, NULL, "PSASTRO.INPUT");
    301         PS_ASSERT (psastroInput, false);
     281        pmFPAfile *psphotOutput = psMetadataLookupPtr(&status, config->files, "PSPHOT.OUTPUT");
     282        PS_ASSERT(psphotOutput, false);
     283
     284        pmFPAfile *psastroInput = pmFPAfileDefineInput(config, psphotOutput->fpa, NULL, "PSASTRO.INPUT");
     285        PS_ASSERT(psastroInput, false);
    302286        psastroInput->mode = PM_FPA_MODE_REFERENCE;
    303287
    304288        // define associated psphot input/output files
    305         if (!psastroDefineFiles (config, psastroInput)) {
    306             psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro");
     289        if (!psastroDefineFiles(config, psastroInput)) {
     290            psError(PSPHOT_ERR_CONFIG, false,
     291                    "Trouble defining the additional input/output files for psastro");
    307292            return false;
    308293        }
    309294
    310295        // deactivate the psastro files, reactive when needed
    311         pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT");
     296        pmFPAfileActivate(config->files, false, "PSASTRO.OUTPUT");
    312297    }
    313298
     
    325310
    326311    // outImage is used as a carrier: input to chipImage -> require the data to remain at the CHIP level
    327     outImage->freeLevel = PS_MIN (outImage->freeLevel, PM_FPA_LEVEL_CHIP);
     312    outImage->freeLevel = PS_MIN(outImage->freeLevel, PM_FPA_LEVEL_CHIP);
    328313    outImage->dataLevel = outImage->freeLevel;
    329     outImage->fileLevel = PS_MIN (outImage->fileLevel, outImage->dataLevel);
     314    outImage->fileLevel = PS_MIN(outImage->fileLevel, outImage->dataLevel);
    330315
    331316    // outMask and outVariance must be freed at the same level as outImage (all freed by pmFPAFreeData)
     
    342327
    343328    // the input data is the same as the outImage data : force the free levels to match
    344     input->freeLevel = PS_MIN (outImage->freeLevel, input->freeLevel);
     329    input->freeLevel = PS_MIN(outImage->freeLevel, input->freeLevel);
    345330
    346331    // define the binned target files (which may just be carriers for some camera configurations)
    347     pmFPAfile *bin1 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1");
     332    pmFPAfile *bin1 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin1, options->yBin1,
     333                                             "PPIMAGE.BIN1");
    348334    if (!bin1) {
    349335        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN1"));
     
    357343    }
    358344
    359     pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
     345    pmFPAfile *bin2 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin2, options->yBin2,
     346                                             "PPIMAGE.BIN2");
    360347    if (!bin2) {
    361348        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN2"));
     
    373360    bin2->freeLevel = PM_FPA_LEVEL_FPA;
    374361
    375     pmFPAfile *jpg1 = pmFPAfileDefineOutput (config, byFPA1->fpa, "PPIMAGE.JPEG1");
     362    pmFPAfile *jpg1 = pmFPAfileDefineOutput(config, byFPA1->fpa, "PPIMAGE.JPEG1");
    376363    if (!jpg1) {
    377364        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG1"));
     
    384371        return NULL;
    385372    }
    386     pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2");
     373    pmFPAfile *jpg2 = pmFPAfileDefineOutput(config, byFPA2->fpa, "PPIMAGE.JPEG2");
    387374    if (!jpg2) {
    388375        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG2"));
     
    404391    // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
    405392    char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS");
    406     psArray *chips = psStringSplitArray (chipLine, ",", false);
     393    psArray *chips = psStringSplitArray(chipLine, ",", false);
    407394    if (chips->n > 0) {
    408395        pmFPASelectChip (input->fpa, -1, true); // deselect all chips
     
    454441    if (psTraceGetLevel("ppImage.config") > 0) {
    455442        // Get a look inside all the files.
    456         psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator
     443        psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL);
    457444        psMetadataItem *item;               // Item from iteration
    458445        fprintf(stderr, "Files:\n");
Note: See TracChangeset for help on using the changeset viewer.