IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 18, 2006, 1:43:28 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to FPA reading/writing functions to support mask and weight map reading/writing. Actually, not so much changes as generalisations to the reading/writing functions. Moved the reading/writing functionality into file-static functions, which the higher level functions for reading/writing particular elements (image, mask, weight) call. Added additional pmFPAfile types for mask and weight, with supporting functionality to call the reading/writing functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmHDU.c

    r9983 r10081  
    8585    if (!hdu->header) {
    8686        psTrace("psModules.camera", 5, "Reading the header...\n");
    87         hdu->header = psFitsReadHeader(NULL, fits);
     87        hdu->header = psFitsReadHeader(hdu->header, fits);
    8888        if (! hdu->header) {
    8989            psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname);
     
    9595}
    9696
     97// Read an HDU from a FITS file
    9798// XXX: Add a region specifier?
    98 bool pmHDURead(pmHDU *hdu, psFits *fits)
    99 {
    100     PS_ASSERT_PTR_NON_NULL(hdu, false);
    101     PS_ASSERT_PTR_NON_NULL(fits, false);
     99bool hduRead(pmHDU *hdu,                // HDU to write
     100             psArray **images,          // Images into which to read
     101             psFits *fits               // FITS file to read
     102            )
     103{
     104    assert(hdu);
     105    assert(images);
     106    assert(fits);
    102107
    103108    // Read the header; includes the move
     
    111116    }
    112117
    113     if (hdu->images) {
     118    if (*images) {
    114119        psLogMsg(__func__, PS_LOG_WARN, "HDU %s has already been read --- overwriting.\n", hdu->extname);
    115         psFree(hdu->images);        // Blow away anything existing
     120        psFree(*images);                // Blow away anything existing
    116121    }
    117122    psTrace("psModules.camera", 5, "Reading the pixels...\n");
    118     hdu->images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0));
    119     if (! hdu->images) {
     123    *images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0));
     124    if (!*images) {
    120125        psError(PS_ERR_IO, false, "Unable to read pixels for extension %s\n", hdu->extname);
    121126        return false;
     
    124129}
    125130
     131bool pmHDURead(pmHDU *hdu, psFits *fits)
     132{
     133    PS_ASSERT_PTR_NON_NULL(hdu, false);
     134    PS_ASSERT_PTR_NON_NULL(fits, false);
     135
     136    return hduRead(hdu, &hdu->images, fits);
     137}
     138
     139bool pmHDUReadMask(pmHDU *hdu, psFits *fits)
     140{
     141    PS_ASSERT_PTR_NON_NULL(hdu, false);
     142    PS_ASSERT_PTR_NON_NULL(fits, false);
     143
     144    return hduRead(hdu, &hdu->masks, fits);
     145}
     146
     147bool pmHDUReadWeight(pmHDU *hdu, psFits *fits)
     148{
     149    PS_ASSERT_PTR_NON_NULL(hdu, false);
     150    PS_ASSERT_PTR_NON_NULL(fits, false);
     151
     152    return hduRead(hdu, &hdu->weights, fits);
     153}
     154
    126155// Write an HDU to a FITS file
    127 bool hduWrite(pmHDU *hdu,               // HDU to write
    128               psArray *images,          // Images to write
    129               psFits *fits              // FITS file to which to write
    130              )
     156static bool hduWrite(pmHDU *hdu,        // HDU to write
     157                     psArray *images,   // Images to write
     158                     psFits *fits       // FITS file to which to write
     159                    )
    131160{
    132161    assert(hdu);
     
    182211}
    183212
     213bool pmHDUWriteWeight(pmHDU *hdu, psFits *fits)
     214{
     215    PS_ASSERT_PTR_NON_NULL(hdu, false);
     216    PS_ASSERT_PTR_NON_NULL(fits, false);
     217
     218    return hduWrite(hdu, hdu->weights, fits);
     219}
Note: See TracChangeset for help on using the changeset viewer.