Changeset 6894
- Timestamp:
- Apr 18, 2006, 2:54:19 PM (20 years ago)
- Location:
- trunk/psModules/src/astrom
- Files:
-
- 2 edited
-
pmFPAConstruct.c (modified) (1 diff)
-
pmFPARead.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmFPAConstruct.c
r6888 r6894 755 755 for (int k = 0; k < readouts->n; k++) { 756 756 pmReadout *readout = readouts->data[k]; // The readout 757 psTrace(__func__, 8, "row0: %d\n", readout->row0); 757 758 psImage *image = readout->image; // The image 758 759 psList *bias = readout->bias; // The list of bias images -
trunk/psModules/src/astrom/pmFPARead.c
r6889 r6894 12 12 #include "pmHDUUtils.h" 13 13 14 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 15 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 16 14 17 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 15 18 // File-static functions … … 17 20 18 21 // Carve a readout from the image pixels 19 static pmReadout *readoutCarve(pmCell *cell, // Cell into which the new readout will be placed 20 psImage *image, // Image that will be carved 21 const psRegion *trimsec, // Trim section 22 const psList *biassecs // Bias sections 23 ) 24 { 25 pmReadout *readout = pmReadoutAlloc(cell); 26 22 static bool readoutCarve(pmReadout *readout, // Readout to be carved up 23 psImage *image, // Image that will be carved 24 const psRegion *trimsec, // Trim section 25 const psList *biassecs // Bias sections 26 ) 27 { 27 28 // The image corresponding to the trim region 28 29 if (psRegionIsBad(*trimsec)) { … … 33 34 return NULL; 34 35 } 35 readout->image = psMemIncrRefCounter(psImageSubset(image, *trimsec)); 36 psRegion region = psRegionSet(trimsec->x0, trimsec->x1, MAX(trimsec->y0 - readout->row0, 0), 37 MIN(trimsec->y1 - readout->row0, image->numRows)); 38 if (readout->image) { 39 psFree(readout->image); // Make way! 40 } 41 readout->image = psMemIncrRefCounter(psImageSubset(image, region)); 36 42 37 43 // Get the list of overscans 44 if (readout->bias->n != 0) { 45 // Make way! 46 psFree(readout->bias); 47 readout->bias = psListAlloc(NULL); 48 } 38 49 psListIterator *iter = psListIteratorAlloc((psList*)biassecs, PS_LIST_HEAD, false); // Iterator 39 50 psRegion *biassec = NULL; // A BIASSEC region from the list … … 46 57 return NULL; 47 58 } 48 psImage *overscan = psMemIncrRefCounter(psImageSubset(image, *biassec)); 59 psRegion region = psRegionSet(biassec->x0, biassec->x1, MAX(biassec->y0 - readout->row0, 0), 60 MIN(biassec->y1 - readout->row0, image->numRows)); 61 psImage *overscan = psMemIncrRefCounter(psImageSubset(image, region)); 49 62 psListAdd(readout->bias, PS_LIST_TAIL, overscan); 50 63 psFree(overscan); … … 73 86 } 74 87 75 if (!pmHDUReadHeader(hdu, fits)) { 76 psError(PS_ERR_IO, false, "Unable to read HDU header!\n"); 88 if (!hdu->header) { 89 if (!pmHDUReadHeader(hdu, fits)) { 90 psError(PS_ERR_IO, false, "Unable to read HDU header!\n"); 91 return false; 92 } 93 pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, false, NULL); 94 } 95 96 // Get the trim and bias sections 97 bool mdok = true; // Status of MD lookup 98 psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); 99 if (!mdok || !trimsec || psRegionIsBad(*trimsec)) { 100 psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set.\n"); 101 return false; 102 } 103 psList *biassecs = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.BIASSEC"); 104 if (!mdok || !biassecs) { 105 psError(PS_ERR_IO, true, "CELL.BIASSEC is not set.\n"); 77 106 return false; 78 107 } 79 108 80 109 // Check the third dimension 81 bool mdok = true; // Status of MD lookup82 110 int naxis = psMetadataLookupS32(&mdok, hdu->header, "NAXIS"); // The number of axes 83 111 if (!mdok) { … … 134 162 psRegion region = psRegionSet(0, naxis1, offset, upper); // Region to be read 135 163 psImage *image = psFitsReadImage(fits, region, z); // The image 136 if (readout->image) {137 psFree(readout->image);138 }139 164 140 165 // Stick the image into the HDU and the readout … … 151 176 } 152 177 hdu->images->data[z] = image; 153 readout->image = psImageSubset(hdu->images->data[z], psRegionSet(0,0,0,0));154 178 readout->row0 = region.y0; 179 readoutCarve(readout, image, trimsec, biassecs); 155 180 156 181 return true; … … 191 216 } 192 217 193 pmReadout *readout = readoutCarve(cell, image, trimsec, biassecs); 218 pmReadout *readout = pmReadoutAlloc(cell); 219 readoutCarve(readout, image, trimsec, biassecs); 194 220 readout->mask = NULL; 195 221 readout->weight = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
