Changeset 21183 for trunk/psModules/src/detrend
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 18 edited
-
pmBias.c (modified) (2 diffs)
-
pmDark.c (modified) (16 diffs)
-
pmDark.h (modified) (3 diffs)
-
pmFlatField.c (modified) (6 diffs)
-
pmFlatField.h (modified) (3 diffs)
-
pmFlatNormalize.c (modified) (12 diffs)
-
pmFringeStats.c (modified) (23 diffs)
-
pmFringeStats.h (modified) (3 diffs)
-
pmMaskBadPixels.c (modified) (8 diffs)
-
pmMaskBadPixels.h (modified) (4 diffs)
-
pmOverscan.c (modified) (2 diffs)
-
pmRemnance.c (modified) (5 diffs)
-
pmRemnance.h (modified) (1 diff)
-
pmShifts.c (modified) (1 diff)
-
pmShifts.h (modified) (1 diff)
-
pmShutterCorrection.c (modified) (19 diffs)
-
pmShutterCorrection.h (modified) (7 diffs)
-
pmSkySubtract.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmBias.c
r19432 r21183 45 45 inImage->data.F32[i][j] -= subImage->data.F32[i+yOffset][j+xOffset]; 46 46 if (inMask && subMask) { 47 inMask->data. U8[i][j] |= subMask->data.U8[i+yOffset][j+xOffset];47 inMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] |= subMask->data.PS_TYPE_IMAGE_MASK_DATA[i+yOffset][j+xOffset]; 48 48 } 49 49 } … … 54 54 inImage->data.F32[i][j] -= subImage->data.F32[i+yOffset][j+xOffset] * scale; 55 55 if (inMask && subMask) { 56 inMask->data. U8[i][j] |= subMask->data.U8[i+yOffset][j+xOffset];56 inMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] |= subMask->data.PS_TYPE_IMAGE_MASK_DATA[i+yOffset][j+xOffset]; 57 57 } 58 58 } -
trunk/psModules/src/detrend/pmDark.c
r19432 r21183 103 103 { 104 104 psArray *values = psArrayAlloc(inputs->n); 105 psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_ U8); // Mask for bad readouts105 psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for bad readouts 106 106 psVector *norm = normConcept ? psVectorAlloc(inputs->n, PS_TYPE_F32) : NULL; // Normalizations for each 107 107 psVector *orders = psVectorAlloc(ordinates->n, PS_TYPE_U8); // Orders for each concept … … 121 121 if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) { 122 122 psWarning("Unable to find value of %s for readout %d", normConcept, i); 123 roMask->data. U8[i] = 0xff;123 roMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 124 124 norm->data.F32[i] = NAN; 125 125 numBadInputs++; … … 128 128 if (normValue == 0.0) { 129 129 psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i); 130 roMask->data. U8[i] = 0xff;130 roMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 131 131 norm->data.F32[i] = NAN; 132 132 numBadInputs++; … … 151 151 for (int j = 0; j < inputs->n; j++) { 152 152 psVector *val = values->data[j]; // Value vector for readout 153 if (roMask->data. U8[j]) {153 if (roMask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 154 154 val->data.F32[i] = NAN; 155 155 continue; … … 159 159 float value = NAN; // Value of ordinate 160 160 if (!ordinateLookup(&value, &inRange, ord->name, ord->scale, ord->min, ord->max, readout)) { 161 roMask->data. U8[j] = 0xff;161 roMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; 162 162 val->data.F32[i] = NAN; 163 163 numBadInputs++; … … 165 165 } 166 166 if (!inRange) { 167 roMask->data. U8[j] = 0xff;167 roMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; 168 168 val->data.F32[i] = NAN; 169 169 numBadInputs++; … … 263 263 264 264 // do the combine work for this portion of the output (range is set by input data) 265 bool pmDarkCombine(pmCell *output, const psArray *inputs, int iter, float rej, ps MaskType maskVal)265 bool pmDarkCombine(pmCell *output, const psArray *inputs, int iter, float rej, psImageMaskType maskVal) 266 266 { 267 267 PS_ASSERT_PTR_NON_NULL(output, false); … … 314 314 // Iterate over pixels, fitting polynomial 315 315 psVector *pixels = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of pixels 316 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_ MASK); // Mask for stack316 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for stack 317 317 for (int i = minInputRows; i < maxInputRows; i++) { 318 318 int yOut = i - outReadout->row0; // y position on output readout … … 330 330 psVectorInit(mask, 0); 331 331 for (int r = 0; r < inputs->n; r++) { 332 if (roMask->data. U8[r]) {333 mask->data.PS_TYPE_ MASK_DATA[r] = 0xff;332 if (roMask->data.PS_TYPE_VECTOR_MASK_DATA[r]) { 333 mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = 0xff; 334 334 continue; 335 335 } … … 343 343 } 344 344 if (readout->mask) { 345 mask->data.PS_TYPE_ MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];345 mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal); 346 346 } 347 347 348 348 } 349 349 350 if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, maskVal, values, iter, rej)) {350 if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, 0xff, values, iter, rej)) { 351 351 psErrorClear(); // Nothing we can do about it 352 352 psVectorInit(poly->coeff, NAN); … … 376 376 const psVector *values = job->args->data[3]; // Values for each ordinate 377 377 378 ps MaskType bad = PS_SCALAR_VALUE(job->args->data[4], U8); // Mask value to give bad pixels378 psImageMaskType bad = PS_SCALAR_VALUE(job->args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Mask value to give bad pixels 379 379 bool doNorm = PS_SCALAR_VALUE(job->args->data[5], U8); // Normalise values? 380 380 float norm = PS_SCALAR_VALUE(job->args->data[6], F32); // Value by which to normalise … … 386 386 387 387 bool pmDarkApplyScan(pmReadout *readout, const pmCell *dark, const psVector *orders, const psVector *values, 388 ps MaskType bad, bool doNorm, float norm, int rowStart, int rowStop)388 psImageMaskType bad, bool doNorm, float norm, int rowStart, int rowStop) 389 389 { 390 390 int numCols = readout->image->numCols; … … 405 405 readout->image->data.F32[y][x] -= value; 406 406 if (readout->mask && !isfinite(value)) { 407 readout->mask->data.PS_TYPE_ MASK_DATA[y][x] = bad;407 readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = bad; 408 408 } 409 409 } … … 414 414 } 415 415 416 bool pmDarkApply(pmReadout *readout, pmCell *dark, ps MaskType bad)416 bool pmDarkApply(pmReadout *readout, pmCell *dark, psImageMaskType bad) 417 417 { 418 418 PS_ASSERT_PTR_NON_NULL(readout, false); … … 424 424 PS_ASSERT_IMAGE_NON_NULL(readout->mask, false); 425 425 PS_ASSERT_IMAGES_SIZE_EQUAL(readout->mask, readout->image, false); 426 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_ MASK, false);426 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false); 427 427 } 428 428 int numTerms = dark->readouts->n; // Number of polynomial terms … … 496 496 psArrayAdd(job->args, 1, orders); 497 497 psArrayAdd(job->args, 1, values); 498 PS_ARRAY_ADD_SCALAR(job->args, bad, PS_TYPE_ MASK);498 PS_ARRAY_ADD_SCALAR(job->args, bad, PS_TYPE_IMAGE_MASK); 499 499 PS_ARRAY_ADD_SCALAR(job->args, doNorm, PS_TYPE_U8); 500 500 PS_ARRAY_ADD_SCALAR(job->args, norm, PS_TYPE_F32); -
trunk/psModules/src/detrend/pmDark.h
r19432 r21183 37 37 int iter, // Number of rejection iterations 38 38 float rej, // Rejection threshold (standard deviations) 39 ps MaskType maskVal // Value to mask39 psImageMaskType maskVal // Value to mask 40 40 ); 41 41 … … 49 49 const psVector *orders, // Polynomial orders for each ordinate 50 50 const psVector *values, // Values for each ordinate 51 ps MaskType bad, // Value to give bad pixels51 psImageMaskType bad, // Value to give bad pixels 52 52 bool doNorm, // Normalise values? 53 53 float norm, // Value by which to normalise … … 58 58 bool pmDarkApply(pmReadout *readout, // Readout to which to apply dark 59 59 pmCell *dark, // Dark to apply 60 ps MaskType bad // Mask value to give bad pixels60 psImageMaskType bad // Mask value to give bad pixels 61 61 ); 62 62 -
trunk/psModules/src/detrend/pmFlatField.c
r19432 r21183 22 22 const psImage *flatMask = job->args->data[3]; // Flat-field mask 23 23 24 ps MaskType badFlat = PS_SCALAR_VALUE(job->args->data[4],U8);24 psImageMaskType badFlat = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 25 25 int xOffset = PS_SCALAR_VALUE(job->args->data[5],S32); 26 26 int yOffset = PS_SCALAR_VALUE(job->args->data[6],S32); … … 38 38 ps##TYPE flatValue = flatImage->data.TYPE[j + yOffset][i + xOffset]; \ 39 39 if (!isfinite(flatValue) || flatValue <= 0.0 || \ 40 (flatMask && flatMask->data. U8[j + yOffset][i + xOffset])) { \40 (flatMask && flatMask->data.PS_TYPE_IMAGE_MASK_DATA[j + yOffset][i + xOffset])) { \ 41 41 if (inMask) { \ 42 inMask->data.PS_TYPE_ MASK_DATA[j][i] |= badFlat; \42 inMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= badFlat; \ 43 43 } \ 44 44 inImage->data.TYPE[j][i] = SPECIAL; \ … … 51 51 52 52 bool pmFlatFieldScan(psImage *inImage, psImage *inMask, const psImage *flatImage, const psImage *flatMask, 53 ps MaskType badFlat, int xOffset, int yOffset, int rowStart, int rowStop)53 psImageMaskType badFlat, int xOffset, int yOffset, int rowStart, int rowStop) 54 54 { 55 55 switch (inImage->type.type) { … … 72 72 } 73 73 74 bool pmFlatField(pmReadout *in, const pmReadout *flat, ps MaskType badFlat)74 bool pmFlatField(pmReadout *in, const pmReadout *flat, psImageMaskType badFlat) 75 75 { 76 76 PS_ASSERT_PTR_NON_NULL(in, false); … … 81 81 PS_ASSERT_IMAGE_NON_EMPTY(flat->image, false); 82 82 if (in->mask) { 83 PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_ MASK, false);83 PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_IMAGE_MASK, false); 84 84 PS_ASSERT_IMAGES_SIZE_EQUAL(in->mask, in->image, false); 85 85 } 86 86 PS_ASSERT_IMAGE_TYPE(flat->image, in->image->type.type, false); 87 87 if (flat->mask) { 88 PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_ MASK, false);88 PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_IMAGE_MASK, false); 89 89 PS_ASSERT_IMAGES_SIZE_EQUAL(flat->mask, flat->image, false); 90 90 } … … 148 148 psArrayAdd(job->args, 1, flatImage); 149 149 psArrayAdd(job->args, 1, flatMask); 150 PS_ARRAY_ADD_SCALAR(job->args, badFlat, PS_TYPE_ U8);150 PS_ARRAY_ADD_SCALAR(job->args, badFlat, PS_TYPE_IMAGE_MASK); 151 151 PS_ARRAY_ADD_SCALAR(job->args, xOffset, PS_TYPE_S32); 152 152 PS_ARRAY_ADD_SCALAR(job->args, yOffset, PS_TYPE_S32); -
trunk/psModules/src/detrend/pmFlatField.h
r19432 r21183 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-09-09 04:10:14$7 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * Copyright 2004-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 25 25 bool pmFlatField(pmReadout *in, ///< Readout with input image 26 26 const pmReadout *flat, ///< Readout with flat image 27 ps MaskType badFlat ///< Mask value to give bad flat pixels27 psImageMaskType badFlat ///< Mask value to give bad flat pixels 28 28 ); 29 29 … … 38 38 const psImage *flatImage, ///< Flat-field image 39 39 const psImage *flatMask, ///< Flat-field mask 40 ps MaskType badFlag, ///< Mask value to give bad pixels40 psImageMaskType badFlag, ///< Mask value to give bad pixels 41 41 int xOffset, int yOffset, ///< Offset between input and flat-field 42 42 int rowStart, int rowStop ///< Scan range -
trunk/psModules/src/detrend/pmFlatNormalize.c
r9730 r21183 9 9 10 10 #include "pmFlatNormalize.h" 11 12 // XXX this function should take the abstract mask names and set bad values in a more precise way 11 13 12 14 // I'm not sure that many many iterations are required, but rather suspect that the system converges within a … … 55 57 // Take the logarithms 56 58 psImage *flux = psImageCopy(NULL, bgMatrix, PS_TYPE_F32); // Copy of the input flux levels matrix 57 psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_ U8); // Mask for bad measurements59 psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_IMAGE_MASK); // Mask for bad measurements 58 60 psImageInit(fluxMask, 0); 59 psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_ U8); // Mask for bad gains61 psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_VECTOR_MASK); // Mask for bad gains 60 62 psVectorInit(gainMask, 0); 61 psVector *expMask = psVectorAlloc(numExps, PS_TYPE_ U8); // Mask for bad exposures63 psVector *expMask = psVectorAlloc(numExps, PS_TYPE_VECTOR_MASK); // Mask for bad exposures 62 64 psVectorInit(expMask, 0); 63 65 for (int i = 0; i < numChips; i++) { … … 75 77 } else { 76 78 // Blank out this measurement 77 fluxMask->data. U8[j][i] = 1;79 fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] = 1; 78 80 flux->data.F32[j][i] = NAN; 79 81 } … … 90 92 int numFluxes = 0; // Number of fluxes 91 93 for (int i = 0; i < numExps; i++) { 92 if (expMask->data. U8[i]) {94 if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 93 95 psTrace("psModules.detrend", 7, "Flux for exposure %d is masked.\n", i); 94 96 continue; … … 98 100 int number = 0; // Number of chips contributing 99 101 for (int j = 0; j < numChips; j++) { 100 if (!gainMask->data. U8[j] && !fluxMask->data.U8[i][j]) {102 if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && !fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) { 101 103 sum += flux->data.F32[i][j] - chipGains->data.F32[j]; 102 104 number++; … … 106 108 expFluxes->data.F32[i] = sum / (float)number; 107 109 } else { 108 expMask->data. U8[i] = 1;110 expMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 109 111 expFluxes->data.F32[i] = NAN; 110 112 } … … 116 118 int numGains = 0; // Number of gains 117 119 for (int i = 0; i < numChips; i++) { 118 if (gainMask->data. U8[i]) {120 if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 119 121 continue; 120 122 } … … 122 124 int number = 0; // Numer of sources contributing 123 125 for (int j = 0; j < numExps; j++) { 124 if (!fluxMask->data. U8[j][i]) {126 if (!fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i]) { 125 127 sum += flux->data.F32[j][i] - expFluxes->data.F32[j]; 126 128 number++; … … 130 132 chipGains->data.F32[i] = sum / (float)number; 131 133 } else { 132 gainMask->data. U8[i] = 1;134 gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 133 135 chipGains->data.F32[i] = NAN; 134 136 } … … 144 146 diff = 0.0; 145 147 for (int i = 0; i < numChips; i++) { 146 if (gainMask->data. U8[i]) {148 if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 147 149 continue; 148 150 } … … 151 153 } 152 154 for (int i = 0; i < numExps; i++) { 153 if (expMask->data. U8[i]) {155 if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 154 156 continue; 155 157 } … … 171 173 // Un-log the vectors 172 174 for (int i = 0; i < numChips; i++) { 173 if (!gainMask->data. U8[i]) {175 if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 174 176 chipGains->data.F32[i] = expf(chipGains->data.F32[i]); 175 177 } 176 178 } 177 179 for (int i = 0; i < numExps; i++) { 178 if (!expMask->data. U8[i]) {180 if (!expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 179 181 expFluxes->data.F32[i] = expf(expFluxes->data.F32[i]); 180 182 } -
trunk/psModules/src/detrend/pmFringeStats.c
r13776 r21183 70 70 fringe->x = psVectorRecycle(fringe->x, fringe->nRequested, PS_TYPE_F32); 71 71 fringe->y = psVectorRecycle(fringe->y, fringe->nRequested, PS_TYPE_F32); 72 fringe->mask = psVectorRecycle(fringe->mask, fringe->nRequested, PS_TYPE_ U8);72 fringe->mask = psVectorRecycle(fringe->mask, fringe->nRequested, PS_TYPE_VECTOR_MASK); 73 73 fringe->x->n = fringe->y->n = fringe->mask->n = fringe->nRequested; 74 74 psVectorInit(fringe->mask, 0); … … 115 115 if (mask) { 116 116 PS_ASSERT_VECTOR_NON_NULL(mask, false); 117 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);117 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 118 118 PS_ASSERT_VECTOR_SIZE(mask, (long)numRows, false); 119 119 } … … 142 142 psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]); 143 143 psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]); 144 ps U8maskValue = 0;145 if (mask && mask->data. U8[i]) {144 psVectorMaskType maskValue = 0; 145 if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 146 146 maskValue = 0xff; 147 147 } 148 psMetadataAdd U8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);148 psMetadataAddVectorMask(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue); 149 149 table->data[i] = row; 150 150 } … … 207 207 psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position 208 208 psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position 209 psVector *mask = psVectorAlloc(numRows, PS_TYPE_ U8); // mask209 psVector *mask = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); // mask 210 210 regions->x = x; 211 211 regions->y = y; 212 212 regions->mask = mask; 213 213 214 #define READ_REGIONS_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \215 VECTOR->data. TYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \214 #define READ_REGIONS_ROW(VECTOR, TYPE, DATATYPE, NAME, DESCRIPTION) \ 215 VECTOR->data.DATATYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \ 216 216 if (!mdok) { \ 217 217 psError(PS_ERR_IO, true, "Unable to find " #DESCRIPTION " .\n"); \ … … 224 224 for (long i = 0; i < numRows; i++) { 225 225 psMetadata *row = table->data[i]; // Table row 226 READ_REGIONS_ROW(x, F32, "x", "x position");227 READ_REGIONS_ROW(y, F32, "y", "y position");228 READ_REGIONS_ROW(mask, U8, "mask", "mask");226 READ_REGIONS_ROW(x, F32, F32, "x", "x position"); 227 READ_REGIONS_ROW(y, F32, F32, "y", "y position"); 228 READ_REGIONS_ROW(mask, VectorMask, PS_TYPE_VECTOR_MASK_DATA, "mask", "mask"); 229 229 } 230 230 psFree(table); … … 259 259 } 260 260 261 pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, ps MaskType maskVal)261 pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, psImageMaskType maskVal) 262 262 { 263 263 PS_ASSERT_PTR_NON_NULL(fringe, NULL); … … 490 490 newRegions->x = psVectorAlloc(numPoints, PS_TYPE_F32); 491 491 newRegions->y = psVectorAlloc(numPoints, PS_TYPE_F32); 492 newRegions->mask = psVectorAlloc(numPoints, PS_TYPE_ U8);492 newRegions->mask = psVectorAlloc(numPoints, PS_TYPE_VECTOR_MASK); 493 493 pmFringeStats *newStats = pmFringeStatsAlloc(newRegions); // The new list of statistics 494 494 … … 500 500 memcpy(&newRegions->x->data.F32[offset], regions->x->data.F32, regions->x->n * sizeof(psF32)); 501 501 memcpy(&newRegions->y->data.F32[offset], regions->y->data.F32, regions->y->n * sizeof(psF32)); 502 memcpy(&newRegions->mask->data. U8[offset], regions->mask->data.U8, regions->mask->n * sizeof(psU8));502 memcpy(&newRegions->mask->data.PS_TYPE_VECTOR_MASK_DATA[offset], regions->mask->data.PS_TYPE_VECTOR_MASK_DATA, regions->mask->n * sizeof(psVectorMaskType)); 503 503 memcpy(&newStats->f->data.F32[offset], fringe->f->data.F32, fringe->f->n * sizeof(psF32)); 504 504 memcpy(&newStats->df->data.F32[offset], fringe->df->data.F32, fringe->df->n * sizeof(psF32)); … … 549 549 if (mask) { 550 550 PS_ASSERT_VECTOR_NON_NULL(mask, false); 551 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);551 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 552 552 PS_ASSERT_VECTOR_SIZE(mask, (long)numRows, false); 553 553 } … … 580 580 psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]); 581 581 psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]); 582 ps U8maskValue = 0; // Mask value583 if (mask && mask->data. U8[i]) {582 psVectorMaskType maskValue = 0; // Mask value 583 if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 584 584 maskValue = 0xff; 585 585 } … … 601 601 psFree(df); 602 602 603 psMetadataAdd U8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);603 psMetadataAddVectorMask(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue); 604 604 table->data[i] = row; 605 605 } … … 648 648 psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position 649 649 psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position 650 psVector *mask = psVectorAlloc(numRows, PS_TYPE_ U8); // mask650 psVector *mask = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); // mask 651 651 regions->x = x; 652 652 regions->y = y; … … 656 656 psArray *fringes = NULL; // Array of fringes, to return 657 657 658 #define READ_FRINGES_VECTOR_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \658 #define READ_FRINGES_VECTOR_ROW(VECTOR, TYPE, DATATYPE, NAME, DESCRIPTION) \ 659 659 { \ 660 VECTOR->data. TYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \660 VECTOR->data.DATATYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \ 661 661 if (!mdok) { \ 662 662 psError(PS_ERR_IO, true, "Unable to find " #DESCRIPTION " for row %ld.\n", i); \ … … 686 686 } 687 687 688 // XXX : need to extend this to support arbitrary types for the vectors on disk 688 689 // Translate the table into vectors 689 690 for (long i = 0; i < numRows; i++) { 690 691 psMetadata *row = table->data[i]; // Table row 691 READ_FRINGES_VECTOR_ROW(x, F32, "x", "x position");692 READ_FRINGES_VECTOR_ROW(y, F32, "y", "y position");693 READ_FRINGES_VECTOR_ROW(mask, U8, "mask", "mask");692 READ_FRINGES_VECTOR_ROW(x, F32, F32, "x", "x position"); 693 READ_FRINGES_VECTOR_ROW(y, F32, F32, "y", "y position"); 694 READ_FRINGES_VECTOR_ROW(mask, VectorMask, PS_TYPE_VECTOR_MASK_DATA, "mask", "mask"); 694 695 READ_FRINGES_ARRAY_ROW(f, F32, "f", "fringe measurement"); 695 696 READ_FRINGES_ARRAY_ROW(df, F32, "df", "fringe error"); … … 782 783 double matrix = 0.0; // The matrix sum 783 784 for (int k = 0; k < numPoints; k++) { 784 if (!mask->data. U8[k]) {785 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[k]) { 785 786 psF32 f1 = (fringe1) ? fringe1->data.F32[k] : 1.0; // Contribution from i fringe 786 787 psF32 f2 = (fringe2) ? fringe2->data.F32[k] : 1.0; // Contribution from j fringe … … 799 800 double vector = 0.0; // The vector sum 800 801 for (int k = 0; k < numPoints; k++) { 801 if (!mask->data. U8[k]) {802 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[k]) { 802 803 psF32 f1 = (fringe1) ? fringe1->data.F32[k] : 1.0; // Contribution from fringe 1 803 804 psF32 s = science->f->data.F32[k]; // Contribution from science measurement … … 855 856 856 857 for (int i = 0; i < diff->n; i++) { 857 if (!mask->data. U8[i]) {858 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 858 859 float difference = science->f->data.F32[i] - scale->coeff->data.F32[0]; 859 860 for (int j = 0; j < fringes->n; j++) { … … 877 878 assert(diffs->type.type == PS_TYPE_F32); 878 879 assert(mask); 879 assert(mask->type.type == PS_TYPE_ U8);880 assert(mask->type.type == PS_TYPE_VECTOR_MASK); 880 881 assert(diffs->n == mask->n); 881 882 … … 888 889 int numClipped = 0; // Number clipped 889 890 for (int i = 0; i < diffs->n; i++) { 890 psTrace("psModules.detrend", 10, "Region %d (%d): %f\n", i, mask->data. U8[i], diffs->data.F32[i]);891 if (!mask->data. U8[i] && fabs(diffs->data.F32[i]) > middle + thresh) {891 psTrace("psModules.detrend", 10, "Region %d (%d): %f\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i], diffs->data.F32[i]); 892 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] && fabs(diffs->data.F32[i]) > middle + thresh) { 892 893 psTrace("psModules.detrend", 5, "Masking %d: %f\n", i, diffs->data.F32[i]); 893 mask->data. U8[i] = 1;894 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 894 895 numClipped++; 895 896 } … … 931 932 // Set up the mask 932 933 if (!regions->mask) { 933 regions->mask = psVectorAlloc(numRegions, PS_TYPE_ U8);934 regions->mask = psVectorAlloc(numRegions, PS_TYPE_VECTOR_MASK); 934 935 psVectorInit(regions->mask, 0); 935 936 } … … 946 947 for (int j = 0; j < numRegions; j++) { 947 948 if (!isfinite(fringe->f->data.F32[j])) { 948 mask->data. U8[j] = 1;949 mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 1; 949 950 psTrace("psModules.detrend", 9, "Masking region %d because not finite in fringe %d.\n", j, i); 950 951 } … … 956 957 FILE *f = fopen ("fringe.dat", "w"); 957 958 for (int j = 0; j < numRegions; j++) { 958 if (mask->data. U8[j]) continue;959 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) continue; 959 960 fprintf (f, "%d %f %f ", j, science->f->data.F32[j], science->df->data.F32[j]); 960 961 for (int i = 0; i < fringes->n; i++) { … … 1014 1015 // XXX note that this modifies the input fringe images 1015 1016 psImage *pmFringeCorrect(pmReadout *readout, pmFringeRegions *fringes, psArray *fringeImages, 1016 psArray *fringeStats, ps MaskType maskVal, float rej,1017 psArray *fringeStats, psImageMaskType maskVal, float rej, 1017 1018 unsigned int nIter, float keepFrac) 1018 1019 { -
trunk/psModules/src/detrend/pmFringeStats.h
r11253 r21183 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $8 * @date $Date: 200 7-01-24 02:54:15$7 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * Copyright 2004-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 102 102 pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, ///< Fringe regions at which to measure 103 103 const pmReadout *readout, ///< Readout for which to measure 104 ps MaskType maskVal ///< Mask value for image104 psImageMaskType maskVal ///< Mask value for image 105 105 ); 106 106 … … 206 206 psArray *fringeImages, ///< Fringe template images to use in correction 207 207 psArray *fringeStats, ///< Fringe stats (for templates) to use in correction 208 ps MaskType maskVal, ///< Value to mask for science image208 psImageMaskType maskVal, ///< Value to mask for science image 209 209 float rej, ///< Rejection threshold, for pmFringeScaleMeasure 210 210 unsigned int nIter, ///< Maximum number of iterations, for pmFringeScaleMeasure -
trunk/psModules/src/detrend/pmMaskBadPixels.c
r18554 r21183 14 14 #include "pmMaskBadPixels.h" 15 15 16 bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, ps MaskType maskVal)16 bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psImageMaskType maskVal) 17 17 { 18 18 PS_ASSERT_PTR_NON_NULL(input, false); 19 19 PS_ASSERT_PTR_NON_NULL(input->mask, false); 20 PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_ MASK, false);20 PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_IMAGE_MASK, false); 21 21 22 22 PS_ASSERT_PTR_NON_NULL(mask, false); 23 23 PS_ASSERT_PTR_NON_NULL(mask->mask, false); 24 PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_ MASK, false);24 PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_IMAGE_MASK, false); 25 25 26 26 psImage *inMask = input->mask; … … 53 53 int offRow = input->row0 - mask->row0; 54 54 55 // masks are both of type PS_TYPE_ MASK56 ps MaskType **exVal = exMask->data.U8;57 ps MaskType **inVal = inMask->data.U8;55 // masks are both of type PS_TYPE_IMAGE_MASK 56 psImageMaskType **exVal = exMask->data.PS_TYPE_IMAGE_MASK_DATA; 57 psImageMaskType **inVal = inMask->data.PS_TYPE_IMAGE_MASK_DATA; 58 58 59 59 // apply exMask values … … 82 82 83 83 bool pmMaskFlagSuspectPixels(pmReadout *output, const pmReadout *readout, float median, float stdev, 84 float rej, ps MaskType maskVal)84 float rej, psImageMaskType maskVal) 85 85 { 86 86 PS_ASSERT_PTR_NON_NULL(readout, false); … … 92 92 PS_ASSERT_IMAGE_NON_EMPTY(readout->mask, false); 93 93 PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, readout->mask, false); 94 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_ MASK, false);94 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false); 95 95 } 96 96 PS_ASSERT_PTR_NON_NULL(output, false); … … 128 128 for (int x = 0; x < image->numCols; x++) { 129 129 if (fabs((image->data.F32[y][x] - median) / stdev) < rej) continue; 130 if (mask && (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal)) continue;130 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue; 131 131 suspect->data.F32[y][x] += 1.0; 132 132 } … … 142 142 143 143 // the maskVal supplied here is the value SET for this mask (ie, it is not used to avoid pixels) 144 bool pmMaskIdentifyBadPixels(pmReadout *output, ps MaskType maskVal, float thresh, pmMaskIdentifyMode mode)144 bool pmMaskIdentifyBadPixels(pmReadout *output, psImageMaskType maskVal, float thresh, pmMaskIdentifyMode mode) 145 145 { 146 146 PS_ASSERT_PTR_NON_NULL(output, false); … … 155 155 PS_ASSERT_IMAGE_NON_EMPTY(output->mask, false); 156 156 PS_ASSERT_IMAGES_SIZE_EQUAL(output->mask, suspects, false); 157 PS_ASSERT_IMAGE_TYPE(output->mask, PS_TYPE_ MASK, false);157 PS_ASSERT_IMAGE_TYPE(output->mask, PS_TYPE_IMAGE_MASK, false); 158 158 } else { 159 output->mask = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_ MASK);159 output->mask = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_IMAGE_MASK); 160 160 } 161 161 int num = psMetadataLookupS32(NULL, output->analysis, PM_MASK_ANALYSIS_NUM); // Number of inputs … … 246 246 for (int x = 0; x < suspects->numCols; x++) { 247 247 if (suspects->data.F32[y][x] >= limit) { 248 badpix->data.PS_TYPE_ MASK_DATA[y][x] = maskVal;248 badpix->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskVal; 249 249 } 250 250 } -
trunk/psModules/src/detrend/pmMaskBadPixels.h
r17228 r21183 5 5 * @author Eugene Magnier, IfA 6 6 * 7 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-03-29 03:10:17$7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * Copyright 2004 Institute for Astronomy, University of Hawaii 10 10 */ … … 40 40 bool pmMaskBadPixels(pmReadout *input, ///< Input science image 41 41 const pmReadout *mask, ///< Mask image to apply 42 ps MaskType maskVal ///< Mask value to apply42 psImageMaskType maskVal ///< Mask value to apply 43 43 ); 44 44 … … 56 56 float stdev, ///< Image standard deviation 57 57 float rej, ///< Rejection threshold (standard deviations) 58 ps MaskType maskVal ///< Mask value for statistics58 psImageMaskType maskVal ///< Mask value for statistics 59 59 ); 60 60 … … 64 64 /// according to the chosen mode. 65 65 bool pmMaskIdentifyBadPixels(pmReadout *output, ///< Output readout, with suspect pixels imageOut 66 ps MaskType maskVal, ///< Value to set for bad pixels66 psImageMaskType maskVal, ///< Value to set for bad pixels 67 67 float thresh, ///< Threshold for bad pixel 68 68 pmMaskIdentifyMode mode ///< Mode for identifying bad pixels -
trunk/psModules/src/detrend/pmOverscan.c
r19846 r21183 67 67 psVector *reduced = psVectorAlloc(pixels->n, PS_TYPE_F32); // Overscan for each row 68 68 psVector *ordinate = psVectorAlloc(pixels->n, PS_TYPE_F32); // Ordinate 69 psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_ U8); // Mask for fitting69 psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_VECTOR_MASK); // Mask for fitting 70 70 71 71 for (int i = 0; i < pixels->n; i++) { 72 72 psVector *values = pixels->data[i]; // Vector with overscan values 73 73 if (values->n > 0) { 74 mask->data. U8[i] = 0;74 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0; 75 75 ordinate->data.F32[i] = 2.0*(float)i/(float)pixels->n - 1.0; // Scale to [-1,1] 76 76 psVectorStats(myStats, values, NULL, NULL, 0); … … 82 82 } else { 83 83 // We'll fit this one out 84 mask->data. U8[i] = 1;84 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 85 85 } 86 86 } -
trunk/psModules/src/detrend/pmRemnance.c
r20669 r21183 13 13 14 14 bool pmRemnance(pmReadout *ro, ///< Readout with input image 15 ps MaskType maskVal, ///< Value of mask16 ps MaskType maskRem, ///< Value to give remance15 psImageMaskType maskVal, ///< Value of mask 16 psImageMaskType maskRem, ///< Value to give remance 17 17 int size, ///< Size of accumulation patches 18 18 float threshold ///< Threshold for masking … … 23 23 PM_ASSERT_READOUT_MASK(ro, false); 24 24 25 psImage *image = ro->image, *mask = ro->mask; // Mask and image from readout 25 psImage *image = ro->image; 26 psImage *mask = ro->mask; // Mask and image from readout 27 26 28 int numCols = image->numCols, numRows = image->numRows; // Size of image 27 29 … … 33 35 psErrorClear(); 34 36 psWarning("Unable to calculate image statistics: masking entire readout."); 35 psBinaryOp(mask, mask, "|", psScalarAlloc(maskRem, PS_TYPE_ MASK));37 psBinaryOp(mask, mask, "|", psScalarAlloc(maskRem, PS_TYPE_IMAGE_MASK)); 36 38 psFree(stats); 37 39 psFree(rng); … … 57 59 } 58 60 for (int y = min; y < max; y++) { 59 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {61 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 60 62 continue; 61 63 } … … 84 86 } 85 87 for (int y = 0; y < maxMask; y++) { 86 mask->data.PS_TYPE_ MASK_DATA[y][x] |= maskRem;88 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskRem; 87 89 } 88 90 numMasked += maxMask; -
trunk/psModules/src/detrend/pmRemnance.h
r20622 r21183 13 13 // GPC1 leaves remnance that flows down from where the annoyed pixels are. 14 14 bool pmRemnance(pmReadout *ro, ///< Readout with input image 15 ps MaskType maskVal, ///< Value of mask16 ps MaskType maskRem, ///< Value to give remance15 psImageMaskType maskVal, ///< Value of mask 16 psImageMaskType maskRem, ///< Value to give remance 17 17 int size, ///< Size of accumulation patches 18 18 float threshold ///< Threshold for masking -
trunk/psModules/src/detrend/pmShifts.c
r15322 r21183 412 412 } 413 413 414 bool pmShiftsConvolve(pmReadout *detrend, const pmCell *source, ps MaskType maskVal)414 bool pmShiftsConvolve(pmReadout *detrend, const pmCell *source, psImageMaskType maskVal) 415 415 { 416 416 PS_ASSERT_PTR(detrend, false); -
trunk/psModules/src/detrend/pmShifts.h
r12696 r21183 46 46 bool pmShiftsConvolve(pmReadout *detrend, ///< Detrend readout to convolve 47 47 const pmCell *source, ///< Science exposure, containing a shifts kernel 48 ps MaskType maskVal ///< Mask value to smear48 psImageMaskType maskVal ///< Mask value to smear 49 49 ); 50 50 -
trunk/psModules/src/detrend/pmShutterCorrection.c
r19432 r21183 198 198 pmShutterCorrection *pmShutterCorrectionLinFit(const psVector *exptime, const psVector *counts, 199 199 const psVector *cntError, const psVector *mask, float offref, 200 int nIter, float rej , psMaskType maskVal)200 int nIter, float rej) 201 201 { 202 202 PS_ASSERT_VECTOR_NON_NULL(exptime, NULL); … … 241 241 stats->clipIter = nIter; 242 242 243 if (!psVectorClipFitPolynomial2D(line, stats, mask, maskVal, counts, cntError, x, y)) {243 if (!psVectorClipFitPolynomial2D(line, stats, mask, 0xff, counts, cntError, x, y)) { 244 244 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to fit shutter correction.\n"); 245 245 psFree(stats); … … 371 371 372 372 bool pmShutterCorrectionMeasure(pmReadout *output, const psArray *readouts, int size, psStatsOptions meanStat, 373 psStatsOptions stdevStat, int nIter, float rej, ps MaskType maskVal)373 psStatsOptions stdevStat, int nIter, float rej, psImageMaskType maskVal) 374 374 { 375 375 PS_ASSERT_ARRAY_NON_NULL(readouts, NULL); … … 457 457 masks->data[i] = psMemIncrRefCounter(mask); 458 458 459 if (mask->type.type != PS_TYPE_ U8) {459 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 460 460 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Bad type for mask: %x\n", mask->type.type); 461 461 goto MEASURE_ERROR; … … 582 582 psImage *shutter = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Shutter correction image 583 583 psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern 584 psVector *mask = psVectorAlloc(num, PS_TYPE_ U8); // Mask for each image584 psVector *mask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for each image 585 585 psVectorInit(mask, 0); 586 586 psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n"); … … 592 592 psImage *maskImage; // Mask image 593 593 if (masks && (maskImage = masks->data[i])) { 594 mask->data. U8[i] = maskImage->data.U8[y][x];594 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal); 595 595 } 596 596 psImage *weight; // Weight image … … 602 602 } 603 603 604 pmShutterCorrection *corr = pmShutterCorrectionLinFit(exptimes, counts, errors, mask, meanRef, 605 nIter, rej, maskVal); 604 pmShutterCorrection *corr = pmShutterCorrectionLinFit(exptimes, counts, errors, mask, meanRef, nIter, rej); 606 605 shutter->data.F32[y][x] = corr->offset; 607 606 pattern->data.F32[y][x] = corr->scale; … … 665 664 666 665 float exptime = PS_SCALAR_VALUE(job->args->data[3],F32); 667 ps MaskType blank = PS_SCALAR_VALUE(job->args->data[4],U8);666 psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 668 667 int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32); 669 668 int rowStop = PS_SCALAR_VALUE(job->args->data[6],S32); … … 672 671 673 672 bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime, 674 ps MaskType blank, int rowStart, int rowStop)673 psImageMaskType blank, int rowStart, int rowStop) 675 674 { 676 675 for (int y = rowStart; y < rowStop; y++) { 677 676 for (int x = 0; x < image->numCols; x++) { 678 677 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 679 mask->data.PS_TYPE_ MASK_DATA[y][x] |= blank;678 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank; 680 679 image->data.F32[y][x] = NAN; 681 680 continue; … … 687 686 } 688 687 689 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, ps MaskType blank)688 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psImageMaskType blank) 690 689 { 691 690 PS_ASSERT_PTR_NON_NULL(readout, false); … … 746 745 for (int x = 0; x < image->numCols; x++) { 747 746 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 748 mask->data.PS_TYPE_ MASK_DATA[y][x] |= blank;747 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank; 749 748 image->data.F32[y][x] = NAN; 750 749 continue; … … 770 769 psArrayAdd(job->args, 1, mask); 771 770 PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32); 772 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_ MASK);771 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_IMAGE_MASK); 773 772 PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32); 774 773 PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32); … … 860 859 psStatsOptions meanStat, ///< Statistic to use for mean 861 860 psStatsOptions stdevStat, ///< Statistic to use for stdev 862 ps MaskType maskVal, ///< Mask value861 psImageMaskType maskVal, ///< Mask value 863 862 psRandom *rng ///< Random number generator 864 863 ) … … 876 875 if (readout->mask) { 877 876 PS_ASSERT_IMAGE_NON_NULL(readout->mask, NULL); 878 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_ MASK, NULL);877 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, NULL); 879 878 PS_ASSERT_IMAGE_SIZE(readout->mask, data->numCols, data->numRows, NULL); 880 879 } … … 1022 1021 1023 1022 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 1024 ps MaskType maskVal)1023 psImageMaskType maskVal) 1025 1024 { 1026 1025 PS_ASSERT_PTR_NON_NULL(shutter, false); … … 1084 1083 bool pmShutterCorrectionGenerate(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 1085 1084 float reference, const pmShutterCorrectionData *data, 1086 int nIter, float rej, ps MaskType maskVal)1085 int nIter, float rej, psImageMaskType maskVal) 1087 1086 { 1088 1087 PS_ASSERT_PTR_NON_NULL(shutter, false); … … 1116 1115 psVector *counts = psVectorAlloc(num, PS_TYPE_F32); // Counts in each image 1117 1116 psVector *errors = psVectorAlloc(num, PS_TYPE_F32); // Counts in each image 1118 psVector *mask = psVectorAlloc(num, PS_TYPE_ MASK); // Mask for each image1117 psVector *mask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for each image 1119 1118 psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n"); 1120 1119 for (int i = minInputRows; i < maxInputRows; i++) { … … 1132 1131 counts->data.F32[r] = image->data.F32[yIn][xIn] * ref; 1133 1132 if (readout->mask) { 1134 mask->data.PS_TYPE_ MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];1133 mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal); 1135 1134 } 1136 1135 if (readout->weight) { … … 1142 1141 } 1143 1142 1144 pmShutterCorrection *corr = pmShutterCorrectionLinFit(data->exptimes, counts, errors, mask, 1145 reference, nIter, rej, maskVal); 1143 pmShutterCorrection *corr = pmShutterCorrectionLinFit(data->exptimes, counts, errors, mask, reference, nIter, rej); 1146 1144 if (!corr) { 1147 1145 // Nothing we can do about it -
trunk/psModules/src/detrend/pmShutterCorrection.h
r19432 r21183 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-09-09 04:10:14$7 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * Copyright 2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 91 91 float offref, ///< Reference time offset 92 92 int nIter, ///< Number of iterations 93 float rej, ///< Rejection threshold (sigma) 94 psMaskType maskVal ///< Mask value 93 float rej ///< Rejection threshold (sigma) 95 94 ); 96 95 … … 121 120 int nIter, ///< Number of iterations 122 121 float rej, ///< Rejection threshold (sigma) 123 ps MaskType maskVal ///< Mask value122 psImageMaskType maskVal ///< Mask value 124 123 ); 125 124 … … 135 134 psImage *mask, ///< Input mask image 136 135 float exptime, ///< Exposure time to which to correct 137 ps MaskType blank, ///< Mask value to give blank pixels136 psImageMaskType blank, ///< Mask value to give blank pixels 138 137 int rowStart, int rowStop ///< Range of scan 139 138 ); … … 145 144 pmReadout *readout, ///< Readout to which to apply shutter correction 146 145 const pmReadout *shutter, ///< Shutter correction readout, with dT for each pixel 147 ps MaskType blank ///< Value to give blank pixels146 psImageMaskType blank ///< Value to give blank pixels 148 147 ); 149 148 … … 181 180 psStatsOptions meanStat, ///< Statistic to use for mean 182 181 psStatsOptions stdevStat, ///< Statistic to use for stdev 183 ps MaskType maskVal, ///< Mask value182 psImageMaskType maskVal, ///< Mask value 184 183 psRandom *rng ///< Random number generator 185 184 ); … … 201 200 int nIter, ///< Number of iterations 202 201 float rej, ///< Rejection threshold (sigma) 203 ps MaskType maskVal ///< Mask value202 psImageMaskType maskVal ///< Mask value 204 203 ); 205 204 206 205 // prepare outputs for shutter correction 207 206 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 208 ps MaskType maskVal);207 psImageMaskType maskVal); 209 208 210 209 /// @} -
trunk/psModules/src/detrend/pmSkySubtract.c
r12742 r21183 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 200 7-04-04 22:42:48 $8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 114 114 115 115 psVector *binVector = psVectorAlloc(binFactor * binFactor, PS_TYPE_F32); 116 psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_ U8);116 psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_VECTOR_MASK); 117 117 psStats *myStats = psStatsAlloc(statOptions); 118 118 … … 126 126 binVector->data.F32[count] = 127 127 origImage->data.F32[row + binRow][col + binCol]; 128 binMask->data. U8[count] = 0;128 binMask->data.PS_TYPE_VECTOR_MASK_DATA[count] = 0; 129 129 } else { 130 130 binVector->data.F32[count] = 0.0; 131 binMask->data. U8[count] = 1;131 binMask->data.PS_TYPE_VECTOR_MASK_DATA[count] = 1; 132 132 } 133 133 count++; … … 313 313 PS_ASSERT_IMAGE_NON_NULL(maskImage, NULL); 314 314 PS_ASSERT_IMAGE_NON_EMPTY(maskImage, NULL); 315 PS_ASSERT_IMAGE_TYPE(maskImage, PS_TYPE_ U8, NULL);315 PS_ASSERT_IMAGE_TYPE(maskImage, PS_TYPE_IMAGE_MASK, NULL); 316 316 PS_ASSERT_IMAGES_SIZE_EQUAL(dataImage, maskImage, NULL); 317 317 psS32 oldPolyX = -1; … … 361 361 for (x=0;x<dataImage->numRows;x++) { 362 362 for (y=0;y<dataImage->numCols;y++) { 363 if (maskImage->data. U8[x][y] == 0) {363 if (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[x][y] == 0) { 364 364 buildSums((psF64) x, (psF64) y, myPoly->nX, myPoly->nY); 365 365 … … 572 572 573 573 if (in->mask != NULL) { 574 binnedMaskImage = psImageCopy(binnedMaskImage, in->mask, PS_TYPE_ U8);574 binnedMaskImage = psImageCopy(binnedMaskImage, in->mask, PS_TYPE_IMAGE_MASK); 575 575 if (binnedMaskImage == NULL) { 576 576 psError(PS_ERR_UNKNOWN, false, "psImageCopy() returned NULL. Returning in image.\n"); … … 581 581 binnedMaskImage = psImageAlloc(binnedImage->numCols, 582 582 binnedImage->numRows, 583 PS_TYPE_ U8);583 PS_TYPE_IMAGE_MASK); 584 584 psImageInit(binnedMaskImage, 0); 585 585 } … … 592 592 binnedMaskImage = psImageAlloc(binnedImage->numCols, 593 593 binnedImage->numRows, 594 PS_TYPE_ U8);594 PS_TYPE_IMAGE_MASK); 595 595 psImageInit(binnedMaskImage, 0); 596 596 } … … 625 625 if (fabs(binnedImage->data.F32[row][col] - binnedMean) > 626 626 (clipSD * binnedStdev)) { 627 binnedMaskImage->data. U8[row][col] = 1;627 binnedMaskImage->data.PS_TYPE_IMAGE_MASK_DATA[row][col] = 1; 628 628 } 629 629 }
Note:
See TracChangeset
for help on using the changeset viewer.
