Changeset 25875
- Timestamp:
- Oct 18, 2009, 10:42:16 AM (17 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 3 edited
-
ppImage.h (modified) (1 diff)
-
ppImageLoop.c (modified) (3 diffs)
-
ppImageParityFlip.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImage.h
r25299 r25875 131 131 132 132 // apply the cell flips to the input data before analysis 133 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view );133 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view, bool native); 134 134 135 135 // Loop over the input -
trunk/ppImage/src/ppImageLoop.c
r25847 r25875 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 } 105 106 // XXX TEST:107 // psphotSaveImage (NULL, readout->image, "test.image.fits");108 105 109 106 // XXX set the options->*Mask values here (after the mask images have been loaded … … 132 129 ppImageDetrendRecord(cell, config, options, view); 133 130 } 131 132 // process each of the readouts 133 // XXX reset the view to the first readout? 134 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 135 if (!readout->data_exists) { 136 continue; 137 } 138 // flip the image to match the raw readout orientation 139 if (!ppImageParityFlip(config, options, view, false)) { 140 ESCAPE("Unable to detrend readout"); 141 } 142 } 143 134 144 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 135 145 if (!ppImageDetrendFree (config, view)) { … … 161 171 } 162 172 timeDetrend += psTimerClear(TIMER_DETREND); 163 164 173 165 174 // we perform photometry on the readouts of this chip in the output -
trunk/ppImage/src/ppImageParityFlip.c
r24228 r25875 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.
