IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21272


Ignore:
Timestamp:
Feb 2, 2009, 3:32:32 PM (17 years ago)
Author:
Paul Price
Message:

Determine if the variance file contains covariances before we try to read them.
Need to explicitly read the headers because the pmHDU.header may not refer to the mask or variance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090128/psModules/src/camera/pmFPARead.c

    r21269 r21272  
    195195
    196196    return naxis3;
     197}
     198
     199// Determine whether a FITS file contains covariance matrices
     200static bool hduCovariance(pmHDU *hdu,   // Header data unit
     201                          psFits *fits  // FITS file
     202    )
     203{
     204    if (!psFitsMoveExtName(fits, hdu->extname)) {
     205        psError(PS_ERR_IO, false, "Unable to move to extension %s", hdu->extname);
     206        return false;
     207    }
     208    // Need to explicitly read the header, since the HDU may not contain the variance header
     209    psMetadata *header = psFitsReadHeader(NULL, fits); // Header
     210    if (!header) {
     211        psError(PS_ERR_IO, false, "Unable to read variance header.");
     212        return false;
     213    }
     214    bool mdok;                          // Status of MD lookup
     215    bool covar = psMetadataLookupBool(&mdok, header, PM_HDU_COVARIANCE_KEYWORD); // Got covariance?
     216    psFree(header);
     217    return covar;
    197218}
    198219
     
    521542    switch (type) {
    522543      case FPA_READ_TYPE_MASK: {
    523           pmHDU *phu = pmHDUGetHighest(cell->parent->parent, cell->parent, cell); // Primary header
    524           if (!pmConfigMaskReadHeader(config, phu->header)) {
    525               psError(PS_ERR_IO, false, "Unable to determine mask bits");
     544          // Need to explicitly read the header, since what's in the pmHDU may not correspond to the mask
     545          psMetadata *header = psFitsReadHeader(NULL, fits);
     546          if (!header) {
     547              psError(PS_ERR_IO, false, "Unable to read mask header.");
    526548              return false;
    527549          }
     550          if (!pmConfigMaskReadHeader(config, header)) {
     551              psError(PS_ERR_IO, false, "Unable to determine mask bits");
     552              psFree(header);
     553              return false;
     554          }
     555          psFree(header);
    528556          bad = pmConfigMaskGet("BAD", config);
    529557          break;
     
    11421170        return false;
    11431171    }
    1144     return pmCellReadCovariance(cell, fits);
     1172    pmHDU *hdu = pmHDUFromCell(cell);   // Header data unit
     1173    if (hduCovariance(hdu, fits)) {
     1174        return pmCellReadCovariance(cell, fits);
     1175    }
     1176    return true;
    11451177}
    11461178
     
    11531185        return false;
    11541186    }
    1155     return pmChipReadCovariance(chip, fits);
     1187    pmHDU *hdu = pmHDUFromChip(chip);   // Header data unit
     1188    if (hduCovariance(hdu, fits)) {
     1189        return pmChipReadCovariance(chip, fits);
     1190    }
     1191    return true;
    11561192}
    11571193
     
    11641200        return false;
    11651201    }
    1166     return pmFPAReadCovariance(fpa, fits);
     1202    pmHDU *hdu = pmHDUFromFPA(fpa);     // Header data unit
     1203    if (hduCovariance(hdu, fits)) {
     1204        return pmFPAReadCovariance(fpa, fits);
     1205    }
     1206    return true;
    11671207}
    11681208
Note: See TracChangeset for help on using the changeset viewer.