IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 30, 2009, 5:20:29 PM (17 years ago)
Author:
watersc1
Message:

Finished up my edits to the detrend cleanup, and some changes to my
copy of burntool and the pslib astrometry. Detrend cleanup has not
been tested yet. That's up next.

Location:
branches/czw_branch/cleanup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup

  • branches/czw_branch/cleanup/psModules/src/camera/pmFPAMaskWeight.c

    r24483 r24951  
    109109    float saturation = psMetadataLookupF32(&mdok, cell->concepts, "CELL.SATURATION"); // Saturation level
    110110    if (!mdok || isnan(saturation)) {
    111         psError(PS_ERR_IO, true, "CELL.SATURATION is not set --- unable to set mask.\n");
    112         return false;
     111        // psError(PS_ERR_IO, true, "CELL.SATURATION is not set --- unable to set mask.\n");
     112        // return false;
     113        psWarning("CELL.SATURATION is not set --- completely masking cell.\n");
     114        saturation = NAN;
    113115    }
    114116    float bad = psMetadataLookupF32(&mdok, cell->concepts, "CELL.BAD"); // Bad level
    115117    if (!mdok || isnan(bad)) {
    116         psError(PS_ERR_IO, true, "CELL.BAD is not set --- unable to set mask.\n");
    117         return false;
     118        // psError(PS_ERR_IO, true, "CELL.BAD is not set --- unable to set mask.\n");
     119        // return false;
     120        psWarning("CELL.BAD is not set --- completely masking cell.\n");
     121        bad = NAN;
    118122    }
    119123    psTrace("psModules.camera", 5, "Saturation: %f, bad: %f\n", saturation, bad);
    120124
     125    // if CELL.GAIN or CELL.READNOISE are not set, then the variance will be set to NAN;
     126    // in this case, we have to set the mask as well
     127    float gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); // Cell gain
     128    if (!mdok) { gain = NAN; }
     129    float readnoise = psMetadataLookupF32(&mdok, cell->concepts, "CELL.READNOISE"); // Cell read noise
     130    if (!mdok) { readnoise = NAN; }
    121131
    122132    // Set up the mask
     
    127137    }
    128138    psImage *mask = readout->mask;      // The mask pixels
     139
     140    // completely mask if SATURATION or BAD are invalid
     141    if (isnan(saturation) || isnan(bad) || isnan(gain) || isnan(readnoise)) {
     142        psImageInit(mask, badMask);
     143        return true;
     144    }
     145
    129146    psImageInit(mask, 0);
    130147
     
    210227    float gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); // Cell gain
    211228    if (!mdok || isnan(gain)) {
    212         psError(PS_ERR_IO, true, "CELL.GAIN is not set --- unable to set variance.\n");
    213         return false;
     229        // psError(PS_ERR_IO, true, "CELL.GAIN is not set --- unable to set variance.\n");
     230        // return false;
     231        psWarning("CELL.GAIN is not set --- setting variance to NAN\n");
     232        gain = NAN;
    214233    }
    215234    float readnoise = psMetadataLookupF32(&mdok, cell->concepts, "CELL.READNOISE"); // Cell read noise
    216235    if (!mdok || isnan(readnoise)) {
    217         psError(PS_ERR_IO, true, "CELL.READNOISE is not set --- unable to set variance.\n");
    218         return false;
    219     }
    220     if (psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) {
     236        // psError(PS_ERR_IO, true, "CELL.READNOISE is not set --- unable to set variance.\n");
     237        // return false;
     238        psWarning("CELL.READNOISE is not set --- setting variance to NAN\n");
     239        readnoise = NAN;
     240    }
     241    // if we have a non-NAN readnoise, then we need to ensure it has been updated (not necessary if NAN)
     242    if (!isnan(gain) && psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) {
    221243        psError(PS_ERR_IO, true, "CELL.READNOISE has not yet been updated for the gain");
    222244        return false;
     245    }
     246
     247    // for invalid input data, set the readout variance to NAN
     248    if (isnan(gain) || isnan(readnoise)) {
     249        if (!readout->variance) {
     250            // generate the image if needed
     251            readout->variance = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_F32);
     252        }
     253        // XXX need to set the mask, if defined
     254        psImageInit(readout->variance, NAN);
     255        return true;
    223256    }
    224257
Note: See TracChangeset for help on using the changeset viewer.