IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 4:08:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging trunk (r25026) to get up-to-date on old branch.

Location:
branches/pap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/psModules

    • Property svn:mergeinfo deleted
  • branches/pap/psModules/src/camera/pmFPARead.c

    r23827 r25027  
    6464
    6565// Set the "thisXXXScan" value in the readout for the appropriate image type
    66 static int readoutSetThisScan(pmReadout *readout, // Readout of interest
     66static void readoutSetThisScan(pmReadout *readout, // Readout of interest
    6767                              fpaReadType type, // Type of image
    6868                              int thisScan // Starting scan number
     
    7272      case FPA_READ_TYPE_IMAGE:
    7373        readout->thisImageScan = thisScan;
    74         return readout->lastImageScan;
     74        return;
    7575      case FPA_READ_TYPE_MASK:
    7676        readout->thisMaskScan = thisScan;
    77         return readout->lastMaskScan;
     77        return;
    7878      case FPA_READ_TYPE_VARIANCE:
    7979        readout->thisVarianceScan = thisScan;
    80         return readout->lastVarianceScan;
     80        return;
    8181      default:
    8282        psAbort("Unknown read type: %x\n", type);
    8383    }
    84     return false;
    8584}
    8685
     
    103102
    104103// Set the "lastXXXScan" value in the readout for the appropriate image type
    105 static int readoutSetLastScan(pmReadout *readout, // Readout of interest
     104static void readoutSetLastScan(pmReadout *readout, // Readout of interest
    106105                              fpaReadType type, // Type of image
    107106                              int lastScan // Last scan number
     
    111110      case FPA_READ_TYPE_IMAGE:
    112111        readout->lastImageScan = lastScan;
    113         return readout->lastImageScan;
     112        return;
    114113      case FPA_READ_TYPE_MASK:
    115114        readout->lastMaskScan = lastScan;
    116         return readout->lastMaskScan;
     115        return;
    117116      case FPA_READ_TYPE_VARIANCE:
    118117        readout->lastVarianceScan = lastScan;
    119         return readout->lastVarianceScan;
     118        return;
    120119      default:
    121120        psAbort("Unknown read type: %x\n", type);
    122121    }
    123     return false;
    124122}
    125123
     
    143141// Determine number of readouts in the FITS file
    144142// In the process, reads the header and concepts
    145 static bool cellNumReadouts(pmCell *cell,    // Cell of interest
     143static int cellNumReadouts(pmCell *cell,    // Cell of interest
    146144                            psFits *fits,    // FITS file
    147145                            pmConfig *config // Configuration
     
    155153    if (!hdu || hdu->blankPHU) {
    156154        psError(PS_ERR_IO, true, "Unable to find HDU");
    157         return false;
     155        return 0;
    158156    }
    159157    if (!pmCellReadHeader(cell, fits, config)) {
    160158        psError(PS_ERR_IO, false, "Unable to read header for cell!\n");
    161         return false;
     159        return 0;
    162160    }
    163161    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS, true, NULL)) {
    164162        psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n");
    165         return false;
     163        return 0;
    166164    }
    167165
     
    171169    if (!mdok) {
    172170        psError(PS_ERR_IO, true, "Unable to find NAXIS in header for extension %s\n", hdu->extname);
    173         return false;
    174     }
     171        return 0;
     172    }
     173
    175174    if (naxis == 0) {
    176175        // No pixels to read
    177176        psError(PS_ERR_IO, true, "No pixels in extension %s.", hdu->extname);
    178         return false;
     177        return 0;
    179178    }
    180179    if (naxis < 2 || naxis > 3) {
    181180        psError(PS_ERR_IO, true, "NAXIS in header of extension %s (= %d) is not valid.\n",
    182181                hdu->extname, naxis);
    183         return false;
     182        return 0;
    184183    }
    185184    int naxis3;                     // Number of image planes
     
    188187        if (!mdok) {
    189188            psError(PS_ERR_IO, true, "Unable to find NAXIS3 in header for extension %s\n", hdu->extname);
    190             return false;
     189            return 0;
    191190        }
    192191    } else {
     
    296295static bool readoutMore(pmReadout *readout, // Readout of interest
    297296                        psFits *fits,    // FITS file
    298                         int z,          // Plane number
     297                        int z,          // Plane number to read
     298                        int *zMax,      // Max plane number in this cell
    299299                        int numScans,   // Number of scans to read at a time
    300300                        fpaReadType type, // Type of image
     
    310310    // N readouts, but numScans set to 0.  only the first should report that it requires data,
    311311    // even if all readouts lack the image pointer.
    312     if (!image) {
     312    if (numScans == 0) {
     313      if (!image) {
    313314        return true;
    314     }
    315 
    316     // If we have already read an image, this result implies we are done (no more to read)
    317     if (numScans == 0) {
    318         return false;
     315      } else {
     316        return false;
     317      }
    319318    }
    320319
     
    324323        return false;
    325324    }
    326     int naxis3 = cellNumReadouts(cell, fits, config); // Number of planes
    327     if (z >= naxis3) {
     325    *zMax = cellNumReadouts(cell, fits, config); // Number of planes
     326    if (z >= *zMax) {
    328327        // No more to read
    329328        return false;
     
    486485                             psFits *fits, // FITS file
    487486                             int z,     // Desired image plane
     487                             int *zMax, // Max plane number in this cell
    488488                             int numScans, // Number of scans (row or col depends on CELL.READDIR); 0 for all
    489489                             int overlap, // Number of scans (row/col) to overlap between scans
     
    511511
    512512    int naxis3 = cellNumReadouts(cell, fits, config); // Number of image planes
     513    if (zMax) *zMax = naxis3;
     514
    513515    if (z >= naxis3) {
    514516        psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).",
     
    592594    }
    593595
    594     // Determine the number of scans to read
    595     int lastScan = readoutSetLastScan(readout, type, thisScan + numScans);
     596    int origThisScan = thisScan;        // Original value of thisScan (starting point for read)
    596597    if (thisScan == 0) {
    597598        overlap = 0;
     
    601602        thisScan = 0;
    602603    }
    603     readoutSetThisScan(readout, type, thisScan);
    604604
    605605    // Calculate limits, adjust readout->row0,col0
     
    620620        }
    621621    }
     622    int lastScan = origThisScan + numScans; // Last scan to read
     623
     624    readoutSetThisScan(readout, type, thisScan);
     625    readoutSetLastScan(readout, type, lastScan);
    622626
    623627    // Blow away existing data.
     
    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.