IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24792


Ignore:
Timestamp:
Jul 14, 2009, 6:38:05 PM (17 years ago)
Author:
eugene
Message:

return max number of planes

File:
1 edited

Legend:

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

    r24058 r24792  
    141141// Determine number of readouts in the FITS file
    142142// In the process, reads the header and concepts
    143 static bool cellNumReadouts(pmCell *cell,    // Cell of interest
     143static int cellNumReadouts(pmCell *cell,    // Cell of interest
    144144                            psFits *fits,    // FITS file
    145145                            pmConfig *config // Configuration
     
    153153    if (!hdu || hdu->blankPHU) {
    154154        psError(PS_ERR_IO, true, "Unable to find HDU");
    155         return false;
     155        return 0;
    156156    }
    157157    if (!pmCellReadHeader(cell, fits, config)) {
    158158        psError(PS_ERR_IO, false, "Unable to read header for cell!\n");
    159         return false;
     159        return 0;
    160160    }
    161161    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS, true, NULL)) {
    162162        psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n");
    163         return false;
     163        return 0;
    164164    }
    165165
     
    169169    if (!mdok) {
    170170        psError(PS_ERR_IO, true, "Unable to find NAXIS in header for extension %s\n", hdu->extname);
    171         return false;
    172     }
     171        return 0;
     172    }
     173
    173174    if (naxis == 0) {
    174175        // No pixels to read
    175176        psError(PS_ERR_IO, true, "No pixels in extension %s.", hdu->extname);
    176         return false;
     177        return 0;
    177178    }
    178179    if (naxis < 2 || naxis > 3) {
    179180        psError(PS_ERR_IO, true, "NAXIS in header of extension %s (= %d) is not valid.\n",
    180181                hdu->extname, naxis);
    181         return false;
     182        return 0;
    182183    }
    183184    int naxis3;                     // Number of image planes
     
    186187        if (!mdok) {
    187188            psError(PS_ERR_IO, true, "Unable to find NAXIS3 in header for extension %s\n", hdu->extname);
    188             return false;
     189            return 0;
    189190        }
    190191    } else {
     
    294295static bool readoutMore(pmReadout *readout, // Readout of interest
    295296                        psFits *fits,    // FITS file
    296                         int z,          // Plane number
     297                        int z,          // Plane number to read
     298                        int *zMax,      // Max plane number in this cell
    297299                        int numScans,   // Number of scans to read at a time
    298300                        fpaReadType type, // Type of image
     
    308310    // N readouts, but numScans set to 0.  only the first should report that it requires data,
    309311    // even if all readouts lack the image pointer.
    310     if (!image) {
     312    if (numScans == 0) {
     313      if (!image) {
    311314        return true;
    312     }
    313 
    314     // If we have already read an image, this result implies we are done (no more to read)
    315     if (numScans == 0) {
    316         return false;
     315      } else {
     316        return false;
     317      }
    317318    }
    318319
     
    322323        return false;
    323324    }
    324     int naxis3 = cellNumReadouts(cell, fits, config); // Number of planes
    325     if (z >= naxis3) {
     325    *zMax = cellNumReadouts(cell, fits, config); // Number of planes
     326    if (z >= *zMax) {
    326327        // No more to read
    327328        return false;
     
    484485                             psFits *fits, // FITS file
    485486                             int z,     // Desired image plane
     487                             int *zMax, // Max plane number in this cell
    486488                             int numScans, // Number of scans (row or col depends on CELL.READDIR); 0 for all
    487489                             int overlap, // Number of scans (row/col) to overlap between scans
     
    509511
    510512    int naxis3 = cellNumReadouts(cell, fits, config); // Number of image planes
     513    if (zMax) *zMax = naxis3;
     514
    511515    if (z >= naxis3) {
    512516        psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).",
     
    10211025
    10221026
    1023 bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
     1027bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, pmConfig *config)
    10241028{
    10251029    PS_ASSERT_PTR_NON_NULL(readout, false);
    10261030    PS_ASSERT_FITS_NON_NULL(fits, false);
    10271031
    1028     return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE, config);
    1029 }
    1030 
    1031 bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, pmConfig *config)
     1032    return readoutMore(readout, fits, z, zMax, numScans, FPA_READ_TYPE_IMAGE, config);
     1033}
     1034
     1035bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, int overlap, pmConfig *config)
    10321036{
    10331037    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    10361040    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
    10371041
    1038     return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_IMAGE, config);
     1042    return readoutReadChunk(readout, fits, z, zMax, numScans, overlap, FPA_READ_TYPE_IMAGE, config);
    10391043}
    10401044
     
    10441048    PS_ASSERT_FITS_NON_NULL(fits, false);
    10451049
    1046     return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_IMAGE, config);
     1050    return readoutReadChunk(readout, fits, z, NULL, 0, 0, FPA_READ_TYPE_IMAGE, config);
    10471051}
    10481052
     
    10841088//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    10851089
    1086 bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
     1090bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, pmConfig *config)
    10871091{
    10881092    PS_ASSERT_PTR_NON_NULL(readout, false);
    10891093    PS_ASSERT_FITS_NON_NULL(fits, false);
    10901094
    1091     return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_MASK, config);
    1092 }
    1093 
    1094 bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,
     1095    return readoutMore(readout, fits, z, zMax, numScans, FPA_READ_TYPE_MASK, config);
     1096}
     1097
     1098bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, int overlap,
    10951099                            pmConfig *config)
    10961100{
     
    11001104    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
    11011105
    1102     return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_MASK, config);
     1106    return readoutReadChunk(readout, fits, z, zMax, numScans, overlap, FPA_READ_TYPE_MASK, config);
    11031107}
    11041108
     
    11081112    PS_ASSERT_FITS_NON_NULL(fits, false);
    11091113
    1110     return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_MASK, config);
     1114    return readoutReadChunk(readout, fits, z, NULL, 0, 0, FPA_READ_TYPE_MASK, config);
    11111115}
    11121116
     
    11391143//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    11401144
    1141 bool pmReadoutMoreVariance(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
     1145bool pmReadoutMoreVariance(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, pmConfig *config)
    11421146{
    11431147    PS_ASSERT_PTR_NON_NULL(readout, false);
    11441148    PS_ASSERT_FITS_NON_NULL(fits, false);
    11451149
    1146     return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_VARIANCE, config);
    1147 }
    1148 
    1149 bool pmReadoutReadChunkVariance(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,
     1150    return readoutMore(readout, fits, z, zMax, numScans, FPA_READ_TYPE_VARIANCE, config);
     1151}
     1152
     1153bool pmReadoutReadChunkVariance(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, int overlap,
    11501154                              pmConfig *config)
    11511155{
     
    11551159    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
    11561160
    1157     return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_VARIANCE, config);
     1161    return readoutReadChunk(readout, fits, z, zMax, numScans, overlap, FPA_READ_TYPE_VARIANCE, config);
    11581162}
    11591163
     
    11631167    PS_ASSERT_FITS_NON_NULL(fits, false);
    11641168
    1165     return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_VARIANCE, config);
     1169    return readoutReadChunk(readout, fits, z, NULL, 0, 0, FPA_READ_TYPE_VARIANCE, config);
    11661170}
    11671171
Note: See TracChangeset for help on using the changeset viewer.