IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 7, 2009, 7:10:01 PM (17 years ago)
Author:
eugene
Message:

handle cases where mask files are missing

Location:
trunk/magic/censorObjects/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/censorObjects/src/censor.h

    r24695 r24714  
    3131bool censorParseCamera (pmConfig *config);
    3232bool censorLoop (pmConfig *config);
    33 bool censorReadout (pmReadout *readout, pmConfig *config, const pmFPAview *view);
     33bool censorReadout (pmReadout *readout, pmConfig *config, const pmFPAview *view, bool badMaskFile);
    3434void censorCleanup (pmConfig *config);
     35bool censorBadFileByView (bool badFile, pmFPAfile *file, pmConfig *config, pmFPAview *view);
    3536
    3637// Return version strings.
  • trunk/magic/censorObjects/src/censorLoop.c

    r24695 r24714  
    4343    }
    4444
     45    // select the input data sources
     46    pmFPAfile *inMask = psMetadataLookupPtr (NULL, config->files, "CENSOR.INPUT.MASK");
     47    if (!inMask) {
     48        psError(CENSOR_ERR_CONFIG, true, "Can't find input masks!\n");
     49        return false;
     50    }
     51
    4552    pmFPAview *view = pmFPAviewAlloc (0);
     53    bool badMaskFile = false;
     54
     55    // check on the mask file at this level if possible
     56    badMaskFile = censorBadFileByView(badMaskFile, inMask, config, view);
    4657
    4758    // files associated with the science image
     
    4960
    5061    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    51         psTrace ("censor", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    52         if (!chip->process || !chip->file_exists) { continue; }
     62        psTrace ("censor", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     63        if (!chip->process || !chip->file_exists) { continue; }
     64
     65        // check on the mask file at this level if possible
     66        badMaskFile = censorBadFileByView(badMaskFile, inMask, config, view);
     67
    5368        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    5469
    5570        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    56             psTrace ("censor", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    57             if (!cell->process || !cell->file_exists) { continue; }
     71            psTrace ("censor", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     72            if (!cell->process || !cell->file_exists) { continue; }
     73
     74            // check on the mask file at this level if possible
     75            badMaskFile = censorBadFileByView(badMaskFile, inMask, config, view);
     76
    5877            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    5978
    6079            // process each of the readouts
    6180            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     81
     82                // check on the mask file at this level if possible
     83                badMaskFile = censorBadFileByView(badMaskFile, inMask, config, view);
     84
    6285                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    6386                if (!readout->data_exists) { continue; }
    6487
    65                 if (!censorReadout (readout, config, view)) ESCAPE;
     88                if (!censorReadout (readout, config, view, badMaskFile)) ESCAPE;
    6689
    6790                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     
    78101    return true;
    79102}
     103
     104bool censorBadFileByView (bool badFile, pmFPAfile *file, pmConfig *config, pmFPAview *view) {
     105
     106    // get the current level
     107    pmFPALevel level = pmFPAviewLevel (view);
     108
     109    // can we try to open this file? (if not, leave the existing badView intact)
     110    if (level != file->fileLevel) return badFile;
     111
     112    // free, and if needed, realloc badView below
     113    badFile = false;
     114
     115    char *filename = pmFPAfileName(file, view, config);
     116    if (filename) {
     117        // activate the file
     118        pmFPAfileActivate (config->files, true, file->name);
     119        psFree (filename);
     120        return false;
     121    }
     122
     123    // de-activate the file
     124    pmFPAfileActivate (config->files, false, file->name);
     125    return true;
     126}
  • trunk/magic/censorObjects/src/censorReadout.c

    r24695 r24714  
    1313# include "censor.h"
    1414
    15 bool censorReadout (pmReadout *readout, pmConfig *config, const pmFPAview *view) {
     15bool censorReadout (pmReadout *readout, pmConfig *config, const pmFPAview *view, bool badMaskFile) {
    1616
    1717    bool status;
     18
     19    // if there is no mask file for this readout drop all sources
     20    if (badMaskFile) {
     21      psMetadataRemoveKey (readout->analysis, "PSPHOT.SOURCES");
     22      return true;
     23    }
    1824
    1925    // select the current recipe
Note: See TracChangeset for help on using the changeset viewer.