Changeset 25160
- Timestamp:
- Aug 20, 2009, 2:42:05 PM (17 years ago)
- Location:
- branches/eam_branches/20090820/ppImage/src
- Files:
-
- 3 edited
-
ppImage.h (modified) (1 diff)
-
ppImageLoop.c (modified) (2 diffs)
-
ppImageParityFlip.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820/ppImage/src/ppImage.h
r24903 r25160 130 130 131 131 // apply the cell flips to the input data before analysis 132 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view );132 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view, bool native); 133 133 134 134 // Loop over the input -
branches/eam_branches/20090820/ppImage/src/ppImageLoop.c
r24229 r25160 99 99 } 100 100 101 // perform the detrend analysis102 if (!ppImageParityFlip(config, options, view )) {101 // flip the image to match the native detector orientation (to match bias, flat, etc) 102 if (!ppImageParityFlip(config, options, view, true)) { 103 103 ESCAPE("Unable to detrend readout"); 104 104 } … … 132 132 ppImageDetrendRecord(cell, config, options, view); 133 133 } 134 135 // process each of the readouts 136 // XXX reset the view to the first readout? 137 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 138 if (!readout->data_exists) { 139 continue; 140 } 141 // flip the image to match the raw readout orientation 142 if (!ppImageParityFlip(config, options, view, false)) { 143 ESCAPE("Unable to detrend readout"); 144 } 145 } 146 134 147 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 135 148 if (!ppImageDetrendFree (config, view)) { -
branches/eam_branches/20090820/ppImage/src/ppImageParityFlip.c
r24228 r25160 10 10 item->data.TYPE = VALUE; } 11 11 12 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view) { 12 // flip the image to have 'native' (detector) or 'raw' (readout) orientation 13 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view, bool native) { 13 14 14 15 bool status; 16 int xParity, yParity; 17 int xParityRaw, yParityRaw; 18 int xParityTarget, yParityTarget; 15 19 16 20 if (!options->applyParity) return true; … … 21 25 pmCell *cell = readout->parent; 22 26 23 int xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 24 if (!status || (xParity != -1 && xParity != 1)) { 25 psWarning("CELL.XPARITY is not set for the input cell; assuming 1.\n"); 26 FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, 1); 27 xParity = 1; 28 } 29 int yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 30 if (!status || (yParity != -1 && yParity != 1)) { 31 psWarning("CELL.YPARITY is not set for the input cell; assuming 1.\n"); 32 FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, 1); 33 yParity = 1; 27 if (native) { 28 // find the current (raw) parity 29 xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 30 if (!status || (xParity != -1 && xParity != 1)) { 31 psWarning("CELL.XPARITY is not set for the input cell; assuming 1.\n"); 32 FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, 1); 33 xParity = 1; 34 } 35 yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 36 if (!status || (yParity != -1 && yParity != 1)) { 37 psWarning("CELL.YPARITY is not set for the input cell; assuming 1.\n"); 38 FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, 1); 39 yParity = 1; 40 } 41 42 // save the raw parity 43 psMetadataAddS32 (cell->concepts, PS_LIST_TAIL, "CELL.XPARITY.RAW", PS_META_REPLACE, "original parity", xParity); 44 psMetadataAddS32 (cell->concepts, PS_LIST_TAIL, "CELL.YPARITY.RAW", PS_META_REPLACE, "original parity", yParity); 45 46 xParityTarget = 1; 47 yParityTarget = 1; 48 } else { 49 // find the current (native) parity 50 xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 51 psAssert (status, "CELL.XPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 52 53 yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 54 psAssert (status, "CELL.YPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 55 56 // find the raw parity 57 xParityRaw = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY.RAW"); 58 psAssert (status, "CELL.XPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 59 60 yParityRaw = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY.RAW"); 61 psAssert (status, "CELL.YPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 62 63 xParityTarget = xParityRaw; 64 yParityTarget = yParityRaw; 34 65 } 35 66 36 67 // for this case, nothing to be done: 37 if ((xParity == 1) && (yParity == 1)) return true;38 68 if ((xParity == xParityTarget) && (yParity == yParityTarget)) return true; 69 39 70 psImage *image = readout->image; 40 71 psImage *var = readout->variance; … … 55 86 56 87 // the three cases (+1,-1), (-1,+1), (-1,-1) should be handled independently 57 if ((xParity == -1) && (yParity == +1)) { 88 89 // flip only in x-direction 90 if ((xParity != xParityTarget) && (yParity == yParityTarget)) { 58 91 for (int iy = 0; iy < Ny; iy++) { 59 92 for (int ix = 0; ix < Nx; ix++) { … … 71 104 } 72 105 } 73 if ((xParity == +1) && (yParity == -1)) { 106 // flip only in y-direction 107 if ((xParity == xParityTarget) && (yParity != yParityTarget)) { 74 108 for (int iy = 0; iy < Ny/2; iy++) { 75 109 memcpy (imrow, image->data.F32[iy], Nx*sizeof(psF32)); … … 90 124 } 91 125 } 92 if ((xParity == -1) && (yParity == -1)) { 126 // flip in both directions 127 if ((xParity != xParityTarget) && (yParity == yParityTarget)) { 93 128 for (int iy = 0; iy < Ny/2; iy++) { 94 129 for (int ix = 0; ix < Nx; ix++) { … … 118 153 } 119 154 120 // FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, 1);121 // FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, 1);155 FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, xParityTarget); 156 FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, yParityTarget); 122 157 123 158 psFree (imrow);
Note:
See TracChangeset
for help on using the changeset viewer.
