IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2006, 5:24:09 PM (20 years ago)
Author:
Paul Price
Message:

Adding pmReadoutWriteNext, which is to be used in concert with pmReadoutReadNext. Updated pmFPAWrite, pmChipWrite, pmCellWrite to optionally not write the pixels (i.e., PHU only), so that an output file should always have a PHU. This necessitated some small changes to the way the 'concepts' are written, in the case that they don't exist.

File:
1 edited

Legend:

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

    r6894 r6896  
    3434        return NULL;
    3535    }
    36     psRegion region = psRegionSet(trimsec->x0, trimsec->x1, MAX(trimsec->y0 - readout->row0, 0),
    37                                   MIN(trimsec->y1 - readout->row0, image->numRows));
     36    psRegion region = psRegionSet(MAX(trimsec->x0 - readout->col0, 0), // x0
     37                                  MIN(trimsec->x1 - readout->col0, image->numCols), // x1
     38                                  MAX(trimsec->y0 - readout->row0, 0), // y0
     39                                  MIN(trimsec->y1 - readout->row0, image->numRows) // y1
     40                                 );
    3841    if (readout->image) {
    3942        psFree(readout->image);         // Make way!
     
    5760            return NULL;
    5861        }
    59         psRegion region = psRegionSet(biassec->x0, biassec->x1, MAX(biassec->y0 - readout->row0, 0),
    60                                       MIN(biassec->y1 - readout->row0, image->numRows));
     62        psRegion region = psRegionSet(MAX(biassec->x0 - readout->col0, 0), // x0
     63                                      MIN(biassec->x1 - readout->col0, image->numCols), // x1
     64                                      MAX(biassec->y0 - readout->row0, 0), // y0
     65                                      MIN(biassec->y1 - readout->row0, image->numRows) // y1
     66                                     );
    6167        psImage *overscan = psMemIncrRefCounter(psImageSubset(image, region));
    6268        psListAdd(readout->bias, PS_LIST_TAIL, overscan);
     
    7682                       psFits *fits,    // FITS file from which to read
    7783                       int z,           // Readout number/plane; zero-offset indexing
    78                        int numRows      // The number of rows to read
     84                       int numScans     // The number of scans to read
    7985                      )
    8086{
     
    96102    // Get the trim and bias sections
    97103    bool mdok = true;                   // Status of MD lookup
    98     psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC");
     104    psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim sections
    99105    if (!mdok || !trimsec || psRegionIsBad(*trimsec)) {
    100106        psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set.\n");
    101107        return false;
    102108    }
    103     psList *biassecs = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.BIASSEC");
     109    psList *biassecs = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.BIASSEC"); // Bias sections
    104110    if (!mdok || !biassecs) {
    105111        psError(PS_ERR_IO, true, "CELL.BIASSEC is not set.\n");
     112        return false;
     113    }
     114    int readdir = psMetadataLookupS32(&mdok, cell->concepts, "CELL.READDIR"); // Read direction
     115    if (!mdok || readdir == 0 || (readdir != -1 && readdir != 1)) {
     116        psError(PS_ERR_IO, true, "CELL.READDIR is not set to -1 or +1.\n");
    106117        return false;
    107118    }
     
    150161    int offset = readout->row0;         // The row number to read
    151162    if (readout->image) {
    152         offset += readout->image->numRows;
    153     }
    154     if (offset >= naxis2) {
     163        if (readdir > 0) {
     164            // Reading rows
     165            offset += readout->image->numRows;
     166        } else {
     167            // Reading columns
     168            offset += readout->image->numCols;
     169        }
     170    }
     171    if ((readdir > 0 && offset >= naxis2) || (readdir < 0 && offset > naxis1)) {
    155172        // We've read everything there is
    156173        return false;
    157174    }
    158     int upper = offset + numRows;       // The upper limit for the pixel read
    159     if (upper > naxis2) {
     175    int upper = offset + numScans;      // The upper limit for the pixel read
     176    if (readdir > 0 && upper > naxis2) {
    160177        upper = naxis2;
    161     }
    162     psRegion region = psRegionSet(0, naxis1, offset, upper); // Region to be read
     178    } else if (readdir < 0 && upper > naxis1) {
     179        upper = naxis1;
     180    }
     181    psRegion region = {0, 0, 0, 0};     // Region to be read
     182    if (readdir > 0) {
     183        region = psRegionSet(0, naxis1, offset, upper); // Read rows
     184    } else {
     185        region = psRegionSet(offset, upper, 0, naxis2); // Read columns
     186    }
    163187    psImage *image = psFitsReadImage(fits, region, z); // The image
    164188
     
    177201    hdu->images->data[z] = image;
    178202    readout->row0 = region.y0;
     203    readout->col0 = region.x0;
    179204    readoutCarve(readout, image, trimsec, biassecs);
    180205
Note: See TracChangeset for help on using the changeset viewer.