Changeset 6896 for trunk/psModules/src/astrom/pmFPARead.c
- Timestamp:
- Apr 18, 2006, 5:24:09 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmFPARead.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmFPARead.c
r6894 r6896 34 34 return NULL; 35 35 } 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 ); 38 41 if (readout->image) { 39 42 psFree(readout->image); // Make way! … … 57 60 return NULL; 58 61 } 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 ); 61 67 psImage *overscan = psMemIncrRefCounter(psImageSubset(image, region)); 62 68 psListAdd(readout->bias, PS_LIST_TAIL, overscan); … … 76 82 psFits *fits, // FITS file from which to read 77 83 int z, // Readout number/plane; zero-offset indexing 78 int num Rows // The number of rows to read84 int numScans // The number of scans to read 79 85 ) 80 86 { … … 96 102 // Get the trim and bias sections 97 103 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 99 105 if (!mdok || !trimsec || psRegionIsBad(*trimsec)) { 100 106 psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set.\n"); 101 107 return false; 102 108 } 103 psList *biassecs = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.BIASSEC"); 109 psList *biassecs = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.BIASSEC"); // Bias sections 104 110 if (!mdok || !biassecs) { 105 111 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"); 106 117 return false; 107 118 } … … 150 161 int offset = readout->row0; // The row number to read 151 162 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)) { 155 172 // We've read everything there is 156 173 return false; 157 174 } 158 int upper = offset + num Rows;// The upper limit for the pixel read159 if ( upper > naxis2) {175 int upper = offset + numScans; // The upper limit for the pixel read 176 if (readdir > 0 && upper > naxis2) { 160 177 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 } 163 187 psImage *image = psFitsReadImage(fits, region, z); // The image 164 188 … … 177 201 hdu->images->data[z] = image; 178 202 readout->row0 = region.y0; 203 readout->col0 = region.x0; 179 204 readoutCarve(readout, image, trimsec, biassecs); 180 205
Note:
See TracChangeset
for help on using the changeset viewer.
