Changeset 21183
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 211 edited
-
ppArith/src/ppArithReadout.c (modified) (2 diffs)
-
ppImage/src/ppImage.h (modified) (1 diff)
-
ppImage/src/ppImageCleanup.c (modified) (1 diff)
-
ppImage/src/ppImageLoop.c (modified) (4 diffs)
-
ppImage/src/ppImageReplaceBackground.c (modified) (4 diffs)
-
ppImage/src/ppImageSetMaskBits.c (modified) (1 diff)
-
ppMerge/src/ppMergeArguments.c (modified) (1 diff)
-
ppMerge/src/ppMergeLoop.c (modified) (1 diff)
-
ppMerge/src/ppMergeLoop_Threaded.c (modified) (3 diffs)
-
ppMerge/src/ppMergeMask.c (modified) (3 diffs)
-
ppMerge/src/ppMergeScaleZero.c (modified) (1 diff)
-
ppMerge/src/ppMergeSetThreads.c (modified) (2 diffs)
-
ppMerge/src/ppMergeThreadLauncher.c (modified) (2 diffs)
-
ppSim/src/ppSim.h (modified) (1 diff)
-
ppSim/src/ppSimMosaicChip.c (modified) (1 diff)
-
ppSim/src/ppSimPhotom.c (modified) (1 diff)
-
ppSim/src/ppSimPhotomReadout.c (modified) (1 diff)
-
ppSim/src/ppSimPhotomReadoutFake.c (modified) (1 diff)
-
ppSim/src/ppSimPhotomReadoutForce.c (modified) (1 diff)
-
ppStack/src/ppStackArguments.c (modified) (1 diff)
-
ppStack/src/ppStackLoop.c (modified) (17 diffs)
-
ppStack/src/ppStackMatch.c (modified) (2 diffs)
-
ppStack/src/ppStackPhotometry.c (modified) (3 diffs)
-
ppStack/src/ppStackReadout.c (modified) (4 diffs)
-
ppStack/src/ppStackSources.c (modified) (1 diff)
-
ppStats/src/ppStats.h (modified) (4 diffs)
-
ppStats/src/ppStatsFPA.c (modified) (1 diff)
-
ppStats/src/ppStatsMetadata.c (modified) (1 diff)
-
ppStats/src/ppStatsPixels.c (modified) (1 diff)
-
ppStats/src/ppStatsReadout.c (modified) (3 diffs)
-
ppSub/src/ppSubArguments.c (modified) (1 diff)
-
ppSub/src/ppSubBackground.c (modified) (3 diffs)
-
ppSub/src/ppSubReadout.c (modified) (8 diffs)
-
psLib/src/fft/psImageFFT.c (modified) (4 diffs)
-
psLib/src/fft/psImageFFT.h (modified) (2 diffs)
-
psLib/src/fits/psFitsImage.c (modified) (9 diffs)
-
psLib/src/fits/psFitsImage.h (modified) (6 diffs)
-
psLib/src/fits/psFitsScale.c (modified) (3 diffs)
-
psLib/src/fits/psFitsScale.h (modified) (1 diff)
-
psLib/src/imageops/psImageBackground.c (modified) (2 diffs)
-
psLib/src/imageops/psImageBackground.h (modified) (2 diffs)
-
psLib/src/imageops/psImageConvolve.c (modified) (45 diffs)
-
psLib/src/imageops/psImageConvolve.h (modified) (7 diffs)
-
psLib/src/imageops/psImageGeomManip.c (modified) (13 diffs)
-
psLib/src/imageops/psImageGeomManip.h (modified) (4 diffs)
-
psLib/src/imageops/psImageInterpolate.c (modified) (14 diffs)
-
psLib/src/imageops/psImageInterpolate.h (modified) (4 diffs)
-
psLib/src/imageops/psImageMap.c (modified) (6 diffs)
-
psLib/src/imageops/psImageMapFit.c (modified) (11 diffs)
-
psLib/src/imageops/psImageMapFit.h (modified) (4 diffs)
-
psLib/src/imageops/psImageMaskOps.c (modified) (14 diffs)
-
psLib/src/imageops/psImageMaskOps.h (modified) (6 diffs)
-
psLib/src/imageops/psImagePixelExtract.c (modified) (17 diffs)
-
psLib/src/imageops/psImagePixelExtract.h (modified) (4 diffs)
-
psLib/src/imageops/psImagePixelInterpolate.c (modified) (11 diffs)
-
psLib/src/imageops/psImagePixelInterpolate.h (modified) (2 diffs)
-
psLib/src/imageops/psImageStats.c (modified) (7 diffs)
-
psLib/src/imageops/psImageStats.h (modified) (4 diffs)
-
psLib/src/mask.notes.txt (added)
-
psLib/src/math/psClip.c (modified) (6 diffs)
-
psLib/src/math/psClip.h (modified) (3 diffs)
-
psLib/src/math/psConstants.h (modified) (2 diffs)
-
psLib/src/math/psHistogram.c (modified) (4 diffs)
-
psLib/src/math/psHistogram.h (modified) (2 diffs)
-
psLib/src/math/psMinimizeLMM.c (modified) (10 diffs)
-
psLib/src/math/psMinimizeLMM_ND.c (modified) (10 diffs)
-
psLib/src/math/psMinimizePolyFit.c (modified) (48 diffs)
-
psLib/src/math/psMinimizePolyFit.h (modified) (9 diffs)
-
psLib/src/math/psMinimizePowell.c (modified) (11 diffs)
-
psLib/src/math/psPolynomialMD.c (modified) (17 diffs)
-
psLib/src/math/psPolynomialMD.h (modified) (2 diffs)
-
psLib/src/math/psPolynomialUtils.c (modified) (5 diffs)
-
psLib/src/math/psPolynomialUtils.h (modified) (2 diffs)
-
psLib/src/math/psStats.c (modified) (40 diffs)
-
psLib/src/math/psStats.h (modified) (2 diffs)
-
psLib/src/mathtypes/psVector.c (modified) (3 diffs)
-
psLib/src/mathtypes/psVector.h (modified) (2 diffs)
-
psLib/src/sys/psType.h (modified) (2 diffs)
-
psLib/src/types/psMetadata.c (modified) (4 diffs)
-
psLib/src/types/psMetadata.h (modified) (3 diffs)
-
psLib/src/types/psPixels.c (modified) (6 diffs)
-
psLib/src/types/psPixels.h (modified) (3 diffs)
-
psModules/src/astrom/pmAstrometryDistortion.c (modified) (3 diffs)
-
psModules/src/astrom/pmAstrometryObjects.c (modified) (2 diffs)
-
psModules/src/camera/pmCellSquish.c (modified) (3 diffs)
-
psModules/src/camera/pmCellSquish.h (modified) (1 diff)
-
psModules/src/camera/pmFPABin.c (modified) (2 diffs)
-
psModules/src/camera/pmFPABin.h (modified) (1 diff)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (23 diffs)
-
psModules/src/camera/pmFPAMaskWeight.h (modified) (11 diffs)
-
psModules/src/camera/pmFPAMosaic.c (modified) (7 diffs)
-
psModules/src/camera/pmFPAMosaic.h (modified) (3 diffs)
-
psModules/src/camera/pmFPARead.c (modified) (1 diff)
-
psModules/src/camera/pmFPA_JPEG.c (modified) (2 diffs)
-
psModules/src/camera/pmHDU.c (modified) (3 diffs)
-
psModules/src/camera/pmReadoutStack.c (modified) (4 diffs)
-
psModules/src/camera/pmReadoutStack.h (modified) (2 diffs)
-
psModules/src/concepts/pmConceptsStandard.c (modified) (2 diffs)
-
psModules/src/config/pmConfigMask.c (modified) (13 diffs)
-
psModules/src/config/pmConfigMask.h (modified) (3 diffs)
-
psModules/src/detrend/pmBias.c (modified) (2 diffs)
-
psModules/src/detrend/pmDark.c (modified) (16 diffs)
-
psModules/src/detrend/pmDark.h (modified) (3 diffs)
-
psModules/src/detrend/pmFlatField.c (modified) (6 diffs)
-
psModules/src/detrend/pmFlatField.h (modified) (3 diffs)
-
psModules/src/detrend/pmFlatNormalize.c (modified) (12 diffs)
-
psModules/src/detrend/pmFringeStats.c (modified) (23 diffs)
-
psModules/src/detrend/pmFringeStats.h (modified) (3 diffs)
-
psModules/src/detrend/pmMaskBadPixels.c (modified) (8 diffs)
-
psModules/src/detrend/pmMaskBadPixels.h (modified) (4 diffs)
-
psModules/src/detrend/pmOverscan.c (modified) (2 diffs)
-
psModules/src/detrend/pmRemnance.c (modified) (5 diffs)
-
psModules/src/detrend/pmRemnance.h (modified) (1 diff)
-
psModules/src/detrend/pmShifts.c (modified) (1 diff)
-
psModules/src/detrend/pmShifts.h (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.c (modified) (19 diffs)
-
psModules/src/detrend/pmShutterCorrection.h (modified) (7 diffs)
-
psModules/src/detrend/pmSkySubtract.c (modified) (9 diffs)
-
psModules/src/imcombine/pmImageCombine.c (modified) (15 diffs)
-
psModules/src/imcombine/pmPSFEnvelope.c (modified) (1 diff)
-
psModules/src/imcombine/pmReadoutCombine.c (modified) (6 diffs)
-
psModules/src/imcombine/pmReadoutCombine.h (modified) (2 diffs)
-
psModules/src/imcombine/pmStack.c (modified) (15 diffs)
-
psModules/src/imcombine/pmStack.h (modified) (2 diffs)
-
psModules/src/imcombine/pmStackReject.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtraction.c (modified) (17 diffs)
-
psModules/src/imcombine/pmSubtraction.h (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionMask.c (modified) (8 diffs)
-
psModules/src/imcombine/pmSubtractionMask.h (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionMatch.c (modified) (4 diffs)
-
psModules/src/imcombine/pmSubtractionMatch.h (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionStamps.c (modified) (6 diffs)
-
psModules/src/objects/pmFootprintArrayGrow.c (modified) (2 diffs)
-
psModules/src/objects/pmFootprintFindAtPoint.c (modified) (7 diffs)
-
psModules/src/objects/pmGrowthCurveGenerate.c (modified) (6 diffs)
-
psModules/src/objects/pmModel.c (modified) (9 diffs)
-
psModules/src/objects/pmModel.h (modified) (5 diffs)
-
psModules/src/objects/pmPSF.h (modified) (2 diffs)
-
psModules/src/objects/pmPSF_IO.c (modified) (2 diffs)
-
psModules/src/objects/pmPSFtry.c (modified) (28 diffs)
-
psModules/src/objects/pmPSFtry.h (modified) (4 diffs)
-
psModules/src/objects/pmResiduals.c (modified) (2 diffs)
-
psModules/src/objects/pmResiduals.h (modified) (2 diffs)
-
psModules/src/objects/pmSource.c (modified) (11 diffs)
-
psModules/src/objects/pmSource.h (modified) (3 diffs)
-
psModules/src/objects/pmSourceFitModel.c (modified) (9 diffs)
-
psModules/src/objects/pmSourceFitModel.h (modified) (3 diffs)
-
psModules/src/objects/pmSourceFitSet.c (modified) (9 diffs)
-
psModules/src/objects/pmSourceFitSet.h (modified) (2 diffs)
-
psModules/src/objects/pmSourceMatch.c (modified) (7 diffs)
-
psModules/src/objects/pmSourceMoments.c (modified) (4 diffs)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (14 diffs)
-
psModules/src/objects/pmSourcePhotometry.h (modified) (2 diffs)
-
psModules/src/objects/pmSourceSky.c (modified) (5 diffs)
-
psModules/src/objects/pmSourceSky.h (modified) (3 diffs)
-
psModules/src/objects/pmSourceVisual.c (modified) (1 diff)
-
psModules/src/objects/pmTrend2D.c (modified) (3 diffs)
-
psModules/src/objects/pmTrend2D.h (modified) (3 diffs)
-
psastro/src/psastroAstromGuess.c (modified) (1 diff)
-
psastro/src/psastroFixChips.c (modified) (1 diff)
-
psastro/src/psastroLuminosityFunction.c (modified) (2 diffs)
-
psastro/src/psastroMaskUpdates.Mosaic.c (modified) (10 diffs)
-
psastro/src/psastroMaskUpdates.c (modified) (11 diffs)
-
psastro/src/psastroMosaicFPtoTP.c (modified) (1 diff)
-
psphot/src/psphot.h (modified) (8 diffs)
-
psphot/src/psphotAddNoise.c (modified) (1 diff)
-
psphot/src/psphotAnnuli.c (modified) (1 diff)
-
psphot/src/psphotApResid.c (modified) (8 diffs)
-
psphot/src/psphotBlendFit.c (modified) (1 diff)
-
psphot/src/psphotChoosePSF.c (modified) (2 diffs)
-
psphot/src/psphotExtendedSourceAnalysis.c (modified) (1 diff)
-
psphot/src/psphotExtendedSourceFits.c (modified) (1 diff)
-
psphot/src/psphotExtendedSources.c (modified) (1 diff)
-
psphot/src/psphotFindDetections.c (modified) (1 diff)
-
psphot/src/psphotFindFootprints.c (modified) (1 diff)
-
psphot/src/psphotFitSet.c (modified) (1 diff)
-
psphot/src/psphotFitSourcesLinear.c (modified) (6 diffs)
-
psphot/src/psphotGuessModels.c (modified) (3 diffs)
-
psphot/src/psphotIsophotal.c (modified) (1 diff)
-
psphot/src/psphotKron.c (modified) (1 diff)
-
psphot/src/psphotMagnitudes.c (modified) (1 diff)
-
psphot/src/psphotMakeGrowthCurve.c (modified) (1 diff)
-
psphot/src/psphotMakeResiduals.c (modified) (13 diffs)
-
psphot/src/psphotMaskReadout.c (modified) (1 diff)
-
psphot/src/psphotModelBackground.c (modified) (1 diff)
-
psphot/src/psphotModelTest.c (modified) (1 diff)
-
psphot/src/psphotModelWithPSF.c (modified) (9 diffs)
-
psphot/src/psphotMosaicChip.c (modified) (1 diff)
-
psphot/src/psphotOutput.c (modified) (6 diffs)
-
psphot/src/psphotPSFConvModel.c (modified) (4 diffs)
-
psphot/src/psphotPetrosian.c (modified) (1 diff)
-
psphot/src/psphotRadialPlot.c (modified) (1 diff)
-
psphot/src/psphotRadialProfile.c (modified) (2 diffs)
-
psphot/src/psphotRadiusChecks.c (modified) (3 diffs)
-
psphot/src/psphotReplaceUnfit.c (modified) (6 diffs)
-
psphot/src/psphotRoughClass.c (modified) (1 diff)
-
psphot/src/psphotSetMaskBits.c (modified) (2 diffs)
-
psphot/src/psphotSignificanceImage.c (modified) (2 diffs)
-
psphot/src/psphotSkyReplace.c (modified) (1 diff)
-
psphot/src/psphotSourceFits.c (modified) (5 diffs)
-
psphot/src/psphotSourcePlots.c (modified) (1 diff)
-
psphot/src/psphotSourceSize.c (modified) (13 diffs)
-
psphot/src/psphotSourceStats.c (modified) (2 diffs)
-
psphot/src/psphotSubtractBackground.c (modified) (1 diff)
-
psphot/src/psphotTestPSF.c (modified) (1 diff)
-
psphot/src/psphotTestSourceOutput.c (modified) (1 diff)
-
psphot/src/psphotVisual.c (modified) (6 diffs)
-
pswarp/src/pswarpLoop.c (modified) (1 diff)
-
pswarp/src/pswarpPixelFraction.c (modified) (3 diffs)
-
pswarp/src/pswarpSetMaskBits.c (modified) (6 diffs)
-
pswarp/src/pswarpTransformReadout.c (modified) (2 diffs)
-
pswarp/src/pswarpTransformTile.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppArith/src/ppArithReadout.c
r15597 r21183 26 26 outImage = output->mask; 27 27 if (!outImage) { 28 output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_ MASK);28 output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_IMAGE_MASK); 29 29 } 30 30 if (!output->image) { … … 37 37 outImage = output->image; 38 38 if (!outImage) { 39 output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_ MASK);39 output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_IMAGE_MASK); 40 40 } 41 41 } -
trunk/ppImage/src/ppImage.h
r20774 r21183 58 58 59 59 // make values for abstract concepts of masking 60 ps MaskType maskValue; // apply this bit-mask to choose masked bits61 ps MaskType markValue; // apply this bit-mask to choose masked bits62 ps MaskType satMask; // Mask value to give saturated pixels63 ps MaskType badMask; // Mask value to give bad pixels64 ps MaskType flatMask; // Mask value to give bad flat pixels65 ps MaskType blankMask; // Mask value to give blank pixels60 psImageMaskType maskValue; // apply this bit-mask to choose masked bits 61 psImageMaskType markValue; // apply this bit-mask to choose masked bits 62 psImageMaskType satMask; // Mask value to give saturated pixels 63 psImageMaskType badMask; // Mask value to give bad pixels 64 psImageMaskType flatMask; // Mask value to give bad flat pixels 65 psImageMaskType blankMask; // Mask value to give blank pixels 66 66 67 67 // non-linear correction parameters -
trunk/ppImage/src/ppImageCleanup.c
r19928 r21183 23 23 // fprintf (stderr, "Found %d leaks at %s\n", Nleaks, "ppImage"); 24 24 25 fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage"); 25 // fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage"); 26 fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppImage"); 26 27 27 28 return; -
trunk/ppImage/src/ppImageLoop.c
r20771 r21183 126 126 } 127 127 128 // measure various statistics for this image128 // measure various pixel-based statistics for this image 129 129 if (!ppImagePixelStats(config, stats, options, view)) { 130 ESCAPE("Unable to measures stats for image");130 ESCAPE("Unable to measures pixel stats for image"); 131 131 } 132 132 if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) { … … 209 209 } 210 210 211 // Write out summary statistics211 // Calculate summary statistics from FPA Metadata 212 212 if (!ppImageMetadataStats(config, stats, options)) { 213 ESCAPE("Unable to write statistics file.");213 ESCAPE("Unable to determine FPA-level metadata statistics."); 214 214 } 215 215 … … 218 218 ESCAPE("save failure for FPA"); 219 219 } 220 221 220 psFree(view); 222 221 … … 230 229 } 231 230 } 231 psFree (stats); 232 232 233 233 return true; -
trunk/ppImage/src/ppImageReplaceBackground.c
r20863 r21183 30 30 // XXX Should this be options->maskValue or options->maskValue & ~options->satMask? 31 31 // The latter will leave saturated pixels high 32 ps MaskType maskVal = options->maskValue;32 psImageMaskType maskVal = options->maskValue; 33 33 34 34 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 35 psMetadataAdd U8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);35 psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal); 36 36 37 37 // Since we are working on a chip-mosaicked image, there should only be a single cell and readout … … 146 146 if (!isfinite(value)) { 147 147 image->data.F32[y][x] = NAN; 148 mask->data.PS_TYPE_ MASK_DATA[y][x] |= options->badMask;148 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->badMask; 149 149 } else { 150 150 image->data.F32[y][x] -= value; … … 157 157 for (int y = 0; y < numRows; y++) { 158 158 for (int x = 0; x < numCols; x++) { 159 if (mask && mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {159 if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 160 160 image->data.F32[y][x] = 0.0; 161 161 } else { … … 163 163 if (!isfinite(value)) { 164 164 image->data.F32[y][x] = NAN; 165 mask->data.PS_TYPE_ MASK_DATA[y][x] |= options->badMask;165 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->badMask; 166 166 } else { 167 167 image->data.F32[y][x] -= value; -
trunk/ppImage/src/ppImageSetMaskBits.c
r18556 r21183 38 38 39 39 // set maskValue and markValue in the psphot recipe 40 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);41 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);40 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue); 41 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue); 42 42 43 43 return true; -
trunk/ppMerge/src/ppMergeArguments.c
r21138 r21183 94 94 } \ 95 95 } \ 96 ps MaskType mask = pmConfigMask(str, config); \97 psMetadataAdd U8(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, mask); \96 psImageMaskType mask = pmConfigMask(str, config); \ 97 psMetadataAddImageMask(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, mask); \ 98 98 } 99 99 -
trunk/ppMerge/src/ppMergeLoop.c
r21139 r21183 38 38 39 39 // set the mask and mark bit values based on the named masks 40 ps MaskType maskVal;41 ps MaskType markVal;40 psImageMaskType maskVal; 41 psImageMaskType markVal; 42 42 if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) { 43 43 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); -
trunk/ppMerge/src/ppMergeLoop_Threaded.c
r21139 r21183 54 54 55 55 // set the mask and mark bit values based on the named masks 56 ps MaskType maskVal;57 ps MaskType markVal;56 psImageMaskType maskVal; 57 psImageMaskType markVal; 58 58 if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) { 59 59 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); … … 257 257 psArrayAdd(job->args, 1, psScalarAlloc(iter, PS_TYPE_S32)); 258 258 psArrayAdd(job->args, 1, psScalarAlloc(rej, PS_TYPE_F32)); 259 psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_ U8));259 psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_IMAGE_MASK)); 260 260 261 261 // call: pmDarkCombine(outCell, fileGroup->readouts, iter, rej, maskVal); … … 276 276 psArrayAdd(job->args, 1, psScalarAlloc(iter, PS_TYPE_S32)); 277 277 psArrayAdd(job->args, 1, psScalarAlloc(rej, PS_TYPE_F32)); 278 psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_ U8));278 psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_IMAGE_MASK)); 279 279 280 280 // call: pmShutterCorrectionGenerate(outRO, pattern, fileGroup->readouts, shutterRef, -
trunk/ppMerge/src/ppMergeMask.c
r18756 r21183 26 26 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask 27 27 28 ps MaskType markVal;29 ps MaskType maskValRaw;28 psImageMaskType markVal; 29 psImageMaskType maskValRaw; 30 30 if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) { 31 31 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); … … 34 34 35 35 char *maskOutName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE"); 36 ps MaskType maskValOut = pmConfigMaskGet (maskOutName, config);36 psImageMaskType maskValOut = pmConfigMaskGet (maskOutName, config); 37 37 if (!maskValOut) { 38 38 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value"); … … 137 137 int x = pixel % numCols; 138 138 int y = pixel / numCols; 139 if (mask && (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskValRaw)) continue;140 if (outMask && (outMask->data.PS_TYPE_ MASK_DATA[y][x] & maskValOut)) continue;139 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue; 140 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue; 141 141 if (!isfinite(image->data.F32[y][x])) continue; 142 142 -
trunk/ppMerge/src/ppMergeScaleZero.c
r18930 r21183 80 80 pmReadout *readout = cell->readouts->data[0]; // Readout of interest 81 81 82 ps MaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask82 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask 83 83 84 84 switch (type) { -
trunk/ppMerge/src/ppMergeSetThreads.c
r19299 r21183 29 29 psScalar *maskVal = job->args->data[4]; 30 30 31 bool status = pmDarkCombine(outCell, fileGroup->readouts, iter->data.S32, rej->data.F32, maskVal->data. U8);31 bool status = pmDarkCombine(outCell, fileGroup->readouts, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA); 32 32 33 33 // after we are done, tell the I/O system that this file group is done … … 49 49 psScalar *maskVal = job->args->data[7]; 50 50 51 bool status = pmShutterCorrectionGenerate(output, pattern, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data. U8);51 bool status = pmShutterCorrectionGenerate(output, pattern, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA); 52 52 53 53 // after we are done, tell the I/O system that this file group is done -
trunk/ppMerge/src/ppMergeThreadLauncher.c
r18839 r21183 60 60 psScalar *maskVal = job->args->data[6]; 61 61 62 bool status = pmDarkCombine(outCell, fileGroup->readouts, darkOrdinates, darkNorm, iter->data.S32, rej->data.F32, maskVal->data. U8);62 bool status = pmDarkCombine(outCell, fileGroup->readouts, darkOrdinates, darkNorm, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA); 63 63 if (!status) { 64 64 self->fault = true; … … 82 82 psScalar *maskVal = job->args->data[6]; 83 83 84 bool status = pmShutterCorrectionGenerate(output, NULL, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data. U8);84 bool status = pmShutterCorrectionGenerate(output, NULL, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA); 85 85 if (!status) { 86 86 self->fault = true; -
trunk/ppSim/src/ppSim.h
r18011 r21183 130 130 bool ppSimInsertGalaxies (pmReadout *readout, psImage *expCorr, psArray *galaxies, pmConfig *config); 131 131 132 bool ppSimMosaicChip(pmConfig *config, const psMaskType blankMask, const pmFPAview *view, 133 const char *outFile, const char *inFile); 132 bool ppSimMosaicChip(pmConfig *config, const psImageMaskType blankMask, const pmFPAview *view, const char *outFile, const char *inFile); 134 133 135 134 bool ppSimPhotom (pmConfig *config, pmFPAview *view); -
trunk/ppSim/src/ppSimMosaicChip.c
r18712 r21183 2 2 3 3 // XXX this is essentially identical to ppImageMosaicChip 4 bool ppSimMosaicChip(pmConfig *config, const ps MaskType blankMask, const pmFPAview *view,4 bool ppSimMosaicChip(pmConfig *config, const psImageMaskType blankMask, const pmFPAview *view, 5 5 const char *outFile, const char *inFile) 6 6 { -
trunk/ppSim/src/ppSimPhotom.c
r20410 r21183 15 15 psphotInit (); 16 16 17 int blankMask = 0; // XXX not sure what this should be set to...17 psImageMaskType blankMask = 1; // XXX not sure what this should be set to... 18 18 ppSimMosaicChip(config, blankMask, view, "PPSIM.FORCE.CHIP", "PPSIM.INPUT"); 19 19 ppSimMosaicChip(config, blankMask, view, "PPSIM.FAKE.CHIP", "PPSIM.OUTPUT"); -
trunk/ppSim/src/ppSimPhotomReadout.c
r21170 r21183 96 96 97 97 // XXX fake sources should measure peak->x,y, force sources should not 98 ps MaskType maskVal = 0xff;98 psImageMaskType maskVal = 0xff; 99 99 psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal); 100 100 ppSimDetections (significance, recipe, fakeSources); -
trunk/ppSim/src/ppSimPhotomReadoutFake.c
r21170 r21183 76 76 77 77 // XXX fake sources should measure peak->x,y, force sources should not 78 ps MaskType maskVal = 0xff;78 psImageMaskType maskVal = 0xff; 79 79 psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal); 80 80 ppSimDetections (significance, recipe, fakeSources); -
trunk/ppSim/src/ppSimPhotomReadoutForce.c
r21170 r21183 69 69 70 70 // XXX fake sources should measure peak->x,y, force sources should not 71 ps MaskType maskVal = 0xff;71 psImageMaskType maskVal = 0xff; 72 72 psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal); 73 73 ppSimDetections (significance, recipe, forceSources); -
trunk/ppStack/src/ppStackArguments.c
r20995 r21183 79 79 } \ 80 80 } \ 81 ps MaskType value = pmConfigMaskGet(name, config); \82 psMetadataAdd U8(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \81 psImageMaskType value = pmConfigMaskGet(name, config); \ 82 psMetadataAddImageMask(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \ 83 83 } 84 84 -
trunk/ppStack/src/ppStackLoop.c
r21092 r21183 403 403 int numGood = 0; // Number of good frames 404 404 int numCols = 0, numRows = 0; // Size of image 405 psVector *inputMask = psVectorAlloc(num, PS_TYPE_ U8); // Mask for inputs405 psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs 406 406 psVectorInit(inputMask, 0); 407 407 psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching … … 449 449 sourceLists->data[i], targetPSF, rng, config)) { 450 450 psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i); 451 inputMask->data. U8[i] = PPSTACK_MASK_MATCH;451 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_MATCH; 452 452 psErrorClear(); 453 453 continue; … … 536 536 psVector *values = psVectorAllocEmpty(num, PS_TYPE_F32); // Values to sort 537 537 for (int i = 0; i < num; i++) { 538 if (inputMask->data.PS_TYPE_ MASK_DATA[i] & PPSTACK_MASK_ALL) {538 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) { 539 539 continue; 540 540 } … … 569 569 numGood = 0; // Number of good images 570 570 for (int i = 0; i < num; i++) { 571 if (inputMask->data.PS_TYPE_MASK_DATA[i] & PPSTACK_MASK_ALL) {571 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) { 572 572 continue; 573 573 } 574 574 if (matchChi2->data.F32[i] > thresh) { 575 575 numRej++; 576 inputMask->data.PS_TYPE_ MASK_DATA[i] |= PPSTACK_MASK_CHI2;576 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_CHI2; 577 577 psLogMsg("ppStack", PS_LOG_INFO, "Rejecting image %d because of large matching chi^2: %f", 578 578 i, matchChi2->data.F32[i]); … … 647 647 648 648 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad 649 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels649 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 650 650 if (!pmReadoutStackDefineOutput(outRO, col0, row0, numCols, numRows, true, true, maskBad)) { 651 651 psError(PS_ERR_UNKNOWN, false, "Unable to prepare output."); … … 728 728 inspect = psArrayAlloc(num); 729 729 for (int i = 0; i < num; i++) { 730 if (inputMask->data. U8[i]) {730 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 731 731 continue; 732 732 } … … 739 739 psArray *results = job->results; // Results of job 740 740 for (int i = 0; i < num; i++) { 741 if (inputMask->data. U8[i]) {741 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 742 742 continue; 743 743 } … … 765 765 // Count images rejected out of hand 766 766 for (int i = 0; i < num; i++) { 767 if (inputMask->data. U8[i]) {767 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 768 768 numRejected++; 769 769 } … … 771 771 772 772 for (int i = 0; i < num; i++) { 773 if (inputMask->data. U8[i]) {773 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 774 774 continue; 775 775 } … … 816 816 // Reject bad pixels 817 817 for (int i = 0; i < num; i++) { 818 if (inputMask->data. U8[i]) {818 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 819 819 continue; 820 820 } … … 859 859 psWarning("Rejection on image %d didn't work --- reject entire image.", i); 860 860 numRejected++; 861 inputMask->data. U8[i] = PPSTACK_MASK_REJECT;861 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_REJECT; 862 862 } else { 863 863 float frac = reject->n / (float)(numCols * numRows); // Pixel fraction … … 870 870 // reject == NULL means reject image completely 871 871 reject = NULL; 872 inputMask->data. U8[i] = PPSTACK_MASK_BAD;872 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_BAD; 873 873 numRejected++; 874 874 } … … 982 982 { 983 983 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad 984 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels984 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 985 985 if (!pmReadoutMaskApply(outRO, maskBad)) { 986 986 psWarning("Unable to apply mask"); … … 992 992 bool wcsDone = false; // Have we done the WCS? 993 993 for (int i = 0; i < num; i++) { 994 if (inputMask->data. U8[i]) {994 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 995 995 continue; 996 996 } … … 1056 1056 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG1"); 1057 1057 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG2"); 1058 ps MaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask1058 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 1059 1059 1060 1060 pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts … … 1078 1078 int renormNum = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); // Number of samples 1079 1079 float renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width of Gaussian phot 1080 ps MaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask1080 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 1081 1081 if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth, 1082 1082 renormMean, renormStdev, NULL)) { … … 1124 1124 psTrace("ppStack", 1, "Gathering statistics on stacked image....\n"); 1125 1125 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad 1126 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels1126 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 1127 1127 1128 1128 ppStatsFPA(stats, outRO->parent->parent->parent, view, maskBad, config); -
trunk/ppStack/src/ppStackMatch.c
r21021 r21183 104 104 105 105 // Generate a background model of the readout we're matching 106 psImage *stackBackgroundModel(pmReadout *ro, ps MaskType maskVal, const psArray *sources, int size)106 psImage *stackBackgroundModel(pmReadout *ro, psImageMaskType maskVal, const psArray *sources, int size) 107 107 { 108 108 psImage *image = ro->image, *mask = ro->mask; // Image and mask of readout … … 169 169 170 170 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in 171 ps MaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch171 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch 172 172 psString maskPoorStr = psMetadataLookupStr(NULL, recipe, "MASK.POOR"); // Name of bits to mask for poor 173 ps MaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels173 psImageMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels 174 174 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad 175 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels175 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 176 176 177 177 bool mdok; // Status of MD lookup -
trunk/ppStack/src/ppStackPhotometry.c
r20995 r21183 45 45 return false; 46 46 } 47 ps MaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask47 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask 48 48 49 49 psImage *image = ro->image, *mask = ro->mask; // Image and mask from readout … … 85 85 float dy2 = PS_SQR(y - v); // Distance from centroid 86 86 for (int u = xMin; u <= xMax; u++) { 87 if (mask->data.PS_TYPE_ MASK_DATA[v][u] & maskVal) {87 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[v][u] & maskVal) { 88 88 numBadPix++; 89 89 continue; … … 133 133 134 134 // set maskValue and markValue in the psphot recipe 135 ps MaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask136 ps MaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking137 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue);138 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for mark", markValue);135 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 136 psImageMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking 137 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue); 138 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for mark", markValue); 139 139 140 140 if (!psphotReadout(config, view)) { -
trunk/ppStack/src/ppStackReadout.c
r20884 r21183 114 114 115 115 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in 116 ps MaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch116 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch 117 117 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad 118 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels118 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 119 119 120 120 int num = readouts->n; // Number of inputs … … 141 141 // Ensure there is a mask, or pmStackCombine will complain 142 142 if (!ro->mask) { 143 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_ MASK);143 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK); 144 144 psImageInit(ro->mask, 0); 145 145 } … … 208 208 209 209 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in 210 ps MaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch210 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch 211 211 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad 212 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels212 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 213 213 214 214 int num = readouts->n; // Number of inputs … … 238 238 // Ensure there is a mask, or pmStackCombine will complain 239 239 if (!ro->mask) { 240 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_ MASK);240 ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK); 241 241 psImageInit(ro->mask, 0); 242 242 } -
trunk/ppStack/src/ppStackSources.c
r21092 r21183 109 109 psVectorInit(mag, NAN); 110 110 for (int j = 0; j < match->num; j++) { 111 if (match->mask->data.PS_TYPE_ MASK_DATA[j]) {111 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 112 112 continue; 113 113 } -
trunk/ppStats/src/ppStats.h
r19626 r21183 24 24 bool doFirstReadout3D; // for 3D data, use the first readout? 25 25 float sample; // Fraction of cell to sample for statistics 26 ps MaskType maskVal;// Mask value for images26 psImageMaskType maskVal; // Mask value for images 27 27 psList *chips; // Chips to look at 28 28 psList *cells; // Cells to look at … … 45 45 pmFPA *fpa, // FPA for which to get statistics 46 46 pmFPAview *view, // View for analysis 47 ps MaskType maskVal, // Value to mask47 psImageMaskType maskVal, // Value to mask 48 48 pmConfig *config // Configuration 49 49 ); … … 77 77 pmFPA *fpa, // FPA for which to get statistics 78 78 pmFPAview *view, // View for analysis 79 ps MaskType maskVal, // Value to mask79 psImageMaskType maskVal, // Value to mask 80 80 pmConfig *config // Configuration 81 81 ); … … 85 85 pmFPA *fpa, // FPA for which to get statistics 86 86 pmFPAview *view, // View for analysis 87 ps MaskType maskVal, // Value to mask87 psImageMaskType maskVal, // Value to mask 88 88 pmConfig *config // Configuration 89 89 ); -
trunk/ppStats/src/ppStatsFPA.c
r18558 r21183 4 4 pmFPA *fpa, // FPA for which to get statistics 5 5 pmFPAview *view, // View for analysis 6 ps MaskType maskVal, // Value to mask6 psImageMaskType maskVal, // Value to mask 7 7 pmConfig *config // Configuration 8 8 ) -
trunk/ppStats/src/ppStatsMetadata.c
r18558 r21183 5 5 pmFPA *fpa, // FPA for which to get statistics 6 6 pmFPAview *view, // View for analysis 7 ps MaskType maskVal, // Value to mask7 psImageMaskType maskVal, // Value to mask 8 8 pmConfig *config // Configuration 9 9 ) -
trunk/ppStats/src/ppStatsPixels.c
r18558 r21183 5 5 pmFPA *fpa, // FPA for which to get statistics 6 6 pmFPAview *view, // View for analysis 7 ps MaskType maskVal, // Value to mask7 psImageMaskType maskVal, // Value to mask 8 8 pmConfig *config // Configuration 9 9 ) -
trunk/ppStats/src/ppStatsReadout.c
r19355 r21183 63 63 int sampleSpace = 1.0 / data->sample; // Space between samples 64 64 psVector *sampleValues = psVectorAlloc(numSamples, PS_TYPE_F32); // Vector of samples 65 psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_MASK); // Corresponding mask 66 if (!mask) { 67 psVectorInit(sampleMask, 0); 68 } 65 psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_VECTOR_MASK); // Corresponding mask 66 psVectorInit(sampleMask, 0); 67 69 68 for (int i = 0; i < numSamples; i++) { 70 69 int j = i * sampleSpace; … … 72 71 int x = j % image->numCols; 73 72 sampleValues->data.F32[i] = image->data.F32[y][x]; 74 if ((!mask || !(mask->data.PS_TYPE_MASK_DATA[y][x] & data->maskVal)) && 75 !isfinite(sampleValues->data.F32[i])) { 76 if (!warnNonFinite) { 77 psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings", 78 x, y); 79 warnNonFinite = true; 80 } 81 sampleMask->data.PS_TYPE_MASK_DATA[i] = data->maskVal; 82 } else if (mask) { 83 sampleMask->data.PS_TYPE_MASK_DATA[i] = mask->data.PS_TYPE_MASK_DATA[y][x]; 84 } 85 } 86 if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, data->maskVal)) { 73 74 // ignore the sampleMask if there is no input mask 75 if (!mask) continue; 76 77 // if this pixel is masked, set the sample mask 78 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & data->maskVal) { 79 sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 80 continue; 81 } 82 83 // mask any unmasked NAN/INF values 84 if (!isfinite(sampleValues->data.F32[i])) { 85 // warn for the first unmasked NAN/INF value 86 if (!warnNonFinite) { 87 psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings", x, y); 88 warnNonFinite = true; 89 } 90 sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1; 91 } 92 } 93 if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, 1)) { 87 94 psWarning("Unable to perform statistics on readout %s.\n", readoutName); 88 95 psErrorClear(); … … 179 186 for (int j = 0; j < readout->mask->numRows; j++) { 180 187 for (int i = 0; i < readout->mask->numCols; i++) { 181 if (readout->mask->data.PS_TYPE_ MASK_DATA[j][i] & data->maskVal) {188 if (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & data->maskVal) { 182 189 numBad++; 183 190 } -
trunk/ppSub/src/ppSubArguments.c
r20568 r21183 216 216 psMetadataAddF32(arguments, PS_LIST_TAIL, "-rej", 0, "Rejection thresold (sigma)", NAN); 217 217 psMetadataAddF32(arguments, PS_LIST_TAIL, "-sys", 0, "Relative systematic error in kernel", NAN); 218 psMetadataAdd U8(arguments, PS_LIST_TAIL, "-mask-bad", 0, "Mask value for bad pixels", 0);219 psMetadataAdd U8(arguments, PS_LIST_TAIL, "-mask-poor", 0, "Mask value for poor pixels", 0);218 psMetadataAddImageMask(arguments, PS_LIST_TAIL, "-mask-bad", 0, "Mask value for bad pixels", 0); 219 psMetadataAddImageMask(arguments, PS_LIST_TAIL, "-mask-poor", 0, "Mask value for poor pixels", 0); 220 220 psMetadataAddF32(arguments, PS_LIST_TAIL, "-poor-frac", 0, "Fraction of weight for poor pixels", NAN); 221 221 psMetadataAddF32(arguments, PS_LIST_TAIL, "-badfrac", 0, "Maximum fraction of bad pixels to accept", 1.0); -
trunk/ppSub/src/ppSubBackground.c
r20775 r21183 30 30 31 31 psString maskBadStr = psMetadataLookupStr(NULL, ppSubRecipe, "MASK.BAD"); // Name of bits to mask for bad 32 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels32 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 33 33 34 34 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 35 psMetadataAdd U8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);35 psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad); 36 36 37 37 psImage *image = ro->image, *mask = ro->mask; // Image and mask of interest … … 59 59 for (int y = 0; y < numRows; y++) { 60 60 for (int x = 0; x < numCols; x++) { 61 if (mask && mask->data.PS_TYPE_ MASK_DATA[y][x] & maskBad) {61 if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskBad) { 62 62 image->data.F32[y][x] = 0.0; 63 63 } else { … … 65 65 if (!isfinite(value)) { 66 66 image->data.F32[y][x] = NAN; 67 mask->data.PS_TYPE_ MASK_DATA[y][x] |= maskBad;67 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskBad; 68 68 } else { 69 69 image->data.F32[y][x] -= value; -
trunk/ppSub/src/ppSubReadout.c
r21024 r21183 103 103 float penalty = psMetadataLookupF32(NULL, recipe, "PENALTY"); // Penalty for wideness 104 104 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.IN"); // Name of bits to mask going in 105 ps MaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch105 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch 106 106 psString maskPoorStr = psMetadataLookupStr(NULL, recipe, "MASK.POOR"); // Name of bits to mask for poor 107 ps MaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels107 psImageMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels 108 108 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad 109 ps MaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels109 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 110 110 float badFrac = psMetadataLookupF32(NULL, recipe, "BADFRAC"); // Maximum bad fraction 111 111 const char *stampsName = psMetadataLookupStr(&mdok, config->arguments, "STAMPS"); // Filename for stamps … … 146 146 pmReadoutSetMask(inRO, pmConfigMaskGet("SAT", config), pmConfigMaskGet("BAD", config)); 147 147 } else { 148 inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);148 inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 149 149 psImageInit(inRO->mask, 0); 150 150 } … … 154 154 pmReadoutSetMask(refRO, pmConfigMaskGet("SAT", config), pmConfigMaskGet("BAD", config)); 155 155 } else { 156 refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);156 refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 157 157 psImageInit(refRO->mask, 0); 158 158 } … … 363 363 } 364 364 if (minuend->mask) { 365 outRO->mask = psImageCopy(outRO->mask, minuend->mask, PS_TYPE_ MASK);365 outRO->mask = psImageCopy(outRO->mask, minuend->mask, PS_TYPE_IMAGE_MASK); 366 366 } 367 367 outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true; 368 368 369 369 if (psMetadataLookupBool(&mdok, recipe, "RENORM")) { 370 ps MaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask370 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 371 371 if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth, 372 372 renormMean, renormStdev, NULL)) { … … 399 399 400 400 // set maskValue and markValue in the psphot recipe 401 ps MaskType maskValue = maskVal;402 ps MaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking403 psMetadataAdd U8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue);404 psMetadataAdd U8(psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for marking",401 psImageMaskType maskValue = maskVal; 402 psImageMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking 403 psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue); 404 psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for marking", 405 405 markValue); 406 406 … … 477 477 for (int y = 0; y < outRO->image->numRows; y++) { 478 478 for (int x = 0; x < outRO->image->numCols; x++) { 479 if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data. U8[y][x] & maskVal)) {480 printf("Unmasked NAN at %d %d --> %d\n", x, y, outRO->mask->data. U8[y][x]);479 if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) { 480 printf("Unmasked NAN at %d %d --> %d\n", x, y, outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]); 481 481 } 482 482 } … … 568 568 569 569 if (psMetadataLookupBool(&mdok, recipe, "RENORM")) { 570 ps MaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask570 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 571 571 if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth, 572 572 renormMean, renormStdev, NULL)) { … … 669 669 // Renormalising for pixels, because that's what magic desires 670 670 if (psMetadataLookupBool(&mdok, recipe, "RENORM")) { 671 ps MaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask671 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 672 672 if (!pmReadoutWeightRenormPixels(outRO, maskValue, renormMean, renormStdev, NULL)) { 673 673 psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances."); -
trunk/psLib/src/fft/psImageFFT.c
r20566 r21183 6 6 /// @author Robert DeSonia, MHPCC 7 7 /// 8 /// @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $9 /// @date $Date: 200 8-11-06 23:36:20$8 /// @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 9 /// @date $Date: 2009-01-27 06:39:37 $ 10 10 /// 11 11 /// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 318 318 319 319 320 psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, ps MaskType maskVal,320 psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, psImageMaskType maskVal, 321 321 const psKernel *kernel) 322 322 { … … 326 326 if (mask) { 327 327 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 328 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);328 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 329 329 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, in, NULL); 330 330 } … … 464 464 for (int y = 0; y < numRows; y++) { 465 465 for (int x = 0; x < numCols; x++) { 466 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {466 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 467 467 data[x + paddedCols * y] = 0; 468 468 } -
trunk/psLib/src/fft/psImageFFT.h
r17320 r21183 5 5 /// @author Robert DeSonia, MHPCC 6 6 /// 7 /// @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 /// @date $Date: 200 8-04-04 22:44:56$7 /// @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 /// @date $Date: 2009-01-27 06:39:37 $ 9 9 /// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 10 10 /// … … 70 70 const psImage *in, ///< Image to convolve 71 71 const psImage *mask, ///< Corresponding mask 72 ps MaskType maskVal,///< Value to mask72 psImageMaskType maskVal, ///< Value to mask 73 73 const psKernel *kernel ///< kernel to colvolve with 74 74 ); -
trunk/psLib/src/fits/psFitsImage.c
r19384 r21183 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.4 0$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-09-05 08:08:33$9 * @version $Revision: 1.41 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 251 251 const psImage *image, // Image to convert 252 252 const psImage *mask, // Mask image, or NULL 253 ps MaskType maskVal, // Value to mask253 psImageMaskType maskVal, // Value to mask 254 254 psRandom *rng, // Random number generator 255 255 bool newScaleZero // Determine a new BSCALE and BZERO? … … 506 506 507 507 bool psFitsWriteImageWithMask(psFits *fits, psMetadata *header, const psImage *input, 508 const psImage *mask, ps MaskType maskVal, int numZPlanes,508 const psImage *mask, psImageMaskType maskVal, int numZPlanes, 509 509 const char *extname) 510 510 { … … 525 525 526 526 bool psFitsInsertImageWithMask(psFits *fits, psMetadata *header, const psImage *image, 527 const psImage *mask, ps MaskType maskVal, int numZPlanes,527 const psImage *mask, psImageMaskType maskVal, int numZPlanes, 528 528 const char *extname, bool after) 529 529 { … … 532 532 PS_ASSERT_IMAGE_NON_NULL(image, false); 533 533 if (mask) { 534 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);534 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 535 535 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false); 536 536 } … … 706 706 } 707 707 708 bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, ps MaskType maskVal,708 bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, psImageMaskType maskVal, 709 709 int x0, int y0, int z) 710 710 { … … 713 713 PS_ASSERT_IMAGE_NON_NULL(input, false); 714 714 if (mask) { 715 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);715 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 716 716 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, input, false); 717 717 } … … 896 896 897 897 bool psFitsWriteImageCubeWithMask(psFits *fits, psMetadata *header, const psArray *input, 898 const psArray *masks, ps MaskType maskVal, const char *extname)898 const psArray *masks, psImageMaskType maskVal, const char *extname) 899 899 { 900 900 PS_ASSERT_FITS_NON_NULL(fits, false); … … 976 976 977 977 bool psFitsUpdateImageCubeWithMask(psFits *fits, const psArray *input, 978 const psArray *masks, ps MaskType maskVal, int x0, int y0)978 const psArray *masks, psImageMaskType maskVal, int x0, int y0) 979 979 { 980 980 PS_ASSERT_FITS_NON_NULL(fits, false); -
trunk/psLib/src/fits/psFitsImage.h
r19384 r21183 4 4 * @author Robert DeSonia, MHPCC 5 5 * 6 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-09-05 08:08:33$6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:37 $ 8 8 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 74 74 const psImage *input, ///< the image to output 75 75 const psImage *mask, ///< the mask image 76 ps MaskType maskVal,///< value to mask76 psImageMaskType maskVal, ///< value to mask 77 77 int depth, ///< the number of z-planes of the FITS image data cube 78 78 const char *extname ///< FITS extension name … … 101 101 const psImage *input, ///< the image to output 102 102 const psImage *mask, ///< the mask image 103 ps MaskType maskVal,///< value to mask103 psImageMaskType maskVal, ///< value to mask 104 104 int depth, ///< the number of z-planes of the FITS image data cube 105 105 const char *extname, ///< FITS extension name … … 128 128 const psImage *input, ///< the image to output 129 129 const psImage *mask, ///< the mask image 130 ps MaskType maskVal,///< value to mask130 psImageMaskType maskVal, ///< value to mask 131 131 int x0, ///< psImage's x-axis origin in FITS image coordinates 132 132 int y0, ///< psImage's y-axis origin in FITS image coordinates … … 157 157 const psArray *input, ///< Array of images 158 158 const psArray *masks, ///< Array of masks 159 ps MaskType maskVal,///< Value to mask159 psImageMaskType maskVal, ///< Value to mask 160 160 const char *extname ///< Name of extension 161 161 ); … … 175 175 const psArray *input, ///< Array of images 176 176 const psArray *masks, ///< Array of masks 177 ps MaskType maskVal,///< Value to mask177 psImageMaskType maskVal, ///< Value to mask 178 178 int x0, ///< x origin of images in FITS image coordinates 179 179 int y0 ///< y origin of images in FITS image coordinates -
trunk/psLib/src/fits/psFitsScale.c
r19383 r21183 100 100 const psImage *image, // Image to scale 101 101 const psImage *mask, // Mask image 102 ps MaskType maskVal, // Value to mask102 psImageMaskType maskVal, // Value to mask 103 103 const psFitsOptions *options // FITS options 104 104 ) … … 167 167 168 168 bool psFitsScaleDetermine(double *bscale, double *bzero, long *blank, const psImage *image, 169 const psImage *mask, ps MaskType maskVal, const psFits *fits)169 const psImage *mask, psImageMaskType maskVal, const psFits *fits) 170 170 { 171 171 PS_ASSERT_PTR_NON_NULL(bscale, false); … … 174 174 PS_ASSERT_IMAGE_NON_NULL(image, false); 175 175 if (mask) { 176 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);176 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 177 177 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false); 178 178 } -
trunk/psLib/src/fits/psFitsScale.h
r19383 r21183 13 13 const psImage *image, ///< Image to scale 14 14 const psImage *mask, ///< Mask image 15 ps MaskType maskVal, ///< Value to mask15 psImageMaskType maskVal, ///< Value to mask 16 16 const psFits *fits ///< FITS options 17 17 ); -
trunk/psLib/src/imageops/psImageBackground.c
r20216 r21183 18 18 // XXX allow the user to choose the stats method? 19 19 // (SAMPLE_MEAN, CLIPPED_MEAN, ROBUST_MEDIAN, FITTED_MEAN) 20 bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, ps MaskType maskValue, psRandom *rng)20 bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psImageMaskType maskValue, psRandom *rng) 21 21 { 22 22 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 23 23 if (mask) { 24 24 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 25 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ U8, NULL);25 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 26 26 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, NULL); 27 27 } … … 63 63 int iy = pixel / nx; 64 64 65 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data. U8[iy][ix] & maskValue)) {65 if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) { 66 66 continue; 67 67 } -
trunk/psLib/src/imageops/psImageBackground.h
r16115 r21183 5 5 * @author EAM, IfA 6 6 * 7 * $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * $Date: 200 8-01-17 22:07:33$7 * $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * $Date: 2009-01-27 06:39:37 $ 9 9 * Copyright 2004-2005 IfA, University of Hawaii 10 10 */ … … 27 27 const psImage *image, // Image for which to get the background 28 28 const psImage *mask, // Mask image 29 ps MaskType maskValue, // Mask pixels which this mask value29 psImageMaskType maskValue, // Mask pixels which this mask value 30 30 psRandom *rng // Random number generator (for pixel selection) 31 31 ); -
trunk/psLib/src/imageops/psImageConvolve.c
r20830 r21183 7 7 /// @author Eugene Magnier, IfA 8 8 /// 9 /// @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $10 /// @date $Date: 200 8-11-26 00:43:12$9 /// @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2009-01-27 06:39:37 $ 11 11 /// 12 12 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 319 319 } 320 320 321 psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, ps MaskType maskVal,322 ps MaskType setVal, int xMin, int xMax, int yMin, int yMax)321 psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psImageMaskType maskVal, 322 psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax) 323 323 { 324 324 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 325 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);325 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 326 326 if (out == mask && ((maskVal & setVal) || !setVal)) { 327 327 psError(PS_ERR_BAD_PARAMETER_VALUE, true, … … 352 352 if (!out) { 353 353 // Propagate the non-masked values 354 out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_ MASK));354 out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_IMAGE_MASK)); 355 355 } 356 356 357 357 // Dereference mask images 358 ps MaskType **maskData = mask->data.PS_TYPE_MASK_DATA;359 ps MaskType **outData = out->data.PS_TYPE_MASK_DATA;358 psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; 359 psImageMaskType **outData = out->data.PS_TYPE_IMAGE_MASK_DATA; 360 360 361 361 if (setVal) { … … 376 376 for (int row = 0; row < numRows; row++) { 377 377 for (int col = 0; col < numCols; col++) { 378 ps MaskType pixel = outData[row][col]; // Pixel value to set378 psImageMaskType pixel = outData[row][col]; // Pixel value to set 379 379 if (pixel & maskVal) { 380 380 // Already done this one … … 395 395 396 396 397 psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, ps MaskType maskVal,398 ps MaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)397 psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psImageMaskType maskVal, 398 psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh) 399 399 { 400 400 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 401 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);401 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 402 402 PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, NULL); 403 403 PS_ASSERT_FLOAT_LESS_THAN(thresh, 1.0, NULL); … … 431 431 for (int y = 0; y < numRows; y++) { 432 432 for (int x = 0; x < numCols; x++) { 433 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {433 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 434 434 onoff->data.F32[y][x] = 1.0; 435 435 } … … 452 452 453 453 if (!out) { 454 out = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);454 out = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 455 455 } 456 456 for (int y = 0; y < numRows; y++) { 457 457 for (int x = 0; x < numCols; x++) { 458 out->data.PS_TYPE_ MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?459 (mask->data.PS_TYPE_ MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_MASK_DATA[y][x];458 out->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ? 459 (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 460 460 } 461 461 } … … 651 651 case PS_TYPE_##TYPE: { \ 652 652 psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_##TYPE); /* Calculation image; BW */ \ 653 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_ MASK); /* Mask for calculation image; BW */ \653 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ \ 654 654 \ 655 655 /** Smooth in X direction **/ \ … … 658 658 int xMin = PS_MAX(i - size, 0); \ 659 659 int xMax = PS_MIN(i + size, xLast); \ 660 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin]; \660 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; \ 661 661 const ps##TYPE *imageData = &image->data.TYPE[j][xMin]; \ 662 662 int uMin = - PS_MIN(i, size); /* Minimum kernel index */ \ … … 673 673 /* BW */ \ 674 674 calculation->data.TYPE[i][j] = sumIG / sumG; \ 675 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0; \675 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; \ 676 676 } else { \ 677 677 /* BW */ \ 678 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0xFF; \678 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; \ 679 679 } \ 680 680 } \ … … 688 688 int yMin = PS_MAX(j - size, 0); \ 689 689 int yMax = PS_MIN(j + size, yLast); \ 690 const ps MaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */ \690 const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ \ 691 691 const ps##TYPE *imageData = &calculation->data.TYPE[i][yMin]; /* BW */ \ 692 692 int vMin = - PS_MIN(j, size); /* Minimum kernel index */ \ … … 714 714 const psImage *image, 715 715 const psImage *mask, 716 ps MaskType maskVal,716 psImageMaskType maskVal, 717 717 float sigma, 718 718 float numSigma, … … 721 721 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 722 722 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 723 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);723 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 724 724 PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL); 725 725 … … 751 751 case PS_TYPE_F32: { 752 752 psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */ 753 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_ MASK); /* Mask for calculation image; BW */753 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ 754 754 755 755 /** Smooth in X direction **/ … … 758 758 int xMin = PS_MAX(i - size, 0); 759 759 int xMax = PS_MIN(i + size, xLast); 760 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];760 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; 761 761 const psF32 *imageData = &image->data.F32[j][xMin]; 762 762 int uMin = - PS_MIN(i, size); /* Minimum kernel index */ … … 776 776 /* BW */ 777 777 calculation->data.F32[i][j] = sumIG / sumG; 778 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0;778 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; 779 779 } else { 780 780 /* BW */ 781 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0xFF;781 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; 782 782 } 783 783 } … … 791 791 int yMin = PS_MAX(j - size, 0); 792 792 int yMax = PS_MIN(j + size, yLast); 793 const ps MaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */793 const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ 794 794 const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */ 795 795 int vMin = - PS_MIN(j, size); /* Minimum kernel index */ … … 832 832 const psImage *image, 833 833 const psImage *mask, 834 ps MaskType maskVal,834 psImageMaskType maskVal, 835 835 psVector *gaussNorm, 836 836 float minGauss, … … 848 848 int xMin = PS_MAX(i - size, 0); 849 849 int xMax = PS_MIN(i + size, xLast); 850 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];850 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; 851 851 const psF32 *imageData = &image->data.F32[j][xMin]; 852 852 int uMin = - PS_MIN(i, size); /* Minimum kernel index */ … … 863 863 /* BW */ 864 864 calculation->data.F32[i][j] = sumIG / sumG; 865 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0;865 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; 866 866 } else { 867 867 /* BW */ 868 calcMask->data.PS_TYPE_ MASK_DATA[i][j] = 0xFF;868 calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; 869 869 } 870 870 } … … 876 876 psImage *calculation, 877 877 psImage *calcMask, 878 ps MaskType maskVal,878 psImageMaskType maskVal, 879 879 psVector *gaussNorm, 880 880 float minGauss, … … 892 892 int yMin = PS_MAX(j - size, 0); 893 893 int yMax = PS_MIN(j + size, yLast); 894 const ps MaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */894 const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ 895 895 const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */ 896 896 int vMin = - PS_MIN(j, size); /* Minimum kernel index */ … … 921 921 const psImage *mask = job->args->data[3]; // input mask 922 922 923 ps MaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],U8);923 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 924 924 psVector *gaussNorm = job->args->data[5]; // gauss kernel 925 925 float minGauss = PS_SCALAR_VALUE(job->args->data[6],F32); … … 941 941 psImage *calculation = job->args->data[1]; // calculation image 942 942 psImage *calcMask = job->args->data[2]; // calculation mask 943 ps MaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],U8);943 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 944 944 945 945 psVector *gaussNorm = job->args->data[4]; // gauss kernel … … 956 956 const psImage *image, 957 957 const psImage *mask, 958 ps MaskType maskVal,958 psImageMaskType maskVal, 959 959 float sigma, 960 960 float numSigma, … … 963 963 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 964 964 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 965 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);965 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 966 966 PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL); 967 967 … … 999 999 case PS_TYPE_F32: { 1000 1000 psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */ 1001 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_ MASK); /* Mask for calculation image; BW */1001 psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ 1002 1002 1003 1003 /** Smooth in X direction **/ … … 1011 1011 psArrayAdd(job->args, 1, (psImage *) image); // cast away const 1012 1012 psArrayAdd(job->args, 1, (psImage *) mask); // cast away const 1013 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ U8);1013 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 1014 1014 psArrayAdd(job->args, 1, gaussNorm); 1015 1015 PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32); … … 1046 1046 psArrayAdd(job->args, 1, calculation); 1047 1047 psArrayAdd(job->args, 1, calcMask); 1048 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ U8);1048 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 1049 1049 psArrayAdd(job->args, 1, gaussNorm); 1050 1050 PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32); … … 1091 1091 bool psImageSmoothMaskF32 (psImage *image, 1092 1092 psImage *mask, 1093 ps MaskType maskVal,1093 psImageMaskType maskVal, 1094 1094 double sigma, 1095 1095 double Nsigma) … … 1122 1122 psVector *calculation = psVectorAlloc(Nx, PS_TYPE_F32); 1123 1123 for (int j = 0; j < Ny; j++) { 1124 ps U8 *vm = mask->data.U8[j];1124 psImageMaskType *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[j]; 1125 1125 psF32 *vi = image->data.F32[j]; 1126 1126 psF32 *vo = calculation->data.F32; … … 1128 1128 for (int i = 0; i < Nx; i++, vi++, vo++, vm++) { 1129 1129 int offset = PS_MIN (i, Nrange); 1130 ps U8*sm = vm - offset;1130 psImageMaskType *sm = vm - offset; 1131 1131 psF32 *si = vi - offset; 1132 1132 psF32 *sg = gauss - offset; … … 1171 1171 int yMax = PS_MIN (j + Nrange + 1, Ny); 1172 1172 for (int n = yMin; n < yMax; n++) { 1173 ps U8 *vm = mask->data.U8[n];1173 psImageMaskType *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[n]; 1174 1174 psF32 *vi = image->data.F32[n]; 1175 1175 psF32 *vo = output->data.F32; … … 1214 1214 const psImage *input, // Input image 1215 1215 int start, int stop, // Range of rows 1216 ps MaskType maskVal, // Value to mask; NOTE subtle difference!1216 psImageMaskType maskVal, // Value to mask; NOTE subtle difference! 1217 1217 int xMin, int xMax // Range in x for kernel 1218 1218 ) 1219 1219 { 1220 1220 // Dereference mask images 1221 ps MaskType **inputData = input->data.PS_TYPE_MASK_DATA;1222 ps MaskType **targetData = target->data.PS_TYPE_MASK_DATA;1221 psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA; 1222 psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA; 1223 1223 1224 1224 int numCols = input->numCols; // Number of columns … … 1241 1241 min = PS_MAX(0, min); 1242 1242 max = PS_MIN(numCols - 1, max); 1243 memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1243 memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1244 1244 } 1245 1245 } … … 1247 1247 // Mask from the minimum to the end of the row 1248 1248 min = PS_MAX(0, min); 1249 memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1249 memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1250 1250 } 1251 1251 } … … 1256 1256 const psImage *input, // Input image 1257 1257 int start, int stop, // Range of rows 1258 ps MaskType setVal, // Value to set; NOTE subtle difference!1258 psImageMaskType setVal, // Value to set; NOTE subtle difference! 1259 1259 int yMin, int yMax // Range in y for kernel 1260 1260 ) 1261 1261 { 1262 1262 // Dereference mask images 1263 ps MaskType **inputData = input->data.PS_TYPE_MASK_DATA;1264 ps MaskType **targetData = target->data.PS_TYPE_MASK_DATA;1263 psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA; 1264 psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA; 1265 1265 1266 1266 int numRows = input->numRows; // Number of rows … … 1308 1308 int start = PS_SCALAR_VALUE(args->data[2], S32); // Row/col to start at 1309 1309 int stop = PS_SCALAR_VALUE(args->data[3], S32); // Row/col to stop at 1310 ps MaskType maskVal = PS_SCALAR_VALUE(args->data[4], U8); // Value to mask/set1310 psImageMaskType maskVal = PS_SCALAR_VALUE(args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Value to mask/set 1311 1311 int kernelMin = PS_SCALAR_VALUE(args->data[5], S32); // Minimum range for kernel 1312 1312 int kernelMax = PS_SCALAR_VALUE(args->data[6], S32); // Maximum range for kernel … … 1317 1317 } 1318 1318 1319 psImage *psImageConvolveMask(psImage *out, const psImage *mask, ps MaskType maskVal,1320 ps MaskType setVal, int xMin, int xMax, int yMin, int yMax)1319 psImage *psImageConvolveMask(psImage *out, const psImage *mask, psImageMaskType maskVal, 1320 psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax) 1321 1321 { 1322 1322 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 1323 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);1323 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 1324 1324 if (out) { 1325 1325 PS_ASSERT_IMAGE_NON_NULL(out, NULL); 1326 PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_ MASK, NULL);1326 PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_IMAGE_MASK, NULL); 1327 1327 PS_ASSERT_IMAGES_SIZE_EQUAL(out, mask, NULL); 1328 1328 if (out == mask && ((maskVal & setVal) || !setVal)) { … … 1354 1354 1355 1355 // Propagate the non-masked values 1356 out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_ MASK));1356 out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_IMAGE_MASK)); 1357 1357 1358 1358 if (!setVal) { … … 1360 1360 } 1361 1361 1362 psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_ MASK); // Temporary convolved image1362 psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Temporary convolved image 1363 1363 psImageInit(conv, 0); 1364 1364 … … 1377 1377 PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32); 1378 1378 PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32); 1379 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ MASK);1379 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 1380 1380 PS_ARRAY_ADD_SCALAR(job->args, xMin, PS_TYPE_S32); 1381 1381 PS_ARRAY_ADD_SCALAR(job->args, xMax, PS_TYPE_S32); … … 1415 1415 PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32); 1416 1416 PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32); 1417 PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_ MASK);1417 PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_IMAGE_MASK); 1418 1418 PS_ARRAY_ADD_SCALAR(job->args, yMin, PS_TYPE_S32); 1419 1419 PS_ARRAY_ADD_SCALAR(job->args, yMax, PS_TYPE_S32); … … 1460 1460 min = PS_MAX(0, min); 1461 1461 max = PS_MIN(numCols - 1, max); 1462 memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1462 memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1463 1463 } 1464 1464 } … … 1466 1466 // Mask from the minimum to the end of the row 1467 1467 min = PS_MAX(0, min); 1468 memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK));1468 memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK)); 1469 1469 } 1470 1470 } -
trunk/psLib/src/imageops/psImageConvolve.h
r20830 r21183 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-11-26 00:43:12$7 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:37 $ 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 148 148 psImage *psImageConvolveMask(psImage *out, ///< Output image, or NULL 149 149 const psImage *mask, ///< Mask to convolve 150 ps MaskType maskVal, ///< Mask value to convolve151 ps MaskType setVal, ///< Mask value to set; 0 to propagate maskVal150 psImageMaskType maskVal, ///< Mask value to convolve 151 psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal 152 152 int xMin, int xMax, int yMin, int yMax ///< Convolution bounds 153 153 ); … … 160 160 psImage *psImageConvolveMaskDirect(psImage *out, ///< Output image, or NULL 161 161 const psImage *mask, ///< Mask to convolve 162 ps MaskType maskVal, ///< Mask value to convolve163 ps MaskType setVal, ///< Mask value to set; 0 to propagate maskVal162 psImageMaskType maskVal, ///< Mask value to convolve 163 psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal 164 164 int xMin, int xMax, int yMin, int yMax ///< Convolution bounds 165 165 ); … … 174 174 psImage *psImageConvolveMaskFFT(psImage *out, ///< Output image, or NULL 175 175 const psImage *mask, ///< Mask to convolve 176 ps MaskType maskVal, ///< Mask value to convolve177 ps MaskType setVal, ///< Mask value to set; 0 to use maskVal176 psImageMaskType maskVal, ///< Mask value to convolve 177 psImageMaskType setVal, ///< Mask value to set; 0 to use maskVal 178 178 int xMin, int xMax, int yMin, int yMax, ///< Convolution bounds 179 179 float thresh ///< Threshold (0..1) for convolved floating-point image … … 201 201 const psImage *image, ///< Input image (F32 or F64) 202 202 const psImage *mask, ///< Mask image 203 ps MaskType maskVal,///< Mask value203 psImageMaskType maskVal, ///< Mask value 204 204 float sigma, ///< Width of the smoothing kernel (pixels) 205 205 float numSigma, ///< Size of the smoothing box (sigma) … … 211 211 const psImage *image, 212 212 const psImage *mask, 213 ps MaskType maskVal,213 psImageMaskType maskVal, 214 214 float sigma, 215 215 float numSigma, … … 219 219 psImage *image, ///< the image to be smoothed 220 220 psImage *mask, ///< optional mask 221 ps MaskType maskVal,221 psImageMaskType maskVal, ///< masked bits 222 222 double sigma, ///< the width of the smoothing kernel in pixels 223 223 double Nsigma ///< the size of the smoothing box in sigmas -
trunk/psLib/src/imageops/psImageGeomManip.c
r20299 r21183 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-10-21 22:10:53$12 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:37 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 const psImage* in, 40 40 const psImage* mask, 41 ps MaskType maskVal,41 psImageMaskType maskVal, 42 42 int scale, 43 43 const psStats* stats) … … 47 47 psS32 outRows; 48 48 psS32 outCols; 49 psVector *vec; // vector to hold the values of a single bin.50 psVector *maskVec = NULL; // vector to hold the mask of a single bin.51 ps MaskType*maskData = NULL;52 psStats *myStats;49 psVector *vec; // vector to hold the values of a single bin. 50 psVector *maskVec = NULL; // vector to hold the mask of a single bin. 51 psVectorMaskType *maskData = NULL; 52 psStats *myStats; 53 53 54 54 if (in == NULL) { … … 86 86 87 87 if (mask != NULL) { 88 if (mask->type.type != PS_TYPE_ MASK) {88 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 89 89 char* typeStr; 90 90 PS_TYPE_NAME(typeStr,mask->type.type); 91 91 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 92 92 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 93 typeStr, PS_TYPE_ MASK_NAME);93 typeStr, PS_TYPE_IMAGE_MASK_NAME); 94 94 psFree(out); 95 95 psFree(vec); 96 96 return NULL; 97 97 } 98 maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_ MASK);99 maskData = maskVec->data.PS_TYPE_ MASK_DATA;98 maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_VECTOR_MASK); 99 maskData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; 100 100 } 101 101 … … 114 114 ps##TYPE *outRowData; \ 115 115 ps##TYPE *vecData = vec->data.TYPE; \ 116 ps MaskType *inRowMask = NULL; \116 psImageMaskType *inRowMask = NULL; \ 117 117 for (psS32 row = 0; row < outRows; row++) { \ 118 118 outRowData = out->data.TYPE[row]; \ … … 126 126 ps##TYPE* inRowData = in->data.TYPE[inRow]; \ 127 127 if (mask != NULL) { \ 128 inRowMask = mask->data.PS_TYPE_ MASK_DATA[inRow]; \128 inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \ 129 129 } \ 130 130 for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \ 131 131 if (maskData != NULL) { \ 132 maskData[n] = inRowMask[inCol]; \132 maskData[n] = (inRowMask[inCol] & maskVal); \ 133 133 } \ 134 134 vecData[n++] = inRowData[inCol]; \ … … 139 139 maskVec->n = n; \ 140 140 } \ 141 psVectorStats(myStats, vec, NULL, maskVec, maskVal);\141 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \ 142 142 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \ 143 143 } \ … … 659 659 660 660 bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask, 661 ps MaskType maskVal, float dx, float dy, double exposed, psMaskType blank,661 psImageMaskType maskVal, float dx, float dy, double exposed, psImageMaskType blank, 662 662 psImageInterpolateMode mode) 663 663 { … … 667 667 PS_ASSERT_IMAGE_NON_NULL(inMask, false); 668 668 PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false); 669 PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_ MASK, false);669 PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_IMAGE_MASK, false); 670 670 } 671 671 … … 675 675 *out = psImageRecycle(*out, numCols, numRows, type); 676 676 if (outMask) { 677 *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_ MASK);677 *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_IMAGE_MASK); 678 678 } 679 679 … … 702 702 for (int row = 0; row < numRows; row++) { \ 703 703 ps##TYPE* outRow = (*out)->data.TYPE[row]; \ 704 ps MaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \704 psImageMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_IMAGE_MASK_DATA[row] : NULL); \ 705 705 float y = row + 0.5 - dy; \ 706 706 for (int col = 0; col < numCols; col++) { \ 707 707 float x = col + 0.5 - dx; \ 708 708 double value; \ 709 ps MaskType valueMask = 0; \709 psImageMaskType valueMask = 0; \ 710 710 if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \ 711 711 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \ … … 750 750 const psImage *input, 751 751 const psImage *inputMask, 752 ps MaskType inputMaskVal,752 psImageMaskType inputMaskVal, 753 753 const psPlaneTransform *outToIn, 754 754 psRegion region, … … 778 778 return NULL; 779 779 } 780 if (inputMask->type.type != PS_TYPE_ MASK) {780 if (inputMask->type.type != PS_TYPE_IMAGE_MASK) { 781 781 char* typeStr; 782 782 PS_TYPE_NAME(typeStr,inputMask->type.type); 783 783 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 784 784 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 785 typeStr, PS_TYPE_ MASK_NAME);785 typeStr, PS_TYPE_IMAGE_MASK_NAME); 786 786 psFree(output); 787 787 return NULL; -
trunk/psLib/src/imageops/psImageGeomManip.h
r16910 r21183 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-03-11 00:41:30$8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:37 $ 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 36 36 const psImage* in, ///< input image 37 37 const psImage* mask, ///< mask for input image. If NULL, no masking is done. 38 ps MaskType maskVal,///< the bits to check in mask.38 psImageMaskType maskVal, ///< the bits to check in mask. 39 39 int scale, ///< the scale to rebin for each dimension 40 40 const psStats* stats … … 106 106 const psImage* in, ///< Input image 107 107 const psImage *inMask, ///< Input mask, or NULL 108 ps MaskType maskVal,///< Value to mask108 psImageMaskType maskVal, ///< Value to mask 109 109 float dx, float dy, ///< Shift to apply 110 110 double exposed, ///< Value to give exposed pixels 111 ps MaskType blank,///< Mask value for exposed pixels111 psImageMaskType blank, ///< Mask value for exposed pixels 112 112 psImageInterpolateMode mode ///< Interpolation mode 113 113 ); … … 159 159 const psImage *input, ///< psImage to apply transform to 160 160 const psImage *inputMask, ///< if not NULL, mask of input psImage 161 ps MaskType inputMaskVal,///< masking value for inputMask161 psImageMaskType inputMaskVal, ///< masking value for inputMask 162 162 const psPlaneTransform *outToIn, ///< the transform to apply 163 163 psRegion region, ///< the size of the transformed image -
trunk/psLib/src/imageops/psImageInterpolate.c
r20758 r21183 7 7 * @author Paul Price, IfA 8 8 * 9 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-11-15 03:09:34$9 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 205 205 psImageInterpolation *psImageInterpolationAlloc(psImageInterpolateMode mode, 206 206 const psImage *image, const psImage *variance, 207 const psImage *mask, ps MaskType maskVal,207 const psImage *mask, psImageMaskType maskVal, 208 208 double badImage, double badVariance, 209 ps MaskType badMask, psMaskType poorMask,209 psImageMaskType badMask, psImageMaskType poorMask, 210 210 float poorFrac, int numKernels) 211 211 { … … 274 274 // Interpolation engine for flat mode (nearest pixel) 275 275 static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue, 276 ps MaskType *maskValue, float x, float y,276 psImageMaskType *maskValue, float x, float y, 277 277 const psImageInterpolation *interp) 278 278 { … … 331 331 if (maskValue) { 332 332 if (interp->mask) { 333 *maskValue = interp->mask->data.PS_TYPE_ MASK_DATA[yInt][xInt];333 *maskValue = interp->mask->data.PS_TYPE_IMAGE_MASK_DATA[yInt][xInt]; 334 334 } else { 335 335 *maskValue = 0; … … 456 456 // Interpolation engine for separable interpolation kernels 457 457 static psImageInterpolateStatus interpolateSeparable(double *imageValue, double *varianceValue, 458 ps MaskType *maskValue, float x, float y,458 psImageMaskType *maskValue, float x, float y, 459 459 const psImageInterpolation *interp) 460 460 { … … 465 465 const psImage *mask = interp->mask; // Image mask 466 466 const psImage *variance = interp->variance; // Image variance 467 ps MaskType maskVal = interp->maskVal; // Value to mask467 psImageMaskType maskVal = interp->maskVal; // Value to mask 468 468 bool wantVariance = variance && varianceValue; // Does the user want the variance value? 469 469 bool haveMask = mask && maskVal; // Does the user want the variance value? … … 582 582 const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \ 583 583 const ps##TYPE *varianceData = &variance->data.TYPE[yPix][xMin]; \ 584 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \584 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \ 585 585 const psF32 *xKernelData = xKernel; \ 586 586 const psF32 *xKernel2Data = xKernel2; \ … … 642 642 /* Dereferenced versions of inputs */ \ 643 643 const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \ 644 const ps MaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \644 const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \ 645 645 const psF32 *xKernelData = xKernel; \ 646 646 const psF32 *xKernel2Data = xKernel2; \ … … 713 713 // Interpolation engine for (separable) interpolation kernels 714 714 static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue, 715 ps MaskType *maskValue, float x, float y,715 psImageMaskType *maskValue, float x, float y, 716 716 const psImageInterpolation *interp) 717 717 { … … 722 722 const psImage *mask = interp->mask; // Image mask 723 723 const psImage *variance = interp->variance; // Image variance 724 ps MaskType maskVal = interp->maskVal; // Value to mask724 psImageMaskType maskVal = interp->maskVal; // Value to mask 725 725 bool wantVariance = variance && varianceValue; // Does the user want the variance value? 726 726 bool haveMask = mask && maskVal; // Does the user want the variance value? … … 790 790 float kernelValue = kernel[j][i]; /* Value of kernel */ \ 791 791 float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \ 792 if (mask->data.PS_TYPE_ MASK_DATA[yPix][xPix] & maskVal) { \792 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \ 793 793 sumBad += kernelValue2; \ 794 794 } else { \ … … 820 820 float kernelValue = kernel[j][i]; /* Value of kernel */ \ 821 821 float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \ 822 if (mask->data.PS_TYPE_ MASK_DATA[yPix][xPix] & maskVal) { \822 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \ 823 823 sumBad += kernelValue2; \ 824 824 } else { \ … … 866 866 867 867 868 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, ps MaskType *maskValue,868 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psImageMaskType *maskValue, 869 869 float x, float y, const psImageInterpolation *interp) 870 870 { … … 885 885 if (maskValue && mask) { 886 886 PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR); 887 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, PS_INTERPOLATE_STATUS_ERROR);887 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, PS_INTERPOLATE_STATUS_ERROR); 888 888 psAssert(image->numCols == mask->numCols && image->numRows == mask->numRows, "Image and mask sizes"); 889 889 } -
trunk/psLib/src/imageops/psImageInterpolate.h
r20327 r21183 7 7 * @author Paul Price, Institute for Astronomy 8 8 * 9 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-10-22 19:21:06$9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 12 12 */ … … 50 50 const psImage *variance; ///< Variance image for interpolation 51 51 const psImage *mask; ///< Mask image for interpolation 52 ps MaskType maskVal;///< Value to mask52 psImageMaskType maskVal; ///< Value to mask 53 53 double badImage; ///< Image value if x,y location is not good 54 54 double badVariance; ///< Variance value if x,y location is not good 55 ps MaskType badMask;///< Mask value to give bad pixels56 ps MaskType poorMask;///< Mask value to give poor pixels55 psImageMaskType badMask; ///< Mask value to give bad pixels 56 psImageMaskType poorMask; ///< Mask value to give poor pixels 57 57 float poorFrac; ///< Fraction of flux in bad pixels before output is marked bad 58 58 bool shifting; ///< Shifting images? Don't interpolate if the shift is exact. … … 69 69 const psImage *variance, // Variance image 70 70 const psImage *mask, // Mask image 71 ps MaskType maskVal, // Value to mask71 psImageMaskType maskVal, // Value to mask 72 72 double badImage, // Value for image if bad 73 73 double badVariance, // Value for variance if bad 74 ps MaskType badMask, // Mask value for bad pixels75 ps MaskType poorMask, // Mask value for poor pixels74 psImageMaskType badMask, // Mask value for bad pixels 75 psImageMaskType poorMask, // Mask value for poor pixels 76 76 float poorFrac, // Fraction of flux for question 77 77 int numKernels // Number of interpolation kernels to pre-calculate … … 83 83 double *imageValue, ///< Return value for image 84 84 double *varianceValue, ///< Return value for variance 85 ps MaskType *maskValue, ///< Return value for mask85 psImageMaskType *maskValue, ///< Return value for mask 86 86 float x, float y, ///< Location to which to interpolate 87 87 const psImageInterpolation *options ///< Options -
trunk/psLib/src/imageops/psImageMap.c
r21172 r21183 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2009-01-27 0 0:00:21$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 145 145 } 146 146 147 psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_ MASK);147 psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_IMAGE_MASK); 148 148 psImage *xCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32); 149 149 psImage *yCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32); … … 212 212 // this will not in general be properly weighted... 213 213 if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) { 214 mask->data. U8[iy][ix] = 0;214 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0; 215 215 // XXX ensure only one option is selected, or save both position and width 216 216 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options); … … 224 224 yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options); 225 225 } else { 226 mask->data. U8[iy][ix] = 1;226 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1; 227 227 } 228 228 … … 353 353 } 354 354 355 psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, ps MaskType maskValue, const psVector *x, const psVector *y)355 psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y) 356 356 { 357 357 PS_ASSERT_IMAGE_MAP_NON_NULL(map, NULL); … … 365 365 366 366 for (int i = 0; i < x->n; i++) { 367 if (mask && (mask->data. U8[i] & maskValue)) {367 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 368 368 result->data.F32[i] = 0.0; 369 369 } else { -
trunk/psLib/src/imageops/psImageMapFit.c
r21172 r21183 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2009-01-27 0 0:00:21$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 47 47 48 48 // map defines the output image dimensions and scaling. 49 bool psImageMapFit(psImageMap *map, const psVector *mask, ps MaskType maskValue,49 bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 50 50 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 51 51 { … … 145 145 for (int i = 0; i < x->n; i++) { 146 146 147 if (mask && (mask->data. U8[i] & maskValue)) continue;147 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue; 148 148 149 149 // base coordinate offset for this point (x,y) relative to this map element (n,m) … … 338 338 339 339 // measure residuals on each pass and clip outliers based on stats 340 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, ps MaskType maskValue,340 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue, 341 341 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 342 342 { … … 377 377 psVector *mask = inMask; 378 378 if (!inMask) { 379 mask = psVectorAlloc (x->n, PS_TYPE_ U8);379 mask = psVectorAlloc (x->n, PS_TYPE_VECTOR_MASK); 380 380 psVectorInit (mask, 0); 381 381 } … … 429 429 for (psS32 i = 0; i < resid->n; i++) { 430 430 // XXX this prevents recovery of previously masked values 431 if (mask->data. U8[i] & maskValue) {431 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue) { 432 432 continue; 433 433 } … … 435 435 if ((resid->data.F32[i] - meanValue > maxClipValue) || (resid->data.F32[i] - meanValue < minClipValue)) { 436 436 psTrace("psLib.imageops", 6, "Masking element %d : %f vs %f : resid is %f\n", i, f->data.F32[i], fit->data.F32[i], resid->data.F32[i]); 437 mask->data. U8[i] |= 0x01;437 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 438 438 continue; 439 439 } … … 455 455 456 456 // map defines the output image dimensions and scaling. 457 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, ps MaskType maskValue,457 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 458 458 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 459 459 { … … 490 490 for (int i = 0; i < y->n; i++) { 491 491 492 if (mask && (mask->data. U8[i] & maskValue)) continue;492 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue; 493 493 494 494 float dy = psImageBinningGetRuffY (map->binning, y->data.F32[i]) - (m + 0.5); … … 603 603 604 604 // map defines the output image dimensions and scaling. 605 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, ps MaskType maskValue,605 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 606 606 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 607 607 { … … 638 638 for (int i = 0; i < x->n; i++) { 639 639 640 if (mask && (mask->data. U8[i] & maskValue)) continue;640 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue; 641 641 642 642 float dx = psImageBinningGetRuffX (map->binning, x->data.F32[i]) - (m + 0.5); -
trunk/psLib/src/imageops/psImageMapFit.h
r15841 r21183 10 10 bool psImageMapFit(psImageMap *map, 11 11 const psVector *mask, 12 ps MaskType maskValue,12 psVectorMaskType maskValue, // 13 13 const psVector *x, 14 14 const psVector *y, … … 21 21 psStats *stats, 22 22 psVector *mask, // WARNING: Mask is modified! 23 ps MaskType maskValue,23 psVectorMaskType maskValue, 24 24 const psVector *x, 25 25 const psVector *y, … … 30 30 bool psImageMapFit1DinY(psImageMap *map, 31 31 const psVector *mask, 32 ps MaskType maskValue,32 psVectorMaskType maskValue, 33 33 const psVector *x, 34 34 const psVector *y, … … 39 39 bool psImageMapFit1DinX(psImageMap *map, 40 40 const psVector *mask, 41 ps MaskType maskValue,41 psVectorMaskType maskValue, 42 42 const psVector *x, 43 43 const psVector *y, -
trunk/psLib/src/imageops/psImageMaskOps.c
r18494 r21183 8 8 * @author David Robbins, MHPCC 9 9 * 10 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-07-12 21:08:33$10 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:37 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 37 37 psRegion region, 38 38 const char *op, 39 ps MaskType maskValue)39 psImageMaskType maskValue) 40 40 { 41 41 if (image == NULL) { … … 53 53 if ((i + image->col0) < region.x0) continue; \ 54 54 if ((i + image->col0) > region.x1) continue; /* is this correct (not >= ?) */ \ 55 image->data.PS_TYPE_ MASK_DATA[j][i] OP maskValue; \55 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \ 56 56 } \ 57 57 } … … 84 84 psRegion region, 85 85 const char *op, 86 ps MaskType maskValue)86 psImageMaskType maskValue) 87 87 { 88 88 if (image == NULL) { … … 100 100 (i + image->col0) < region.x0 || \ 101 101 (i + image->col0) > region.x1 ) { \ 102 image->data.PS_TYPE_ MASK_DATA[j][i] OP maskValue; \102 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \ 103 103 } } } 104 104 … … 131 131 double radius, 132 132 const char *op, 133 ps MaskType maskValue)133 psImageMaskType maskValue) 134 134 { 135 135 if (image == NULL) { … … 150 150 r2 = PS_SQR(dx) + PS_SQR(dy); \ 151 151 if (r2 <= R2) { \ 152 image->data.PS_TYPE_ MASK_DATA[iy][ix] OP maskValue; \152 image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \ 153 153 } } } 154 154 … … 182 182 double radius, 183 183 const char *op, 184 ps MaskType maskValue)184 psImageMaskType maskValue) 185 185 { 186 186 … … 201 201 r2 = PS_SQR(dx) + PS_SQR(dy); \ 202 202 if (r2 > R2) { \ 203 image->data.PS_TYPE_ MASK_DATA[iy][ix] OP maskValue; \203 image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \ 204 204 } } } 205 205 … … 228 228 psImage *psImageGrowMask(psImage *out, 229 229 const psImage *in, 230 ps MaskType maskVal,230 psImageMaskType maskVal, 231 231 unsigned int growSize, 232 ps MaskType growVal)232 psImageMaskType growVal) 233 233 { 234 234 if (in == NULL) { … … 237 237 return NULL; 238 238 } 239 if (in->type.type != PS_TYPE_ MASK) {239 if (in->type.type != PS_TYPE_IMAGE_MASK) { 240 240 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 241 "Invalid input image. Input image type must match ps MaskType.\n");241 "Invalid input image. Input image type must match psImageMaskType.\n"); 242 242 return NULL; 243 243 } … … 261 261 for (k = 0; k < in->numRows; k++) { 262 262 for (l = 0; l < in->numCols; l++) { 263 out->data.PS_TYPE_ MASK_DATA[k][l] = in->data.PS_TYPE_MASK_DATA[k][l];264 changed->data.PS_TYPE_ MASK_DATA[k][l] = 0;263 out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = in->data.PS_TYPE_IMAGE_MASK_DATA[k][l]; 264 changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 0; 265 265 } 266 266 } … … 268 268 for (int i = 0; i < in->numRows; i++) { 269 269 for (int j = 0; j < in->numCols; j++) { 270 if ( (in->data.PS_TYPE_ MASK_DATA[i][j] & maskVal) != 0 &&271 changed->data.PS_TYPE_ MASK_DATA[i][j] == 0) {270 if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) != 0 && 271 changed->data.PS_TYPE_IMAGE_MASK_DATA[i][j] == 0) { 272 272 m = i - growSize; 273 273 if (m < 0) { … … 281 281 for (l = n; l <= (j + growSize) && l < in->numCols; l++) { 282 282 if (((k-i)*(k-i) + (l-j)*(l-j)) <= (growSize*growSize)) { 283 out->data.PS_TYPE_ MASK_DATA[k][l] |= growVal;284 if ( (in->data.PS_TYPE_ MASK_DATA[i][j] & maskVal) == 0 ) {285 changed->data.PS_TYPE_ MASK_DATA[k][l] = 1;283 out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] |= growVal; 284 if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) == 0 ) { 285 changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 1; 286 286 } 287 287 } -
trunk/psLib/src/imageops/psImageMaskOps.h
r11248 r21183 6 6 * @author David Robbins, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 200 7-01-23 22:47:23$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:37 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 psRegion region, ///< the specified region 33 33 const char *op, ///< the logical operation 34 ps MaskType maskValue///< the specified bits34 psImageMaskType maskValue ///< the specified bits 35 35 ); 36 36 … … 44 44 psRegion region, ///< the specified region 45 45 const char *op, ///< the logical operation 46 ps MaskType maskValue///< the specified bits46 psImageMaskType maskValue ///< the specified bits 47 47 ); 48 48 … … 58 58 double radius, ///< the radius of the specified circle 59 59 const char *op, ///< the logical operation 60 ps MaskType maskValue///< the specified bits60 psImageMaskType maskValue ///< the specified bits 61 61 ); 62 62 … … 72 72 double radius, ///< the radius of the specified circle 73 73 const char *op, ///< the logical operation 74 ps MaskType maskValue///< the specified bits74 psImageMaskType maskValue ///< the specified bits 75 75 ); 76 76 … … 89 89 psImage *out, ///< the image to set and return 90 90 const psImage *in, ///< the input to image 91 ps MaskType maskVal,///< the specified mask value91 psImageMaskType maskVal, ///< the specified mask value 92 92 unsigned int growSize, ///< the range of values from maskVal 93 ps MaskType growVal///< the output value to set93 psImageMaskType growVal ///< the output value to set 94 94 ); 95 95 -
trunk/psLib/src/imageops/psImagePixelExtract.c
r20306 r21183 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-10-22 02:10:37 $10 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:37 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 206 206 const psImage* input, 207 207 const psImage* mask, 208 ps MaskType maskVal,208 psImageMaskType maskVal, 209 209 psRegion region, 210 210 psImageCutDirection direction, … … 357 357 return NULL; 358 358 } 359 if (mask->type.type != PS_TYPE_ MASK) {359 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 360 360 char* typeStr; 361 361 PS_TYPE_NAME(typeStr,mask->type.type); 362 362 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 363 363 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 364 typeStr, PS_TYPE_ MASK_NAME);364 typeStr, PS_TYPE_IMAGE_MASK_NAME); 365 365 psFree(out); 366 366 return NULL; … … 394 394 psVector* imgVec = psVectorAlloc(numRows, type); 395 395 psVector* maskVec = NULL; 396 ps MaskType* maskData = NULL;396 psImageMaskType* maskData = NULL; 397 397 psPixelCoord* outPosition = NULL; 398 398 … … 416 416 417 417 if (mask != NULL) { 418 maskVec = psVectorAlloc(numRows, mask->type.type); 419 } 420 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 418 maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); 419 } 420 421 #define PSIMAGE_CUT_VERTICAL(TYPE) \ 421 422 case PS_TYPE_##TYPE: { \ 422 ps MaskType* maskVecData = NULL; \423 for (psS32 c =col0;c<col1;c++) { \423 psVectorMaskType* maskVecData = NULL; \ 424 for (psS32 c = col0; c < col1; c++) { \ 424 425 ps##TYPE *imgData = input->data.TYPE[row0] + c; \ 425 426 ps##TYPE *imgVecData = imgVec->data.TYPE; \ 426 427 if (maskVec != NULL) { \ 427 maskVecData = maskVec->data.U8; \ 428 maskData = (psMaskType* )(mask->data.U8[row0]) + c; \ 428 maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \ 429 maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \ 430 /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \ 429 431 } \ 430 for (psS32 r=row0;r<row1;r++) { \ 431 *(imgVecData++) = *imgData; \ 432 for (psS32 r = row0; r < row1; r++) { \ 433 *imgVecData = *imgData; \ 434 imgVecData ++; \ 432 435 imgData += inCols; \ 433 436 if (maskVecData != NULL) { \ 434 *(maskVecData++) = *maskData; \ 437 *maskVecData = (*maskData & maskVal); \ 438 maskVecData ++; \ 435 439 maskData += inCols; \ 436 440 } \ 437 441 } \ 438 psVectorStats(myStats, imgVec,NULL,maskVec,maskVal); \442 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \ 439 443 *outData = psStatsGetValue(myStats, statistic); \ 440 444 if (outPosition != NULL) { \ … … 471 475 psFree(imgVec); 472 476 psFree(maskVec); 477 473 478 } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) { 474 479 // Cut in Y direction 480 // XXX use this if we drop the hackish stuff below: psVector* imgVec = psVectorAlloc(numCols, type); 475 481 psVector* imgVec = NULL; 476 482 psVector* maskVec = NULL; … … 479 485 480 486 // fill in psVector to fake out the statistics functions. 487 // XXX EAM : this seems rather hackish: just use the needed psVectorAlloc (like above)? 481 488 imgVec = psAlloc(sizeof(psVector)); 482 489 imgVec->type = input->type; 483 490 P_PSVECTOR_SET_NALLOC(imgVec,numCols); 484 if (mask != NULL) { 485 maskVec = psAlloc(sizeof(psVector)); 486 maskVec->type = mask->type; 487 P_PSVECTOR_SET_NALLOC(maskVec,numCols); 488 } 491 imgVec->n = imgVec->nalloc; 492 489 493 // recycle output to make a proper sized/type output structure 490 494 // n.b. type is double as that is the type given for all stats in … … 492 496 out = psVectorRecycle(out, numRows, PS_TYPE_F64); 493 497 out->n = numRows; 494 imgVec->n = imgVec->nalloc;495 maskVec->n = maskVec->nalloc;496 498 if (coords != NULL) { 497 499 coords = psPixelsRealloc(coords, numRows); … … 507 509 } 508 510 511 if (mask != NULL) { 512 maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); 513 // XXX the old code (below) faked out the mask vector 514 // maskVec = psAlloc(sizeof(psVector)); 515 // maskVec->type = mask->type; 516 // P_PSVECTOR_SET_NALLOC(maskVec,numCols); 517 // maskVec->n = maskVec->nalloc; 518 } 519 509 520 for (psS32 r = row0; r < row1; r++) { 510 521 // point the vector struct to the 511 522 // data to calculate the stats 512 523 imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize); 524 525 // set the vector mask pixels based on the image pixels 513 526 if (maskVec != NULL) { 514 maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType)); 515 } 516 psVectorStats(myStats, imgVec, NULL, maskVec, maskVal); 527 psVectorMaskType *maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; 528 psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[r][col0]; 529 for (psS32 c = col0; c < col1; c++) { 530 *maskVecData = (*maskData & maskVal); 531 maskVecData ++; 532 maskData ++; 533 } 534 } 535 536 psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); 517 537 *outData = psStatsGetValue(myStats, statistic); 518 538 if (outPosition != NULL) { … … 544 564 const psImage* input, 545 565 const psImage* mask, 546 ps MaskType maskVal,566 psImageMaskType maskVal, 547 567 psRegion region, 548 568 unsigned int nSamples, … … 651 671 return NULL; 652 672 } 653 if (mask->type.type != PS_TYPE_ MASK) {673 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 654 674 char* typeStr; 655 675 PS_TYPE_NAME(typeStr,mask->type.type); 656 676 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 657 677 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 658 typeStr, PS_TYPE_ MASK_NAME);678 typeStr, PS_TYPE_IMAGE_MASK_NAME); 659 679 psFree(out); 660 680 return NULL; … … 739 759 const psImage* input, 740 760 const psImage* mask, 741 ps MaskType maskVal,761 psImageMaskType maskVal, 742 762 float x, 743 763 float y, … … 765 785 return NULL; 766 786 } 767 if (mask->type.type != PS_TYPE_ MASK) {787 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 768 788 char* typeStr; 769 789 PS_TYPE_NAME(typeStr,mask->type.type); 770 790 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 771 791 _("Input psImage mask type, %s, is not the supported mask datatype of %s."), 772 typeStr, PS_TYPE_ MASK_NAME);792 typeStr, PS_TYPE_IMAGE_MASK_NAME); 773 793 psFree(out); 774 794 return NULL; … … 868 888 if (mask != NULL) { 869 889 bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]), 870 PS_TYPE_ MASK);890 PS_TYPE_VECTOR_MASK); 871 891 } 872 892 } … … 877 897 for (psS32 row=startRow; row <= endRow; row++) { 878 898 psF32* inRow = input->data.F32[row]; 879 ps MaskType* maskRow = NULL;899 psImageMaskType* maskRow = NULL; 880 900 if (mask != NULL) { 881 maskRow = mask->data.PS_TYPE_ MASK_DATA[row];901 maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row]; 882 902 } 883 903 for (psS32 col=startCol; col <= endCol; col++) { … … 899 919 900 920 if (maskRow != NULL) { 901 bufferMask[r]->data.PS_TYPE_ MASK_DATA[n] = maskRow[col];921 bufferMask[r]->data.PS_TYPE_VECTOR_MASK_DATA[n] = (maskRow[col] & maskVal); 902 922 bufferMask[r]->n = n+1; 903 923 } … … 913 933 914 934 for (psS32 r = 0; r < numOut; r++) { 915 psVectorStats(myStats, buffer[r], NULL, bufferMask[r],maskVal);935 psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff); 916 936 outData[r] = psStatsGetValue(myStats, statistic); 917 937 } -
trunk/psLib/src/imageops/psImagePixelExtract.h
r11248 r21183 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 200 7-01-23 22:47:23$7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:37 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 84 84 const psImage* input, ///< the input image in which to perform the slice 85 85 const psImage* mask, ///< the mask for the input image. 86 ps MaskType maskVal,///< the mask value to apply to the mask86 psImageMaskType maskVal, ///< the mask value to apply to the mask 87 87 psRegion region, ///< the slice region 88 88 psImageCutDirection direction, ///< the slice dimension and direction … … 112 112 const psImage* input, ///< the input image in which to perform the cut 113 113 const psImage* mask, ///< the mask for the input image. 114 ps MaskType maskVal,///< the mask value to apply to the mask114 psImageMaskType maskVal, ///< the mask value to apply to the mask 115 115 psRegion region, ///< the start and end points to cut along 116 116 unsigned int nSamples, ///< the number of samples along the cut … … 135 135 const psImage* input, ///< the input image in which to perform the cut 136 136 const psImage* mask, ///< the mask for the input image. 137 ps MaskType maskVal,///< the mask value to apply to the mask137 psImageMaskType maskVal, ///< the mask value to apply to the mask 138 138 float x, ///< the column of the center of the cut circle 139 139 float y, ///< the row of the center of the cut circle -
trunk/psLib/src/imageops/psImagePixelInterpolate.c
r15254 r21183 11 11 * @author Eugene Magnier, IfA 12 12 * 13 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $14 * @date $Date: 200 7-10-09 19:25:44$13 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2009-01-27 06:39:37 $ 15 15 * 16 16 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 54 54 /* do not test self */ \ 55 55 if (!jx && !jy) { continue; } \ 56 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \56 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \ 57 57 nGood ++; \ 58 58 } \ … … 67 67 // just the mask, the output image contains enum values which define the type of interpolation which 68 68 // can be performed 69 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, ps MaskType maskVal) {69 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal) { 70 70 71 71 psImage *result = psImageAlloc (mask->numCols, mask->numRows, PS_TYPE_S32); … … 79 79 80 80 // state of the good pixels (unmasked) 81 if (!(mask->data.PS_TYPE_ MASK_DATA[iy][ix] & maskVal)) {81 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal)) { 82 82 // count good neighbor pixels (+ self) 83 83 int nGood = 0; … … 94 94 if (jx + ix < 0) { continue; } 95 95 if (jx + ix >= mask->numCols) { continue; } 96 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }96 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 97 97 nGood ++; 98 98 minX = PS_MIN (minX, jx); … … 137 137 138 138 // interpolate the poor pixels using the available options 139 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, ps MaskType maskVal) {139 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal) { 140 140 141 141 assert (image->numCols == state->numCols); … … 185 185 if (!jx && !jy) { continue; } 186 186 // skip masked pixels 187 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }187 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 188 188 x->data.F32[n] = jx; 189 189 y->data.F32[n] = jy; … … 241 241 242 242 // interpolate the good pixels to their true centers 243 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, ps MaskType maskVal) {243 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal) { 244 244 245 245 assert (value->numCols == state->numCols); … … 299 299 if (jx + ix >= value->numCols) { continue; } 300 300 // skip masked pixels 301 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }301 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 302 302 x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx]; 303 303 y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx]; … … 331 331 if (jx + ix >= value->numCols) { continue; } 332 332 // skip masked pixels 333 if (mask->data.PS_TYPE_ MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }333 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 334 334 x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx]; 335 335 y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx]; … … 363 363 for (int iy = 0; iy < value->numRows; iy++) { 364 364 for (int ix = 0; ix < value->numCols; ix++) { 365 if (mask->data.PS_TYPE_ MASK_DATA[iy][ix] & maskVal) { continue; }365 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { continue; } 366 366 value->data.F32[iy][ix] = output->data.F32[iy][ix]; 367 367 } -
trunk/psLib/src/imageops/psImagePixelInterpolate.h
r14924 r21183 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 200 7-09-20 23:54:25$9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:37 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 34 34 } psImagePixelInterpolateType; 35 35 36 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, ps MaskType maskVal);37 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, ps MaskType maskVal);38 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, ps MaskType maskVal);36 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal); 37 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal); 38 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal); 39 39 40 40 /// @} -
trunk/psLib/src/imageops/psImageStats.c
r12431 r21183 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 6$ $Name: not supported by cvs2svn $12 * @date $Date: 200 7-03-14 00:39:50$11 * @version $Revision: 1.107 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-01-27 06:39:37 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 53 53 const psImage* in, 54 54 const psImage* mask, 55 ps MaskType maskVal)55 psImageMaskType maskVal) 56 56 { 57 57 psVector *junkData = NULL; … … 62 62 PS_ASSERT_IMAGE_NON_NULL(in, false) 63 63 if (mask != NULL) { 64 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ U8, false);64 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 65 65 PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false); 66 66 } 67 68 if (in->parent == NULL) { 69 // stuff the image data into a psVector struct. 70 // XXX this is a bit hackish: does it save much time? (avoids a Nx*Ny alloc) 71 junkData = (psVector *) psAlloc(sizeof(psVector)); 72 junkData->type = in->type; 73 P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols); 74 junkData->n = junkData->nalloc; 75 junkData->data.U8 = in->data.V[0]; // since psImage data is contiguous... 76 } else { 77 // image not necessarily contiguous 78 int numRows = in->numRows; 79 int numCols = in->numCols; 80 int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type)); 81 82 junkData = psVectorAlloc(numRows*numCols, in->type.type); 83 84 psU8* data = junkData->data.U8; 85 for (int row = 0; row < numRows; row++) { 86 memcpy(data, in->data.V[row], rowSize); 87 data += rowSize; 88 } 89 } 90 91 if (mask != NULL) { 92 // image not necessarily contiguous, generate a temp vector to hold the full image 93 int numRows = mask->numRows; 94 int numCols = mask->numCols; 95 96 junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK); 97 98 psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA; 99 for (int row = 0, nVect = 0; row < numRows; row++) { 100 for (int col = 0; col < numCols; col++, nVect++) { 101 data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal); 102 } 103 } 104 } 105 106 psVectorStats(stats, junkData, NULL, junkMask, 0xff); 107 108 psFree(junkMask); 109 psFree(junkData); 110 return true; 111 } 112 113 /***************************************************************************** 114 NOTE: We assume that the psHistogram structure out has already been allocated 115 and initialized. 116 *****************************************************************************/ 117 bool psImageHistogram(psHistogram* out, 118 const psImage* in, 119 const psImage* mask, 120 psImageMaskType maskVal) 121 { 122 PS_ASSERT_PTR_NON_NULL(out, false); 123 PS_ASSERT_PTR_NON_NULL(in, false); 124 if (mask != NULL) { 125 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 126 PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false); 127 } 128 psVector* junkData = NULL; 129 psVector* junkMask = NULL; 67 130 68 131 if (in->parent == NULL) { … … 89 152 90 153 if (mask != NULL) { 91 if (mask->parent == NULL) { 92 // stuff the mask data into a psVector struct. 93 junkMask = psAlloc(sizeof(psVector)); 94 junkMask->type = mask->type; 95 P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols); 96 junkMask->n = junkMask->nalloc; 97 junkMask->data.U8 = mask->data.V[0]; 98 } else { 99 // image not necessarily contiguous 100 int numRows = mask->numRows; 101 int numCols = mask->numCols; 102 int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type)); 103 104 junkMask = psVectorAlloc(numRows*numCols, mask->type.type); 105 106 psU8* data = junkMask->data.U8; 107 for (int row = 0; row < numRows; row++) { 108 memcpy(data, mask->data.V[row], rowSize); 109 data += rowSize; 110 } 111 } 112 } 113 114 psVectorStats(stats, junkData, NULL, junkMask, maskVal); 115 116 psFree(junkMask); 117 psFree(junkData); 118 return true; 119 } 120 121 /***************************************************************************** 122 NOTE: We assume that the psHistogram structure out has already been allocated 123 and initialized. 124 *****************************************************************************/ 125 bool psImageHistogram(psHistogram* out, 126 const psImage* in, 127 const psImage* mask, 128 psMaskType maskVal) 129 { 130 PS_ASSERT_PTR_NON_NULL(out, false); 131 PS_ASSERT_PTR_NON_NULL(in, false); 132 if (mask != NULL) { 133 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false); 134 PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false); 135 } 136 psVector* junkData = NULL; 137 psVector* junkMask = NULL; 138 139 if (in->parent == NULL) { 140 // stuff the image data into a psVector struct. 141 junkData = (psVector *) psAlloc(sizeof(psVector)); 142 junkData->type = in->type; 143 P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols); 144 junkData->n = junkData->nalloc; 145 junkData->data.U8 = in->data.V[0]; // since psImage data is contiguous... 146 } else { 147 // image not necessarily contiguous 148 int numRows = in->numRows; 149 int numCols = in->numCols; 150 int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type)); 151 152 junkData = psVectorAlloc(numRows*numCols, in->type.type); 153 154 psU8* data = junkData->data.U8; 155 for (int row = 0; row < numRows; row++) { 156 memcpy(data, in->data.V[row], rowSize); 157 data += rowSize; 158 } 159 } 160 161 if (mask != NULL) { 162 if (mask->parent == NULL) { 163 // stuff the mask data into a psVector struct. 164 junkMask = psAlloc(sizeof(psVector)); 165 junkMask->type = mask->type; 166 P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols); 167 junkMask->n = junkMask->nalloc; 168 junkMask->data.U8 = mask->data.V[0]; 169 } else { 170 // image not necessarily contiguous 171 int numRows = mask->numRows; 172 int numCols = mask->numCols; 173 int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type)); 174 175 junkMask = psVectorAlloc(numRows*numCols, mask->type.type); 176 177 psU8* data = junkMask->data.U8; 178 for (int row = 0; row < numRows; row++) { 179 memcpy(data, mask->data.V[row], rowSize); 180 data += rowSize; 181 } 182 } 154 // image not necessarily contiguous; vector & image mask types do not match 155 int numRows = mask->numRows; 156 int numCols = mask->numCols; 157 158 junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK); 159 160 psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA; 161 for (int row = 0, nVect = 0; row < numRows; row++) { 162 for (int col = 0; col < numCols; col++, nVect++) { 163 data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal); 164 } 165 } 183 166 } 184 167 … … 472 455 long psImageCountPixelMask (psImage *mask, 473 456 psRegion region, 474 ps MaskType value)457 psImageMaskType value) 475 458 { 476 459 long Npixels = 0; … … 479 462 int x1 = 0; 480 463 int y1 = 0; 481 psElemType type;482 464 483 465 // this is not a valid error: a psRegion with ranges outside the valid pixels … … 608 590 y1 = row1; 609 591 610 type = mask->type.type; 611 if (type != PS_TYPE_MASK) { 612 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 613 "psImage type does not match the specified psMaskType!\n"); 614 return -1; 615 } 616 592 # define PS_IMAGE_COUNT_PIXEL_MASK(NAME,TYPE) \ 593 case PS_TYPE_##NAME: \ 594 for (long j = y0; j < y1; j++) { \ 595 for (long i = x0; i < x1; i++) { \ 596 if (mask->data.TYPE[j][i] & value) { \ 597 Npixels ++; \ 598 } \ 599 } \ 600 } \ 601 break; 602 603 psElemType type = mask->type.type; 617 604 switch (type) { 618 case PS_TYPE_U8: 619 case PS_TYPE_U16: 620 for (long j = y0; j < y1; j++) { 621 for (long i = x0; i < x1; i++) { 622 if (mask->data.PS_TYPE_MASK_DATA[j][i] & value) { 623 Npixels ++; 624 } 625 } 626 } 627 break; 628 case PS_TYPE_S8: 629 case PS_TYPE_S16: 630 case PS_TYPE_S32: 631 case PS_TYPE_S64: 632 case PS_TYPE_U32: 633 case PS_TYPE_U64: 634 case PS_TYPE_F32: 635 case PS_TYPE_F64: 605 PS_IMAGE_COUNT_PIXEL_MASK(U8, U8); 606 PS_IMAGE_COUNT_PIXEL_MASK(U16,U16); 607 PS_IMAGE_COUNT_PIXEL_MASK(U32,U32); 608 PS_IMAGE_COUNT_PIXEL_MASK(U64,U64); 609 PS_IMAGE_COUNT_PIXEL_MASK(S8, S8); 610 PS_IMAGE_COUNT_PIXEL_MASK(S16,S16); 611 PS_IMAGE_COUNT_PIXEL_MASK(S32,S32); 612 PS_IMAGE_COUNT_PIXEL_MASK(S64,S64); 613 636 614 default: 637 615 // XXX this should include the mask type (as a string) 638 616 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 639 _("Input psImage mask type is not a supported maskdatatype"));617 _("Input psImage is an unsupported datatype")); 640 618 641 619 return -1; -
trunk/psLib/src/imageops/psImageStats.h
r11759 r21183 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $12 * @date $Date: 200 7-02-13 03:01:23$11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-01-27 06:39:37 $ 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 14 14 */ … … 42 42 const psImage* in, ///< image (or subimage) to calculate stats 43 43 const psImage* mask, ///< mask data for image (NULL ok) 44 ps MaskType maskVal///< mask value for mask44 psImageMaskType maskVal ///< mask value for mask 45 45 ); 46 46 … … 57 57 const psImage* in, ///< Image data to be histogramed. 58 58 const psImage* mask, ///< mask data for image (NULL ok) 59 ps MaskType maskVal///< mask Mask for mask59 psImageMaskType maskVal ///< mask Mask for mask 60 60 ); 61 61 … … 97 97 psImage *mask, ///< input image to count 98 98 psRegion region, ///< input region of image 99 ps MaskType value///< the mask value to satisfy99 psImageMaskType value ///< the mask value to satisfy 100 100 ); 101 101 -
trunk/psLib/src/math/psClip.c
r11756 r21183 22 22 23 23 psClipParams *psClipParamsAlloc(psStatsOptions meanStat, psStatsOptions stdevStat, 24 ps MaskType masked, psMaskType clipped)24 psVectorMaskType masked, psVectorMaskType clipped) 25 25 { 26 26 psClipParams *params = psAlloc(sizeof(psClipParams)); // Clip parameters … … 48 48 PS_ASSERT_VECTOR_NON_NULL(values, -1); 49 49 PS_ASSERT_VECTOR_NON_NULL(mask, -1); 50 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, -1);50 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1); 51 51 PS_ASSERT_PTR(params, -1); 52 52 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1); … … 62 62 } 63 63 64 ps MaskType masked = params->masked; // Indicates masked values65 ps MaskType clipped = params->clipped; // Indicates clipped values64 psVectorMaskType masked = params->masked; // Indicates masked values 65 psVectorMaskType clipped = params->clipped; // Indicates clipped values 66 66 masked |= clipped; // Make sure we're also masking clipped values 67 ps MaskType *maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference mask67 psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference mask 68 68 long totalMasked = 0; // Total number of pixels masked 69 69 … … 120 120 PS_ASSERT_VECTOR_NON_NULL(values, -1); 121 121 PS_ASSERT_VECTOR_NON_NULL(mask, -1); 122 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, -1);122 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1); 123 123 PS_ASSERT_PTR(params, -1); 124 124 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1); … … 141 141 } 142 142 143 ps MaskType masked = params->masked; // Indicates masked values144 ps MaskType clipped = params->clipped; // Indicates clipped values143 psVectorMaskType masked = params->masked; // Indicates masked values 144 psVectorMaskType clipped = params->clipped; // Indicates clipped values 145 145 masked |= clipped; // Make sure we're also masking clipped values 146 146 … … 158 158 case PS_TYPE_##TYPE: { \ 159 159 ps##TYPE *valuesData = values->data.TYPE; /* Dereference for speed */ \ 160 ps MaskType *maskData = mask->data.PS_TYPE_MASK_DATA; /* Dereference mask for speed */ \160 psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; /* Dereference mask for speed */ \ 161 161 if (errors) { \ 162 162 ps##TYPE *errorsData = errors->data.TYPE; \ -
trunk/psLib/src/math/psClip.h
r14452 r21183 4 4 * @author Paul Price, IfA. 5 5 * 6 * $Revision: 1. 5$ $Name: not supported by cvs2svn $7 * $Date: 200 7-08-09 01:40:07$6 * $Revision: 1.6 $ $Name: not supported by cvs2svn $ 7 * $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2007 Institute for Astronomy, University of Hawaii 9 9 */ … … 25 25 int iter; ///< Number of rejection iterations; unused by psClip functions 26 26 float rej; ///< Rejection limit (standard deviations) 27 ps MaskType masked; ///< Mask value for entries already masked28 ps MaskType clipped; ///< Mask value to give to clipped entries27 psVectorMaskType masked; ///< Mask value for entries already masked 28 psVectorMaskType clipped; ///< Mask value to give to clipped entries 29 29 double mean; ///< Resultant mean 30 30 double stdev; ///< Resultant stdev … … 35 35 psClipParams *psClipParamsAlloc(psStatsOptions meanStat, ///< Stats option to use for mean 36 36 psStatsOptions stdevStat, ///< Stats option to use for standard deviation 37 ps MaskType masked, ///< Mask value for entries already masked38 ps MaskType clipped ///< Mask value to give to clipped entries37 psVectorMaskType masked, ///< Mask value for entries already masked 38 psVectorMaskType clipped ///< Mask value to give to clipped entries 39 39 ) PS_ATTR_MALLOC; 40 40 -
trunk/psLib/src/math/psConstants.h
r17035 r21183 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.9 6$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-03-18 18:25:00$7 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 68 68 // These defines for bitwise opertaions are necessary to yield results of the proper size (use instead of ~) 69 #define PS_NOT_U8(A)(UCHAR_MAX-(A)) // Perform bitwise NOT on A which is of type U8 70 #define PS_NOT_U16(A)(USHORT_MAX-(A)) // Perform bitwaise NOT on A which is of type U16 69 #define PS_NOT_U8(A)(UINT8_MAX-(A)) // Perform bitwise NOT on A which is of type U8 70 #define PS_NOT_U16(A)(UINT16_MAX-(A)) // Perform bitwaise NOT on A which is of type U16 71 #define PS_NOT_U32(A)(UINT32_MAX-(A)) // Perform bitwise NOT on A which is of type U8 72 #define PS_NOT_U64(A)(UINT64_MAX-(A)) // Perform bitwaise NOT on A which is of type U16 71 73 72 74 /// @} -
trunk/psLib/src/math/psHistogram.c
r17565 r21183 5 5 * @author GLG (MHPCC), EAM (IfA) 6 6 * 7 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-05-07 23:11:30$7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2006 IfA, University of Hawaii … … 231 231 const psVector* errors, 232 232 const psVector* mask, 233 ps MaskType maskVal)233 psVectorMaskType maskVal) 234 234 { 235 235 psTrace("psLib.math", 3, "---- %s() begin ----\n", __func__); … … 244 244 if (mask) { 245 245 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 246 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);246 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 247 247 } 248 248 if (errors) { … … 274 274 for (long i = 0; i < inF32->n; i++) { 275 275 // Check if this pixel is masked, and if so, skip it. 276 if (!mask || (mask && (!(mask->data. U8[i] & maskVal)))) {276 if (!mask || (mask && (!(mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)))) { 277 277 if (inF32->data.F32[i] < out->bounds->data.F32[0]) { 278 278 // If this pixel is below minimum value, count it, then skip. -
trunk/psLib/src/math/psHistogram.h
r14452 r21183 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 200 7-08-09 01:40:07$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * 12 12 * Copyright 2004-2005 IfA, University of Hawaii … … 88 88 const psVector* errors, ///< Errors 89 89 const psVector* mask, ///< Mask dat for input vector 90 ps MaskType maskVal///< Mask value91 );90 psVectorMaskType maskVal ///< Mask value 91 ); 92 92 93 93 /// @} -
trunk/psLib/src/math/psMinimizeLMM.c
r19845 r21183 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-10-02 20:49:22$12 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 74 74 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 75 75 if (paramMask) { 76 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);76 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 77 77 } 78 78 … … 113 113 // set tmpBeta values which are not masked 114 114 for (int j = 0, n = 0; j < params->n; j++) { 115 if (paramMask && (paramMask->data. U8[j])) continue;115 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 116 116 tmpBeta->data.F32[j] = Beta->data.F32[n]; 117 117 n++; … … 120 120 // apply Beta to get new Params values 121 121 for (int j = 0; j < params->n; j++) { 122 if (paramMask && (paramMask->data. U8[j])) {122 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 123 123 Params->data.F32[j] = params->data.F32[j]; 124 124 continue; … … 140 140 // apply tmpBeta after limits have been checked 141 141 for (int j = 0, n = 0; j < params->n; j++) { 142 if (paramMask && (paramMask->data. U8[j])) continue;142 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 143 143 Beta->data.F32[n] = tmpBeta->data.F32[j]; 144 144 n++; … … 269 269 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 270 270 if (paramMask) { 271 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);271 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 272 272 } 273 273 … … 297 297 // we track alpha,beta and params,deriv separately 298 298 for (int j = 0, J = 0; j < params->n; j++) { 299 if (paramMask && (paramMask->data. U8[j])) continue;299 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 300 300 301 301 weight = deriv->data.F32[j] * dy->data.F32[i]; 302 302 303 303 for (int k = 0, K = 0; k <= j; k++) { 304 if (paramMask && (paramMask->data. U8[k])) continue;304 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 305 305 alpha->data.F32[J][K] += weight * deriv->data.F32[k]; 306 306 K++; … … 351 351 paramMask = constraint->paramMask; 352 352 if (paramMask != NULL) { 353 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ U8, false);353 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 354 354 PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false); 355 355 } … … 493 493 psImageInit (covar, 0.0); 494 494 for (int j = 0, J = 0; j < params->n; j++) { 495 if (paramMask && (paramMask->data. U8[j])) {495 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 496 496 covar->data.F32[j][j] = 1.0; 497 497 continue; 498 498 } 499 499 for (int k = 0, K = 0; k < params->n; k++) { 500 if (paramMask && (paramMask->data. U8[k])) continue;500 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 501 501 covar->data.F32[j][k] = Alpha->data.F32[J][K]; 502 502 K++; … … 535 535 nParams = 0; 536 536 for (int i = 0; i < paramMask->n; i++) { 537 if (paramMask->data. U8[i]) continue;537 if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 538 538 nParams ++; 539 539 } -
trunk/psLib/src/math/psMinimizeLMM_ND.c
r17442 r21183 8 8 * @author EAM, IfA 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-04-11 08:01:29$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * 13 13 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 55 55 paramMask = constraint->paramMask; 56 56 if (paramMask != NULL) { 57 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ U8, false);57 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 58 58 PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false); 59 59 } … … 201 201 psImageInit (covar, 0.0); 202 202 for (int j = 0, J = 0; j < params->n; j++) { 203 if (paramMask && (paramMask->data. U8[j])) {203 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 204 204 covar->data.F32[j][j] = 1.0; 205 205 continue; 206 206 } 207 207 for (int k = 0, K = 0; k < params->n; k++) { 208 if (paramMask && (paramMask->data. U8[k])) continue;208 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 209 209 covar->data.F32[j][k] = Alpha->data.F32[J][K]; 210 210 K++; … … 251 251 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 252 252 if (paramMask) { 253 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);253 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 254 254 } 255 255 … … 282 282 // set tmpBeta values which are not masked 283 283 for (int j = 0, n = 0; j < params->n; j++) { 284 if (paramMask && (paramMask->data. U8[j])) continue;284 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 285 285 tmpBeta->data.F32[j] = Beta->data.F32[n]; 286 286 n++; … … 289 289 // apply Beta to get new Params values 290 290 for (int j = 0; j < params->n; j++) { 291 if (paramMask && (paramMask->data. U8[j])) {291 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 292 292 Params->data.F32[j] = params->data.F32[j]; 293 293 continue; … … 309 309 // apply tmpBeta after limits have been checked 310 310 for (int j = 0, n = 0; j < params->n; j++) { 311 if (paramMask && (paramMask->data. U8[j])) continue;311 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 312 312 Beta->data.F32[n] = tmpBeta->data.F32[j]; 313 313 n++; … … 438 438 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 439 439 if (paramMask) { 440 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);440 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 441 441 } 442 442 … … 474 474 // we track alpha,beta and params,deriv separately 475 475 for (int j = 0, J = 0; j < params->n; j++) { 476 if (paramMask && (paramMask->data. U8[j])) continue;476 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 477 477 478 478 weight = deriv->data.F32[j] * dy->data.F32[i]; 479 479 480 480 for (int k = 0, K = 0; k <= j; k++) { 481 if (paramMask && (paramMask->data. U8[k])) continue;481 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 482 482 alpha->data.F32[J][K] += weight * deriv->data.F32[k]; 483 483 K++; … … 512 512 nParams = 0; 513 513 for (int i = 0; i < paramMask->n; i++) { 514 if (paramMask->data. U8[i]) continue;514 if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 515 515 nParams ++; 516 516 } -
trunk/psLib/src/math/psMinimizePolyFit.c
r19304 r21183 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-09-02 19:03:38 $12 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 307 307 psPolynomial1D* myPoly, 308 308 const psVector *mask, 309 ps MaskType maskValue,309 psVectorMaskType maskValue, 310 310 const psVector* y, 311 311 const psVector* yErr, … … 326 326 if (mask != NULL) { 327 327 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, NULL); 328 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, NULL);328 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL); 329 329 } 330 330 … … 354 354 psF64 **matrix = A->data.F64; // Least-squares matrix 355 355 psF64 *vector = B->data.F64; // Least-squares vector 356 ps U8*dataMask = NULL; // Mask for data356 psVectorMaskType *dataMask = NULL; // Mask for data 357 357 if (mask) { 358 dataMask = mask->data. U8;359 } 360 ps U8*coeffMask = myPoly->coeffMask; // Mask for polynomial terms358 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 359 } 360 psMaskType *coeffMask = myPoly->coeffMask; // Mask for polynomial terms 361 361 psF64 *yData = y->data.F64; // Coordinate data 362 362 psF64 *yErrData = NULL; // Errors in the coordinate … … 473 473 psPolynomial1D* myPoly, 474 474 const psVector *mask, 475 ps MaskType maskValue,475 psVectorMaskType maskValue, 476 476 const psVector *f, 477 477 const psVector *fErr, … … 484 484 if (mask) { 485 485 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 486 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);486 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 487 487 } 488 488 if (x) { … … 529 529 530 530 // Dereference some pointers for speed in the loop 531 ps U8*dataMask = NULL; // Dereferenced version of mask for data points531 psVectorMaskType *dataMask = NULL; // Dereferenced version of mask for data points 532 532 if (mask) { 533 dataMask = mask->data. U8;534 } 535 ps U8*coeffMask = myPoly->coeffMask; // Dereferenced version of mask for polynomial terms533 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 534 } 535 psMaskType *coeffMask = myPoly->coeffMask; // Dereferenced version of mask for polynomial terms 536 536 psF64 *ordinates = NULL; // Dereferenced version of ordinate data 537 537 if (x) { … … 698 698 psPolynomial1D *poly, 699 699 const psVector *mask, 700 ps MaskType maskValue,700 psVectorMaskType maskValue, 701 701 const psVector *f, 702 702 const psVector *fErr, … … 711 711 if (mask != NULL) { 712 712 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 713 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);713 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 714 714 } 715 715 if (fErr != NULL) { … … 782 782 psStats *stats, 783 783 const psVector *mask, 784 ps MaskType maskValue,784 psVectorMaskType maskValue, 785 785 const psVector *f, 786 786 const psVector *fErr, … … 794 794 PS_ASSERT_VECTOR_NON_NULL(mask, false); 795 795 PS_ASSERT_VECTORS_SIZE_EQUAL(mask, f, false); 796 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);796 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 797 797 798 798 if (fErr != NULL) { … … 862 862 if (mask != NULL) { 863 863 for (psS32 i = 0 ; i < mask->n ; i++) { 864 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data. U8[i]);864 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 865 865 } 866 866 } … … 895 895 if (mask != NULL) { 896 896 for (psS32 i = 0 ; i < mask->n ; i++) { 897 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {897 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 898 898 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 899 899 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 922 922 // recovery is not allowed with this scheme 923 923 for (psS32 i = 0; i < resid->n; i++) { 924 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {924 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 925 925 continue; 926 926 } … … 936 936 937 937 if (mask != NULL) { 938 mask->data. U8[i] |= 0x01;938 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 939 939 } 940 940 continue; … … 979 979 psPolynomial2D* myPoly, 980 980 const psVector* mask, 981 ps MaskType maskValue,981 psVectorMaskType maskValue, 982 982 const psVector *f, 983 983 const psVector *fErr, … … 1003 1003 if (mask != NULL) { 1004 1004 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false); 1005 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1005 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1006 1006 } 1007 1007 … … 1026 1026 psF64 **matrix = A->data.F64; // Dereference the least-squares matrix 1027 1027 psF64 *vector = B->data.F64; // Dereference the least-squares vector 1028 ps U8**coeffMask = myPoly->coeffMask; // Dereference mask for polynomial terms1029 ps U8*dataMask = NULL; // Dereference mask for data1028 psMaskType **coeffMask = myPoly->coeffMask; // Dereference mask for polynomial terms 1029 psVectorMaskType *dataMask = NULL; // Dereference mask for data 1030 1030 if (mask) { 1031 dataMask = mask->data. U8;1031 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 1032 1032 } 1033 1033 psF64 *xData = x->data.F64; // Dereference x … … 1162 1162 psPolynomial2D *poly, 1163 1163 const psVector *mask, 1164 ps MaskType maskValue,1164 psVectorMaskType maskValue, 1165 1165 const psVector *f, 1166 1166 const psVector *fErr, … … 1179 1179 if (mask != NULL) { 1180 1180 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1181 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1181 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1182 1182 } 1183 1183 if (fErr != NULL) { … … 1231 1231 psStats *stats, 1232 1232 const psVector *mask, 1233 ps MaskType maskValue,1233 psVectorMaskType maskValue, 1234 1234 const psVector *f, 1235 1235 const psVector *fErr, … … 1254 1254 1255 1255 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1256 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1256 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1257 1257 1258 1258 if (fErr != NULL) { … … 1300 1300 if (mask != NULL) { 1301 1301 for (psS32 i = 0 ; i < mask->n ; i++) { 1302 psTrace("psLib.math", 7, "mask[%d] is %d\n", i, mask->data. U8[i]);1302 psTrace("psLib.math", 7, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 1303 1303 } 1304 1304 } … … 1329 1329 if (mask != NULL) { 1330 1330 for (psS32 i = 0 ; i < mask->n ; i++) { 1331 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {1331 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 1332 1332 psTrace("psLib.math", 7, "point %d at %f %f : value, fit : %f %f resid: %f\n", 1333 1333 i, x->data.F32[i], y->data.F32[i], f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 1356 1356 // recovery is not allowed with this scheme 1357 1357 for (psS32 i = 0; i < resid->n; i++) { 1358 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {1358 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 1359 1359 continue; 1360 1360 } … … 1370 1370 1371 1371 if (mask != NULL) { 1372 mask->data. U8[i] |= 0x01;1372 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 1373 1373 } 1374 1374 continue; … … 1403 1403 psPolynomial3D* myPoly, 1404 1404 const psVector* mask, 1405 ps MaskType maskValue,1405 psVectorMaskType maskValue, 1406 1406 const psVector *f, 1407 1407 const psVector *fErr, … … 1433 1433 if (mask != NULL) { 1434 1434 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1435 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1435 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1436 1436 } 1437 1437 … … 1464 1464 fErrData = fErr->data.F64; 1465 1465 } 1466 ps U8*dataMask = NULL; // Mask for data1466 psVectorMaskType *dataMask = NULL; // Mask for data 1467 1467 if (mask) { 1468 dataMask = mask->data. U8;1469 } 1470 ps U8***coeffMask = myPoly->coeffMask; // Mask for polynomial terms1468 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 1469 } 1470 psMaskType ***coeffMask = myPoly->coeffMask; // Mask for polynomial terms 1471 1471 int nYZterm = nYterm * nZterm; // Multiplication of the numbers, to calculate the index 1472 1472 … … 1603 1603 psPolynomial3D *poly, 1604 1604 const psVector *mask, 1605 ps MaskType maskValue,1605 psVectorMaskType maskValue, 1606 1606 const psVector *f, 1607 1607 const psVector *fErr, … … 1623 1623 if (mask != NULL) { 1624 1624 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1625 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1625 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1626 1626 } 1627 1627 if (fErr != NULL) { … … 1677 1677 psStats *stats, 1678 1678 const psVector *mask, 1679 ps MaskType maskValue,1679 psVectorMaskType maskValue, 1680 1680 const psVector *f, 1681 1681 const psVector *fErr, … … 1705 1705 1706 1706 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 1707 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1707 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1708 1708 1709 1709 if (fErr != NULL) { … … 1751 1751 if (mask != NULL) { 1752 1752 for (psS32 i = 0 ; i < mask->n ; i++) { 1753 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data. U8[i]);1753 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 1754 1754 } 1755 1755 } … … 1778 1778 if (mask != NULL) { 1779 1779 for (psS32 i = 0 ; i < mask->n ; i++) { 1780 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {1780 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 1781 1781 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 1782 1782 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 1805 1805 // recovery is not allowed with this scheme 1806 1806 for (psS32 i = 0; i < resid->n; i++) { 1807 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {1807 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 1808 1808 continue; 1809 1809 } … … 1819 1819 1820 1820 if (mask != NULL) { 1821 mask->data. U8[i] |= 0x01;1821 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 1822 1822 } 1823 1823 continue; … … 1850 1850 psPolynomial4D* myPoly, 1851 1851 const psVector* mask, 1852 ps MaskType maskValue,1852 psVectorMaskType maskValue, 1853 1853 const psVector *f, 1854 1854 const psVector *fErr, … … 1884 1884 if (mask) { 1885 1885 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false); 1886 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);1886 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 1887 1887 } 1888 1888 … … 1918 1918 fErrData = fErr->data.F64; 1919 1919 } 1920 ps U8*dataMask = NULL; // Mask for data1920 psVectorMaskType *dataMask = NULL; // Mask for data 1921 1921 if (mask) { 1922 dataMask = mask->data. U8;1923 } 1924 ps U8****coeffMask = myPoly->coeffMask; // Mask for polynomial terms1922 dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA; 1923 } 1924 psMaskType ****coeffMask = myPoly->coeffMask; // Mask for polynomial terms 1925 1925 int nYZTterm = nYterm * nZterm * nTterm; // Multiplication of the numbers, for calculating the index 1926 1926 int nZTterm = nZterm * nTterm; // Multiplication of the numbers, for calculating the index … … 2068 2068 psPolynomial4D *poly, 2069 2069 const psVector *mask, 2070 ps MaskType maskValue,2070 psVectorMaskType maskValue, 2071 2071 const psVector *f, 2072 2072 const psVector *fErr, … … 2091 2091 if (mask) { 2092 2092 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 2093 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);2093 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 2094 2094 } 2095 2095 if (fErr != NULL) { … … 2148 2148 psStats *stats, 2149 2149 const psVector *mask, 2150 ps MaskType maskValue,2150 psVectorMaskType maskValue, 2151 2151 const psVector *f, 2152 2152 const psVector *fErr, … … 2181 2181 2182 2182 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false); 2183 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);2183 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 2184 2184 2185 2185 if (fErr != NULL) { … … 2227 2227 if (mask != NULL) { 2228 2228 for (psS32 i = 0 ; i < mask->n ; i++) { 2229 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data. U8[i]);2229 psTrace("psLib.math", 6, "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 2230 2230 } 2231 2231 } … … 2255 2255 if (mask != NULL) { 2256 2256 for (psS32 i = 0 ; i < mask->n ; i++) { 2257 if (!((mask != NULL) && (mask->data. U8[i] & maskValue))) {2257 if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) { 2258 2258 psTrace("psLib.math", 6, "(f, fit)[%d] is (%f, %f). resid is (%f)\n", 2259 2259 i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]); … … 2282 2282 // recovery is not allowed with this scheme 2283 2283 for (psS32 i = 0; i < resid->n; i++) { 2284 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {2284 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 2285 2285 continue; 2286 2286 } … … 2296 2296 2297 2297 if (mask != NULL) { 2298 mask->data. U8[i] |= 0x01;2298 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 2299 2299 } 2300 2300 continue; -
trunk/psLib/src/math/psMinimizePolyFit.h
r11248 r21183 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 200 7-01-23 22:47:23$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 12 12 * … … 48 48 psPolynomial1D *poly, 49 49 const psVector *mask, 50 ps MaskType maskValue,50 psVectorMaskType maskValue, 51 51 const psVector *f, 52 52 const psVector *fErr, … … 57 57 psPolynomial2D *poly, 58 58 const psVector *mask, 59 ps MaskType maskValue,59 psVectorMaskType maskValue, 60 60 const psVector *f, 61 61 const psVector *fErr, … … 67 67 psPolynomial3D *poly, 68 68 const psVector *mask, 69 ps MaskType maskValue,69 psVectorMaskType maskValue, 70 70 const psVector *f, 71 71 const psVector *fErr, … … 78 78 psPolynomial4D *poly, 79 79 const psVector *mask, 80 ps MaskType maskValue,80 psVectorMaskType maskValue, 81 81 const psVector *f, 82 82 const psVector *fErr, … … 92 92 psStats *stats, 93 93 const psVector *mask, 94 ps MaskType maskValue,94 psVectorMaskType maskValue, 95 95 const psVector *f, 96 96 const psVector *fErr, … … 102 102 psStats *stats, 103 103 const psVector *mask, 104 ps MaskType maskValue,104 psVectorMaskType maskValue, 105 105 const psVector *f, 106 106 const psVector *fErr, … … 113 113 psStats *stats, 114 114 const psVector *mask, 115 ps MaskType maskValue,115 psVectorMaskType maskValue, 116 116 const psVector *f, 117 117 const psVector *fErr, … … 125 125 psStats *stats, 126 126 const psVector *mask, 127 ps MaskType maskValue,127 psVectorMaskType maskValue, 128 128 const psVector *f, 129 129 const psVector *fErr, -
trunk/psLib/src/math/psMinimizePowell.c
r11668 r21183 11 11 * NOTE: XXX: The SDR is silent about data types. F32 is implemented here. 12 12 * 13 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $14 * @date $Date: 200 7-02-06 21:36:09$13 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2009-01-27 06:39:38 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 43 43 #define PS_VECTOR_ADD_MULTIPLE(BASE, BASEMASK, LINE, OUT, MUL) \ 44 44 for (psS32 i=0;i<BASE->n;i++) { \ 45 if (BASEMASK->data. U8[i] == 0) { \45 if (BASEMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { \ 46 46 OUT->data.F32[i] = BASE->data.F32[i] + (MUL * LINE->data.F32[i]); \ 47 47 } else { \ … … 62 62 BOOL_VAR = true; \ 63 63 for (psS32 i=0;i<IN->n;i++) { \ 64 if ((INMASK->data. U8[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \64 if ((INMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \ 65 65 BOOL_VAR = false; \ 66 66 break; \ … … 359 359 PS_ASSERT_VECTOR_NON_NULL(paramMask, NAN); 360 360 PS_ASSERT_VECTOR_NON_EMPTY(paramMask, NAN); 361 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ U8, NAN);361 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, NAN); 362 362 PS_ASSERT_PTR_NON_NULL(coords, NAN); 363 363 PS_ASSERT_PTR_NON_NULL(func, NAN); … … 388 388 for (i=0;i<params->n;i++) { 389 389 psTrace("psLib.math", 6, "(params, paramMask, line)[%d] is (%f %d %f)\n", i, 390 params->data.F32[i], paramMask->data. U8[i], line->data.F32[i]);390 params->data.F32[i], paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i], line->data.F32[i]); 391 391 } 392 392 } … … 527 527 528 528 if (paramMask == NULL) { 529 myParamMask = psVectorAlloc(params->n, PS_TYPE_ U8);529 myParamMask = psVectorAlloc(params->n, PS_TYPE_VECTOR_MASK); 530 530 psVectorInit(myParamMask, 0); 531 531 } else { … … 572 572 biggestIter = 0; 573 573 for (i=0;i<numDims;i++) { 574 if (myParamMask->data. U8[i] == 0) {574 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 575 575 P_PSMINIMIZATION_SET_MAXITER((&dummyMin),PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS); 576 576 *(float*)&dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE; … … 603 603 // 4: Set the vector u = Q - P 604 604 for (i=0;i<numDims;i++) { 605 if (myParamMask->data. U8[i] == 0) {605 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 606 606 u->data.F32[i] = Q->data.F32[i] - params->data.F32[i]; 607 607 u->n++; … … 649 649 650 650 for (i=0;i<numDims;i++) { 651 if (myParamMask->data. U8[i] == 0) {651 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 652 652 pQP->data.F32[i] = (2 * Q->data.F32[i]) - params->data.F32[i]; 653 653 } else { … … 663 663 if (term1 < term2) { 664 664 for (i=0;i<numDims;i++) { 665 if (myParamMask->data. U8[i] == 0) {665 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 666 666 ((psVector *) v->data[biggestIter])->data.F32[i] = u->data.F32[i]; 667 667 } … … 671 671 // 7: Set P to Q 672 672 for (i=0;i<numDims;i++) { 673 if (myParamMask->data. U8[i] == 0) {673 if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 674 674 params->data.F32[i] = Q->data.F32[i]; 675 675 } -
trunk/psLib/src/math/psPolynomialMD.c
r19085 r21183 132 132 const psVector *values, // Measured values 133 133 const psVector *mask, // Mask for values 134 ps MaskType maskVal134 psVectorMaskType maskVal 135 135 ) 136 136 { … … 143 143 int numGood = numValues; // Number of good values 144 144 for (int i = 0; i < numValues; i++) { 145 if (mask && (mask->data. U8[i] & maskVal)) {145 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) { 146 146 numGood--; 147 147 continue; … … 253 253 254 254 bool psPolynomialMDFit(psPolynomialMD *poly, const psVector *values, const psVector *errors, 255 const psVector *mask, ps MaskType maskVal, const psArray *coordsArray)255 const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray) 256 256 { 257 257 PS_ASSERT_POLYNOMIALMD_NON_NULL(poly, false); … … 268 268 if (mask) { 269 269 PS_ASSERT_VECTOR_NON_NULL(mask, false); 270 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, false);270 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 271 271 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 272 272 } … … 294 294 PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false); 295 295 296 if (mask && (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal)) {296 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) { 297 297 continue; 298 298 } … … 321 321 } 322 322 323 // XXX this function should take a (ps MaskType markVal) argument323 // XXX this function should take a (psVectorMaskType markVal) argument 324 324 bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors, 325 const psVector *mask, ps MaskType maskVal, const psArray *coordsArray,325 const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray, 326 326 int numIter, float rej) 327 327 { … … 340 340 if (mask) { 341 341 PS_ASSERT_VECTOR_NON_NULL(mask, false); 342 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, false);342 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 343 343 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 344 344 } … … 355 355 356 356 // copy the input mask to a local temporary mask 357 poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_ U8); // Our own mask for input values357 poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values 358 358 psVectorInit(poly->ownMask, 0); 359 359 for (int i = 0; mask && (i < numValues); i++) { 360 if (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal) {361 poly->ownMask->data. U8[i] = 0xff;360 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) { 361 poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 362 362 numGood--; 363 363 } … … 392 392 i, values->data.F32[i], values->data.F32[i] - poly->deviations->data.F32[i], poly->deviations->data.F32[i], limit); 393 393 394 if (poly->ownMask->data. U8[i]) continue;394 if (poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 395 395 396 396 if (fabs(poly->deviations->data.F32[i]) > limit) { … … 398 398 i, values->data.F32[i], values->data.F32[i] + poly->deviations->data.F32[i], 399 399 poly->deviations->data.F32[i], limit); 400 poly->ownMask->data. U8[i] = 0xff;400 poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 401 401 numClipped++; 402 402 numGood--; … … 435 435 psVectorInit(vector, 0.0); 436 436 for (int i = 0; i < numValues; i++) { 437 if (mask->data. U8[i]) {437 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 438 438 continue; 439 439 } … … 462 462 463 463 bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors, 464 const psVector *mask, ps MaskType maskVal, const psArray *coordsArray,464 const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray, 465 465 int numIter, float rej) 466 466 { … … 478 478 if (mask) { 479 479 PS_ASSERT_VECTOR_NON_NULL(mask, false); 480 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ MASK, false);480 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 481 481 PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false); 482 482 } … … 500 500 PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false); 501 501 502 if (mask && (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal)) {502 if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) { 503 503 continue; 504 504 } … … 516 516 psImage *matrix = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix 517 517 psVector *vector = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector 518 psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_ U8); // Our own mask for input values518 psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values 519 519 psVectorInit(ownMask, 0); 520 520 if (mask) { 521 521 for (int i = 0; i < numValues; i++) { 522 if (mask->data.PS_TYPE_ MASK_DATA[i] & maskVal) {523 ownMask->data. U8[i] = 0xff;522 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) { 523 ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 524 524 numGood--; 525 525 } … … 551 551 float limit = rej * poly->stdevFit; // Rejection limit 552 552 for (int i = 0; i < numValues; i++) { 553 if (ownMask->data. U8[i]) {553 if (ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 554 554 continue; 555 555 } … … 558 558 i, values->data.F32[i], psPolynomialMDEval(poly, coordsArray->data[i]), 559 559 deviations->data.F32[i], limit); 560 ownMask->data. U8[i] = 0xff;560 ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 561 561 numClipped++; 562 562 numGood--; -
trunk/psLib/src/math/psPolynomialMD.h
r19085 r21183 52 52 const psVector *errors, ///< Errors 53 53 const psVector *mask, ///< Mask 54 ps MaskType maskVal, ///< Value to mask54 psVectorMaskType maskVal, ///< Value to mask 55 55 const psArray *coordsArray ///< Array of coordinates 56 56 ); … … 61 61 const psVector *errors, ///< Errors 62 62 const psVector *mask, ///< Mask 63 ps MaskType maskVal, ///< Value to mask63 psVectorMaskType maskVal, ///< Value to mask 64 64 const psArray *coordsArray, ///< Array of coordinates 65 65 int numIter, ///< Number of rejection iterations -
trunk/psLib/src/math/psPolynomialUtils.c
r19844 r21183 21 21 psStats *stats, 22 22 const psVector *mask, 23 ps MaskType maskValue,23 psVectorMaskType maskValue, 24 24 const psVector *f, 25 25 const psVector *fErr, … … 36 36 if (mask != NULL) { 37 37 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, NULL); 38 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, NULL);38 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL); 39 39 } 40 40 PS_ASSERT_VECTOR_NON_NULL(x, NULL); … … 106 106 // recovery is not allowed with this scheme 107 107 for (int i = 0; i < resid->n; i++) { 108 if ((mask != NULL) && (mask->data. U8[i] & maskValue)) {108 if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) { 109 109 continue; 110 110 } … … 112 112 if (resid->data.F64[i] - stats->sampleMedian > sigma*maxClipSigma) { 113 113 if (mask != NULL) { 114 mask->data. U8[i] |= 0x01;114 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 115 115 } 116 116 continue; … … 118 118 if (resid->data.F64[i] - stats->sampleMedian < sigma*minClipSigma) { 119 119 if (mask != NULL) { 120 mask->data. U8[i] |= 0x01;120 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01; 121 121 } 122 122 continue; -
trunk/psLib/src/math/psPolynomialUtils.h
r11248 r21183 2 2 * @brief extra psPolynomial-related functions 3 3 * 4 * $Revision: 1. 5$ $Name: not supported by cvs2svn $5 * $Date: 200 7-01-23 22:47:23$4 * $Revision: 1.6 $ $Name: not supported by cvs2svn $ 5 * $Date: 2009-01-27 06:39:38 $ 6 6 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 7 7 */ … … 24 24 psStats *stats, // Statistics to use in clipping 25 25 const psVector *mask, // Mask for input values 26 ps MaskType maskValue,// Mask value26 psVectorMaskType maskValue, // Mask value 27 27 const psVector *f, // Value of the function, f(x,y,z,t) 28 28 const psVector *fErr, // Error in the value -
trunk/psLib/src/math/psStats.c
r20515 r21183 13 13 * use ->min and ->max (PS_STAT_USE_RANGE) 14 14 * 15 * @version $Revision: 1.23 0$ $Name: not supported by cvs2svn $16 * @date $Date: 200 8-11-04 00:55:14$15 * @version $Revision: 1.231 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2009-01-27 06:39:38 $ 17 17 * 18 18 * Copyright 2006 IfA, University of Hawaii … … 68 68 #define PS_CLIPPED_SIGMA_UB 10.0 69 69 #define PS_POLY_MEDIAN_MAX_ITERATIONS 30 70 #define MASK_MARK 0x80 // bit to use internally to mark data as bad 70 71 #define MASK_MARK 0x80 // XXX : can we change this? bit to use internally to mark data as bad 71 72 #define PS_ROBUST_MAX_ITERATIONS 20 // Maximum number of iterations for robust statistics 72 73 … … 178 179 const psVector* errors, 179 180 const psVector* maskVector, 180 ps MaskType maskVal,181 psVectorMaskType maskVal, 181 182 psStats* stats) 182 183 { … … 190 191 int numData = myVector->n; // Number of data points 191 192 192 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;193 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 193 194 bool useRange = stats->options & PS_STAT_USE_RANGE; 194 195 … … 245 246 static long vectorMinMax(const psVector* myVector, 246 247 const psVector* maskVector, 247 ps MaskType maskVal,248 psVectorMaskType maskVal, 248 249 psStats* stats 249 250 ) … … 257 258 int numValid = 0; // Number of valid values 258 259 259 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;260 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 260 261 bool useRange = stats->options & PS_STAT_USE_RANGE; 261 262 … … 302 303 static bool vectorSampleMedian(const psVector* inVector, 303 304 const psVector* maskVector, 304 ps MaskType maskVal,305 psVectorMaskType maskVal, 305 306 psStats* stats) 306 307 { … … 308 309 309 310 bool useRange = stats->options & PS_STAT_USE_RANGE; 310 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8; // Dereference the vector311 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference the vector 311 312 psF32 *input = inVector->data.F32; // Dereference the vector 312 313 … … 387 388 const psVector* errors, 388 389 const psVector* maskVector, 389 ps MaskType maskVal,390 psVectorMaskType maskVal, 390 391 psStats* stats) 391 392 { … … 407 408 408 409 psF32 *data = myVector->data.F32; // Dereference 409 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;410 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 410 411 bool useRange = stats->options & PS_STAT_USE_RANGE; 411 412 psF32 *errorsData = (errors == NULL) ? NULL : errors->data.F32; … … 468 469 static bool vectorSampleMoments(const psVector* myVector, 469 470 const psVector* maskVector, 470 ps MaskType maskVal,471 psVectorMaskType maskVal, 471 472 psStats* stats) 472 473 { … … 490 491 491 492 psF32 *data = myVector->data.F32; // Dereference 492 ps U8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;493 psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; 493 494 bool useRange = stats->options & PS_STAT_USE_RANGE; 494 495 … … 557 558 const psVector* errors, 558 559 psVector* maskInput, 559 ps MaskType maskValInput,560 psVectorMaskType maskValInput, 560 561 psStats* stats 561 562 ) … … 580 581 581 582 // We copy the mask vector, to preserve the original 582 ps MaskType maskVal = MASK_MARK | maskValInput;583 psVectorMaskType maskVal = MASK_MARK | maskValInput; 583 584 584 585 // use the temporary vector for local temporary mask 585 stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_ U8);586 stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_VECTOR_MASK); 586 587 psVector *tmpMask = stats->tmpMask; 587 588 psVectorInit(tmpMask, 0); 588 589 if (maskInput) { 589 590 for (long i = 0; i < myVector->n; i++) { 590 if (maskInput->data. U8[i] & maskValInput) {591 tmpMask->data. U8[i] = maskVal;591 if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) { 592 tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal; 592 593 } 593 594 } … … 629 630 // sqrt(A)) 630 631 for (long j = 0; j < myVector->n; j++) { 631 if (!tmpMask->data. U8[j] &&632 if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && 632 633 fabsf(myVector->data.F32[j] - clippedMean) > stats->clipSigma * errors->data.F32[j]) { 633 tmpMask->data. U8[j] = 0xff;634 tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; 634 635 psTrace(TRACE, 10, "Clipped %ld: %f +/- %f\n", j, 635 636 myVector->data.F32[j], errors->data.F32[j]); … … 640 641 } else { 641 642 for (long j = 0; j < myVector->n; j++) { 642 if (!tmpMask->data. U8[j] &&643 if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && 643 644 fabsf(myVector->data.F32[j] - clippedMean) > (stats->clipSigma * clippedStdev)) { 644 tmpMask->data. U8[j] = 0xff;645 tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; 645 646 psTrace(TRACE, 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]); 646 647 numClipped++; … … 715 716 const psVector* errors, 716 717 psVector* maskInput, 717 ps MaskType maskValInput,718 psVectorMaskType maskValInput, 718 719 psStats* stats) 719 720 { … … 726 727 // and tested even if there is no supplied mask (and/or the maskVal is 0) 727 728 // XXX this would be better if we had globally defined mask values 728 ps MaskType maskVal = MASK_MARK | maskValInput;729 psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_ MASK); // The actual mask we will use729 psVectorMaskType maskVal = MASK_MARK | maskValInput; 730 psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_VECTOR_MASK); // The actual mask we will use 730 731 psVectorInit(mask, 0); 731 732 if (maskInput) { 732 733 for (long i = 0; i < myVector->n; i++) { 733 if (maskInput->data. U8[i] & maskValInput) {734 mask->data. U8[i] = maskVal;734 if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) { 735 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal; 735 736 } 736 737 } … … 934 935 if ((myVector->data.F32[i] < medianLo) || (myVector->data.F32[i] > medianHi)) { 935 936 // XXXX is this correct? is MASK_MARK safe? 936 mask->data. U8[i] |= MASK_MARK;937 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= MASK_MARK; 937 938 psTrace(TRACE, 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]); 938 939 } … … 998 999 long N50 = 0; 999 1000 for (long i = 0 ; i < myVector->n ; i++) { 1000 if (!mask->data. U8[i] &&1001 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] && 1001 1002 (binLo25F32 <= myVector->data.F32[i]) && (binHi25F32 >= myVector->data.F32[i])) { 1002 1003 N50++; … … 1046 1047 const psVector* errors, 1047 1048 psVector* mask, 1048 ps MaskType maskVal,1049 psVectorMaskType maskVal, 1049 1050 psStats* stats) 1050 1051 { … … 1224 1225 const psVector* errors, 1225 1226 psVector* mask, 1226 ps MaskType maskVal,1227 psVectorMaskType maskVal, 1227 1228 psStats* stats) 1228 1229 { … … 1347 1348 // fitStats->clipIter = 3.0; 1348 1349 // fitStats->clipSigma = 3.0; 1349 // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_ U8);1350 // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_VECTOR_MASK); 1350 1351 // psVectorInit (fitMask, 0); 1351 1352 … … 1418 1419 const psVector* errors, 1419 1420 psVector* mask, 1420 ps MaskType maskVal,1421 psVectorMaskType maskVal, 1421 1422 psStats* stats) 1422 1423 { … … 1713 1714 const psVector* errors, 1714 1715 psVector* mask, 1715 ps MaskType maskVal,1716 psVectorMaskType maskVal, 1716 1717 psStats* stats) 1717 1718 { … … 2225 2226 const psVector* errors, 2226 2227 const psVector* mask, 2227 ps MaskType maskVal)2228 psVectorMaskType maskVal) 2228 2229 { 2229 2230 psTrace(TRACE, 3,"---- %s() begin ----\n", __func__); … … 2233 2234 if (mask) { 2234 2235 PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, false); 2235 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_ U8, false);2236 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false); 2236 2237 } 2237 2238 if (errors) { … … 2255 2256 } 2256 2257 } 2257 psVector *mask U8= NULL; // Input mask vector, U8 version2258 psVector *maskVector = NULL; // Input mask vector, U8 version 2258 2259 if (mask) { 2259 if (mask->type.type == PS_TYPE_ MASK) {2260 mask U8= psMemIncrRefCounter((psPtr)mask);2260 if (mask->type.type == PS_TYPE_VECTOR_MASK) { 2261 maskVector = psMemIncrRefCounter((psPtr)mask); 2261 2262 } else { 2262 mask U8 = psVectorCopy(NULL, mask, PS_TYPE_MASK);2263 maskVector = psVectorCopy(NULL, mask, PS_TYPE_VECTOR_MASK); 2263 2264 } 2264 2265 } … … 2279 2280 // ************************************************************************ 2280 2281 if (stats->options & PS_STAT_SAMPLE_MEAN) { 2281 if (!vectorSampleMean(inF32, errorsF32, mask U8, maskVal, stats)) {2282 if (!vectorSampleMean(inF32, errorsF32, maskVector, maskVal, stats)) { 2282 2283 psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector sample mean"); 2283 2284 status &= false; … … 2287 2288 // ************************************************************************ 2288 2289 if (stats->options & (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE)) { 2289 if (!vectorSampleMedian(inF32, mask U8, maskVal, stats)) {2290 if (!vectorSampleMedian(inF32, maskVector, maskVal, stats)) { 2290 2291 psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample median"); 2291 2292 status &= false; … … 2295 2296 // ************************************************************************ 2296 2297 if (stats->options & PS_STAT_SAMPLE_STDEV) { 2297 if (!vectorSampleStdev(inF32, errorsF32, mask U8, maskVal, stats)) {2298 if (!vectorSampleStdev(inF32, errorsF32, maskVector, maskVal, stats)) { 2298 2299 psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample stdev"); 2299 2300 status &= false; … … 2302 2303 2303 2304 if (stats->options & (PS_STAT_SAMPLE_SKEWNESS | PS_STAT_SAMPLE_KURTOSIS)) { 2304 if (!vectorSampleMoments(inF32, mask U8, maskVal, stats)) {2305 if (!vectorSampleMoments(inF32, maskVector, maskVal, stats)) { 2305 2306 psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample moments"); 2306 2307 status &= false; … … 2310 2311 // ************************************************************************ 2311 2312 if (stats->options & (PS_STAT_MAX | PS_STAT_MIN)) { 2312 if (vectorMinMax(inF32, mask U8, maskVal, stats) == 0) {2313 if (vectorMinMax(inF32, maskVector, maskVal, stats) == 0) { 2313 2314 psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector minimum and maximum"); 2314 2315 status &= false; … … 2318 2319 // ************************************************************************ 2319 2320 if (stats->options & (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | PS_STAT_ROBUST_QUARTILE)) { 2320 if (!vectorRobustStats(inF32, errorsF32, mask U8, maskVal, stats)) {2321 if (!vectorRobustStats(inF32, errorsF32, maskVector, maskVal, stats)) { 2321 2322 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate robust statistics")); 2322 2323 status &= false; … … 2326 2327 // ************************************************************************ 2327 2328 if (stats->options & (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV)) { 2328 if (!vectorFittedStats(inF32, errorsF32, mask U8, maskVal, stats)) {2329 if (!vectorFittedStats(inF32, errorsF32, maskVector, maskVal, stats)) { 2329 2330 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2330 2331 status &= false; … … 2337 2338 psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V2"); 2338 2339 } 2339 if (!vectorFittedStats_v2(inF32, errorsF32, mask U8, maskVal, stats)) {2340 if (!vectorFittedStats_v2(inF32, errorsF32, maskVector, maskVal, stats)) { 2340 2341 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2341 2342 status &= false; … … 2348 2349 psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V3"); 2349 2350 } 2350 if (!vectorFittedStats_v3(inF32, errorsF32, mask U8, maskVal, stats)) {2351 if (!vectorFittedStats_v3(inF32, errorsF32, maskVector, maskVal, stats)) { 2351 2352 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2352 2353 status &= false; … … 2359 2360 psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V4"); 2360 2361 } 2361 if (!vectorFittedStats_v4(inF32, errorsF32, mask U8, maskVal, stats)) {2362 if (!vectorFittedStats_v4(inF32, errorsF32, maskVector, maskVal, stats)) { 2362 2363 psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics")); 2363 2364 status &= false; … … 2367 2368 // ************************************************************************ 2368 2369 if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) { 2369 if (!vectorClippedStats(inF32, errorsF32, mask U8, maskVal, stats)) {2370 if (!vectorClippedStats(inF32, errorsF32, maskVector, maskVal, stats)) { 2370 2371 psError(PS_ERR_UNKNOWN, false, "Failed to calculate clipped statistics\n"); 2371 2372 status &= false; … … 2375 2376 psFree(inF32); 2376 2377 psFree(errorsF32); 2377 psFree(mask U8);2378 psFree(maskVector); 2378 2379 psTrace(TRACE, 3,"---- %s() end ----\n", __func__); 2379 2380 return status; -
trunk/psLib/src/math/psStats.h
r18876 r21183 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-08-03 20:55:09$10 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 13 13 */ … … 96 96 */ 97 97 bool psVectorStats( 98 psStats* stats, ///< stats structure defines stats to be calculated and how99 const psVector* in, ///< Vector to be analysed.100 const psVector* errors, ///< Errors.101 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL102 ps MaskType maskVal///< Only mask elements with one of these bits set in maskVector98 psStats* stats, ///< stats structure defines stats to be calculated and how 99 const psVector* in, ///< Vector to be analysed. 100 const psVector* errors, ///< Errors. 101 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL 102 psVectorMaskType maskVal ///< Only mask elements with one of these bits set in maskVector 103 103 ); 104 104 -
trunk/psLib/src/mathtypes/psVector.c
r20547 r21183 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.10 4$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-11-05 11:12:40$12 * @version $Revision: 1.105 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 987 987 } 988 988 989 // count number of pixels with given mask value 989 // count number of pixels with given mask value. the comparison is against a U64 type to 990 // allow any int-type of vector. all signed and unsigned int types are allowed 990 991 long psVectorCountPixelMask (psVector *mask, 991 ps MaskTypevalue)992 psU64 value) 992 993 { 993 994 long Npixels = 0; … … 998 999 } 999 1000 1000 psElemType type; 1001 type = mask->type.type; 1002 1003 if (type != PS_TYPE_MASK) { 1004 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 1005 "psVector type does not match the specified psMaskType!\n"); 1006 return -1; 1007 } 1008 1001 # define PS_VECTOR_COUNT_PIXEL_MASK(NAME,TYPE) \ 1002 case PS_TYPE_##NAME: \ 1003 for (long i = 0; i < mask->n; i++) { \ 1004 if (mask->data.TYPE[i] & value) { \ 1005 Npixels ++; \ 1006 } \ 1007 } \ 1008 break; 1009 1010 psElemType type = mask->type.type; 1009 1011 switch (type) { 1010 case PS_TYPE_U8: 1011 case PS_TYPE_U16: 1012 for (long i = 0; i < mask->n; i++) { 1013 if (mask->data.PS_TYPE_MASK_DATA[i] & value) { 1014 Npixels ++; 1015 } 1016 } 1017 break; 1018 case PS_TYPE_S8: 1019 case PS_TYPE_S16: 1020 case PS_TYPE_S32: 1021 case PS_TYPE_S64: 1022 case PS_TYPE_U32: 1023 case PS_TYPE_U64: 1024 case PS_TYPE_F32: 1025 case PS_TYPE_F64: 1012 PS_VECTOR_COUNT_PIXEL_MASK(U8, U8); 1013 PS_VECTOR_COUNT_PIXEL_MASK(U16,U16); 1014 PS_VECTOR_COUNT_PIXEL_MASK(U32,U32); 1015 PS_VECTOR_COUNT_PIXEL_MASK(U64,U64); 1016 PS_VECTOR_COUNT_PIXEL_MASK(S8, S8); 1017 PS_VECTOR_COUNT_PIXEL_MASK(S16,S16); 1018 PS_VECTOR_COUNT_PIXEL_MASK(S32,S32); 1019 PS_VECTOR_COUNT_PIXEL_MASK(S64,S64); 1026 1020 default: 1027 1021 psError(PS_ERR_BAD_PARAMETER_TYPE, true, -
trunk/psLib/src/mathtypes/psVector.h
r19502 r21183 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.7 3$ $Name: not supported by cvs2svn $13 * @date $Date: 200 8-09-12 00:22:48 $12 * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 15 15 */ … … 379 379 */ 380 380 long psVectorCountPixelMask( 381 psVector *mask, ///< input vector to count382 ps MaskType value///< the mask value to satisfy381 psVector *mask, ///< input vector to count 382 psU64 value ///< the mask value to satisfy 383 383 ); 384 384 -
trunk/psLib/src/sys/psType.h
r14454 r21183 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.6 2$ $Name: not supported by cvs2svn $13 * @date $Date: 200 7-08-09 03:30:47$12 * @version $Revision: 1.63 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2009-01-27 06:39:38 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 141 141 } psDataType; 142 142 143 // macros to abstract the generic mask type : these values must be consistent 143 144 #define PS_TYPE_MASK PS_TYPE_U8 /**< the psElemType to use for mask image */ 144 145 #define PS_TYPE_MASK_DATA U8 /**< the data member to use for mask image */ 145 146 #define PS_TYPE_MASK_NAME "psU8" /**< the data type for mask as a string */ 146 147 #define PS_MIN_MASK_TYPE 0 /**< minimum valid Mask value */ 148 #define PS_MAX_MASK_TYPE UINT8_MAX /**< maximum valid Mask value */ 147 149 typedef psU8 psMaskType; ///< the C datatype for a mask image 150 #define PS_NOT_MASK(A)(UINT8_MAX-(A)) 151 152 // alternate versions if needed 153 // #define PS_NOT_MASK(A)(UINT16_MAX-(A)) 154 // #define PS_NOT_MASK(A)(UINT32_MAX-(A)) 155 // #define PS_NOT_MASK(A)(UINT64_MAX-(A)) 156 157 // macros to abstract the vector mask type : these values must be consistent 158 #define PS_TYPE_VECTOR_MASK PS_TYPE_U8 /**< the psElemType to use for mask image */ 159 #define PS_TYPE_VECTOR_MASK_DATA U8 /**< the data member to use for mask image */ 160 #define PS_TYPE_VECTOR_MASK_NAME "psU8" /**< the data type for mask as a string */ 161 #define PS_MIN_VECTOR_MASK_TYPE 0 /**< minimum valid Vector Mask value */ 162 #define PS_MAX_VECTOR_MASK_TYPE UINT8_MAX /**< maximum valid Vector Mask value */ 163 typedef psU8 psVectorMaskType; ///< the C datatype for a mask image 164 #define PS_NOT_VECTOR_MASK(A)(UINT8_MAX-(A)) 165 166 // macros to abstract the image mask type : these values must be consistent 167 #define PS_TYPE_IMAGE_MASK PS_TYPE_U16 /**< the psElemType to use for mask image */ 168 #define PS_TYPE_IMAGE_MASK_DATA U16 /**< the data member to use for mask image */ 169 #define PS_TYPE_IMAGE_MASK_NAME "psU16" /**< the data type for mask as a string */ 170 #define PS_MIN_IMAGE_MASK_TYPE 0 /**< minimum valid Image Mask value */ 171 #define PS_MAX_IMAGE_MASK_TYPE UINT16_MAX /**< maximum valid Image Mask value */ 172 typedef psU16 psImageMaskType; ///< the C datatype for a mask image 173 #define PS_NOT_IMAGE_MASK(A)(UINT16_MAX-(A)) 148 174 149 175 #define PS_MIN_S8 INT8_MIN /**< minimum valid psS8 value */ -
trunk/psLib/src/types/psMetadata.c
r20417 r21183 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.17 4$ $Name: not supported by cvs2svn $15 * @date $Date: 200 8-10-28 00:13:19$14 * @version $Revision: 1.175 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2009-01-27 06:39:38 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 866 866 METADATA_ADD_TYPE(F32,psF32,PS_DATA_F32) 867 867 METADATA_ADD_TYPE(F64,psF64,PS_DATA_F64) 868 869 METADATA_ADD_TYPE(Mask,psMaskType,PS_TYPE_MASK) 870 METADATA_ADD_TYPE(VectorMask,psVectorMaskType,PS_TYPE_VECTOR_MASK) 871 METADATA_ADD_TYPE(ImageMask,psImageMaskType,PS_TYPE_IMAGE_MASK) 872 868 873 METADATA_ADD_TYPE(List,psList*,PS_DATA_LIST) 869 874 METADATA_ADD_TYPE(Str,const char*,PS_DATA_STRING) … … 1011 1016 } 1012 1017 1013 #define psMetadataLookupNumTYPE(TYPE ) \1014 ps##TYPE psMetadataLookup## TYPE(bool *status, const psMetadata *md, const char *key) \1018 #define psMetadataLookupNumTYPE(TYPE,NAME) \ 1019 ps##TYPE psMetadataLookup##NAME(bool *status, const psMetadata *md, const char *key) \ 1015 1020 { \ 1016 1021 psMetadataItem *metadataItem = NULL; \ … … 1081 1086 } 1082 1087 1083 psMetadataLookupNumTYPE(F32) 1084 psMetadataLookupNumTYPE(F64) 1085 psMetadataLookupNumTYPE(S8) 1086 psMetadataLookupNumTYPE(S16) 1087 psMetadataLookupNumTYPE(S32) 1088 psMetadataLookupNumTYPE(S64) 1089 psMetadataLookupNumTYPE(U8) 1090 psMetadataLookupNumTYPE(U16) 1091 psMetadataLookupNumTYPE(U32) 1092 psMetadataLookupNumTYPE(U64) 1093 psMetadataLookupNumTYPE(Bool) 1088 psMetadataLookupNumTYPE(F32,F32) 1089 psMetadataLookupNumTYPE(F64,F64) 1090 psMetadataLookupNumTYPE(S8,S8) 1091 psMetadataLookupNumTYPE(S16,S16) 1092 psMetadataLookupNumTYPE(S32,S32) 1093 psMetadataLookupNumTYPE(S64,S64) 1094 psMetadataLookupNumTYPE(U8,U8) 1095 psMetadataLookupNumTYPE(U16,U16) 1096 psMetadataLookupNumTYPE(U32,U32) 1097 psMetadataLookupNumTYPE(U64,U64) 1098 psMetadataLookupNumTYPE(Bool,Bool) 1099 1100 psMetadataLookupNumTYPE(MaskType,Mask) 1101 psMetadataLookupNumTYPE(VectorMaskType,VectorMask) 1102 psMetadataLookupNumTYPE(ImageMaskType,ImageMask) 1094 1103 1095 1104 psMetadataItem* psMetadataGet(const psMetadata *md, -
trunk/psLib/src/types/psMetadata.h
r19056 r21183 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.10 5$ $Name: not supported by cvs2svn $12 * @date $Date: 200 8-08-14 03:18:41$11 * @version $Revision: 1.106 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2009-01-27 06:39:38 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 763 763 764 764 765 /** Add a psMaskType value to metadata collection. 766 * 767 * @return bool: True for success, False for failure. 768 */ 769 bool psMetadataAddMask( 770 psMetadata* md, ///< Metadata collection to insert metadata item 771 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 772 const char* name, ///< Name of metadata item 773 int format, ///< psMetadataFlag options/flags 774 const char* comment, ///< Comment for metadata item 775 psMaskType value ///< Value for metadata item data 776 ); 777 778 779 /** Add a psVectorMaskType value to metadata collection. 780 * 781 * @return bool: True for success, False for failure. 782 */ 783 bool psMetadataAddVectorMask( 784 psMetadata* md, ///< Metadata collection to insert metadata item 785 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 786 const char* name, ///< Name of metadata item 787 int format, ///< psMetadataFlag options/flags 788 const char* comment, ///< Comment for metadata item 789 psVectorMaskType value ///< Value for metadata item data 790 ); 791 792 793 /** Add a psImageMaskType value to metadata collection. 794 * 795 * @return bool: True for success, False for failure. 796 */ 797 bool psMetadataAddImageMask( 798 psMetadata* md, ///< Metadata collection to insert metadata item 799 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 800 const char* name, ///< Name of metadata item 801 int format, ///< psMetadataFlag options/flags 802 const char* comment, ///< Comment for metadata item 803 psImageMaskType value ///< Value for metadata item data 804 ); 805 806 807 765 808 /** Add a psList to metadata collection. 766 809 * … … 1095 1138 */ 1096 1139 psU64 psMetadataLookupU64( 1140 bool *status, ///< Status of lookup. 1141 const psMetadata *md, ///< Metadata collection to lookup metadata item. 1142 const char *key ///< Name of metadata key. 1143 ); 1144 1145 1146 /** Find an item in the metadata collection based on key name and return its integer value. 1147 * 1148 * Items may be found in the metadata by providing a key. If the key is 1149 * non-unique, the value of the first item is returned. If the item is not 1150 * found, zero is returned. 1151 * 1152 * @return psMaskType : Value of metadata item. 1153 */ 1154 psMaskType psMetadataLookupMask( 1155 bool *status, ///< Status of lookup. 1156 const psMetadata *md, ///< Metadata collection to lookup metadata item. 1157 const char *key ///< Name of metadata key. 1158 ); 1159 1160 1161 /** Find an item in the metadata collection based on key name and return its integer value. 1162 * 1163 * Items may be found in the metadata by providing a key. If the key is 1164 * non-unique, the value of the first item is returned. If the item is not 1165 * found, zero is returned. 1166 * 1167 * @return psVectorMaskType : Value of metadata item. 1168 */ 1169 psVectorMaskType psMetadataLookupVectorMask( 1170 bool *status, ///< Status of lookup. 1171 const psMetadata *md, ///< Metadata collection to lookup metadata item. 1172 const char *key ///< Name of metadata key. 1173 ); 1174 1175 1176 /** Find an item in the metadata collection based on key name and return its integer value. 1177 * 1178 * Items may be found in the metadata by providing a key. If the key is 1179 * non-unique, the value of the first item is returned. If the item is not 1180 * found, zero is returned. 1181 * 1182 * @return psImageMaskType : Value of metadata item. 1183 */ 1184 psImageMaskType psMetadataLookupImageMask( 1097 1185 bool *status, ///< Status of lookup. 1098 1186 const psMetadata *md, ///< Metadata collection to lookup metadata item. -
trunk/psLib/src/types/psPixels.c
r19539 r21183 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-09-12 22:36:29$9 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 150 150 const psPixels *pixels, 151 151 psRegion region, 152 ps MaskType maskVal)152 psImageMaskType maskVal) 153 153 { 154 154 PS_ASSERT_PIXELS_NON_NULL(pixels, NULL); … … 169 169 int numRows = y1 - y0 + 1, numCols = x1 - x0 + 1; // Size of image 170 170 171 out = psImageRecycle(out, numCols, numRows, PS_TYPE_ MASK);171 out = psImageRecycle(out, numCols, numRows, PS_TYPE_IMAGE_MASK); 172 172 if (!out) { 173 173 psError(PS_ERR_UNKNOWN, false, _("Failed to create image of size %dx%d."), numCols, numRows); … … 181 181 // cycle through the vector of pixels and insert pixels into image 182 182 long length = pixels->n; // Length of pixel array 183 ps MaskType** outData = out->data.PS_TYPE_MASK_DATA;183 psImageMaskType** outData = out->data.PS_TYPE_IMAGE_MASK_DATA; 184 184 for (int p = 0; p < length; p++) { 185 185 float x = pixels->data[p].x; … … 196 196 psPixels* psPixelsFromMask(psPixels* out, 197 197 const psImage* mask, 198 ps MaskType maskVal)198 psImageMaskType maskVal) 199 199 { 200 200 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 201 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);201 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 202 202 203 203 int numRows = mask->numRows, numCols = mask->numCols; // Size of image … … 214 214 for (int y = 0; y < numRows; y++) { 215 215 for (int x = 0; x < numCols; x++) { 216 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {216 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 217 217 psPixelsAdd(out, out->nalloc, x, y); 218 218 } -
trunk/psLib/src/types/psPixels.h
r19539 r21183 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-09-12 22:36:29$8 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 189 189 const psPixels* pixels, ///< list of pixels to use 190 190 psRegion region, ///< region to define the output mask image 191 ps MaskType maskVal///< the mask bit-values to act upon191 psImageMaskType maskVal ///< the mask bit-values to act upon 192 192 ); 193 193 … … 205 205 psPixels *out, ///< psPixels to recycle, or NULL 206 206 const psImage *mask, ///< the input mask psImage 207 ps MaskType maskVal///< the mask bit-values to act upon207 psImageMaskType maskVal ///< the mask bit-values to act upon 208 208 ); 209 209 -
trunk/psModules/src/astrom/pmAstrometryDistortion.c
r19305 r21183 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-09-02 19:05:09$9 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-27 06:39:38 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 121 121 // this analysis has too few data points to use the robust median method 122 122 stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 123 mask = psVectorAlloc (Npts, PS_TYPE_ MASK);123 mask = psVectorAlloc (Npts, PS_TYPE_VECTOR_MASK); 124 124 psVectorInit (mask, 0); 125 125 … … 206 206 // this analysis has too few data points to use the robust median method 207 207 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 208 psVector *mask = psVectorAlloc (gradients->n, PS_TYPE_ MASK);208 psVector *mask = psVectorAlloc (gradients->n, PS_TYPE_VECTOR_MASK); 209 209 psVectorInit (mask, 0); 210 210 -
trunk/psModules/src/astrom/pmAstrometryObjects.c
r20801 r21183 8 8 * @author EAM, IfA 9 9 * 10 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-11-20 01:26:07$10 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 227 227 228 228 // constant errors 229 psVector *mask = psVectorAlloc (match->n, PS_TYPE_ U8);229 psVector *mask = psVectorAlloc (match->n, PS_TYPE_VECTOR_MASK); 230 230 psVectorInit (mask, 0); 231 231 -
trunk/psModules/src/camera/pmCellSquish.c
r12696 r21183 12 12 13 13 14 bool pmCellSquish(pmCell *cell, ps MaskType maskVal, bool useShifts)14 bool pmCellSquish(pmCell *cell, psImageMaskType maskVal, bool useShifts) 15 15 { 16 16 PS_ASSERT_PTR_NON_NULL(cell, false); … … 116 116 psImage *squishImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Squished image 117 117 psImageInit(squishImage, 0.0); 118 psImage *squishMask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK); // Squished mask118 psImage *squishMask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Squished mask 119 119 psImageInit(squishMask, 0); 120 120 … … 159 159 squishImage->data.F32[ySquish][xSquish] += image->data.F32[y][x]; 160 160 if (mask) { 161 squishMask->data.PS_TYPE_ MASK_DATA[ySquish][xSquish] |= mask->data.U8[y][x] & maskVal;161 squishMask->data.PS_TYPE_IMAGE_MASK_DATA[ySquish][xSquish] |= mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal; 162 162 } 163 163 } -
trunk/psModules/src/camera/pmCellSquish.h
r12696 r21183 7 7 /// already have been read) and masks. 8 8 bool pmCellSquish(pmCell *cell, ///< Cell to have readouts combined 9 ps MaskType maskVal, ///< Value to be masked9 psImageMaskType maskVal, ///< Value to be masked 10 10 bool useShifts ///< Use the shifts when squishing? 11 11 ); -
trunk/psModules/src/camera/pmFPABin.c
r20442 r21183 9 9 #include "pmFPABin.h" 10 10 11 bool pmReadoutRebin(pmReadout *out, const pmReadout *in, ps MaskType maskVal, int xBin, int yBin)11 bool pmReadoutRebin(pmReadout *out, const pmReadout *in, psImageMaskType maskVal, int xBin, int yBin) 12 12 { 13 13 PM_ASSERT_READOUT_NON_NULL(out, false); … … 50 50 for (int y = yStart; y < yStop; y++) { 51 51 for (int x = xStart; x < xStop; x++) { 52 if (inMask && (inMask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal)) {52 if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) { 53 53 continue; 54 54 } -
trunk/psModules/src/camera/pmFPABin.h
r19695 r21183 9 9 bool pmReadoutRebin(pmReadout *out, ///< Output readout 10 10 const pmReadout *in,///< Input readout 11 ps MaskType maskVal, ///< Value to mask11 psImageMaskType maskVal, ///< Value to mask 12 12 int xBin, int yBin ///< Binning factors in x and y 13 13 ); -
trunk/psModules/src/camera/pmFPAMaskWeight.c
r20749 r21183 42 42 continue; 43 43 } 44 masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_ U8);44 masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK); 45 45 psImageInit(masks->data[i], 0); 46 46 } … … 98 98 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 99 99 100 bool pmReadoutSetMask(pmReadout *readout, ps MaskType satMask, psMaskType badMask)100 bool pmReadoutSetMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask) 101 101 { 102 102 PS_ASSERT_PTR_NON_NULL(readout, false); … … 124 124 if (!readout->mask) { 125 125 // Generate a (throwaway) mask image, if required 126 readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_ U8);126 readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK); 127 127 } 128 128 psImage *mask = readout->mask; // The mask pixels … … 131 131 // Dereference pointers for speed 132 132 psF32 **imageData = image->data.F32;// The image 133 ps U8 **maskData = mask->data.U8; // The mask133 psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; // The mask 134 134 135 135 for (int i = 0; i < image->numRows; i++) { … … 153 153 // pixels. currently, it will set mask bits if (value <= BAD) or (value >= SATURATION) 154 154 // should we optionally ignore these tests? 155 bool pmReadoutGenerateMask(pmReadout *readout, ps MaskType satMask, psMaskType badMask)155 bool pmReadoutGenerateMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask) 156 156 { 157 157 PS_ASSERT_PTR_NON_NULL(readout, false); … … 294 294 } 295 295 296 bool pmReadoutGenerateMaskWeight(pmReadout *readout, ps MaskType satMask, psMaskType badMask, bool poisson)296 bool pmReadoutGenerateMaskWeight(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson) 297 297 { 298 298 PS_ASSERT_PTR_NON_NULL(readout, false); … … 306 306 } 307 307 308 bool pmCellGenerateMaskWeight(pmCell *cell, ps MaskType satMask, psMaskType badMask, bool poisson)308 bool pmCellGenerateMaskWeight(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson) 309 309 { 310 310 PS_ASSERT_PTR_NON_NULL(cell, false); … … 321 321 322 322 323 bool pmReadoutWeightRenormPixels(const pmReadout *readout, ps MaskType maskVal,323 bool pmReadoutWeightRenormPixels(const pmReadout *readout, psImageMaskType maskVal, 324 324 psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng) 325 325 { … … 363 363 364 364 365 bool pmReadoutWeightRenormPhot(const pmReadout *readout, ps MaskType maskVal, int num, float width,365 bool pmReadoutWeightRenormPhot(const pmReadout *readout, psImageMaskType maskVal, int num, float width, 366 366 psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng) 367 367 { … … 411 411 psVector *source = psVectorAlloc(num, PS_TYPE_F32); // Measurements of fake sources 412 412 psVector *guess = psVectorAlloc(num, PS_TYPE_F32); // Guess at significance 413 psVector *photMask = psVectorAlloc(num, PS_TYPE_ MASK); // Mask for fluxes413 psVector *photMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for fluxes 414 414 for (int i = 0; i < num; i++) { 415 415 // Coordinates of interest … … 433 433 float yGauss = gauss->data.F32[v]; // Value of Gaussian in y 434 434 for (int u = 0, x = xPix - size; u < fullSize; u++, x++) { 435 if (mask && mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {435 if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 436 436 continue; 437 437 } … … 453 453 } 454 454 455 photMask->data.PS_TYPE_ MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&455 photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) && 456 456 isfinite(sumWeight) && sumGauss > 0 && sumGauss2 > 0) ? 457 457 0 : 0xFF); … … 493 493 ratio->data.F32[i] = measuredSig / guess->data.F32[i]; 494 494 if (guess->data.F32[i] <= 0.0 || source->data.F32[i] <= 0.0 || !isfinite(ratio->data.F32[i])) { 495 photMask->data.PS_TYPE_ MASK_DATA[i] = 0xFF;495 photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xFF; 496 496 } 497 497 psTrace("psModules.camera", 9, "Ratio %d: %f, %f, %f\n", … … 523 523 524 524 525 bool pmReadoutWeightRenorm(const pmReadout *readout, ps MaskType maskVal, psStatsOptions meanStat,525 bool pmReadoutWeightRenorm(const pmReadout *readout, psImageMaskType maskVal, psStatsOptions meanStat, 526 526 psStatsOptions stdevStat, int width, psRandom *rng) 527 527 { … … 591 591 592 592 593 bool pmReadoutMaskNonfinite(pmReadout *readout, ps MaskType maskVal)593 bool pmReadoutMaskNonfinite(pmReadout *readout, psImageMaskType maskVal) 594 594 { 595 595 PM_ASSERT_READOUT_NON_NULL(readout, false); … … 601 601 602 602 if (!readout->mask) { 603 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);603 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 604 604 } 605 605 psImage *mask = readout->mask; // Readout's mask … … 608 608 for (int x = 0; x < numCols; x++) { 609 609 if (!isfinite(image->data.F32[y][x]) || (weight && !isfinite(weight->data.F32[y][x]))) { 610 mask->data.PS_TYPE_ MASK_DATA[y][x] |= maskVal;610 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskVal; 611 611 } 612 612 } … … 618 618 619 619 620 bool pmReadoutMaskApply(pmReadout *readout, ps MaskType maskVal)620 bool pmReadoutMaskApply(pmReadout *readout, psImageMaskType maskVal) 621 621 { 622 622 PM_ASSERT_READOUT_NON_NULL(readout, false); … … 625 625 626 626 int numCols = readout->image->numCols, numRows = readout->image->numRows; // Size of image 627 ps MaskType **maskData = readout->mask->data.PS_TYPE_MASK_DATA; // Dereference mask627 psImageMaskType **maskData = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask 628 628 psF32 **imageData = readout->image->data.F32;// Dereference image 629 629 psF32 **weightData = readout->weight ? readout->weight->data.F32 : NULL; // Dereference weight map … … 644 644 645 645 646 bool pmReadoutInterpolateBadPixels(pmReadout *readout, ps MaskType maskVal, psImageInterpolateMode mode,647 float poorFrac, ps MaskType maskPoor, psMaskType maskBad)646 bool pmReadoutInterpolateBadPixels(pmReadout *readout, psImageMaskType maskVal, psImageInterpolateMode mode, 647 float poorFrac, psImageMaskType maskPoor, psImageMaskType maskBad) 648 648 { 649 649 PM_ASSERT_READOUT_NON_NULL(readout, false); … … 667 667 psVector *imagePix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for image 668 668 psVector *weightPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for weight 669 psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_MASK); // Corresponding values for mask 669 psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_IMAGE_MASK); // Corresponding values for mask 670 // NOTE: maskPix carries the actual image mask values -- do NOT use 671 // PS_TYPE_VECTOR_MASK here; it is storage, and is not treated as a vector mask 670 672 671 673 long numBad = 0; // Number of bad pixels interpolated 672 674 for (int y = 0; y < numRows; y++) { 673 675 for (int x = 0; x < numCols; x++) { 674 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {676 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 675 677 double imageValue, weightValue; // Image and weight value from interpolation 676 psMaskType maskValue = 0; // Mask value from interpolation 677 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, 678 x, y, interp); 678 psImageMaskType maskValue = 0; // Mask value from interpolation 679 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, x, y, interp); 679 680 if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) { 680 681 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y); … … 697 698 imagePix->data.F32[numBad] = imageValue; 698 699 weightPix->data.F32[numBad] = weightValue; 699 maskPix->data.PS_TYPE_ MASK_DATA[numBad] = maskValue;700 maskPix->data.PS_TYPE_IMAGE_MASK_DATA[numBad] = maskValue; 700 701 numBad++; 701 702 } … … 709 710 image->data.F32[y][x] = imagePix->data.F32[i]; 710 711 weight->data.F32[y][x] = weightPix->data.F32[i]; 711 mask->data.PS_TYPE_ MASK_DATA[y][x] = maskPix->data.PS_TYPE_MASK_DATA[i];712 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_IMAGE_MASK_DATA[i]; 712 713 } 713 714 -
trunk/psModules/src/camera/pmFPAMaskWeight.h
r20486 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-10-31 21:50:16$7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 42 42 /// iterating using pmReadoutReadNext, in which case the HDU can't be generated. 43 43 bool pmReadoutSetMask(pmReadout *readout, ///< Readout for which to set mask 44 ps MaskType satMask, ///< Mask value to give saturated pixels45 ps MaskType badMask ///< Mask value to give bad (low) pixels44 psImageMaskType satMask, ///< Mask value to give saturated pixels 45 psImageMaskType badMask ///< Mask value to give bad (low) pixels 46 46 ); 47 47 … … 62 62 /// is suitable for output (complete with HDU entry). This is intended for most operations. 63 63 bool pmReadoutGenerateMask(pmReadout *readout, ///< Readout for which to generate mask 64 ps MaskType sat, ///< Mask value to give saturated pixels65 ps MaskType bad ///< Mask value to give bad (low) pixels64 psImageMaskType sat, ///< Mask value to give saturated pixels 65 psImageMaskType bad ///< Mask value to give bad (low) pixels 66 66 ); 67 67 … … 79 79 /// Calls pmReadoutGenerateMask and pmReadoutGenerateWeight for the readout 80 80 bool pmReadoutGenerateMaskWeight(pmReadout *readout, ///< Readout for which to generate mask and weights 81 ps MaskType sat, ///< Mask value to give saturated pixels82 ps MaskType bad, ///< Mask value to give bad (low) pixels81 psImageMaskType sat, ///< Mask value to give saturated pixels 82 psImageMaskType bad, ///< Mask value to give bad (low) pixels 83 83 bool poisson ///< Use poisson weights (in addition to read noise)? 84 84 ); … … 88 88 /// Calls pmReadoutGenerateMaskWeight for each readout within the cell. 89 89 bool pmCellGenerateMaskWeight(pmCell *cell, ///< Cell for which to generate mask and weights 90 ps MaskType sat, ///< Mask value to give saturated pixels91 ps MaskType bad, ///< Mask value to give bad (low) pixels90 psImageMaskType sat, ///< Mask value to give saturated pixels 91 psImageMaskType bad, ///< Mask value to give bad (low) pixels 92 92 bool poisson ///< Use poisson weights (in addition to read noise)? 93 93 ); … … 98 98 bool pmReadoutWeightRenormPixels( 99 99 const pmReadout *readout, ///< Readout to normalise 100 ps MaskType maskVal, ///< Value to mask100 psImageMaskType maskVal, ///< Value to mask 101 101 psStatsOptions meanStat, ///< Statistic to measure the mean (of the variance map) 102 102 psStatsOptions stdevStat, ///< Statistic to measure the stdev (of the image) … … 110 110 bool pmReadoutWeightRenormPhot( 111 111 const pmReadout *readout, ///< Readout to normalise 112 ps MaskType maskVal, ///< Value to mask112 psImageMaskType maskVal, ///< Value to mask 113 113 int num, ///< Number of instances to measure over the image 114 114 float width, ///< Photometry width … … 123 123 /// that patch corresponds. 124 124 bool pmReadoutWeightRenorm(const pmReadout *readout, // Readout to normalise 125 ps MaskType maskVal, // Value to mask125 psImageMaskType maskVal, // Value to mask 126 126 psStatsOptions meanStat, // Statistic to measure the mean (of the variance map) 127 127 psStatsOptions stdevStat, // Statistic to measure the stdev (of the image) … … 136 136 /// the provided value. 137 137 bool pmReadoutMaskNonfinite(pmReadout *readout, ///< Readout to mask 138 ps MaskType maskVal ///< Mask value to give non-finite pixels138 psImageMaskType maskVal ///< Mask value to give non-finite pixels 139 139 ); 140 140 … … 145 145 /// sets masked areas to NAN in the image and weight. 146 146 bool pmReadoutMaskApply(pmReadout *readout, ///< Readout to mask 147 ps MaskType maskVal ///< Mask value for which to apply mask147 psImageMaskType maskVal ///< Mask value for which to apply mask 148 148 ); 149 149 … … 152 152 /// Scan the mask image for bad pixels, and interpolate over them using the nominated options 153 153 bool pmReadoutInterpolateBadPixels(pmReadout *readout, ///< Readout to work on 154 ps MaskType maskVal, ///< Value to mask154 psImageMaskType maskVal, ///< Value to mask 155 155 psImageInterpolateMode mode, ///< Interpolation mode 156 156 float poorFrac, ///< Maximum bad fraction of kernel for "poor" status 157 ps MaskType maskPoor, ///< Mask value to give poor pixels158 ps MaskType maskBad ///< Mask value to give bad pixels157 psImageMaskType maskPoor, ///< Mask value to give poor pixels 158 psImageMaskType maskBad ///< Mask value to give bad pixels 159 159 ); 160 160 -
trunk/psModules/src/camera/pmFPAMosaic.c
r19073 r21183 471 471 numImages++; 472 472 473 // Only implemented for F32 and U8 images so far.474 assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8);475 473 // All input types must be the same 476 474 if (type == 0) { … … 537 535 if (xBinSource->data.S32[i] == xBinTarget && yBinSource->data.S32[i] == yBinTarget) { 538 536 switch (type) { 537 COPY_WITH_PARITY_DIFFERENCE(U8); 538 COPY_WITH_PARITY_DIFFERENCE(U16); 539 COPY_WITH_PARITY_DIFFERENCE(U32); 540 COPY_WITH_PARITY_DIFFERENCE(U64); 541 COPY_WITH_PARITY_DIFFERENCE(S8); 542 COPY_WITH_PARITY_DIFFERENCE(S16); 543 COPY_WITH_PARITY_DIFFERENCE(S32); 544 COPY_WITH_PARITY_DIFFERENCE(S64); 539 545 COPY_WITH_PARITY_DIFFERENCE(F32); 540 COPY_WITH_PARITY_DIFFERENCE( U8);546 COPY_WITH_PARITY_DIFFERENCE(F64); 541 547 default: 542 548 psAbort("Should never get here.\n"); … … 548 554 // We have to do all of the hard work ourselves 549 555 switch (type) { 550 FILL_IN(F32); 551 FILL_IN(U8); 556 FILL_IN(U8); 557 FILL_IN(U16); 558 FILL_IN(U32); 559 FILL_IN(U64); 560 FILL_IN(S8); 561 FILL_IN(S16); 562 FILL_IN(S32); 563 FILL_IN(S64); 564 FILL_IN(F32); 565 FILL_IN(F64); 552 566 default: 553 567 psAbort("Should never get here.\n"); … … 730 744 const pmChip *chip, // Chip to mosaic 731 745 const pmCell *targetCell, // Cell to which to mosaic 732 ps MaskType blank // Mask value to give blank pixels746 psImageMaskType blank // Mask value to give blank pixels 733 747 ) 734 748 { … … 838 852 const pmChip *targetChip, // Chip to which to mosaic 839 853 const pmCell *targetCell, // Cell to which to mosaic 840 ps MaskType blank // Mask value to give blank pixels854 psImageMaskType blank // Mask value to give blank pixels 841 855 ) 842 856 { … … 994 1008 // the mosaic image. 995 1009 996 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, ps MaskType blank)1010 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psImageMaskType blank) 997 1011 { 998 1012 // Target exists, and has only a single cell … … 1225 1239 1226 1240 1227 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, ps MaskType blank)1241 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psImageMaskType blank) 1228 1242 { 1229 1243 // Target exists, and has only a single chip with single cell -
trunk/psModules/src/camera/pmFPAMosaic.h
r13898 r21183 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $7 * @date $Date: 200 7-06-20 02:22:26$6 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 24 24 const pmChip *source, ///< Source chip whose cells will be mosaicked 25 25 bool deepCopy, ///< Require a deep copy (disregard 'nice' chip) 26 ps MaskType blank ///< Mask value to give blank pixels26 psImageMaskType blank ///< Mask value to give blank pixels 27 27 ); 28 28 … … 36 36 const pmFPA *source, ///< FPA whose chips and cells will be mosaicked 37 37 bool deepCopy, ///< Require a deep copy (disregard 'nice' chip) 38 ps MaskType blank ///< Mask value to give blank pixels38 psImageMaskType blank ///< Mask value to give blank pixels 39 39 ); 40 40 /// @} -
trunk/psModules/src/camera/pmFPARead.c
r19246 r21183 35 35 static psElemType pixelTypes[] = { 36 36 PS_TYPE_F32, 37 PS_TYPE_ MASK,37 PS_TYPE_IMAGE_MASK, 38 38 PS_TYPE_F32, 39 39 0 -
trunk/psModules/src/camera/pmFPA_JPEG.c
r19653 r21183 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-09-23 02:00:36$7 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 157 157 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 158 158 stats->nSubsample = 10000; 159 ps MaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask159 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask 160 160 float mean = 0, delta = 0; // 161 161 if (!psImageBackground(stats, NULL, readout->image, readout->mask, maskVal, rng)) { -
trunk/psModules/src/camera/pmHDU.c
r19385 r21183 167 167 const psArray *images, // Images to write 168 168 const psArray *masks, // Masks to use when writing 169 ps MaskType maskVal,// Value to mask169 psImageMaskType maskVal,// Value to mask 170 170 psFits *fits // FITS file to which to write 171 171 ) … … 222 222 PS_ASSERT_PTR_NON_NULL(fits, false); 223 223 224 ps MaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask224 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask 225 225 return hduWrite(hdu, hdu->images, hdu->masks, maskVal, fits); 226 226 } … … 240 240 PS_ASSERT_PTR_NON_NULL(fits, false); 241 241 242 ps MaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask242 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask 243 243 return hduWrite(hdu, hdu->weights, hdu->masks, maskVal, fits); 244 244 } -
trunk/psModules/src/camera/pmReadoutStack.c
r18830 r21183 78 78 79 79 // XXX for the moment, use col0, row0, numCols, numRows supplied from the outside 80 bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, ps MaskType blank)80 bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psImageMaskType blank) 81 81 { 82 82 PS_ASSERT_PTR_NON_NULL(readout, false); … … 94 94 // XXX is this an error? 95 95 if (readout->mask) return false; 96 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);96 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 97 97 psImageInit(readout->mask, blank); 98 98 } … … 163 163 bool pmReadoutUpdateSize(pmReadout *readout, int minCols, int minRows, 164 164 int numCols, int numRows, bool mask, bool weight, 165 ps MaskType blank)165 psImageMaskType blank) 166 166 { 167 167 PS_ASSERT_PTR_NON_NULL(readout, false); … … 191 191 if (mask) { 192 192 if (!readout->mask) { 193 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);193 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 194 194 psImageInit(readout->mask, blank); 195 195 } 196 196 if (readout->mask->numCols < numCols || readout->mask->numRows < numRows) { 197 psImage *newMask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);197 psImage *newMask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 198 198 psImageInit(newMask, blank); 199 199 psImageOverlaySection(newMask, readout->mask, readout->col0, readout->row0, "="); -
trunk/psModules/src/camera/pmReadoutStack.h
r18830 r21183 14 14 bool mask, ///< Worry about the mask? 15 15 bool weight, ///< Worry about the weight? 16 ps MaskType blank ///< Mask value to give to blank pixels16 psImageMaskType blank ///< Mask value to give to blank pixels 17 17 ); 18 18 … … 47 47 48 48 // XXX for the moment, use col0, row0, numCols, numRows supplied from the outside 49 bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, ps MaskType blank);49 bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psImageMaskType blank); 50 50 51 51 bool pmReadoutStackSetOutputSize(int *col0, int *row0, int *numCols, int *numRows, const psArray *inputs); -
trunk/psModules/src/concepts/pmConceptsStandard.c
r20598 r21183 16 16 #include "pmConceptsWrite.h" 17 17 #include "pmConceptsStandard.h" 18 19 // XXX why are these functions not supporting all types (S64, U64 often missing)? 18 20 19 21 // The functions in this file are intended to be called solely within the psModules concepts code. For this … … 591 593 TYPE_CASE(binning, concept, U16); 592 594 TYPE_CASE(binning, concept, U32); 595 // TYPE_CASE(binning, concept, U64); 593 596 TYPE_CASE(binning, concept, S8); 594 597 TYPE_CASE(binning, concept, S16); 595 598 TYPE_CASE(binning, concept, S32); 599 // TYPE_CASE(binning, concept, S64); 596 600 default: 597 601 psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name, -
trunk/psModules/src/config/pmConfigMask.c
r19870 r21183 9 9 #include "pmConfigMask.h" 10 10 11 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 // Private functions 13 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 14 15 // maskSetValues examine named mask values and set the bits for maskValue and markValue. 16 // Ensures that the below-named bad mask values are set, and calculates the mask value to catch them all 17 // Ensure that the below-named other mask values are set (to 0x00 if necessary) 18 19 // List of mask names for "bad" (i.e., mask me please) pixels 20 static const char *badMaskNames[] = { "DETECTOR", // Something is wrong with the detector 21 "DARK", // Pixel doesn't dark-subtract properly 22 "FLAT", // Pixel doesn't flat-field properly 23 "BLANK", // Pixel doesn't contain valid data 24 "RANGE",// Pixel is out-of-range of linearity 25 "SAT", // Pixel is saturated 26 // "LOW", // Pixel is low 27 // "CONV", // Pixel is bad after convolution with a bad pixel 28 "BAD", // Pixel is low 29 "BAD.WARP", // Pixel is bad after convolution with a bad pixel 30 "CR", // Pixel contains a cosmic ray 31 "GHOST",// Pixel contains an optical ghost 32 NULL // End marker 11 static pmConfigMaskInfo masks[] = { 12 { "DETECTOR", NULL, 0x00, true }, // Something is wrong with the detector 13 { "DARK", "DETECTOR", 0x00, true }, // Pixel doesn't dark-subtract properly 14 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 15 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 16 { "RANGE", NULL, 0x00, true }, // Pixel is out-of-range of linearity 17 { "SAT", "RANGE", 0x01, true }, // Pixel is saturated 18 { "BAD", "RANGE", 0x01, true }, // Pixel is low 19 { "BAD.WARP", NULL, 0x01, true }, // Pixel is bad after convolution with a bad pixel 20 { "CR", NULL, 0x00, true }, // Pixel contains a cosmic ray 21 { "GHOST", NULL, 0x00, true }, // Pixel contains an optical ghost 22 { "POOR.WARP", NULL, 0x00, false }, // Pixel is poor after convolution with a bad pixel 23 // "LOW" Pixel is low 24 // "CONV" Pixel is bad after convolution with a bad pixel 33 25 }; 34 // Fallback names in case a bad mask name is not defined 35 static const char *fallbackMaskNames[] = { NULL, // DETECTOR 36 "DETECTOR", // DARK 37 "DETECTOR", // FLAT 38 "DETECTOR", // BLANK 39 NULL, // RANGE 40 "RANGE", // SAT 41 "RANGE", // LOW 42 NULL, // CONV 43 NULL, // CR 44 NULL, // GHOST 45 }; 46 // Default values in case a bad mask name and its fallback is not defined 47 static const psMaskType defaultMask[] = { 0x00, // DETECTOR 48 0x00, // DARK 49 0x01, // FLAT 50 0x01, // BLANK 51 0x00, // RANGE 52 0x01, // SAT 53 0x01, // LOW 54 0x01, // CONV 55 0x00, // CR 56 0x00 // GHOST 57 }; 58 // Other mask names to ensure exist; these shouldn't be combined in the MASK.VALUE 59 static const char *otherMaskNames[] = { // "POOR", // Pixel is poor after convolution with a bad pixel 60 "POOR.WARP", // Pixel is poor after convolution with a bad pixel 61 NULL // End marker 62 }; 63 64 static bool maskSetValues(psMaskType *outMaskValue, // Value of MASK.VALUE, returned 65 psMaskType *outMarkValue, // Value of MARK.VALUE, returned 66 psMetadata *source // Source of mask bits 67 ) 26 27 // The functions in this file do not force the recipe or header values to be stored as the same 28 // type as psImageMaskType : they only check that the given values will fit in the space 29 // provided by psImageMaskType. This should allow some backwards compatibility (old 8-bit 30 // masks will work with a 16-bit system), but will catch unhandled conflicts (trying to fit 16 31 // bits in 8-bits of space). 32 33 // XXX this file does not have psError vs psWarning worked out correctly. some of the 34 // failure modes should result in errors, not just warnings. 35 36 // pmConfigMaskSetInMetadata examines named mask values and set the bits for maskValue and 37 // markValue. Ensures that the below-named mask values are set, and calculates the mask value 38 // to catch all of the mask values marked as 'bad'. Supplies the fallback name if the primary 39 // name is not found, or the default values if the fallback name is not found. 40 41 bool pmConfigMaskSetInMetadata(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned 42 psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned 43 psMetadata *source // Source of mask bits 44 ) 68 45 { 69 46 PS_ASSERT_METADATA_NON_NULL(source, false); 70 47 71 48 // Ensure all the bad mask names exist, and set the value to catch all bad pixels 72 psMaskType maskValue = 0; // Value to mask to catch all the bad pixels 73 for (int i = 0; badMaskNames[i]; i++) { 74 const char *name = badMaskNames[i]; // Name for mask 75 const char *fallback = fallbackMaskNames[i]; // Fallback for mask 76 49 psImageMaskType maskValue = 0; // Value to mask to catch all the bad pixels 50 psImageMaskType allMasks = 0; // Value to mask to catch all masked bits (to set MARK) 51 52 int nMasks = sizeof (masks) / sizeof (pmConfigMaskInfo); 53 54 for (int i = 0; i < nMasks; i++) { 77 55 bool mdok; // Status of MD lookup 78 psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask 56 psImageMaskType value = psMetadataLookupImageMaskFromGeneric(&mdok, source, masks[i].badMaskName); // Value of mask 57 if (!mdok) { 58 psWarning ("problem with mask value %s\n", masks[i].badMaskName); 59 } 60 79 61 if (!value) { 80 if (fallback) { 81 value = psMetadataLookupU8(&mdok, source, fallback); 82 } 83 if (!value) { 84 value = defaultMask[i]; 85 } 86 psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value); 87 } 88 maskValue |= value; 89 } 90 91 // Ensure all the other mask names exist 92 for (int i = 0; otherMaskNames[i]; i++) { 93 const char *name = otherMaskNames[i]; // Name for mask 94 bool mdok; // Status of MD lookup 95 psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask 96 if (!value) { 97 psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00); 98 } 62 if (masks[i].fallbackName) { 63 value = psMetadataLookupImageMaskFromGeneric(&mdok, source, masks[i].fallbackName); 64 } 65 if (!value) { 66 value = masks[i].defaultMaskValue; 67 } 68 psMetadataAddImageMask(source, PS_LIST_TAIL, masks[i].badMaskName, PS_META_REPLACE, NULL, value); 69 } 70 if (masks[i].isBad) { 71 maskValue |= value; 72 } 73 allMasks |= value; 99 74 } 100 75 101 76 // search for an unset bit to use for MARK: 102 psMaskType markValue = 0x80; 103 104 int nBits = sizeof(psMaskType) * 8; 77 psImageMaskType markValue = 0x00; 78 psImageMaskType markTrial = 0x01; 79 80 int nBits = sizeof(psImageMaskType) * 8; 105 81 for (int i = 0; !markValue && (i < nBits); i++) { 106 if ( maskValue & markValue) {107 mark Value >>= 1;82 if (allMasks & markTrial) { 83 markTrial <<= 1; 108 84 } else { 109 markValue = mark Value;85 markValue = markTrial; 110 86 } 111 87 } … … 116 92 117 93 // update the list with the results 118 psMetadataAdd U8(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);119 psMetadataAdd U8(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);94 psMetadataAddImageMask(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue); 95 psMetadataAddImageMask(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue); 120 96 121 97 if (outMaskValue) { … … 130 106 131 107 // Get a mask value by name(s) 132 static psMaskType maskGet(psMetadata *source, // Source of masks133 const char *masks // Mask values to get134 )135 { 136 ps MaskType mask = 0; // Mask value, to return108 psImageMaskType pmConfigMaskGetFromMetadata(psMetadata *source, // Source of masks 109 const char *masks // Mask values to get 110 ) 111 { 112 psImageMaskType mask = 0; // Mask value, to return 137 113 138 114 psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names … … 140 116 const char *name = names->data[i]; // Symbolic name of interest 141 117 bool mdok; // Status of MD lookup 142 ps MaskType value = psMetadataLookupU8(&mdok, source, name);118 psImageMaskType value = psMetadataLookupImageMaskFromGeneric(&mdok, source, name); 143 119 if (!mdok) { 144 120 // Try and generate the value if we can 145 121 if (strcmp(name, "MASK.VALUE") == 0 || strcmp(name, "MARK.VALUE") == 0) { 146 if (! maskSetValues(NULL, NULL, source)) {122 if (!pmConfigMaskSetInMetadata(NULL, NULL, source)) { 147 123 psError(PS_ERR_UNKNOWN, false, "Unable to set mask bits."); 148 124 return 0; 149 125 } 150 value = psMetadataLookup U8(&mdok, source, name);126 value = psMetadataLookupImageMaskFromGeneric(&mdok, source, name); 151 127 psAssert(mdok, "Should have generated mask value"); 152 128 } else { … … 163 139 } 164 140 141 // lookup an image mask value by name from a psMetadata, without requiring the entry to 142 // be of type psImageMaskType, but verifying that it will fit in psImageMaskType 143 psImageMaskType psMetadataLookupImageMaskFromGeneric (bool *status, const psMetadata *md, const char *name) { 144 145 *status = true; 146 147 // select the mask bit name from the header 148 psMetadataItem *item = psMetadataLookup (md, name); 149 if (!item) { 150 psWarning("Unable to find header keyword %s when parsing mask", name); 151 *status = false; 152 return 0; 153 } 154 155 // the value may be any of the U8, U16, U32, U64 types : accept the value regardless of type size 156 psU64 fullValue = 0; 157 switch (item->type) { 158 case PS_DATA_U8: 159 fullValue = item->data.U8; 160 break; 161 case PS_DATA_U16: 162 fullValue = item->data.U16; 163 break; 164 case PS_DATA_U32: 165 fullValue = item->data.U32; 166 break; 167 case PS_DATA_U64: 168 fullValue = item->data.U64; 169 break; 170 case PS_DATA_S8: 171 fullValue = item->data.S8; 172 break; 173 case PS_DATA_S16: 174 fullValue = item->data.S16; 175 break; 176 case PS_DATA_S32: 177 fullValue = item->data.S32; 178 break; 179 case PS_DATA_S64: 180 fullValue = item->data.S64; 181 break; 182 default: 183 psWarning("Mask entry %s in metadata is not of a mask type", name); 184 *status = false; 185 return 0; 186 } 187 188 // will the incoming value fit within the current image mask type? 189 if (fullValue > PS_MAX_IMAGE_MASK_TYPE) { 190 psWarning("Mask entry %s in metadata is larger than allowed by the psImageMaskType", name); 191 *status = false; 192 return 0; 193 } 194 psImageMaskType value = fullValue; 195 // XXX validate that value is a 2^n value? 196 197 return value; 198 } 199 165 200 // Remove from the header keywords starting with the provided string 166 static int maskRemoveHeader(psMetadata *header, // Header from which to remove keywords167 const char *start // Remove keywords that start with this string168 )201 int pmConfigMaskRemoveHeaderKeywords(psMetadata *header, // Header from which to remove keywords 202 const char *start // Remove keywords that start with this string 203 ) 169 204 { 170 205 psString regex = NULL; // Regular expression for keywords … … 182 217 } 183 218 219 // look up the named mask value(s) from the MASKS recipe in the config system 220 psImageMaskType pmConfigMaskGet(const char *masks, const pmConfig *config) 221 { 222 psAssert(config, "Require configuration"); 223 PS_ASSERT_STRING_NON_EMPTY(masks, 0); 224 225 bool mdok; // Status of MD lookup 226 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, "MASKS"); // The recipe 227 if (!recipe) { 228 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 229 return 0; 230 } 231 232 psImageMaskType mask = pmConfigMaskGetFromMetadata (recipe, masks); 233 return mask; 234 } 235 236 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue) 237 { 238 psAssert(config, "Require configuration"); 239 PS_ASSERT_STRING_NON_EMPTY(maskName, false); 240 241 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 242 if (!recipe) { 243 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 244 return false; 245 } 246 247 bool status = psMetadataAddImageMask(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue); 248 return status; 249 } 250 251 252 // replace the named masks in the recipe with values in the header: 253 // replace only the names in the header in the recipe 254 bool pmConfigMaskReadHeader(pmConfig *config, const psMetadata *header) 255 { 256 PS_ASSERT_PTR_NON_NULL(config, false); 257 PS_ASSERT_METADATA_NON_NULL(header, false); 258 259 bool status = false; 260 261 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 262 if (!recipe) { 263 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 264 return false; 265 } 266 267 // MASK.VALUE and MARK.VALUE aren't usually set in the recipe, but may be set in the header: create fake 268 // versions so that it won't complain later 269 if (!psMetadataLookup(recipe, "MASK.VALUE")) { 270 psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0); 271 } 272 if (!psMetadataLookup(recipe, "MARK.VALUE")) { 273 psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0); 274 } 275 276 // How many mask values do we need to read? We raise an error if this is not found, 277 // unless the MASK.FORCE is set to true in the camera config 278 int nMask = psMetadataLookupS32(&status, header, "MSKNUM"); 279 if (!status) { 280 if (psMetadataLookupBool(&status, config->camera, "MASK.FORCE")) { 281 psWarning("No mask values in header. Assuming MASKS recipe is accurate because of MASK.FORCE"); 282 return true; 283 } 284 psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header."); 285 return false; 286 } 287 288 // Loop over the expected number of header mask names. For each named mask value, there 289 // should be a pair of header keywords, one for the name and one for the value 290 char namekey[80]; // Keyword name for symbolic name of mask entry 291 char valuekey[80]; // Keyword name for value of mask entry 292 for (int i = 0; i < nMask; i++) { 293 snprintf(namekey, 64, "MSKNAM%02d", i); 294 snprintf(valuekey, 64, "MSKVAL%02d", i); 295 296 char *name = psMetadataLookupStr(&status, header, namekey); 297 if (!status || !name) { 298 psWarning("Unable to find header keyword %s when parsing mask", namekey); 299 continue; 300 } 301 302 psImageMaskType headerValue = psMetadataLookupImageMaskFromGeneric (&status, header, valuekey); 303 if (!status) { 304 psWarning("Failed to get mask value %s from header, skipping", valuekey); 305 continue; 306 } 307 308 // since we may read multiple mask files, we need to warn (or error?) if any of the 309 // header mask values conflict with other header mask values; However, the original 310 // mask values from the recipe do not need to match the header values. 311 312 // when we add a header mask value, we will also add the NAME.ALREADY entry; check for 313 // the NAME.ALREADY entry to see if we have previously added this mask value from a 314 // header. 315 316 psString nameAlready = NULL; // Name of key with ".ALREADY" added 317 psStringAppend(&nameAlready, "%s.ALREADY", name); 318 bool already = psMetadataLookupBool(&status, recipe, nameAlready); // Already read this one? 319 320 bool inRecipe = false; 321 psImageMaskType recipeValue = psMetadataLookupImageMaskFromGeneric (&inRecipe, recipe, name); 322 if (!inRecipe) { 323 psWarning("Mask value %s is not defined in the recipe", name); 324 } 325 326 if (already) { 327 assert (inRecipe); // XXX makes no sense for NAME.ALREADY to be in without NAME 328 if (recipeValue != headerValue) { 329 psWarning("New mask header value does not match previously loaded entry: %x vs %x", headerValue, recipeValue); 330 psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, PS_META_REPLACE, "Bitmask bit value", headerValue); 331 // XXX alternatively, error here 332 } 333 } else { 334 psMetadataAddBool(recipe, PS_LIST_TAIL, nameAlready, 0, "Already read this mask value", true); 335 psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, PS_META_REPLACE, "Bitmask bit value", headerValue); 336 } 337 338 psFree(nameAlready); 339 } 340 341 return true; 342 } 343 344 // write the named mask bits to the header 345 bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header) 346 { 347 PS_ASSERT_PTR_NON_NULL(config, false); 348 PS_ASSERT_METADATA_NON_NULL(header, false); 349 350 pmConfigMaskRemoveHeaderKeywords(header, "MSKNAM"); 351 pmConfigMaskRemoveHeaderKeywords(header, "MSKVAL"); 352 if (psMetadataLookup(header, "MSKNUM")) { 353 psMetadataRemoveKey(header, "MSKNUM"); 354 } 355 356 char namekey[80]; 357 char valuekey[80]; 358 359 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 360 if (!recipe) { 361 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 362 return false; 363 } 364 365 int nMask = 0; 366 367 psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator 368 psMetadataItem *item; // Item from iteration 369 while ((item = psMetadataGetAndIncrement(iter))) { 370 371 // XXX this would give a false positive for mask which include '.ALREADY' in their names 372 char *ptr = strstr (item->name, ".ALREADY"); 373 if (ptr) continue; 374 375 psU64 fullValue = 0; 376 switch (item->type) { 377 case PS_DATA_U8: 378 fullValue = item->data.U8; 379 break; 380 case PS_DATA_U16: 381 fullValue = item->data.U16; 382 break; 383 case PS_DATA_U32: 384 fullValue = item->data.U32; 385 break; 386 case PS_DATA_U64: 387 fullValue = item->data.U64; 388 break; 389 default: 390 psWarning("mask recipe entry %s is not a bit value\n", item->name); 391 continue; 392 } 393 assert (fullValue <= PS_MAX_IMAGE_MASK_TYPE); // this should have been asserted on read... 394 395 snprintf(namekey, 64, "MSKNAM%02d", nMask); 396 snprintf(valuekey, 64, "MSKVAL%02d", nMask); 397 398 psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name); 399 psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", fullValue); 400 nMask++; 401 } 402 psFree(iter); 403 404 psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask); 405 return true; 406 } 407 408 409 bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config) 410 { 411 PS_ASSERT_PTR_NON_NULL(config, false); 412 413 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe 414 if (!recipe) { 415 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe."); 416 return false; 417 } 418 419 bool status = pmConfigMaskSetInMetadata(outMaskValue, outMarkValue, recipe); 420 return status; 421 } 422 184 423 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 185 424 // FPA version of mask functions. These are not ready to go yet. … … 187 426 188 427 #if 0 189 bool pmFPAMaskSetValues(psMaskType *outMaskValue, psMaskType *outMarkValue, pmFPA *fpa) 190 { 428 429 bool pmFPAMaskWriteHeader(psMetadata *header, const pmFPA *fpa) 430 { 431 PS_ASSERT_METADATA_NON_NULL(header, false); 191 432 PS_ASSERT_PTR_NON_NULL(fpa, false); 192 433 434 // clear out the header of the associated keywords: 435 pmConfigMaskRemoveHeaderKeywords(header, "MSKNAM"); 436 pmConfigMaskRemoveHeaderKeywords(header, "MSKVAL"); 437 if (psMetadataLookup(header, "MSKNUM")) { 438 psMetadataRemoveKey(header, "MSKNUM"); 439 } 440 441 char namekey[80], valuekey[80]; // Mask name and mask value header keywords 442 int numMask = 0; // Number of mask entries 443 444 psMetadataIterator *iter = psMetadataIteratorAlloc(fpa->masks, PS_LIST_HEAD, NULL); // Iterator 445 psMetadataItem *item; // Item from iteration 446 while ((item = psMetadataGetAndIncrement(iter))) { 447 if (item->type != PS_TYPE_IMAGE_MASK) { 448 psWarning("mask recipe entry %s is not of a mask type (%x)", item->name, item->type); 449 continue; 450 } 451 452 snprintf(namekey, 64, "MSKNAM%02d", numMask); 453 snprintf(valuekey, 64, "MSKVAL%02d", numMask); 454 455 psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name); 456 psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_IMAGE_MASK_DATA); 457 numMask++; 458 } 459 psFree(iter); 460 461 return psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Number of named mask entries", numMask); 462 } 463 464 bool pmFPAMaskSetValues(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, pmFPA *fpa) 465 { 466 PS_ASSERT_PTR_NON_NULL(fpa, false); 467 193 468 return maskSetValues(outMaskValue, outMarkValue, fpa->masks); 194 469 } 195 470 196 ps MaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)471 psImageMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config) 197 472 { 198 473 PS_ASSERT_PTR_NON_NULL(fpa, 0); … … 201 476 202 477 if (fpa->masks) { 203 return maskGet(fpa->masks, masks);478 return pmConfigMaskGetFromMetadata(fpa->masks, masks); 204 479 } 205 480 return pmConfigMaskGet(masks, config); 206 481 } 207 482 208 bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, ps MaskType maskValue)483 bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psImageMaskType maskValue) 209 484 { 210 485 PS_ASSERT_PTR_NON_NULL(fpa, 0); … … 214 489 fpa->masks = psMetadataAlloc(); 215 490 } 216 return psMetadataAdd U8(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);491 return psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue); 217 492 } 218 493 … … 250 525 continue; 251 526 } 252 ps U8 bit = psMetadataLookupU8(&mdok, header, valuekey);527 psImageMaskType bit = psMetadataLookupImageMask(&mdok, header, valuekey); 253 528 if (!mdok) { 254 529 psWarning("Unable to find header keyword %s when parsing mask", namekey); … … 260 535 psMetadataItem *item = psMetadataLookup(fpa->masks, name); // Item in recipe with current value 261 536 if (item) { 262 psAssert(item->type == PS_TYPE_ MASK, "Mask entry %s is not of a mask type (%x)",537 psAssert(item->type == PS_TYPE_IMAGE_MASK, "Mask entry %s is not of a mask type (%x)", 263 538 name, item->type); 264 if (item->data.PS_TYPE_ MASK_DATA != bit) {539 if (item->data.PS_TYPE_IMAGE_MASK_DATA != bit) { 265 540 psWarning("New mask entry %s doesn't match previously loaded entry: %x vs %x", 266 name, bit, item->data.PS_TYPE_ MASK_DATA);541 name, bit, item->data.PS_TYPE_IMAGE_MASK_DATA); 267 542 } 268 543 } else { 269 psMetadataAdd U8(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);544 psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit); 270 545 } 271 546 } … … 281 556 psMetadataItem *item; // Item from iteration 282 557 while ((item = psMetadataGetAndIncrement(iter))) { 283 if (item->type != PS_TYPE_ MASK) {558 if (item->type != PS_TYPE_IMAGE_MASK) { 284 559 psWarning("Recipe mask entry %s is not of a mask type (%x)", item->name, item->type); 285 560 continue; 286 561 } 287 562 if (!psMetadataLookup(fpa->masks, item->name)) { 288 psMetadataAdd U8(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,289 item->data.PS_TYPE_ MASK_DATA);563 psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment, 564 item->data.PS_TYPE_IMAGE_MASK_DATA); 290 565 } 291 566 } … … 294 569 return true; 295 570 } 296 297 298 bool pmFPAMaskWriteHeader(psMetadata *header, const pmFPA *fpa)299 {300 PS_ASSERT_METADATA_NON_NULL(header, false);301 PS_ASSERT_PTR_NON_NULL(fpa, false);302 303 maskRemoveHeader(header, "MSKNAM");304 maskRemoveHeader(header, "MSKVAL");305 if (psMetadataLookup(header, "MSKNUM")) {306 psMetadataRemoveKey(header, "MSKNUM");307 }308 309 char namekey[80], valuekey[80]; // Mask name and mask value header keywords310 int numMask = 0; // Number of mask entries311 312 psMetadataIterator *iter = psMetadataIteratorAlloc(fpa->masks, PS_LIST_HEAD, NULL); // Iterator313 psMetadataItem *item; // Item from iteration314 while ((item = psMetadataGetAndIncrement(iter))) {315 if (item->type != PS_TYPE_MASK) {316 psWarning("mask recipe entry %s is not of a mask type (%x)", item->name, item->type);317 continue;318 }319 320 snprintf(namekey, 64, "MSKNAM%02d", numMask);321 snprintf(valuekey, 64, "MSKVAL%02d", numMask);322 323 psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);324 psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);325 numMask++;326 }327 psFree(iter);328 329 return psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Number of named mask entries", numMask);330 }331 332 571 #endif 333 334 335 psMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)336 {337 psAssert(config, "Require configuration");338 PS_ASSERT_STRING_NON_EMPTY(masks, 0);339 340 bool mdok; // Status of MD lookup341 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, "MASKS"); // The recipe342 if (!recipe) {343 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");344 return 0;345 }346 return maskGet(recipe, masks);347 }348 349 350 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue)351 {352 psAssert(config, "Require configuration");353 PS_ASSERT_STRING_NON_EMPTY(maskName, false);354 355 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe356 if (!recipe) {357 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");358 return false;359 }360 361 return psMetadataAddU8(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);362 }363 364 365 // replace the named masks in the recipe with values in the header:366 // replace only the names in the header in the recipe367 bool pmConfigMaskReadHeader(pmConfig *config, const psMetadata *header)368 {369 PS_ASSERT_PTR_NON_NULL(config, false);370 PS_ASSERT_METADATA_NON_NULL(header, false);371 372 bool status = false;373 374 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe375 if (!recipe) {376 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");377 return false;378 }379 380 // MASK.VALUE and MARK.VALUE aren't usually set in the recipe, but may be set in the header: create fake381 // versions so that it won't complain later382 if (!psMetadataLookup(recipe, "MASK.VALUE")) {383 psMetadataAddU8(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);384 }385 if (!psMetadataLookup(recipe, "MARK.VALUE")) {386 psMetadataAddU8(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);387 }388 389 int nMask = psMetadataLookupS32(&status, header, "MSKNUM");390 if (!status) {391 if (psMetadataLookupBool(&status, config->camera, "MASK.FORCE")) {392 psWarning("No mask values in header. Assuming MASKS recipe is accurate because of MASK.FORCE");393 return true;394 }395 psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header.");396 return false;397 }398 399 char namekey[80]; // Keyword name for symbolic name of mask entry400 char valuekey[80]; // Keyword name for value of mask entry401 for (int i = 0; i < nMask; i++) {402 snprintf(namekey, 64, "MSKNAM%02d", i);403 snprintf(valuekey, 64, "MSKVAL%02d", i);404 405 char *name = psMetadataLookupStr(&status, header, namekey);406 if (!status || !name) {407 psWarning("Unable to find header keyword %s when parsing mask", namekey);408 continue;409 }410 psU8 bit = psMetadataLookupU8(&status, header, valuekey);411 if (!status) {412 psWarning("Unable to find header keyword %s when parsing mask", namekey);413 continue;414 }415 416 // XXX validate that bit is a 2^n value?417 418 psString nameAlready = NULL; // Name of key with ".ALREADY" added419 psStringAppend(&nameAlready, "%s.ALREADY", name);420 bool already = psMetadataLookupBool(&status, recipe, nameAlready); // Already read this one?421 422 psMetadataItem *item = psMetadataLookup(recipe, name); // Item in recipe with current value423 if (item && item->type != PS_TYPE_MASK) {424 psWarning("Mask recipe entry is not of a mask type (%x)", item->type);425 item->type = PS_TYPE_MASK;426 }427 428 if (already) {429 if (item && item->data.U8 != bit) {430 psWarning("New mask recipe entry doesn't match previously loaded entry: %x vs %x",431 bit, item->data.U8);432 }433 } else {434 psMetadataAddBool(recipe, PS_LIST_TAIL, nameAlready, 0, "Already read this mask value", true);435 }436 437 if (!item) {438 psWarning("Mask recipe entry %s not in recipe\n", name);439 psMetadataAddU8(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);440 } else {441 item->data.U8 = bit;442 }443 444 psFree(nameAlready);445 }446 447 448 return true;449 }450 451 452 453 // write the named mask bits to the header454 bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header)455 {456 PS_ASSERT_PTR_NON_NULL(config, false);457 PS_ASSERT_METADATA_NON_NULL(header, false);458 459 maskRemoveHeader(header, "MSKNAM");460 maskRemoveHeader(header, "MSKVAL");461 if (psMetadataLookup(header, "MSKNUM")) {462 psMetadataRemoveKey(header, "MSKNUM");463 }464 465 char namekey[80];466 char valuekey[80];467 468 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe469 if (!recipe) {470 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");471 return false;472 }473 474 int nMask = 0;475 476 psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator477 psMetadataItem *item; // Item from iteration478 while ((item = psMetadataGetAndIncrement(iter))) {479 if (strcmp(item->name + strlen(item->name) - strlen(".ALREADY"), ".ALREADY") == 0) {480 continue;481 }482 483 if (item->type != PS_DATA_U8) {484 psWarning("mask recipe entry %s is not a bit value\n", item->name);485 continue;486 }487 488 snprintf(namekey, 64, "MSKNAM%02d", nMask);489 snprintf(valuekey, 64, "MSKVAL%02d", nMask);490 491 psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);492 psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);493 nMask++;494 }495 psFree(iter);496 497 psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);498 return true;499 }500 501 502 bool pmConfigMaskSetBits(psMaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config)503 {504 PS_ASSERT_PTR_NON_NULL(config, false);505 506 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe507 if (!recipe) {508 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");509 return false;510 }511 512 return maskSetValues(outMaskValue, outMarkValue, recipe);513 } -
trunk/psModules/src/config/pmConfigMask.h
r18598 r21183 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-07-17 20:37:20$6 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2007 Institute for Astronomy, University of Hawaii 9 9 */ … … 20 20 /// @{ 21 21 22 // structure to hold the properties of a mask value 23 typedef struct { 24 char *badMaskName; // name for "bad" (i.e., mask me please) pixels 25 char *fallbackName; // Fallback name in case a bad mask name is not defined 26 psImageMaskType defaultMaskValue; // Default value in case a bad mask name and its fallback are not defined 27 bool isBad; // include this value as part of the MASK.VALUE entry (generically bad) 28 } pmConfigMaskInfo; 29 30 // pmConfigMaskSetInMetadata examines named mask values and set the bits for maskValue and 31 // markValue. Ensures that the below-named mask values are set, and calculates the mask value 32 // to catch all of the mask values marked as 'bad'. Supplies the fallback name if the primary 33 // name is not found, or the default values if the fallback name is not found. 34 bool pmConfigMaskSetInMetadata(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned 35 psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned 36 psMetadata *source // Source of mask bits 37 ); 38 39 40 // Get a mask value by name(s) 41 psImageMaskType pmConfigMaskGetFromMetadata(psMetadata *source, // Source of masks 42 const char *masks // Mask values to get 43 ); 44 45 46 // lookup an image mask value by name from a psMetadata, without requiring the entry to 47 // be of type psImageMaskType, but verifying that it will fit in psImageMaskType 48 psImageMaskType psMetadataLookupImageMaskFromGeneric (bool *status, const psMetadata *md, const char *name); 49 50 // Remove from the header keywords starting with the provided string 51 int pmConfigMaskRemoveHeaderKeywords(psMetadata *header, // Header from which to remove keywords 52 const char *start // Remove keywords that start with this string 53 ); 54 22 55 /// Return a mask value given a list of symbolic names 23 56 /// 24 57 /// The mask values are derived from the MASKS recipe 25 ps MaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited58 psImageMaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited 26 59 const pmConfig *config ///< Configuration 27 60 ); 28 61 29 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, ps MaskType maskValue);62 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue); 30 63 31 64 // replace the named masks in the recipe with values in the header: … … 36 69 bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header); 37 70 38 bool pmConfigMaskSetBits(ps MaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config);71 bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config); 39 72 40 73 #endif -
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 } -
trunk/psModules/src/imcombine/pmImageCombine.c
r12742 r21183 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $11 * @date $Date: 200 7-04-04 22:42:48 $10 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * 13 13 * XXX: pmRejectPixels() has a known bug with the pmImageTransform() call. … … 17 17 */ 18 18 19 // XXX this is somewhat messy and unclear on the masking. 20 19 21 #ifdef HAVE_CONFIG_H 20 22 #include <config.h> … … 53 55 54 56 buffer->pixels = psVectorAlloc(numImages, PS_TYPE_F32); 55 buffer->masks = psVectorAlloc(numImages, PS_TYPE_ MASK);57 buffer->masks = psVectorAlloc(numImages, PS_TYPE_VECTOR_MASK); 56 58 buffer->errors = psVectorAlloc(numImages, PS_TYPE_F32); 57 59 buffer->stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); … … 67 69 const psArray *errors, // Array of input error images 68 70 const psArray *masks, // Array of input masks 69 ps U32maskVal, // Mask value71 psImageMaskType maskVal, // Mask value 70 72 psS32 numIter, // Number of rejection iterations 71 73 psF32 sigmaClip, // Number of standard deviations at which to reject … … 115 117 if (masks) { 116 118 psImage *mask = masks->data[i]; // Mask of interest 117 pixelMasks->data.U8[i] = mask->data.U8[y][x]; 118 } // Set the pixel error data, if necessary 119 pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal); 120 } 121 // Set the pixel error data, if necessary 119 122 if (errors) { 120 123 psImage *error = errors->data[i]; // Error image of interest … … 128 131 for (int iter = 0; iter < numIter; iter++) { 129 132 // Combine all the pixels, using the specified stat. 130 if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, maskVal)) {133 if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, 0xff)) { 131 134 combine->data.F32[y][x] = NAN; 132 135 psFree(buffer); … … 148 151 float stdev = stats->sampleStdev; 149 152 for (int i = 0; i < numImages; i++) { 150 if (!(pixelMasks->data. U8[i] & maskVal) &&153 if (!(pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i] & 0xff) && 151 154 fabs(pixelData->data.F32[i] - combinedPixel) > sigmaClip * stdev) { 152 155 // Reject pixel as questionable 153 156 numRejects++; 154 pixelMasks->data. U8[i] = maskVal;157 pixelMasks->data.PS_TYPE_IMAGE_MASK_DATA[i] = 0xff; 155 158 if (questionablePixels) { 156 159 // Mark the pixel as questionable … … 191 194 const psArray *errors, ///< Array of input error images 192 195 const psArray *masks, ///< Array of input masks 193 ps U32maskVal, ///< Mask value196 psImageMaskType maskVal, ///< Mask value 194 197 const psPixels *pixels, ///< Pixels to combine 195 198 psS32 numIter, ///< Number of rejection iterations … … 231 234 psImage *mask = masks->data[i]; 232 235 PS_ASSERT_IMAGE_SIZE(mask, numCols, numRows, NULL); 233 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, NULL);236 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL); 234 237 } 235 238 } … … 319 322 int num = 0; 320 323 psVector *pixels = psVectorAlloc(8, PS_TYPE_F32); // Array of pixels 321 psVector *mask = psVectorAlloc(8, PS_TYPE_ U8); // Corresponding mask324 psVector *mask = psVectorAlloc(8, PS_TYPE_VECTOR_MASK); // Corresponding mask 322 325 323 326 // Get limits … … 329 332 for (int j = yMin; j <= yMax; j++) { 330 333 for (int i = xMin; i <= xMax; i++) { 331 if ((i != x) && (j != y) && (0 == imageMask->data. U8[j][i])) {334 if ((i != x) && (j != y) && (0 == imageMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i])) { 332 335 pixels->data.F32[num] = image->data.F32[j][i]; 333 mask->data. U8[num] = 0;336 mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0; 334 337 num++; 335 338 } else { 336 mask->data. U8[num] = 1;339 mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 1; 337 340 } 338 341 } … … 347 350 if ((i != x) && (j != y)) { 348 351 pixels->data.F32[num] = image->data.F32[j][i]; 349 mask->data. U8[num] = 0;352 mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0; 350 353 num++; 351 354 } else { 352 mask->data. U8[num] = 1;355 mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 1; 353 356 } 354 357 } … … 473 476 for (psS32 i = 0 ; i < image->numRows ; i++) { 474 477 for (psS32 j = 0 ; j < image->numCols ; j++) { 475 imgF32->data.F32[i][j] = (psF32) image->data. U8[i][j];478 imgF32->data.F32[i][j] = (psF32) image->data.PS_TYPE_IMAGE_MASK_DATA[i][j]; 476 479 } 477 480 } … … 518 521 PS_ASSERT_IMAGE_NON_NULL(tmpMask, NULL); 519 522 PS_ASSERT_IMAGE_NON_EMPTY(tmpMask, NULL); 520 PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL); 523 PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL); // XXX really F32?? 521 524 PS_ASSERT_IMAGES_SIZE_EQUAL(tmpImage, tmpMask, NULL); 522 525 } … … 571 574 572 575 // 573 // Create a ps U8mask image from the list of cosmic pixels.576 // Create a psImageMaskType mask image from the list of cosmic pixels. 574 577 // 575 578 psImage *maskImage = NULL; -
trunk/psModules/src/imcombine/pmPSFEnvelope.c
r20999 r21183 223 223 // *** readout->weight = (psImage*)psBinaryOp(NULL, readout->image, "*", psScalarAlloc(WEIGHT_FACTOR, PS_TYPE_F32)); 224 224 readout->weight = (psImage*)psBinaryOp(NULL, readout->image, "+", psScalarAlloc(WEIGHT_VAL, PS_TYPE_F32)); 225 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);225 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 226 226 psImageInit(readout->mask, 0); 227 227 -
trunk/psModules/src/imcombine/pmReadoutCombine.c
r19086 r21183 105 105 106 106 // note the mask value actually used 107 ps MaskType maskVal = params->maskVal; // The mask value107 psImageMaskType maskVal = params->maskVal; // The mask value 108 108 if (maskVal) { 109 109 psString comment = NULL; // Comment to add to header … … 247 247 psF32 *pixelsData = pixels->data.F32; // Dereference pixels 248 248 249 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_ U8); // Mask for stack250 ps U8 *maskData = mask->data.U8; // Dereference mask249 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for stack 250 psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference mask 251 251 252 252 psVector *weights = NULL; // Stack of weights … … 260 260 261 261 float keepFrac = 1.0 - params->fracLow - params->fracHigh; // Fraction of pixels to keep 262 ps MaskType maskVal = params->maskVal; // The mask value262 psImageMaskType maskVal = params->maskVal; // The mask value 263 263 264 264 #ifndef PS_NO_TRACE … … 278 278 // Dereference output products 279 279 psF32 **outputImage = output->image->data.F32; // Output image 280 ps U8 **outputMask = output->mask->data.U8; // Output mask280 psImageMaskType **outputMask = output->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Output mask 281 281 psF32 **outputWeight = NULL; // Output weight map 282 282 if (output->weight) { … … 303 303 304 304 int numValid = 0; // Number of valid pixels in the stack 305 memset(maskData, 0, mask->n * sizeof(ps U8)); // Reset the mask305 memset(maskData, 0, mask->n * sizeof(psVectorMaskType)); // Reset the mask 306 306 for (int r = 0; r < inputs->n; r++) { 307 307 pmReadout *readout = inputs->data[r]; // Input readout … … 318 318 // Check mask 319 319 psImage *roMask = readout->mask; // The mask image 320 if (roMask && roMask->data. U8[yIn][xIn] & maskVal) {320 if (roMask && roMask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal) { 321 321 maskData[r] = 1; 322 322 continue; -
trunk/psModules/src/imcombine/pmReadoutCombine.h
r18830 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-08-01 00:01:26$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 */ … … 22 22 typedef struct { 23 23 psStatsOptions combine; ///< Statistic to use when performing the combination 24 ps MaskType maskVal;///< Mask value25 ps MaskType blank;///< Mask value to give blank (i.e., no data) pixels24 psImageMaskType maskVal; ///< Mask value 25 psImageMaskType blank; ///< Mask value to give blank (i.e., no data) pixels 26 26 int nKeep; ///< Mimimum number of pixels to keep 27 27 float fracHigh; ///< Fraction of high pixels to immediately throw -
trunk/psModules/src/imcombine/pmStack.c
r20712 r21183 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-11-13 03:50:30$10 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 13 13 * … … 63 63 64 64 buffer->pixels = psVectorAlloc(numImages, PS_TYPE_F32); 65 buffer->masks = psVectorAlloc(numImages, PS_TYPE_ MASK);65 buffer->masks = psVectorAlloc(numImages, PS_TYPE_VECTOR_MASK); 66 66 buffer->variances = psVectorAlloc(numImages, PS_TYPE_F32); 67 67 buffer->weights = psVectorAlloc(numImages, PS_TYPE_F32); … … 143 143 assert(!masks || values->n == masks->n); 144 144 assert(values->type.type == PS_TYPE_F32); 145 assert(!masks || masks->type.type == PS_TYPE_ MASK);145 assert(!masks || masks->type.type == PS_TYPE_VECTOR_MASK); 146 146 assert(sortBuffer && sortBuffer->nalloc >= values->n && sortBuffer->type.type == PS_TYPE_F32); 147 147 … … 149 149 int num = 0; // Number of valid values 150 150 for (int i = 0; i < values->n; i++) { 151 if (!masks || !masks->data.PS_TYPE_ MASK_DATA[i]) {151 if (!masks || !masks->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 152 152 sortBuffer->data.F32[num++] = values->data.F32[i]; 153 153 } … … 215 215 const psVector *reject, // Indices of pixels to reject, or NULL 216 216 int x, int y, // Coordinates of interest; frame of output image 217 ps MaskType maskVal, // Value to mask218 ps MaskType bad, // Value to give bad pixels217 psImageMaskType maskVal, // Value to mask 218 psImageMaskType bad, // Value to give bad pixels 219 219 int numIter, // Number of rejection iterations 220 220 float rej, // Number of standard deviations at which to reject … … 258 258 int xIn = x - data->readout->col0, yIn = y - data->readout->row0; // Coordinates on input readout 259 259 psImage *mask = data->readout->mask; // Mask of interest 260 if (mask->data.PS_TYPE_ MASK_DATA[yIn][xIn] & maskVal) {260 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal) { 261 261 continue; 262 262 } … … 283 283 // Default option is that the pixel is bad 284 284 float imageValue = NAN, varianceValue = NAN; // Value for combined image and variance map 285 ps MaskType maskValue = bad; // Value for combined mask285 psImageMaskType maskValue = bad; // Value for combined mask 286 286 switch (num) { 287 287 case 0: … … 382 382 // Mask a pixel for inspection 383 383 #define MASK_PIXEL_FOR_INSPECTION() \ 384 pixelMasks->data.PS_TYPE_ MASK_DATA[j] = 0xff; \384 pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; \ 385 385 combineInspect(inputs, x, y, pixelSources->data.U16[j]); \ 386 386 numClipped++; \ … … 388 388 389 389 for (int j = 0; j < num; j++) { 390 if (pixelMasks->data.PS_TYPE_ MASK_DATA[j]) {390 if (pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 391 391 continue; 392 392 } … … 408 408 409 409 image->data.F32[y][x] = imageValue; 410 mask->data.PS_TYPE_ MASK_DATA[y][x] = maskValue;410 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskValue; 411 411 if (variance) { 412 412 variance->data.F32[y][x] = varianceValue; … … 438 438 PS_ASSERT_IMAGE_TYPE(data->readout->image, PS_TYPE_F32, false); 439 439 PS_ASSERT_IMAGE_NON_NULL(data->readout->mask, false); 440 PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_ MASK, false);440 PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_IMAGE_MASK, false); 441 441 PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->mask, false); 442 442 *numCols = data->readout->image->numCols; … … 469 469 PS_ASSERT_IMAGE_NON_NULL(data->readout->mask, false); 470 470 PS_ASSERT_IMAGE_TYPE(data->readout->image, PS_TYPE_F32, false); 471 PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_ MASK, false);471 PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_IMAGE_MASK, false); 472 472 PS_ASSERT_IMAGE_SIZE(data->readout->image, *numCols, *numRows, false); 473 473 PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->mask, false); … … 562 562 563 563 /// Stack input images 564 bool pmStackCombine(pmReadout *combined, psArray *input, ps MaskType maskVal, psMaskType bad,564 bool pmStackCombine(pmReadout *combined, psArray *input, psImageMaskType maskVal, psImageMaskType bad, 565 565 int kernelSize, int numIter, float rej, float sys, 566 566 bool entire, bool useVariance, bool safe) … … 587 587 PS_ASSERT_IMAGE_TYPE(combined->image, PS_TYPE_F32, false); 588 588 PS_ASSERT_IMAGE_NON_NULL(combined->mask, false); 589 PS_ASSERT_IMAGE_TYPE(combined->mask, PS_TYPE_ MASK, false);589 PS_ASSERT_IMAGE_TYPE(combined->mask, PS_TYPE_IMAGE_MASK, false); 590 590 PS_ASSERT_IMAGES_SIZE_EQUAL(combined->image, combined->mask, false); 591 591 } … … 698 698 psImage *combinedMask = combined->mask; // Combined mask 699 699 if (!combinedMask) { 700 combined->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);700 combined->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 701 701 combinedMask = combined->mask; 702 702 } -
trunk/psModules/src/imcombine/pmStack.h
r20497 r21183 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $11 * @date $Date: 200 8-11-01 02:59:33$10 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-01-27 06:39:38 $ 12 12 * 13 13 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 43 43 bool pmStackCombine(pmReadout *combined,///< Combined readout (output) 44 44 psArray *input, ///< Input array of pmStackData 45 ps MaskType maskVal, ///< Mask value of bad pixels46 ps MaskType bad, ///< Mask value to give rejected pixels45 psImageMaskType maskVal, ///< Mask value of bad pixels 46 psImageMaskType bad, ///< Mask value to give rejected pixels 47 47 int kernelSize, ///< Half-size of the convolution kernel 48 48 int numIter, ///< Number of iterations -
trunk/psModules/src/imcombine/pmStackReject.c
r20838 r21183 61 61 } 62 62 63 int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK); // Number of bytes to copy63 int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy 64 64 psAssert(convolved->numCols - 2 * box == xMax - xMin, "Bad number of columns"); 65 65 psAssert(convolved->numRows - 2 * box == yMax - yMin, "Bad number of rows"); 66 66 67 67 for (int yTarget = yMin, ySource = box; yTarget < yMax; yTarget++, ySource++) { 68 memcpy(&target->data.PS_TYPE_ MASK_DATA[yTarget][xMin],69 &convolved->data.PS_TYPE_ MASK_DATA[ySource][box], numBytes);68 memcpy(&target->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][xMin], 69 &convolved->data.PS_TYPE_IMAGE_MASK_DATA[ySource][box], numBytes); 70 70 } 71 71 psFree(convolved); 72 72 } else { 73 73 // Just copy over 74 int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_ MASK); // Number of bytes to copy74 int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy 75 75 for (int yTarget = yMin; yTarget < yMax; yTarget++) { 76 memcpy(&target->data.PS_TYPE_ MASK_DATA[yTarget][xMin],77 &source->data.PS_TYPE_ MASK_DATA[yTarget][xMin], numBytes);76 memcpy(&target->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][xMin], 77 &source->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][xMin], numBytes); 78 78 } 79 79 } … … 262 262 bool oldThreads = psImageConvolveSetThreads(false); // Old value of threading for psImageColvolve 263 263 264 psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_ MASK); // Grown image264 psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image 265 265 psImageInit(target, 0); 266 266 if (threaded) { -
trunk/psModules/src/imcombine/pmSubtraction.c
r20838 r21183 246 246 psImage *image, // Image to convolve 247 247 psImage *mask, // Mask image 248 ps MaskType maskVal, // Value to mask248 psImageMaskType maskVal, // Value to mask 249 249 const psKernel *kernel, // Kernel by which to convolve 250 250 psRegion region,// Region of interest … … 291 291 psImage *sys, // Systematic error image 292 292 psImage *mask, // Mask image 293 ps MaskType maskVal, // Value to mask293 psImageMaskType maskVal, // Value to mask 294 294 const psKernel *kernel, // Kernel by which to convolve 295 295 psRegion region,// Region of interest … … 373 373 float background, // Background value to apply 374 374 psRegion region, // Region to convolve 375 ps MaskType maskBad, // Value to give bad pixels376 ps MaskType maskPoor, // Value to give poor pixels375 psImageMaskType maskBad, // Value to give bad pixels 376 psImageMaskType maskPoor, // Value to give poor pixels 377 377 float poorFrac, // Fraction for "poor" 378 378 bool useFFT, // Use FFT to convolve? … … 385 385 } 386 386 387 ps MaskType subBad; // Bad pixels in subtraction mask388 ps MaskType subConvBad; // Bad pixels in subtraction mask when convolving389 ps MaskType subConvPoor; // Poor pixels in subtraction mask when convolving387 psImageMaskType subBad; // Bad pixels in subtraction mask 388 psImageMaskType subConvBad; // Bad pixels in subtraction mask when convolving 389 psImageMaskType subConvPoor; // Poor pixels in subtraction mask when convolving 390 390 if (kernels->mode == PM_SUBTRACTION_MODE_1 || (kernels->mode == PM_SUBTRACTION_MODE_DUAL && !wantDual)) { 391 391 subBad = PM_SUBTRACTION_MASK_BAD_1; … … 437 437 for (int yTarget = rowMin, ySource = box; yTarget < rowMax; yTarget++, ySource++) { 438 438 // Dereference images 439 ps MaskType *target = &convMask->data.PS_TYPE_MASK_DATA[yTarget][colMin]; // Target values440 ps MaskType *source = &convolved->data.PS_TYPE_MASK_DATA[ySource][box]; // Source values439 psImageMaskType *target = &convMask->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][colMin]; // Target values 440 psImageMaskType *source = &convolved->data.PS_TYPE_IMAGE_MASK_DATA[ySource][box]; // Source values 441 441 for (int xTarget = colMin; xTarget < colMax; xTarget++, target++, source++) { 442 442 if (*source & subConvBad) { … … 783 783 PS_ASSERT_VECTOR_TYPE(deviations, PS_TYPE_F32, -1); 784 784 PS_ASSERT_IMAGE_NON_EMPTY(subMask, -1); 785 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_ MASK, -1);785 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, -1); 786 786 787 787 // I used to measure the rms deviation about zero, and use that as the sigma against which to clip, but … … 794 794 795 795 int numStamps = 0; // Number of used stamps 796 psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_ MASK); // Mask, for statistics796 psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_VECTOR_MASK); // Mask, for statistics 797 797 psVectorInit(mask, 0); 798 798 for (int i = 0; i < stamps->num; i++) { 799 799 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 800 800 if (stamp->status != PM_SUBTRACTION_STAMP_USED) { 801 mask->data.PS_TYPE_ MASK_DATA[i] = 0xff;801 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 802 802 continue; 803 803 } … … 869 869 for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) { 870 870 for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) { 871 subMask->data.PS_TYPE_ MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ;871 subMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ; 872 872 } 873 873 } … … 997 997 psImage *sys1, psImage *sys2, // Systematic error images 998 998 psImage *subMask, // Input subtraction mask 999 ps MaskType maskBad, // Mask value to give bad pixels1000 ps MaskType maskPoor, // Mask value to give poor pixels999 psImageMaskType maskBad, // Mask value to give bad pixels 1000 psImageMaskType maskPoor, // Mask value to give poor pixels 1001 1001 float poorFrac, // Fraction for "poor" 1002 1002 const psRegion *region, // Patch to convolve … … 1035 1035 1036 1036 if ((kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) && ro1->mask) { 1037 ps MaskType **target = convMask->data.PS_TYPE_MASK_DATA; // Target mask1038 ps MaskType **source = ro1->mask->data.PS_TYPE_MASK_DATA; // Source mask1037 psImageMaskType **target = convMask->data.PS_TYPE_IMAGE_MASK_DATA; // Target mask 1038 psImageMaskType **source = ro1->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Source mask 1039 1039 1040 1040 for (int y = yMin; y < yMax; y++) { … … 1045 1045 } 1046 1046 if ((kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) && ro2->mask) { 1047 ps MaskType **target = convMask->data.PS_TYPE_MASK_DATA; // Target mask1048 ps MaskType **source = ro2->mask->data.PS_TYPE_MASK_DATA; // Source mask1047 psImageMaskType **target = convMask->data.PS_TYPE_IMAGE_MASK_DATA; // Target mask 1048 psImageMaskType **source = ro2->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Source mask 1049 1049 1050 1050 for (int y = yMin; y < yMax; y++) { … … 1075 1075 psImage *sys2 = args->data[10]; // Systematic error image 2 1076 1076 psImage *subMask = args->data[11]; // Subtraction mask 1077 ps MaskType maskBad = PS_SCALAR_VALUE(args->data[12], U8); // Output mask value for bad pixels1078 ps MaskType maskPoor = PS_SCALAR_VALUE(args->data[13], U8); // Output mask value for poor pixels1077 psImageMaskType maskBad = PS_SCALAR_VALUE(args->data[12], PS_TYPE_IMAGE_MASK_DATA); // Output mask value for bad pixels 1078 psImageMaskType maskPoor = PS_SCALAR_VALUE(args->data[13], PS_TYPE_IMAGE_MASK_DATA); // Output mask value for poor pixels 1079 1079 float poorFrac = PS_SCALAR_VALUE(args->data[14], F32); // Fraction for "poor" 1080 1080 const psRegion *region = args->data[15]; // Region to convolve 1081 1081 const pmSubtractionKernels *kernels = args->data[16]; // Kernels 1082 bool doBG = PS_SCALAR_VALUE(args->data[17], U8); // Do background subtraction?1083 bool useFFT = PS_SCALAR_VALUE(args->data[18], U8); // Use FFT for convolution?1082 bool doBG = PS_SCALAR_VALUE(args->data[17], PS_TYPE_IMAGE_MASK_DATA); // Do background subtraction? 1083 bool useFFT = PS_SCALAR_VALUE(args->data[18], PS_TYPE_IMAGE_MASK_DATA); // Use FFT for convolution? 1084 1084 1085 1085 return subtractionConvolvePatch(numCols, numRows, x0, y0, out1, out2, convMask, ro1, ro2, sys1, sys2, … … 1088 1088 1089 1089 bool pmSubtractionConvolve(pmReadout *out1, pmReadout *out2, const pmReadout *ro1, const pmReadout *ro2, 1090 psImage *subMask, int stride, ps MaskType maskBad, psMaskType maskPoor,1090 psImage *subMask, int stride, psImageMaskType maskBad, psImageMaskType maskPoor, 1091 1091 float poorFrac, float sysError, const psRegion *region, 1092 1092 const pmSubtractionKernels *kernels, bool doBG, bool useFFT) … … 1121 1121 if (subMask) { 1122 1122 PS_ASSERT_IMAGE_NON_NULL(subMask, false); 1123 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_ MASK, false);1123 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, false); 1124 1124 PS_ASSERT_IMAGE_SIZE(subMask, numCols, numRows, false); 1125 1125 } … … 1182 1182 if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) { 1183 1183 if (!out1->mask) { 1184 out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);1184 out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 1185 1185 } 1186 1186 convMask = out1->mask; … … 1194 1194 } else { 1195 1195 if (!out2->mask) { 1196 out2->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);1196 out2->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 1197 1197 } 1198 1198 convMask = out2->mask; … … 1285 1285 psMutexUnlock(subMask); 1286 1286 } 1287 PS_ARRAY_ADD_SCALAR(args, maskBad, PS_TYPE_ U8);1288 PS_ARRAY_ADD_SCALAR(args, maskPoor, PS_TYPE_ U8);1287 PS_ARRAY_ADD_SCALAR(args, maskBad, PS_TYPE_IMAGE_MASK); 1288 PS_ARRAY_ADD_SCALAR(args, maskPoor, PS_TYPE_IMAGE_MASK); 1289 1289 PS_ARRAY_ADD_SCALAR(args, poorFrac, PS_TYPE_F32); 1290 1290 psArrayAdd(args, 1, subRegion); -
trunk/psModules/src/imcombine/pmSubtraction.h
r20568 r21183 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-11-07 00:03:18 $8 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 10 10 * Copyright 2004-207 Institute for Astronomy, University of Hawaii 11 11 */ … … 104 104 psImage *subMask, ///< Subtraction mask (or NULL) 105 105 int stride, ///< Size of convolution patches 106 ps MaskType maskBad, ///< Mask value to give bad pixels107 ps MaskType maskPoor, ///< Mask value to give poor pixels106 psImageMaskType maskBad, ///< Mask value to give bad pixels 107 psImageMaskType maskPoor, ///< Mask value to give poor pixels 108 108 float poorFrac, ///< Fraction for "poor" 109 109 float sysError, ///< Relative systematic error -
trunk/psModules/src/imcombine/pmSubtractionMask.c
r20832 r21183 20 20 psImage *weight, // Weight map to mark as blank (or NULL) 21 21 int x, int y, // Coordinates to mark blank 22 ps MaskType blank // Blank mask value22 psImageMaskType blank // Blank mask value 23 23 ) 24 24 { 25 25 image->data.F32[y][x] = NAN; 26 26 if (mask) { 27 mask->data.PS_TYPE_ MASK_DATA[y][x] |= blank;27 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank; 28 28 } 29 29 if (weight) { … … 37 37 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 38 38 39 psImage *pmSubtractionMask(const psImage *mask1, const psImage *mask2, ps MaskType maskVal,39 psImage *pmSubtractionMask(const psImage *mask1, const psImage *mask2, psImageMaskType maskVal, 40 40 int size, int footprint, float badFrac, bool useFFT) 41 41 { 42 42 PS_ASSERT_IMAGE_NON_NULL(mask1, NULL); 43 PS_ASSERT_IMAGE_TYPE(mask1, PS_TYPE_ MASK, NULL);43 PS_ASSERT_IMAGE_TYPE(mask1, PS_TYPE_IMAGE_MASK, NULL); 44 44 if (mask2) { 45 45 PS_ASSERT_IMAGE_NON_NULL(mask2, NULL); 46 PS_ASSERT_IMAGE_TYPE(mask2, PS_TYPE_ MASK, NULL);46 PS_ASSERT_IMAGE_TYPE(mask2, PS_TYPE_IMAGE_MASK, NULL); 47 47 PS_ASSERT_IMAGES_SIZE_EQUAL(mask2, mask1, NULL); 48 48 } … … 57 57 58 58 // Dereference inputs for convenience 59 ps MaskType **data1 = mask1->data.PS_TYPE_MASK_DATA;60 ps MaskType **data2 = NULL;59 psImageMaskType **data1 = mask1->data.PS_TYPE_IMAGE_MASK_DATA; 60 psImageMaskType **data2 = NULL; 61 61 if (mask2) { 62 data2 = mask2->data.PS_TYPE_ MASK_DATA;62 data2 = mask2->data.PS_TYPE_IMAGE_MASK_DATA; 63 63 } 64 64 … … 86 86 87 87 // Worried about the masks for bad pixels and bad stamps colliding, so make our own mask 88 psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK); // The global mask88 psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // The global mask 89 89 psImageInit(mask, 0); 90 ps MaskType **maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference for convenience90 psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference for convenience 91 91 92 92 // Block out a border around the edge of the image … … 161 161 162 162 bool pmSubtractionBorder(psImage *image, psImage *weight, psImage *mask, 163 int size, ps MaskType blank)163 int size, psImageMaskType blank) 164 164 { 165 165 PS_ASSERT_IMAGE_NON_NULL(image, false); … … 168 168 PS_ASSERT_IMAGE_NON_NULL(mask, false); 169 169 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false); 170 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);170 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 171 171 } 172 172 if (weight) { … … 211 211 } 212 212 PS_ASSERT_IMAGE_NON_NULL(mask, false); 213 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_ MASK, false);213 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false); 214 214 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false); 215 215 … … 233 233 234 234 int numCols = image->numCols, numRows = image->numRows; // Size of image 235 ps MaskType **maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference mask235 psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask 236 236 237 237 for (int y = 0; y < numRows; y++) { -
trunk/psModules/src/imcombine/pmSubtractionMask.h
r17729 r21183 7 7 psImage *pmSubtractionMask(const psImage *refMask, ///< Mask for the reference image (will be convolved) 8 8 const psImage *inMask, ///< Mask for the input image, or NULL 9 ps MaskType maskVal, ///< Value to mask out9 psImageMaskType maskVal, ///< Value to mask out 10 10 int size, ///< Half-size of the kernel (pmSubtractionKernels.size) 11 11 int footprint, ///< Half-size of the kernel footprint … … 19 19 psImage *mask, ///< Mask (or NULL) 20 20 int size, ///< Kernel half-size 21 ps MaskType blank ///< Mask value for blank regions21 psImageMaskType blank ///< Mask value for blank regions 22 22 ); 23 23 -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r21149 r21183 98 98 int inner, int ringsOrder, int binning, float penalty, 99 99 bool optimum, const psVector *optFWHMs, int optOrder, float optThreshold, 100 int iter, float rej, float sysError, ps MaskType maskVal, psMaskType maskBad,101 ps MaskType maskPoor, float poorFrac, float badFrac, pmSubtractionMode subMode)100 int iter, float rej, float sysError, psImageMaskType maskVal, psImageMaskType maskBad, 101 psImageMaskType maskPoor, float poorFrac, float badFrac, pmSubtractionMode subMode) 102 102 { 103 103 if (subMode != PM_SUBTRACTION_MODE_2) { … … 565 565 if (width1 == 0 || width2 == 0) { 566 566 ratios->data.F32[index] = NAN; 567 mask->data.PS_TYPE_ MASK_DATA[index] = 0xff;567 mask->data.PS_TYPE_IMAGE_MASK_DATA[index] = 0xff; 568 568 } else { 569 569 ratios->data.F32[index] = (float)width1 / (float)width2; 570 mask->data.PS_TYPE_ MASK_DATA[index] = 0;570 mask->data.PS_TYPE_IMAGE_MASK_DATA[index] = 0; 571 571 psTrace("psModules.imcombine", 3, "Stamp %d (%.1f,%.1f) widths: %d, %d --> %f\n", 572 572 index, stamp->x, stamp->y, width1, width2, ratios->data.F32[index]); … … 596 596 PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(stamps, PM_SUBTRACTION_MODE_ERR); 597 597 598 psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_ MASK); // Mask for stamps598 psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_VECTOR_MASK); // Mask for stamps 599 599 psVector *ratios = psVectorAlloc(stamps->num, PS_TYPE_F32); // Ratios of widths 600 600 … … 624 624 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 625 625 if (stamp->status != PM_SUBTRACTION_STAMP_CALCULATE && stamp->status != PM_SUBTRACTION_STAMP_USED) { 626 mask->data.PS_TYPE_ MASK_DATA[i] = 0xff;626 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 627 627 continue; 628 628 } -
trunk/psModules/src/imcombine/pmSubtractionMatch.h
r20568 r21183 40 40 float rej, ///< Rejection threshold 41 41 float sysError, ///< Relative systematic error 42 ps MaskType maskVal, ///< Value to mask for input43 ps MaskType maskBad, ///< Mask for output bad pixels44 ps MaskType maskPoor, ///< Mask for output poor pixels42 psImageMaskType maskVal, ///< Value to mask for input 43 psImageMaskType maskBad, ///< Mask for output bad pixels 44 psImageMaskType maskPoor, ///< Mask for output poor pixels 45 45 float poorFrac, ///< Fraction for "poor" 46 46 float badFrac, ///< Maximum fraction of bad input pixels to accept -
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r20937 r21183 98 98 99 99 // Determine mask value 100 ps MaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2;100 psImageMaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2; 101 101 switch (mode) { 102 102 case PM_SUBTRACTION_MODE_1: … … 115 115 116 116 // Check the immediate pixel 117 if (clean && (mask->data.PS_TYPE_ MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) {117 if (clean && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) { 118 118 clean = false; 119 119 } … … 126 126 for (int j = yMin; j <= yMax; j++) { 127 127 for (int i = xMin; i <= xMax; i++) { 128 if (mask->data.PS_TYPE_ MASK_DATA[j][i] & maskVal) {128 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal) { 129 129 clean = false; 130 130 goto CHECK_STAMP_MASK_DONE; … … 139 139 for (int j = yMin; j <= yMax; j++) { 140 140 for (int i = xMin; i <= xMax; i++) { 141 mask->data.PS_TYPE_ MASK_DATA[j][i] |= PM_SUBTRACTION_MASK_REJ;141 mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= PM_SUBTRACTION_MASK_REJ; 142 142 } 143 143 } … … 235 235 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 236 236 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL); 237 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_ MASK, NULL);237 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL); 238 238 } 239 239 PS_ASSERT_INT_NONNEGATIVE(footprint, NULL); … … 377 377 if (subMask) { 378 378 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 379 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_ MASK, NULL);379 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL); 380 380 if (image) { 381 381 PS_ASSERT_IMAGE_NON_NULL(image, NULL); -
trunk/psModules/src/objects/pmFootprintArrayGrow.c
r20937 r21183 3 3 * @author RHL, Princeton & IfA; EAM, IfA 4 4 * 5 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-01-27 06:39:38 $ 7 7 * Copyright 2006 Institute for Astronomy, University of Hawaii 8 8 */ … … 45 45 // Use a separable convolution: should be faster 46 46 idImage = (psImage*)psBinaryOp(idImage, idImage, "MIN", psScalarAlloc(1, PS_TYPE_S32)); 47 psImage *idImageMask = psImageCopy(NULL, idImage, PS_TYPE_ MASK); // Image with 1 = object47 psImage *idImageMask = psImageCopy(NULL, idImage, PS_TYPE_IMAGE_MASK); // Image with 1 = object 48 48 psImage *grownIdImage = psImageConvolveMask(NULL, idImageMask, 0x01, 0x01, -r, r, -r, r); // Grown mask 49 49 if (!grownIdImage) { -
trunk/psModules/src/objects/pmFootprintFindAtPoint.c
r20937 r21183 4 4 * @author RHL, Princeton & IfA; EAM, IfA 5 5 * 6 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-12-08 02:51:14$6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 77 77 78 78 if (mask != NULL) { // remember that we've detected these pixels 79 ps MaskType *mpix = &mask->data.PS_TYPE_MASK_DATA[span->y - mask->row0][span->x0 - mask->col0];79 psImageMaskType *mpix = &mask->data.PS_TYPE_IMAGE_MASK_DATA[span->y - mask->row0][span->x0 - mask->col0]; 80 80 81 81 for (int i = 0; i <= span->x1 - span->x0; i++) { … … 143 143 psF32 *imgRowF32 = NULL; // row pointer if F32 144 144 psS32 *imgRowS32 = NULL; // " " " " !F32 145 ps MaskType *maskRow = NULL; // masks's row pointer145 psImageMaskType *maskRow = NULL; // masks's row pointer 146 146 147 147 const int row0 = img->row0; … … 186 186 imgRowF32 = img->data.F32[i]; // only one of 187 187 imgRowS32 = img->data.S32[i]; // these is valid! 188 maskRow = mask->data.PS_TYPE_ MASK_DATA[i];188 maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[i]; 189 189 // 190 190 // Search left from the pixel diagonally to the left of (i - di, x0). If there's … … 354 354 * looking for the rest of the pmFootprint. These are generally set from peaks. 355 355 */ 356 psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);356 psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 357 357 P_PSIMAGE_SET_ROW0(mask, row0); 358 358 P_PSIMAGE_SET_COL0(mask, col0); … … 365 365 for (int i = 0; i < peaks->n; i++) { 366 366 pmPeak *peak = peaks->data[i]; 367 mask->data.PS_TYPE_ MASK_DATA[peak->y - mask->row0][peak->x - mask->col0] |= PM_SSPAN_STOP;367 mask->data.PS_TYPE_IMAGE_MASK_DATA[peak->y - mask->row0][peak->x - mask->col0] |= PM_SSPAN_STOP; 368 368 } 369 369 } … … 375 375 imgRowF32 = img->data.F32[row]; // only one of 376 376 imgRowS32 = img->data.S32[row]; // these is valid! 377 ps MaskType *maskRow = mask->data.PS_TYPE_MASK_DATA[row];377 psImageMaskType *maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row]; 378 378 { 379 379 int i; -
trunk/psModules/src/objects/pmGrowthCurveGenerate.c
r20937 r21183 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-12-08 02:51:14$7 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2004 Institute for Astronomy, University of Hawaii … … 41 41 #include "pmErrorCodes.h" 42 42 43 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, ps MaskType maskVal, psMaskType markVal, float xc, float yc);43 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal, float xc, float yc); 44 44 45 45 /*****************************************************************************/ … … 48 48 49 49 // we generate the growth curve for the center of the image with the specified psf model 50 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, ps MaskType maskVal, psMaskType markVal)50 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal) 51 51 { 52 52 PS_ASSERT_PTR_NON_NULL(readout, false); … … 119 119 } 120 120 121 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, ps MaskType maskVal, psMaskType markVal, float xc, float yc) {121 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal, float xc, float yc) { 122 122 123 123 float fitMag, apMag; … … 162 162 psImage *view = psImageSubset (image, region); 163 163 psImage *pixels = psImageCopy (NULL, view, PS_TYPE_F32); 164 psImage *mask = psImageCopy (NULL, view, PS_TYPE_ U8);164 psImage *mask = psImageCopy (NULL, view, PS_TYPE_IMAGE_MASK); 165 165 166 166 psImageInit (pixels, 0.0); … … 189 189 return NULL; 190 190 } 191 psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_ U8(markVal));191 psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 192 192 193 193 // the 'ignore' mode is for testing -
trunk/psModules/src/objects/pmModel.c
r20592 r21183 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-11-09 00:28:18 $8 * @version $Revision: 1.26 $ $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 … … 172 172 pmModelOpMode mode, 173 173 bool add, 174 ps MaskType maskVal,174 psImageMaskType maskVal, 175 175 int dx, 176 176 int dy … … 229 229 psF32 **Rx = NULL; 230 230 psF32 **Ry = NULL; 231 ps U8**Rm = NULL;231 psImageMaskType **Rm = NULL; 232 232 233 233 if (model->residuals) { … … 237 237 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL; 238 238 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL; 239 Rm = (model->residuals->mask) ? model->residuals->mask->data. U8: NULL;239 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 240 240 if (Ro) { 241 241 NX = model->residuals->Ro->numCols; … … 249 249 for (psS32 iy = 0; iy < image->numRows; iy++) { 250 250 for (psS32 ix = 0; ix < image->numCols; ix++) { 251 if ((mask != NULL) && (mask->data. U8[iy][ix] & maskVal))251 if ((mask != NULL) && (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal)) 252 252 continue; 253 253 … … 351 351 pmModel *model, 352 352 pmModelOpMode mode, 353 ps MaskType maskVal)353 psImageMaskType maskVal) 354 354 { 355 355 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 365 365 pmModel *model, 366 366 pmModelOpMode mode, 367 ps MaskType maskVal)367 psImageMaskType maskVal) 368 368 { 369 369 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 379 379 pmModel *model, 380 380 pmModelOpMode mode, 381 ps MaskType maskVal,381 psImageMaskType maskVal, 382 382 int dx, 383 383 int dy) … … 395 395 pmModel *model, 396 396 pmModelOpMode mode, 397 ps MaskType maskVal,397 psImageMaskType maskVal, 398 398 int dx, 399 399 int dy) -
trunk/psModules/src/objects/pmModel.h
r20945 r21183 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-12-09 21:16:09$7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 150 150 pmModel *model, ///< The input pmModel 151 151 pmModelOpMode mode, ///< mode to control how the model is added into the image 152 ps MaskType maskVal///< Value to mask152 psImageMaskType maskVal ///< Value to mask 153 153 ); 154 154 … … 168 168 pmModel *model, ///< The input pmModel 169 169 pmModelOpMode mode, ///< mode to control how the model is added into the image 170 ps MaskType maskVal///< Value to mask170 psImageMaskType maskVal ///< Value to mask 171 171 ); 172 172 … … 175 175 pmModel *model, 176 176 pmModelOpMode mode, 177 ps MaskType maskVal,177 psImageMaskType maskVal, 178 178 int dx, 179 179 int dy); … … 183 183 pmModel *model, 184 184 pmModelOpMode mode, 185 ps MaskType maskVal,185 psImageMaskType maskVal, 186 186 int dx, 187 187 int dy); -
trunk/psModules/src/objects/pmPSF.h
r20945 r21183 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-09 21:16:09$8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 102 102 double pmPSF_SXYtoModel (psF32 *fittedPar); 103 103 104 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, ps MaskType maskVal, psMaskType mark);104 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType mark); 105 105 pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...); 106 106 -
trunk/psModules/src/objects/pmPSF_IO.c
r20937 r21183 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.37 $ $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 … … 871 871 psFitsReadImageBuffer(psf->residuals->Ry, file->fits, fullImage, 2); // Desired pixels 872 872 } 873 // XXX notice that we are not saving the resid->mask 873 874 } 874 875 -
trunk/psModules/src/objects/pmPSFtry.c
r21173 r21183 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.68 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 00:01:33 $ 9 * 7 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 10 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 10 * … … 115 114 test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F32); 116 115 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F32); 117 test->mask = psVectorAlloc (sources->n, PS_TYPE_ U8);116 test->mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK); 118 117 119 118 psVectorInit (test->mask, 0); … … 148 147 149 148 // generate a pmPSFtry with a copy of the test PSF sources 150 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, ps MaskType maskVal, psMaskType markVal)149 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal) 151 150 { 152 151 bool status; … … 176 175 pmSource *source = psfTry->sources->data[i]; 177 176 if (!source->moments) { 178 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;177 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 179 178 continue; 180 179 } 181 180 if (!source->moments->nPixels) { 182 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;181 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 183 182 continue; 184 183 } … … 186 185 source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type); 187 186 if (source->modelEXT == NULL) { 188 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;187 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 189 188 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 190 189 continue; … … 198 197 199 198 // clear object mask to define valid pixels 200 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));199 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 201 200 202 201 // exclude the poor fits 203 202 if (!status) { 204 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;203 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 205 204 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y); 206 205 continue; … … 231 230 232 231 // masked for: bad model fit, outlier in parameters 233 if (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL) {232 if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) { 234 233 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : source is masked\n", i, source->peak->x, source->peak->y); 235 234 continue; … … 239 238 source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf); 240 239 if (source->modelPSF == NULL) { 241 psfTry->mask->data. U8[i] = PSFTRY_MASK_BAD_MODEL;240 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL; 242 241 abort(); 243 242 continue; … … 253 252 // skip poor fits 254 253 if (!status) { 255 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));256 psfTry->mask->data. U8[i] = PSFTRY_MASK_PSF_FAIL;254 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 255 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL; 257 256 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y); 258 257 continue; … … 261 260 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal); 262 261 if (!status || isnan(source->apMag)) { 263 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));264 psfTry->mask->data. U8[i] = PSFTRY_MASK_BAD_PHOT;262 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 263 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT; 265 264 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y); 266 265 continue; … … 268 267 269 268 // clear object mask to define valid pixels 270 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));269 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 271 270 272 271 psfTry->fitMag->data.F32[i] = source->psfMag; … … 292 291 psVector *flux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 293 292 psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 294 psVector *mask = psVectorAlloc (psfTry->sources->n, PS_TYPE_ MASK);293 psVector *mask = psVectorAlloc (psfTry->sources->n, PS_TYPE_VECTOR_MASK); 295 294 296 295 // generate the x and y vectors, and mask missing models … … 300 299 flux->data.F32[i] = 0.0; 301 300 chisq->data.F32[i] = 0.0; 302 mask->data. U8[i] = 0xff;301 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 303 302 } else { 304 303 flux->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_I0]; 305 304 chisq->data.F32[i] = source->modelPSF->chisq / source->modelPSF->nDOF; 306 mask->data. U8[i] = 0;305 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0; 307 306 } 308 307 } … … 312 311 313 312 // linear clipped fit of chisq trend vs flux 314 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 315 0xff, chisq, NULL, flux); 313 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 0xff, chisq, NULL, flux); 316 314 psStatsOptions meanStat = psStatsMeanOption(options->stats->options); // Statistic for mean 317 315 psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev … … 370 368 371 369 for (int i = 0; i < psfTry->sources->n; i++) { 372 if (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL)370 if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) 373 371 continue; 374 372 r2rflux->data.F32[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F32[i]); … … 379 377 FILE *f = fopen ("apresid.dat", "w"); 380 378 for (int i = 0; i < psfTry->sources->n; i++) { 381 int keep = (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL);379 int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL); 382 380 383 381 pmSource *source = psfTry->sources->data[i]; … … 427 425 psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux); 428 426 for (int i = 0; i < psfTry->sources->n; i++) { 429 int keep = (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL);427 int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL); 430 428 431 429 pmSource *source = psfTry->sources->data[i]; … … 603 601 for (int i = 0; i < sources->n; i++) { 604 602 // skip any masked sources (failed to fit one of the model steps or get a magnitude) 605 if (srcMask->data. U8[i]) continue;603 if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 606 604 607 605 pmSource *source = sources->data[i]; … … 624 622 625 623 psVector *dz = NULL; 626 psVector *mask = psVectorAlloc (sources->n, PS_TYPE_ U8);624 psVector *mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK); 627 625 628 626 // check the fit residuals and increase Nx,Ny until the error is minimized … … 632 630 // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky) 633 631 for (int i = 0; i < mask->n; i++) { 634 mask->data. U8[i] = srcMask->data.U8[i];632 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 635 633 } 636 634 if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) { … … 651 649 // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky) 652 650 for (int i = 0; i < mask->n; i++) { 653 mask->data. U8[i] = srcMask->data.U8[i];651 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 654 652 } 655 653 if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) { … … 663 661 // copy mask back to srcMask 664 662 for (int i = 0; i < mask->n; i++) { 665 srcMask->data. U8[i] = mask->data.U8[i];663 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 666 664 } 667 665 … … 736 734 pmTrend2DEval (psf->params->data[PM_PAR_E1], x->data.F32[i], y->data.F32[i]), 737 735 pmTrend2DEval (psf->params->data[PM_PAR_E2], x->data.F32[i], y->data.F32[i]), 738 srcMask->data. U8[i]);736 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 739 737 } 740 738 fclose (f); … … 851 849 852 850 // the mask marks the values not used to calculate the ApTrend 853 psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_ U8);851 psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_VECTOR_MASK); 854 852 // copy mask values to fitMask as a starting point 855 853 for (int i = 0; i < fitMask->n; i++) { 856 fitMask->data. U8[i] = mask->data.U8[i];854 fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 857 855 } 858 856 … … 943 941 // XXX copy fitMask values back to mask 944 942 for (int i = 0; i < fitMask->n; i++) { 945 mask->data. U8[i] = fitMask->data.U8[i];943 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 946 944 } 947 945 psFree (fitMask); … … 951 949 952 950 // calculate the scatter of the parameters 953 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, ps MaskType maskValue, psStatsOptions stdevOpt)951 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt) 954 952 { 955 953 … … 994 992 psVector *dE1subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 995 993 psVector *dE2subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 996 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_ U8);994 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK); 997 995 998 996 int n = 0; … … 1007 1005 dE2subset->data.F32[j] = e2res->data.F32[N]; 1008 1006 1009 mkSubset->data. U8[j] = mask->data.U8[N];1010 if (!mask->data. U8[N]) nValid ++;1007 mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j] = mask->data.PS_TYPE_VECTOR_MASK_DATA[N]; 1008 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[N]) nValid ++; 1011 1009 } 1012 1010 if (nValid < 3) continue; -
trunk/psModules/src/objects/pmPSFtry.h
r21174 r21183 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-01-27 0 0:02:16$8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 48 48 pmPSF *psf; ///< Add comment. 49 49 psArray *sources; ///< pointers to the original sources 50 psVector *mask; ///< Add comment.50 psVector *mask; ///< PS_TYPE_VECTOR_MASK to flag good and bad sources 51 51 psVector *metric; ///< Add comment. 52 52 psVector *metricErr; ///< Add comment. … … 89 89 * 90 90 */ 91 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, ps MaskType maskVal, psMaskType mark);91 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType mark); 92 92 93 93 /** pmPSFtryMetric() … … 129 129 bool pmPSFFitShapeParams (pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask); 130 130 bool pmPSFFitShapeParamsMap (pmPSF *psf, int scale, float *scatterTotal, psVector *mask, psVector *x, psVector *y, psVector *mag, psVector *e0obs, psVector *e1obs, psVector *e2obs, psVector *dz); 131 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, ps MaskType maskValue, psStatsOptions stdevOpt);131 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt); 132 132 bool pmPSFShapeParamsErrors (float *errorFloor, psVector *mag, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, int nGroup, psStatsOptions stdevOpt); 133 133 -
trunk/psModules/src/objects/pmResiduals.c
r15562 r21183 4 4 * 5 5 * @author EAM, IfA 6 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $7 * @date $Date: 200 7-11-10 01:09:20$6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2004 IfA, University of Hawaii 9 9 */ … … 43 43 resid->Ry = psImageAlloc (nX, nY, PS_TYPE_F32); 44 44 resid->weight = psImageAlloc (nX, nY, PS_TYPE_F32); 45 resid->mask = psImageAlloc (nX, nY, PS_TYPE_U8); 45 resid->mask = psImageAlloc (nX, nY, PM_TYPE_RESID_MASK); 46 47 // NOTE : the residual mask is internal only : 1 byte is sufficient 46 48 47 49 resid->xBin = xBin; -
trunk/psModules/src/objects/pmResiduals.h
r15562 r21183 4 4 * 5 5 * @author EAM, IfA 6 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $7 * @date $Date: 200 7-11-10 01:09:20$6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2004 IfA, University of Hawaii 9 9 */ … … 31 31 bool psMemCheckResiduals(psPtr ptr); 32 32 33 // macros to abstract the resid mask type : these values must be consistent 34 #define PM_TYPE_RESID_MASK PS_TYPE_U8 /**< the psElemType to use for mask image */ 35 #define PM_TYPE_RESID_MASK_DATA U8 /**< the data member to use for mask image */ 36 #define PM_TYPE_RESID_MASK_NAME "psU8" /**< the data type for mask as a string */ 37 typedef psU8 pmResidMaskType; ///< the C datatype for a mask image 38 #define PM_NOT_RESID_MASK(A)(UINT8_MAX-(A)) 39 33 40 /// @} 34 41 # endif -
trunk/psModules/src/objects/pmSource.c
r20937 r21183 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.6 6$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.67 $ $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 … … 171 171 172 172 // the maskObj is a unique mask array; create a new mask image 173 source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_ MASK) : NULL;173 source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL; 174 174 175 175 source->type = in->type; … … 205 205 mySource->maskView = psImageSubset(readout->mask, srcRegion); 206 206 // the object mask is a copy, and used to define the source pixels 207 mySource->maskObj = psImageCopy(NULL, mySource->maskView, PS_TYPE_ MASK);207 mySource->maskObj = psImageCopy(NULL, mySource->maskView, PS_TYPE_IMAGE_MASK); 208 208 } 209 209 mySource->region = srcRegion; … … 255 255 // re-copy the main mask pixels. NOTE: the user will need to reset the object mask 256 256 // pixels (eg, with psImageKeepCircle) 257 mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_ MASK);257 mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_IMAGE_MASK); 258 258 259 259 // drop the old modelFlux pixels and force the user to re-create … … 505 505 *****************************************************************************/ 506 506 507 bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, ps MaskType maskSat)507 bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, psImageMaskType maskSat) 508 508 { 509 509 psTrace("psModules.objects", 5, "---- begin ----"); … … 738 738 psF32 *vPix = source->pixels->data.F32[row]; 739 739 psF32 *vWgt = source->weight->data.F32[row]; 740 ps U8 *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];740 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 741 741 742 742 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 848 848 # endif 849 849 // construct a realization of the source model 850 bool pmSourceCacheModel (pmSource *source, ps MaskType maskVal) {850 bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal) { 851 851 PS_ASSERT_PTR_NON_NULL(source, false); 852 852 // select appropriate model … … 867 867 // construct a realization of the source model 868 868 // XXX this function should optionally save an existing psf image from modelFlux 869 bool pmSourceCachePSF (pmSource *source, ps MaskType maskVal) {869 bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal) { 870 870 PS_ASSERT_PTR_NON_NULL(source, false); 871 871 … … 885 885 886 886 // should we call pmSourceCacheModel if it does not exist? 887 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, ps MaskType maskVal, int dx, int dy)887 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy) 888 888 { 889 889 PS_ASSERT_PTR_NON_NULL(source, false); … … 915 915 } 916 916 917 ps U8**mask = NULL;917 psImageMaskType **mask = NULL; 918 918 if (source->maskObj) { 919 mask = source->maskObj->data. U8;919 mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 920 920 } 921 921 … … 957 957 } 958 958 959 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, ps MaskType maskVal) {959 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal) { 960 960 return pmSourceOp (source, mode, true, maskVal, 0, 0); 961 961 } 962 962 963 bool pmSourceSub (pmSource *source, pmModelOpMode mode, ps MaskType maskVal) {963 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal) { 964 964 return pmSourceOp (source, mode, false, maskVal, 0, 0); 965 965 } 966 966 967 bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, ps MaskType maskVal, int dx, int dy) {967 bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy) { 968 968 return pmSourceOp (source, mode, true, maskVal, dx, dy); 969 969 } 970 970 971 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, ps MaskType maskVal, int dx, int dy) {971 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy) { 972 972 return pmSourceOp (source, mode, false, maskVal, dx, dy); 973 973 } -
trunk/psModules/src/objects/pmSource.h
r20945 r21183 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-09 21:16:09$5 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-01-27 06:39:38 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 210 210 psMetadata *metadata, ///< Contains classification parameters 211 211 pmPSFClump clump, ///< Statistics about the PSF clump 212 ps MaskType maskSat///< Mask value for saturated pixels212 psImageMaskType maskSat ///< Mask value for saturated pixels 213 213 ); 214 214 … … 231 231 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source); 232 232 233 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, ps MaskType maskVal);234 bool pmSourceSub (pmSource *source, pmModelOpMode mode, ps MaskType maskVal);235 bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, ps MaskType maskVal, int dx, int dy);236 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, ps MaskType maskVal, int dx, int dy);237 238 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, ps MaskType maskVal, int dx, int dy);239 bool pmSourceCacheModel (pmSource *source, ps MaskType maskVal);240 bool pmSourceCachePSF (pmSource *source, ps MaskType maskVal);233 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal); 234 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal); 235 bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy); 236 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy); 237 238 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy); 239 bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal); 240 bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal); 241 241 242 242 int pmSourceSortBySN (const void **a, const void **b); -
trunk/psModules/src/objects/pmSourceFitModel.c
r20937 r21183 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.29 $ $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 … … 56 56 pmModel *model, 57 57 pmSourceFitMode mode, 58 ps MaskType maskVal)58 psImageMaskType maskVal) 59 59 { 60 60 psTrace("psModules.objects", 5, "---- %s begin ----\n", __func__); … … 81 81 for (psS32 j = 0; j < source->pixels->numCols; j++) { 82 82 // skip masked points 83 if (source->maskObj->data. U8[i][j] & maskVal) {83 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) { 84 84 continue; 85 85 } … … 121 121 // create the minimization constraints 122 122 psMinConstraint *constraint = psMinConstraintAlloc(); 123 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_ U8);123 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK); 124 124 constraint->checkLimits = model->modelLimits; 125 125 … … 131 131 nParams = 1; 132 132 psVectorInit (constraint->paramMask, 1); 133 constraint->paramMask->data. U8[PM_PAR_I0] = 0;133 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0; 134 134 break; 135 135 case PM_SOURCE_FIT_PSF: … … 137 137 nParams = 3; 138 138 psVectorInit (constraint->paramMask, 1); 139 constraint->paramMask->data. U8[PM_PAR_I0] = 0;140 constraint->paramMask->data. U8[PM_PAR_XPOS] = 0;141 constraint->paramMask->data. U8[PM_PAR_YPOS] = 0;139 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0; 140 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_XPOS] = 0; 141 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_YPOS] = 0; 142 142 break; 143 143 case PM_SOURCE_FIT_EXT: … … 145 145 nParams = params->n - 1; 146 146 psVectorInit (constraint->paramMask, 0); 147 constraint->paramMask->data. U8[PM_PAR_SKY] = 1;147 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1; 148 148 break; 149 149 default: … … 175 175 fprintf (stderr, "%f ", params->data.F32[i]); 176 176 } 177 if ((constraint->paramMask != NULL) && constraint->paramMask->data. U8[i])177 if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) 178 178 continue; 179 179 dparams->data.F32[i] = sqrt(covar->data.F32[i][i]); … … 192 192 if (constraint->paramMask != NULL) { 193 193 psVector *delta = psVectorAlloc (params->n, PS_TYPE_F32); 194 psVector *altmask = psVectorAlloc (params->n, PS_TYPE_ U8);195 altmask->data. U8[0] = 1;194 psVector *altmask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK); 195 altmask->data.PS_TYPE_VECTOR_MASK_DATA[0] = 1; 196 196 for (int i = 1; i < dparams->n; i++) { 197 altmask->data. U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1;197 altmask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) ? 0 : 1; 198 198 } 199 199 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model->modelFunc); 200 200 201 201 for (int i = 0; i < dparams->n; i++) { 202 if (!constraint->paramMask->data. U8[i])202 if (!constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) 203 203 continue; 204 204 // note that delta is the value *subtracted* from the parameter -
trunk/psModules/src/objects/pmSourceFitModel.h
r13898 r21183 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $6 * @date $Date: 200 7-06-20 02:22:26$5 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-01-27 06:39:38 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 41 41 pmModel *model, ///< model to be fitted 42 42 pmSourceFitMode mode, ///< define parameters to be fitted 43 ps MaskType maskVal///< Value to mask43 psImageMaskType maskVal ///< Value to mask 44 44 ); 45 45 … … 71 71 psArray *modelSet, ///< model to be fitted 72 72 pmSourceFitMode mode, ///< define parameters to be fitted 73 ps MaskType maskVal///< Vale to mask73 psImageMaskType maskVal ///< Vale to mask 74 74 75 75 ); -
trunk/psModules/src/objects/pmSourceFitSet.c
r21163 r21183 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-24 20:52:26 $ 10 * 8 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-01-27 06:39:38 $ 11 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 12 11 * … … 394 393 for (int j = 0; j < paramOne->n; j++) { 395 394 if (j == PM_PAR_I0) continue; 396 constraint->paramMask->data. U8[n + j] = 1;395 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1; 397 396 } 398 397 break; … … 403 402 if (j == PM_PAR_YPOS) continue; 404 403 if (j == PM_PAR_I0) continue; 405 constraint->paramMask->data. U8[n + j] = 1;404 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1; 406 405 } 407 406 break; 408 407 case PM_SOURCE_FIT_EXT: 409 408 // EXT model fits all params (except sky) 410 constraint->paramMask->data. U8[n + PM_PAR_SKY] = 1;409 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + PM_PAR_SKY] = 1; 411 410 break; 412 411 default: … … 445 444 psArray *modelSet, 446 445 pmSourceFitMode mode, 447 ps MaskType maskVal)446 psImageMaskType maskVal) 448 447 { 449 448 psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__); … … 469 468 for (psS32 j = 0; j < source->pixels->numCols; j++) { 470 469 // skip masked points 471 if (source->maskObj->data. U8[i][j] & maskVal) {470 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) { 472 471 continue; 473 472 } … … 515 514 // create the minimization constraints 516 515 psMinConstraint *constraint = psMinConstraintAlloc(); 517 constraint->paramMask = psVectorAlloc (thisSet->nParamSet, PS_TYPE_ U8);516 constraint->paramMask = psVectorAlloc (thisSet->nParamSet, PS_TYPE_VECTOR_MASK); 518 517 constraint->checkLimits = pmSourceFitSetCheckLimits; 519 518 … … 528 527 if (psTraceGetLevel("psModules.objects") >= 5) { 529 528 for (int i = 0; i < params->n; i++) { 530 fprintf (stderr, "%d %f %d\n", i, params->data.F32[i], constraint->paramMask->data. U8[i]);529 fprintf (stderr, "%d %f %d\n", i, params->data.F32[i], constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 531 530 } 532 531 } … … 560 559 psVector *dparams = psVectorAlloc (thisSet->nParamSet, PS_TYPE_F32); 561 560 for (int i = 0; i < dparams->n; i++) { 562 if ((constraint->paramMask != NULL) && constraint->paramMask->data. U8[i])561 if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) 563 562 continue; 564 563 dparams->data.F32[i] = sqrt(covar->data.F32[i][i]); … … 568 567 if (constraint->paramMask != NULL) { 569 568 psVector *delta = psVectorAlloc (params->n, PS_TYPE_F32); 570 psVector *altmask = psVectorAlloc (params->n, PS_TYPE_ U8);571 altmask->data. U8[0] = 1;569 psVector *altmask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK); 570 altmask->data.PS_TYPE_VECTOR_MASK_DATA[0] = 1; 572 571 for (int i = 1; i < dparams->n; i++) { 573 altmask->data. U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1;572 altmask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) ? 0 : 1; 574 573 } 575 574 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, pmSourceFitSetFunction); 576 575 577 576 for (int i = 0; i < dparams->n; i++) { 578 if (!constraint->paramMask->data. U8[i])577 if (!constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) 579 578 continue; 580 579 // note that delta is the value *subtracted* from the parameter -
trunk/psModules/src/objects/pmSourceFitSet.h
r21163 r21183 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $6 * @date $Date: 2009-01-2 4 20:52:26$5 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-01-27 06:39:38 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 54 54 */ 55 55 bool pmSourceFitSet( 56 pmSource *source, ///< The input pmSource57 psArray *modelSet, ///< model to be fitted58 pmSourceFitMode mode, ///< define parameters to be fitted59 ps MaskType maskVal///< Vale to mask56 pmSource *source, ///< The input pmSource 57 psArray *modelSet, ///< model to be fitted 58 pmSourceFitMode mode, ///< define parameters to be fitted 59 psImageMaskType maskVal ///< Vale to mask 60 60 61 61 ); -
trunk/psModules/src/objects/pmSourceMatch.c
r21105 r21183 122 122 match->image = psVectorAllocEmpty(num, PS_TYPE_U32); 123 123 match->index = psVectorAllocEmpty(num, PS_TYPE_U32); 124 match->mask = psVectorAllocEmpty(num, PS_TYPE_ MASK);124 match->mask = psVectorAllocEmpty(num, PS_TYPE_VECTOR_MASK); 125 125 126 126 return match; … … 143 143 match->image->data.S32[num] = image; 144 144 match->index->data.S32[num] = index; 145 match->mask->data.PS_TYPE_ MASK_DATA[num] = 0;145 match->mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0; 146 146 match->num++; 147 147 … … 316 316 double star = 0.0, starErr = 0.0; // Accumulators for star 317 317 for (int j = 0; j < match->num; j++) { 318 if (match->mask->data.PS_TYPE_ MASK_DATA[j]) {318 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 319 319 continue; 320 320 } … … 347 347 pmSourceMatch *match = matches->data[i]; // Matched stars 348 348 for (int j = 0; j < match->num; j++) { 349 if (match->mask->data.PS_TYPE_ MASK_DATA[j]) {349 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 350 350 continue; 351 351 } … … 373 373 pmSourceMatch *match = matches->data[i]; // Matched stars 374 374 for (int j = 0; j < match->num; j++) { 375 if (match->mask->data.PS_TYPE_ MASK_DATA[j]) {375 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 376 376 continue; 377 377 } … … 474 474 pmSourceMatch *match = matches->data[i]; // Matched stars 475 475 for (int j = 0; j < match->num; j++) { 476 if (match->mask->data.PS_TYPE_ MASK_DATA[j]) {476 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 477 477 continue; 478 478 } … … 488 488 if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) { 489 489 numRejected++; 490 match->mask->data.PS_TYPE_ MASK_DATA[j] = 0xFF;490 match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF; 491 491 } 492 492 } -
trunk/psModules/src/objects/pmSourceMoments.c
r20937 r21183 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.7 $ $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 … … 100 100 psF32 *vPix = source->pixels->data.F32[row]; 101 101 psF32 *vWgt = source->weight->data.F32[row]; 102 ps U8 *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];102 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 103 103 104 104 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 190 190 psF32 *vPix = source->pixels->data.F32[row]; 191 191 psF32 *vWgt = source->weight->data.F32[row]; 192 ps U8 *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];192 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 193 193 194 194 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 342 342 psF32 *vPix = source->pixels->data.F32[row]; 343 343 psF32 *vWgt = source->weight->data.F32[row]; 344 ps U8 *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];344 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 345 345 346 346 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { -
trunk/psModules/src/objects/pmSourcePhotometry.c
r20937 r21183 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.4 7$ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.48 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-01-27 06:39:38 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 66 66 67 67 // XXX masked region should be (optionally) elliptical 68 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, ps MaskType maskVal)68 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal) 69 69 { 70 70 PS_ASSERT_PTR_NON_NULL(source, false); … … 306 306 307 307 // return source aperture magnitude 308 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, ps MaskType maskVal)308 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal) 309 309 { 310 310 PS_ASSERT_PTR_NON_NULL(apMag, false); … … 324 324 325 325 psF32 **imData = image->data.F32; 326 ps U8 **mkData = mask->data.U8;326 psImageMaskType **mkData = mask->data.PS_TYPE_IMAGE_MASK_DATA; 327 327 328 328 // measure apMag … … 344 344 345 345 // return source aperture magnitude 346 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, ps MaskType maskVal)346 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal) 347 347 { 348 348 PS_ASSERT_PTR_NON_NULL(pixWeight, false); … … 412 412 if (my >= NY) 413 413 continue; 414 if (mask->data. U8[my][mx] & maskVal)414 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal) 415 415 continue; 416 416 … … 475 475 for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) { 476 476 for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) { 477 if (Ti->data. U8[yi][xi])478 continue; 479 if (Tj->data. U8[yj][xj])477 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi]) 478 continue; 479 if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj]) 480 480 continue; 481 481 … … 540 540 for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) { 541 541 for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) { 542 if (Ti->data. U8[yi][xi])543 continue; 544 if (Tj->data. U8[yj][xj])542 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi]) 543 continue; 544 if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj]) 545 545 continue; 546 546 … … 578 578 for (int yi = 0; yi < Pi->numRows; yi++) { 579 579 for (int xi = 0; xi < Pi->numCols; xi++) { 580 if (Ti->data. U8[yi][xi])580 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi]) 581 581 continue; 582 582 if (!unweighted_sum) { … … 613 613 614 614 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, 615 ps MaskType maskVal)615 psImageMaskType maskVal) 616 616 { 617 617 PS_ASSERT_PTR_NON_NULL(model, false); … … 624 624 for (int j = 0; j < image->numRows; j++) { 625 625 for (int i = 0; i < image->numCols; i++) { 626 if (mask->data. U8[j][i] & maskVal)626 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal) 627 627 continue; 628 628 if (weight->data.F32[j][i] <= 0) … … 657 657 for (int yi = 0; yi < Pi->numRows; yi++) { 658 658 for (int xi = 0; xi < Pi->numCols; xi++) { 659 if (Ti->data. U8[yi][xi])659 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi]) 660 660 continue; 661 661 if (!unweighted_sum) { … … 734 734 for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) { 735 735 for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) { 736 if (Ti->data. U8[yi][xi])737 continue; 738 if (Tj->data. U8[yj][xj])736 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi]) 737 continue; 738 if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj]) 739 739 continue; 740 740 … … 798 798 for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) { 799 799 for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) { 800 if (Ti->data. U8[yi][xi])801 continue; 802 if (Tj->data. U8[yj][xj])800 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi]) 801 continue; 802 if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj]) 803 803 continue; 804 804 -
trunk/psModules/src/objects/pmSourcePhotometry.h
r18554 r21183 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-07-15 20:25:00$6 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-01-27 06:39:38 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 46 46 psImage *image, ///< image pixels to be used 47 47 psImage *mask, ///< mask of pixels to ignore 48 ps MaskType maskVal///< Value to mask48 psImageMaskType maskVal ///< Value to mask 49 49 ); 50 50 51 51 bool pmSourceMagnitudesInit (psMetadata *config); 52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, ps MaskType maskVal);53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, ps MaskType maskVal);54 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, ps MaskType maskVal);52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal); 53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal); 54 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal); 55 55 56 56 -
trunk/psModules/src/objects/pmSourceSky.c
r20937 r21183 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.19 $ $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 … … 52 52 psStatsOptions statsOptions, 53 53 psF32 Radius, 54 ps MaskType maskVal,55 ps MaskType markVal)54 psImageMaskType maskVal, 55 psImageMaskType markVal) 56 56 { 57 57 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 86 86 return false; 87 87 } 88 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_ U8(markVal));88 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_IMAGE_MASK(markVal)); 89 89 double value = psStatsGetValue(myStats, statistic); 90 90 psFree(myStats); … … 107 107 psStatsOptions statsOptions, 108 108 psF32 Radius, 109 ps MaskType maskVal,110 ps MaskType markVal109 psImageMaskType maskVal, 110 psImageMaskType markVal 111 111 ) 112 112 { … … 142 142 return false; 143 143 } 144 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_ U8(markVal));144 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_IMAGE_MASK(markVal)); 145 145 double value = psStatsGetValue(myStats, statistic); 146 146 psFree(myStats); -
trunk/psModules/src/objects/pmSourceSky.h
r13898 r21183 2 2 * @author EAM, IfA; GLG, MHPCC 3 3 * 4 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $5 * @date $Date: 200 7-06-20 02:22:26$4 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 5 * @date $Date: 2009-01-27 06:39:38 $ 6 6 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 7 7 */ … … 30 30 psStatsOptions statsOptions, ///< The statistic used in calculating the background sky 31 31 float Radius, ///< The inner radius of the square annulus to exclude 32 ps MaskType maskVal, ///< Value to mask33 ps MaskType mark ///< Mask value for marking32 psImageMaskType maskVal, ///< Value to mask 33 psImageMaskType mark ///< Mask value for marking 34 34 ); 35 35 … … 40 40 psStatsOptions statsOptions, ///< The statistic used in calculating the background sky 41 41 float Radius, ///< The inner radius of the square annulus to exclude 42 ps MaskType maskVal, ///< Value to mask43 ps MaskType mark ///< Mask value for marking42 psImageMaskType maskVal, ///< Value to mask 43 psImageMaskType mark ///< Mask value for marking 44 44 ); 45 45 -
trunk/psModules/src/objects/pmSourceVisual.c
r20582 r21183 57 57 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 58 58 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i]; 59 if (mask->data. U8[i]) continue;59 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 60 60 min = PS_MIN (min, resid->data.F32[i]); 61 61 max = PS_MAX (max, resid->data.F32[i]); -
trunk/psModules/src/objects/pmTrend2D.c
r21172 r21183 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2009-01-27 0 0:00:44$5 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-01-27 06:39:38 $ 7 7 * Copyright 2004 Institute for Astronomy, University of Hawaii 8 8 * … … 179 179 } 180 180 181 bool pmTrend2DFit(pmTrend2D *trend, psVector *mask, ps MaskType maskVal, const psVector *x,181 bool pmTrend2DFit(pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x, 182 182 const psVector *y, const psVector *f, const psVector *df) 183 183 { … … 234 234 } 235 235 236 psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, ps MaskType maskValue, const psVector *x, const psVector *y)236 psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y) 237 237 { 238 238 PM_ASSERT_TREND2D_NON_NULL(trend, NULL); -
trunk/psModules/src/objects/pmTrend2D.h
r21172 r21183 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2009-01-27 0 0:00:45$7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 80 80 bool pmTrend2DFit(pmTrend2D *trend, 81 81 psVector *mask, // Warning: mask is modified! 82 ps MaskType maskVal,82 psVectorMaskType maskVal, 83 83 const psVector *x, 84 84 const psVector *y, … … 90 90 float x, float y 91 91 ); 92 psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, ps MaskType maskValue,92 psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, psVectorMaskType maskValue, 93 93 const psVector *x, const psVector *y 94 94 ); -
trunk/psastro/src/psastroAstromGuess.c
r20805 r21183 267 267 psVector *cornerDn = psVectorAllocEmpty (100, PS_TYPE_F32); 268 268 269 psVector *cornerMK = psVectorAllocEmpty (100, PS_TYPE_ U8);269 psVector *cornerMK = psVectorAllocEmpty (100, PS_TYPE_VECTOR_MASK); 270 270 271 271 if (DEBUG) psastroDumpCorners ("corners.up.guess3.dat", "corners.dn.guess3.dat", fpa); -
trunk/psastro/src/psastroFixChips.c
r20805 r21183 160 160 psPlaneTransform *map = psPlaneTransformAlloc (1, 1); 161 161 162 psVector *mask = psVectorAlloc (nPts, PS_TYPE_ U8);162 psVector *mask = psVectorAlloc (nPts, PS_TYPE_VECTOR_MASK); 163 163 psVectorInit (mask, 0); 164 164 -
trunk/psastro/src/psastroLuminosityFunction.c
r20805 r21183 91 91 psLogMsg ("psastro", 4, "fitting %d points to luminosity function\n", n); 92 92 93 psVector *mask = psVectorAlloc (Mag->n, PS_TYPE_ MASK);93 psVector *mask = psVectorAlloc (Mag->n, PS_TYPE_VECTOR_MASK); 94 94 psVectorInit (mask, 0); 95 95 … … 108 108 double mMaxValid = NAN; 109 109 for (int i = 0; i < Mag->n; i++) { 110 if (mask->data. U8[i]) continue;110 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 111 111 if (isnan(mMinValid) || (Mag->data.F32[i] < mMinValid)) { 112 112 mMinValid = Mag->data.F32[i]; -
trunk/psastro/src/psastroMaskUpdates.Mosaic.c
r20650 r21183 9 9 pmCell *pmCellInChip (pmChip *chip, float x, float y); 10 10 bool pmCellCoordsForChip (float *xCell, float *yCell, pmCell *cell, float xChip, float yChip); 11 bool psastroMaskCircle (psImage *mask, charvalue, float x0, float y0, float dX, float dY);12 bool psastroMaskBox (psImage *mask, charvalue, float x0, float y0, float dL, float dW, float theta);13 void psastroMaskLine (psImage *mask, charvalue, double x1, double y1, double x2, double y2, int dW);14 void psastroMaskLineBresen (psImage *mask, charvalue, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);15 void psastroMaskRectangle (psImage *mask, charvalue, int x0, int y0, int x1, int y1);11 bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY); 12 bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta); 13 void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW); 14 void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords); 15 void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1); 16 16 17 17 // create a mask or mask regions based on the collection of reference stars that are … … 25 25 float zeropt, exptime; 26 26 27 ps MaskType maskValue = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels28 ps MaskType maskBlank = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels27 psImageMaskType maskValue = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels 28 psImageMaskType maskBlank = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels 29 29 30 30 // select the current recipe … … 342 342 343 343 // XXX should be doing an OR 344 bool psastroMaskCircle (psImage *mask, charvalue, float x0, float y0, float dX, float dY) {344 bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY) { 345 345 346 346 // XXX need to worry about row0, col0 … … 357 357 if (r2 > 1.0) continue; 358 358 359 mask->data. U8[jy][jx] |= value;359 mask->data.PS_TYPE_IMAGE_MASK_DATA[jy][jx] |= value; 360 360 } 361 361 } … … 364 364 365 365 // XXX should be doing an OR 366 bool psastroMaskBox (psImage *mask, charvalue, float x0, float y0, float dL, float dW, float theta) {366 bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta) { 367 367 368 368 // draw a series of lines (from -0.5*dW to +0.5*dW) of length dL, starting at x0, y0, angle theta … … 379 379 380 380 // identify the quadrant and draw the correct line 381 void psastroMaskLine (psImage *mask, charvalue, double x1, double y1, double x2, double y2, int dW) {381 void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW) { 382 382 383 383 int FlipDirect, FlipCoords; … … 408 408 // use the Bresenham line drawing technique 409 409 // integer-only Bresenham line-draw version which is fast 410 void psastroMaskLineBresen (psImage *mask, charvalue, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {410 void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) { 411 411 412 412 int X, Y, dX, dY; … … 425 425 if (y < 0) continue; 426 426 if (y >= mask->numCols) continue; 427 mask->data. U8[X][y] |= value;427 mask->data.PS_TYPE_IMAGE_MASK_DATA[X][y] |= value; 428 428 } 429 429 } else { … … 432 432 if (y < 0) continue; 433 433 if (y >= mask->numRows) continue; 434 mask->data. U8[y][X] |= value;434 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][X] |= value; 435 435 } 436 436 } … … 450 450 } 451 451 452 void psastroMaskRectangle (psImage *mask, charvalue, int x0, int y0, int x1, int y1) {452 void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1) { 453 453 for (int iy = PS_MAX(0,y0); iy < PS_MIN(y1,mask->numRows); iy++) { 454 454 for (int ix = PS_MAX(0,x0); ix < PS_MIN(x1,mask->numCols); ix++) { 455 mask->data. U8[iy][ix] |= value;456 } 457 } 458 } 459 455 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= value; 456 } 457 } 458 } 459 -
trunk/psastro/src/psastroMaskUpdates.c
r21018 r21183 11 11 bool pmChipCoordsForCell (float *xChip, float *yChip, pmCell *cell, float xCell, float yCell); 12 12 13 bool psastroMaskCircle (psImage *mask, charvalue, float x0, float y0, float dX, float dY);14 bool psastroMaskBox (psImage *mask, charvalue, float x0, float y0, float dL, float dW, float theta);15 void psastroMaskLine (psImage *mask, charvalue, double x1, double y1, double x2, double y2, int dW);16 void psastroMaskLineBresen (psImage *mask, charvalue, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);17 void psastroMaskRectangle (psImage *mask, charvalue, int x0, int y0, int x1, int y1);13 bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY); 14 bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta); 15 void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW); 16 void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords); 17 void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1); 18 18 19 19 // create a mask or mask regions based on the collection of reference stars that are … … 27 27 float zeropt, exptime; 28 28 29 ps MaskType maskValue = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels30 31 // ps MaskType maskBlank = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels29 psImageMaskType maskValue = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels 30 31 // psImageMaskType maskBlank = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels 32 32 33 33 // select the current recipe … … 376 376 377 377 // XXX should be doing an OR 378 bool psastroMaskCircle (psImage *mask, charvalue, float x0, float y0, float dX, float dY) {378 bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY) { 379 379 380 380 // XXX need to worry about row0, col0 … … 391 391 if (r2 > 1.0) continue; 392 392 393 mask->data. U8[jy][jx] |= value;393 mask->data.PS_TYPE_IMAGE_MASK_DATA[jy][jx] |= value; 394 394 } 395 395 } … … 398 398 399 399 // XXX should be doing an OR 400 bool psastroMaskBox (psImage *mask, charvalue, float x0, float y0, float dL, float dW, float theta) {400 bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta) { 401 401 402 402 // draw a series of lines (from -0.5*dW to +0.5*dW) of length dL, starting at x0, y0, angle theta … … 413 413 414 414 // identify the quadrant and draw the correct line 415 void psastroMaskLine (psImage *mask, charvalue, double x1, double y1, double x2, double y2, int dW) {415 void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW) { 416 416 417 417 int FlipDirect, FlipCoords; … … 442 442 // use the Bresenham line drawing technique 443 443 // integer-only Bresenham line-draw version which is fast 444 void psastroMaskLineBresen (psImage *mask, charvalue, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {444 void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) { 445 445 446 446 int X, Y, dX, dY; … … 459 459 if (y < 0) continue; 460 460 if (y >= mask->numCols) continue; 461 mask->data. U8[X][y] |= value;461 mask->data.PS_TYPE_IMAGE_MASK_DATA[X][y] |= value; 462 462 } 463 463 } else { … … 466 466 if (y < 0) continue; 467 467 if (y >= mask->numRows) continue; 468 mask->data. U8[y][X] |= value;468 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][X] |= value; 469 469 } 470 470 } … … 484 484 } 485 485 486 void psastroMaskRectangle (psImage *mask, charvalue, int x0, int y0, int x1, int y1) {486 void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1) { 487 487 488 488 int xs = PS_MAX (0, PS_MIN (mask->numCols, PS_MIN (x0, x1))); … … 493 493 for (int iy = ys; iy < ye; iy++) { 494 494 for (int ix = xs; ix < xe; ix++) { 495 mask->data. U8[iy][ix] |= value;496 } 497 } 498 } 499 495 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= value; 496 } 497 } 498 } 499 -
trunk/psastro/src/psastroMosaicFPtoTP.c
r19314 r21183 74 74 75 75 // constant errors 76 psVector *mask = psVectorAlloc (X->n, PS_TYPE_ U8);76 psVector *mask = psVectorAlloc (X->n, PS_TYPE_VECTOR_MASK); 77 77 psVectorInit (mask, 0); 78 78 -
trunk/psphot/src/psphot.h
r21166 r21183 40 40 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources); 41 41 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 42 bool psphotReplaceUnfitSources (psArray *sources, psMaskType maskVal); 42 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal); 43 43 44 bool psphotReplaceAllSources (psArray *sources, psMetadata *recipe); 44 45 bool psphotRemoveAllSources (psArray *sources, psMetadata *recipe); … … 70 71 71 72 // used by psphotFindDetections 72 psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, ps MaskType maskVal);73 psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal); 73 74 psArray *psphotFindPeaks (psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int nMax); 74 bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, ps MaskType maskVal);75 bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal); 75 76 psErrorCode psphotCullPeaks(const psImage *img, const psImage *weight, const psMetadata *recipe, psArray *footprints); 76 77 … … 81 82 // basic support functions 82 83 void psphotModelClassInit (void); 83 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, ps MaskType maskVal);84 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal); 84 85 bool psphotSetMaskAndWeight (pmConfig *config, pmReadout *readout, psMetadata *recipe); 85 86 void psphotSourceFreePixels (psArray *sources); … … 87 88 // functions to set the correct source pixels 88 89 bool psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type); 89 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, ps MaskType markVal);90 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, ps MaskType markVal, float dR);90 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal); 91 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal, float dR); 91 92 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type); 92 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, ps MaskType markVal);93 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal); 93 94 94 95 // output functions … … 109 110 bool psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout); 110 111 bool psphotInitLimitsEXT (psMetadata *recipe); 111 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, ps MaskType maskVal, psMaskType markVal);112 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, ps MaskType maskVal, psMaskType markVal);113 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, ps MaskType maskVal, psMaskType markVal);114 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, ps MaskType maskVal, psMaskType markVal);115 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, ps MaskType maskVal, psMaskType markVal);112 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal); 113 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal); 114 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal); 115 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal); 116 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 116 117 117 118 // functions to support simultaneous multi-source fitting 118 bool psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode, ps MaskType maskVal);119 bool psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psImageMaskType maskVal); 119 120 120 121 // plotting functions (available if libkapa is installed) … … 137 138 bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize); 138 139 139 bool psphotAddWithTest (pmSource *source, bool useState, ps MaskType maskVal);140 bool psphotSubWithTest (pmSource *source, bool useState, ps MaskType maskVal);141 bool psphotSetState (pmSource *source, bool curState, ps MaskType maskVal);140 bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal); 141 bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal); 142 bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal); 142 143 bool psphotDeblendSatstars (psArray *sources, psMetadata *recipe); 143 144 bool psphotSourceSize (pmConfig *config, pmReadout *readout, psArray *sources, psMetadata *recipe, long first); 144 145 145 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, ps MaskType maskVal);146 147 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, ps MaskType maskVal, psMaskType markVal, int psfSize);146 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal); 147 148 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize); 148 149 149 150 psKernel *psphotKernelFromPSF (pmSource *source, int nPix); 150 151 151 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, ps MaskType maskVal);152 bool psphotPetrosian (pmSource *source, psMetadata *recipe, ps MaskType maskVal);153 bool psphotIsophotal (pmSource *source, psMetadata *recipe, ps MaskType maskVal);154 bool psphotAnnuli (pmSource *source, psMetadata *recipe, ps MaskType maskVal);155 bool psphotKron (pmSource *source, psMetadata *recipe, ps MaskType maskVal);152 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); 153 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); 154 bool psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); 155 bool psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); 156 bool psphotKron (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); 156 157 157 158 // psphotVisual functions … … 168 169 bool psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources); 169 170 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf); 170 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, ps MaskType maskVal);171 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal); 171 172 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources); 172 173 bool psphotVisualShowFlags (psArray *sources); … … 223 224 bool psphotMakeFluxScale (psImage *image, psMetadata *recipe, pmPSF *psf); 224 225 bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf); 225 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, ps MaskType maskVal, psMaskType markVal);226 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal); 226 227 227 228 bool psphotCheckStarDistribution (psArray *sources, psArray *stars, pmPSFOptions *options); -
trunk/psphot/src/psphotAddNoise.c
r20593 r21183 23 23 24 24 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 25 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels25 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 26 26 assert (maskVal); 27 27 -
trunk/psphot/src/psphotAnnuli.c
r17396 r21183 1 1 # include "psphotInternal.h" 2 2 3 bool psphotAnnuli (pmSource *source, psMetadata *recipe, ps MaskType maskVal) {3 bool psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) { 4 4 5 5 assert (source->extpars); -
trunk/psphot/src/psphotApResid.c
r21175 r21183 44 44 45 45 // bit-masks to test for good/bad pixels 46 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");46 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 47 47 assert (maskVal); 48 48 49 49 // bit-mask to mark pixels not used in analysis 50 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");50 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 51 51 assert (markVal); 52 52 … … 100 100 psArrayAdd(job->args, 1, psf); 101 101 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 102 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ U8); // XXX change this to use abstract mask type info102 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 103 103 104 104 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nskip … … 139 139 140 140 // gather the stats to assess the aperture residuals 141 psVector *mask = psVectorAllocEmpty (300, PS_TYPE_ U8);141 psVector *mask = psVectorAllocEmpty (300, PS_TYPE_VECTOR_MASK); 142 142 psVector *mag = psVectorAllocEmpty (300, PS_TYPE_F32); 143 143 psVector *xPos = psVectorAllocEmpty (300, PS_TYPE_F32); … … 176 176 yPos->data.F32[Npsf] = model->params->data.F32[PM_PAR_YPOS]; 177 177 178 mask->data. U8[Npsf] = 0;178 mask->data.PS_TYPE_VECTOR_MASK_DATA[Npsf] = 0; 179 179 180 180 dMag->data.F32[Npsf] = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; … … 242 242 mag->data.F32[i], dMag->data.F32[i], dMagSys->data.F32[i], 243 243 apResid->data.F32[i], apResidRes->data.F32[i], 244 mask->data. U8[i]);244 mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 245 245 } 246 246 fclose (dumpFile); … … 325 325 psVector *dMSubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 326 326 psVector *dASubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 327 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_ U8);327 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK); 328 328 329 329 int n = 0; … … 334 334 dMSubset->data.F32[j] = dMag->data.F32[N]; 335 335 dASubset->data.F32[j] = dap->data.F32[N]; 336 mkSubset->data. U8[j] = mask->data.U8[N];336 mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j] = mask->data.PS_TYPE_VECTOR_MASK_DATA[N]; 337 337 } 338 338 dMSubset->n = j; … … 460 460 pmPSF *psf = job->args->data[1]; 461 461 pmSourcePhotometryMode photMode = PS_SCALAR_VALUE(job->args->data[2],S32); 462 ps MaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],U8);462 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 463 463 464 464 for (int i = 0; i < sources->n; i++) { -
trunk/psphot/src/psphotBlendFit.c
r21166 r21183 133 133 134 134 // bit-masks to test for good/bad pixels 135 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");135 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 136 136 assert (maskVal); 137 137 138 138 // bit-mask to mark pixels not used in analysis 139 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");139 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 140 140 assert (markVal); 141 141 -
trunk/psphot/src/psphotChoosePSF.c
r21082 r21183 24 24 25 25 // bit-masks to test for good/bad pixels 26 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");26 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 27 27 assert (maskVal); 28 28 29 29 // bit-mask to mark pixels not used in analysis 30 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");30 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 31 31 assert (markVal); 32 32 … … 258 258 for (int i = 0; i < try->sources->n; i++) { 259 259 pmSource *source = try->sources->data[i]; 260 if (try->mask->data. U8[i]) {260 if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 261 261 source->mode &= ~PM_SOURCE_MODE_PSFSTAR; 262 262 } -
trunk/psphot/src/psphotExtendedSourceAnalysis.c
r19881 r21183 12 12 13 13 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 14 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels14 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 15 15 assert (maskVal); 16 16 -
trunk/psphot/src/psphotExtendedSourceFits.c
r19881 r21183 13 13 14 14 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 15 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels15 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 16 16 assert (maskVal); 17 17 18 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels18 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels 19 19 assert (markVal); 20 20 -
trunk/psphot/src/psphotExtendedSources.c
r17111 r21183 12 12 13 13 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 14 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels14 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 15 15 assert (maskVal); 16 16 -
trunk/psphot/src/psphotFindDetections.c
r20453 r21183 10 10 11 11 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 12 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels12 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 13 13 assert (maskVal); 14 14 -
trunk/psphot/src/psphotFindFootprints.c
r20831 r21183 1 1 # include "psphotInternal.h" 2 2 3 bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, ps MaskType maskVal) {3 bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal) { 4 4 5 5 bool status; -
trunk/psphot/src/psphotFitSet.c
r14337 r21183 2 2 3 3 // This is only used by psphotModelTest.c 4 bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode, ps MaskType maskVal) {4 bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psImageMaskType maskVal) { 5 5 6 6 double x, y, Io; -
trunk/psphot/src/psphotFitSourcesLinear.c
r20938 r21183 10 10 // the analysis is performed wrt the simulated pixel values 11 11 12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, ps MaskType markVal);12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal); 13 13 14 14 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) { … … 23 23 24 24 // bit-masks to test for good/bad pixels 25 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");25 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 26 26 assert (maskVal); 27 27 28 28 // bit-mask to mark pixels not used in analysis 29 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");29 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 30 30 assert (markVal); 31 31 … … 233 233 // on the pixels which correspond to all of the sources of interest. These elements fill in 234 234 // the border matrix components in the sparse matrix equation. 235 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, ps MaskType markVal) {235 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal) { 236 236 237 237 // generate the image-wide weight terms … … 248 248 float x = model->params->data.F32[PM_PAR_XPOS]; 249 249 float y = model->params->data.F32[PM_PAR_YPOS]; 250 psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_ U8(markVal));250 psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_IMAGE_MASK(markVal)); 251 251 } 252 252 … … 254 254 psF32 **image = readout->image->data.F32; 255 255 psF32 **weight = readout->weight->data.F32; 256 ps U8 **mask = readout->mask->data.U8;256 psImageMaskType **mask = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; 257 257 258 258 double w, x, y, x2, xy, y2, xc, yc, wt, f, fo, fx, fy; … … 288 288 289 289 // turn off MARK for all image pixels 290 psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_ U8(markVal));290 psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_IMAGE_MASK(markVal)); 291 291 292 292 // set the Border T elements -
trunk/psphot/src/psphotGuessModels.c
r21166 r21183 41 41 42 42 // bit-masks to test for good/bad pixels 43 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");43 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 44 44 assert (maskVal); 45 45 46 46 // bit-mask to mark pixels not used in analysis 47 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");47 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 48 48 assert (markVal); 49 49 … … 73 73 74 74 // XXX change these to use abstract mask type info 75 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_ U8);76 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_ U8);75 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 76 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 77 77 78 78 if (!psThreadJobAddPending(job)) { … … 130 130 pmPSF *psf = job->args->data[2]; 131 131 132 ps MaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],U8);133 ps MaskType markVal = PS_SCALAR_VALUE(job->args->data[4],U8);132 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 133 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 134 134 135 135 int nSrc = 0; -
trunk/psphot/src/psphotIsophotal.c
r17561 r21183 1 1 # include "psphotInternal.h" 2 2 3 bool psphotIsophotal (pmSource *source, psMetadata *recipe, ps MaskType maskVal) {3 bool psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) { 4 4 5 5 assert (source->extpars); -
trunk/psphot/src/psphotKron.c
r17396 r21183 1 1 # include "psphotInternal.h" 2 2 3 bool psphotKron (pmSource *source, psMetadata *recipe, ps MaskType maskVal) {3 bool psphotKron (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) { 4 4 5 5 psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n"); -
trunk/psphot/src/psphotMagnitudes.c
r21166 r21183 28 28 29 29 // bit-masks to test for good/bad pixels 30 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");30 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 31 31 assert (maskVal); 32 32 33 33 // bit-mask to mark pixels not used in analysis 34 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");34 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 35 35 assert (markVal); 36 36 -
trunk/psphot/src/psphotMakeGrowthCurve.c
r20453 r21183 11 11 12 12 // bit-masks to test for good/bad pixels 13 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");13 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 14 14 assert (maskVal); 15 15 16 16 // bit-mask to mark pixels not used in analysis 17 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");17 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 18 18 assert (markVal); 19 19 -
trunk/psphot/src/psphotMakeResiduals.c
r20453 r21183 1 1 # include "psphotInternal.h" 2 2 3 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, ps MaskType maskVal) {3 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal) { 4 4 5 5 bool status, isPSF; 6 6 double flux, dflux; 7 ps U8mflux;7 psImageMaskType mflux; 8 8 9 9 psTimerStart ("psphot.residuals"); … … 69 69 // - set output pixel, weight, and mask 70 70 71 // XXX need to set these correctly!! 72 const int badMask = 1; // mask bits 73 const int poorMask = 2; // from psImageInterpolate 74 const int clippedMask = 4; // mask bit set for clipped values 71 // these mask values do not correspond to the recipe values: they 72 // are not propagated to images: they just need to fit in an 8-bit 73 // value. they are supplied to psImageInterpolate, which takes a 74 // psImageMaskType; the mask portion of the result from 75 // psImageInterpolate is supplied to fmasks, which is then used by 76 // psVectorStats 77 78 const psImageMaskType badMask = 0x01; // mask bits 79 const psImageMaskType poorMask = 0x02; // from psImageInterpolate 80 const psImageMaskType clippedMask = 0x04; // mask bit set for clipped values 81 const psVectorMaskType fmaskVal = badMask | poorMask | clippedMask; 75 82 76 83 // determine the maximum image size from the input sources … … 95 102 psImage *image = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 96 103 psImage *weight = psImageCopy (NULL, source->weight, PS_TYPE_F32); 97 psImage *mask = psImageCopy (NULL, source->maskView, PS_TYPE_ U8);104 psImage *mask = psImageCopy (NULL, source->maskView, PS_TYPE_IMAGE_MASK); 98 105 pmModelSub (image, mask, model, PM_MODEL_OP_FUNC, maskVal); 99 106 … … 103 110 psBinaryOp (weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32)); 104 111 105 // we willinterpolate the image and weight - include the mask or not?106 // XXX consider better values for the mask bits 107 psImageInterpolation *interp =108 psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);109 psArrayAdd (input, 100, interp);112 // we interpolate the image and weight - include the mask or not? 113 // XXX why not the mask? 114 // psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, mask, maskVal, 0.0, 0.0, badMask, poorMask, 0.0, 0); 115 psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0); 116 psArrayAdd (input, 100, interp); 110 117 111 118 // save the X,Y position for future reference … … 131 138 psVector *fluxes = psVectorAlloc (input->n, PS_TYPE_F32); 132 139 psVector *dfluxes = psVectorAlloc (input->n, PS_TYPE_F32); 133 psVector *fmasks = psVectorAlloc (input->n, PS_TYPE_ U8);140 psVector *fmasks = psVectorAlloc (input->n, PS_TYPE_VECTOR_MASK); 134 141 135 142 // statistic to use to determine baseline for clipping … … 164 171 bool offImage = false; 165 172 if (psImageInterpolate (&flux, &dflux, &mflux, ix, iy, interp) == PS_INTERPOLATE_STATUS_OFF) { 173 // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux); 166 174 // This pixel is off the image 167 175 offImage = true; 168 fmasks->data. U8[i] = 1;169 // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);170 } 171 fluxes->data.F32[i] = flux; 172 dfluxes->data.F32[i] = dflux;173 fmasks->data.U8[i] = mflux;176 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask; 177 } else { 178 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type? 179 } 180 fluxes->data.F32[i] = flux; 181 dfluxes->data.F32[i] = dflux; 174 182 if (isnan(flux)) { 175 fmasks->data. U8[i] = 1;176 } 177 if (fmasks->data. U8[i] == 0) {183 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask; 184 } 185 if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { 178 186 nGoodPixel ++; 179 187 } 180 188 } 181 189 182 // skip pixels w hich are off the image...190 // skip pixels with insufficient data 183 191 bool validPixel = (SPATIAL_ORDER == 0) ? (nGoodPixel > 1) : (nGoodPixel > 3); 184 192 if (!validPixel) { … … 186 194 resid->Rx->data.F32[oy][ox] = 0.0; 187 195 resid->Ry->data.F32[oy][ox] = 0.0; 188 resid->mask->data. U8[oy][ox] = 1;196 resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask; 189 197 continue; 190 198 } … … 192 200 // measure the robust median to determine a baseline reference value 193 201 *fluxClip = *fluxClipDef; 194 psVectorStats (fluxClip, fluxes, NULL, fmasks, 0xff);202 psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal); 195 203 psErrorClear(); // clear (ignore) any outstanding errors 196 204 … … 202 210 float swing = fabs(delta) / sigma; 203 211 204 // make this a user option 212 // mask pixels which are out of range 205 213 if (swing > nSigma) { 206 fmasks->data. U8[i] = clippedMask;207 } 208 if (!fmasks->data. U8[i]) nKeep++;214 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask; 215 } 216 if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++; 209 217 } 210 218 … … 212 220 // measure the desired statistic on the unclipped pixels 213 221 *fluxStats = *fluxStatsDef; 214 psVectorStats (fluxStats, fluxes, NULL, fmasks, 0xff);222 psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal); 215 223 psErrorClear(); // clear (ignore) any outstanding errors 216 224 … … 220 228 221 229 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) { 222 resid->mask->data. U8[oy][ox] = 1;223 } 224 225 // fprintf (stderr, "res: %2d %2d : %6.4f %6.4f %6.4f %3d %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data. U8[oy][ox]);230 resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = 1; 231 } 232 233 // fprintf (stderr, "res: %2d %2d : %6.4f %6.4f %6.4f %3d %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]); 226 234 227 235 } else { … … 230 238 psVectorInit(B, 0.0); 231 239 for (int i = 0; i < fluxes->n; i++) { 232 if (fmasks->data. U8[i]) continue;240 if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 233 241 B->data.F64[0] += fluxes->data.F32[i]/dfluxes->data.F32[i]; 234 242 B->data.F64[1] += fluxes->data.F32[i]*xC->data.F32[i]/dfluxes->data.F32[i]; … … 260 268 261 269 float dRo = sqrt(A->data.F32[0][0]); 262 // fprintf (stderr, "res: %2d %2d : %6.4f %6.4f %6.4f %3d %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.U8[oy][ox]); 270 // fprintf (stderr, "res: %2d %2d : %6.4f %6.4f %6.4f %3d %1d\n", 271 // ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]); 263 272 264 273 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*dRo/sqrt(nKeep)) { 265 resid->mask->data. U8[oy][ox] = 1;274 resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = 1; 266 275 } 267 276 //resid->weight->data.F32[oy][ox] = XXX; -
trunk/psphot/src/psphotMaskReadout.c
r18832 r21183 9 9 // XXX drop the write to recipe and move config into psphotRoughClass? 10 10 // XXX alternatively, define a function to set the psphot recipe masks 11 ps MaskType maskSat = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels12 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);11 psImageMaskType maskSat = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels 12 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat); 13 13 14 ps MaskType maskBad = pmConfigMaskGet("BAD", config); // Mask value for bad pixels15 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);14 psImageMaskType maskBad = pmConfigMaskGet("BAD", config); // Mask value for bad pixels 15 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad); 16 16 17 17 // generate mask & weight images if they don't already exit -
trunk/psphot/src/psphotModelBackground.c
r21108 r21183 46 46 47 47 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 48 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels48 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 49 49 assert (maskVal); 50 50 -
trunk/psphot/src/psphotModelTest.c
r19881 r21183 13 13 14 14 // bit-masks to test for good/bad pixels 15 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");15 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 16 16 assert (maskVal); 17 17 18 18 // bit-mask to mark pixels not used in analysis 19 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");19 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 20 20 assert (markVal); 21 21 -
trunk/psphot/src/psphotModelWithPSF.c
r17396 r21183 20 20 paramMask = constraint->paramMask; 21 21 if (paramMask != NULL) { 22 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);22 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 23 23 PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false); 24 24 } … … 145 145 psImageInit (covar, 0.0); 146 146 for (int j = 0, J = 0; j < params->n; j++) { 147 if (paramMask && (paramMask->data. U8[j])) {147 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 148 148 covar->data.F32[j][j] = 1.0; 149 149 continue; 150 150 } 151 151 for (int k = 0, K = 0; k < params->n; k++) { 152 if (paramMask && (paramMask->data. U8[k])) continue;152 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 153 153 covar->data.F32[j][k] = Alpha->data.F32[J][K]; 154 154 K++; … … 197 197 PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false); 198 198 if (paramMask) { 199 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_ MASK, false);199 PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false); 200 200 } 201 201 … … 224 224 // XXX probably should not skipped masked points: 225 225 // XXX skip if convolution of unmasked pixels will not see this pixel 226 // if (source->maskObj->data. U8[i][j]) {226 // if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) { 227 227 // continue; 228 228 // } … … 246 246 247 247 for (int n = 0; n < params->n; n++) { 248 if ((paramMask != NULL) && (paramMask->data. U8[n])) { continue; }248 if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; } 249 249 psImage *dmodel = pcm->dmodels->data[n]; 250 250 dmodel->data.F32[i][j] = deriv->data.F32[n]; … … 285 285 // XXX are we doing the right thing with the mask? 286 286 // skip masked points 287 if (source->maskObj->data. U8[i][j]) {287 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) { 288 288 continue; 289 289 } … … 308 308 // alpha & beta only contain unmasked elements 309 309 for (int n1 = 0, N1 = 0; n1 < params->n; n1++) { 310 if ((paramMask != NULL) && (paramMask->data. U8[n1])) continue;310 if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n1])) continue; 311 311 psImage *dmodel = pcm->dmodelsConv->data[n1]; 312 312 float weight = dmodel->data.F32[i][j] * yweight; 313 313 for (int n2 = 0, N2 = 0; n2 <= n1; n2++) { 314 if ((paramMask != NULL) && (paramMask->data. U8[n2])) continue;314 if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n2])) continue; 315 315 dmodel = pcm->dmodelsConv->data[n2]; 316 316 alpha->data.F32[N1][N2] += weight * dmodel->data.F32[i][j]; … … 357 357 for (psS32 n = 0; n < params->n; n++) { 358 358 pcm->dmodels->data[n] = NULL; 359 if ((paramMask != NULL) && (paramMask->data. U8[n])) { continue; }359 if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; } 360 360 pcm->dmodels->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 361 361 } … … 366 366 for (psS32 n = 0; n < params->n; n++) { 367 367 pcm->dmodelsConv->data[n] = NULL; 368 if ((paramMask != NULL) && (paramMask->data. U8[n])) { continue; }368 if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; } 369 369 pcm->dmodelsConv->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 370 370 } -
trunk/psphot/src/psphotMosaicChip.c
r18712 r21183 25 25 } 26 26 27 ps MaskType blankMask = pmConfigMaskGet("BLANK", config);27 psImageMaskType blankMask = pmConfigMaskGet("BLANK", config); 28 28 29 29 // mosaic the chip, forcing a deep copy (resulting images are not subimages) -
trunk/psphot/src/psphotOutput.c
r20237 r21183 74 74 for (int j = 0; j < source->pixels->numCols; j++) { 75 75 // skip masked points 76 if (source->maskObj->data. U8[i][j]) {76 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) { 77 77 continue; 78 78 } … … 87 87 source->pixels->data.F32[i][j], 88 88 1.0 / source->weight->data.F32[i][j], 89 source->maskObj->data. U8[i][j]);89 source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]); 90 90 } 91 91 } … … 237 237 238 238 // XXX add args as needed 239 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, ps MaskType maskVal, psMaskType markVal) {239 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal) { 240 240 241 241 psphotSaveImage (NULL, readout->image, "rawstars.fits"); … … 243 243 for (int i = 0; i < try->sources->n; i++) { 244 244 // masked for: bad model fit, outlier in parameters 245 if (try->mask->data. U8[i] & PSFTRY_MASK_ALL)245 if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) 246 246 continue; 247 247 … … 256 256 psImageKeepCircle (source->maskObj, x, y, radius, "OR", markVal); 257 257 pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal); 258 psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_ U8(markVal));258 psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 259 259 } 260 260 … … 264 264 265 265 // masked for: bad model fit, outlier in parameters 266 if (try->mask->data. U8[i] & PSFTRY_MASK_ALL) continue;266 if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue; 267 267 268 268 pmSource *source = try->sources->data[i]; -
trunk/psphot/src/psphotPSFConvModel.c
r18555 r21183 9 9 // modelConv to contain the fitted parameters, and the modelFlux to contain the 10 10 // convolved model image. 11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, ps MaskType maskVal, psMaskType markVal, int psfSize) {11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) { 12 12 13 13 // maskVal is used to test for rejected pixels, and must include markVal … … 72 72 // create the minimization constraints 73 73 psMinConstraint *constraint = psMinConstraintAlloc(); 74 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_ U8);74 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK); 75 75 constraint->checkLimits = modelConv->modelLimits; 76 76 … … 79 79 int nParams = params->n - 1; 80 80 psVectorInit (constraint->paramMask, 0); 81 constraint->paramMask->data. U8[PM_PAR_SKY] = 1;81 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1; 82 82 83 83 // force the floating parameters to fall within the contraint ranges … … 97 97 fprintf (stderr, "%f ", params->data.F32[i]); 98 98 } 99 if ((constraint->paramMask != NULL) && constraint->paramMask->data. U8[i])99 if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) 100 100 continue; 101 101 dparams->data.F32[i] = sqrt(covar->data.F32[i][i]); -
trunk/psphot/src/psphotPetrosian.c
r17561 r21183 1 1 # include "psphotInternal.h" 2 2 3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, ps MaskType maskVal) {3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) { 4 4 5 5 bool status; -
trunk/psphot/src/psphotRadialPlot.c
r15017 r21183 60 60 for (int iy = 0; iy < source->pixels->numRows; iy++) { 61 61 for (int ix = 0; ix < source->pixels->numCols; ix++) { 62 if (source->maskObj->data. U8[iy][ix]) {62 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 63 63 rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ; 64 64 fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]); -
trunk/psphot/src/psphotRadialProfile.c
r17396 r21183 17 17 } 18 18 19 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, ps MaskType maskVal) {19 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) { 20 20 21 21 // allocate pmSourceExtendedParameters, if not already defined … … 54 54 for (int iy = 0; iy < source->pixels->numRows; iy++) { 55 55 for (int ix = 0; ix < source->pixels->numCols; ix++) { 56 if (source->maskObj->data. U8[iy][ix]) continue;56 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) continue; 57 57 radius->data.F32[n] = hypot (ix - Xo, iy - Yo) ; 58 58 flux->data.F32[n] = source->pixels->data.F32[iy][ix]; -
trunk/psphot/src/psphotRadiusChecks.c
r19308 r21183 19 19 20 20 // call this function whenever you (re)-define the PSF model 21 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, ps MaskType markVal)21 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) 22 22 { 23 23 psF32 *PAR = model->params->data.F32; … … 50 50 } 51 51 52 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, ps MaskType markVal, float dR) {52 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal, float dR) { 53 53 54 54 psF32 *PAR = model->params->data.F32; … … 86 86 87 87 // call this function whenever you (re)-define the EXT model 88 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, ps MaskType markVal) {88 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) { 89 89 90 90 psF32 *PAR = model->params->data.F32; -
trunk/psphot/src/psphotReplaceUnfit.c
r20453 r21183 2 2 3 3 // replace the flux for sources which failed 4 bool psphotReplaceUnfitSources (psArray *sources, ps MaskType maskVal) {4 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal) { 5 5 6 6 pmSource *source; … … 31 31 32 32 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 33 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels33 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 34 34 assert (maskVal); 35 35 … … 55 55 56 56 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 57 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels57 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 58 58 assert (maskVal); 59 59 … … 72 72 73 73 // add source, if the source has been subtracted; do not modify state 74 bool psphotAddWithTest (pmSource *source, bool useState, ps MaskType maskVal) {74 bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal) { 75 75 76 76 // what is current state? (true : add; false : sub) … … 83 83 84 84 // sub source, if the source has been added; do not modify state 85 bool psphotSubWithTest (pmSource *source, bool useState, ps MaskType maskVal) {85 bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal) { 86 86 87 87 // what is current state? (true : sub; false : add) … … 94 94 95 95 // add or sub source to match recorded state: supply current state as true (add) or false (sub) 96 bool psphotSetState (pmSource *source, bool curState, ps MaskType maskVal) {96 bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal) { 97 97 98 98 // what is desired state? (true : add; false : sub) -
trunk/psphot/src/psphotRoughClass.c
r20453 r21183 57 57 58 58 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 59 ps MaskType maskSat = psMetadataLookupU8(&status, recipe, "MASK.SAT"); // Mask value for bad pixels59 psImageMaskType maskSat = psMetadataLookupImageMask(&status, recipe, "MASK.SAT"); // Mask value for bad pixels 60 60 assert (maskSat); 61 61 -
trunk/psphot/src/psphotSetMaskBits.c
r18469 r21183 10 10 bool psphotSetMaskBits (pmConfig *config) { 11 11 12 ps MaskType maskValue;13 ps MaskType markValue;12 psImageMaskType maskValue; 13 psImageMaskType markValue; 14 14 15 15 if (!pmConfigMaskSetBits (&maskValue, &markValue, config)) { … … 26 26 27 27 // set maskValue and markValue in the psphot recipe 28 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markValue);29 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskValue);28 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markValue); 29 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskValue); 30 30 31 31 return true; -
trunk/psphot/src/psphotSignificanceImage.c
r20829 r21183 4 4 // (S/N)^2. If FWMH_X,Y have been recorded, use them, otherwise use PEAKS_SMOOTH_SIGMA for the 5 5 // smoothing kernel. 6 psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, ps MaskType maskVal) {6 psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal) { 7 7 8 8 float SIGMA_SMTH, NSIGMA_SMTH; … … 110 110 for (int i = 0; i < smooth_im->numCols; i++) { 111 111 float value = smooth_im->data.F32[j][i]; 112 if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data. U8[j][i] & maskVal)) {112 if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal)) { 113 113 smooth_im->data.F32[j][i] = 0.0; 114 114 } else { -
trunk/psphot/src/psphotSkyReplace.c
r20453 r21183 17 17 // select the corresponding images 18 18 psF32 **image = readout->image->data.F32; 19 ps U8 **mask = readout->mask->data.U8;19 psImageMaskType **mask = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; 20 20 psF32 **back = background->image->data.F32; 21 21 -
trunk/psphot/src/psphotSourceFits.c
r21166 r21183 22 22 } 23 23 24 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, ps MaskType maskVal, psMaskType markVal) {24 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) { 25 25 26 26 float x, y, dR; … … 147 147 } 148 148 149 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, ps MaskType maskVal, psMaskType markVal) {149 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) { 150 150 151 151 double chiTrend; … … 208 208 } 209 209 210 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, ps MaskType maskVal, psMaskType markVal) {210 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) { 211 211 212 212 bool okEXT, okDBL; … … 318 318 319 319 // fit a double PSF source to an extended blob 320 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, ps MaskType maskVal, psMaskType markVal) {320 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) { 321 321 322 322 float dx, dy; … … 370 370 } 371 371 372 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, ps MaskType maskVal, psMaskType markVal) {372 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) { 373 373 374 374 NfitEXT ++; -
trunk/psphot/src/psphotSourcePlots.c
r19869 r21183 7 7 8 8 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 9 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels9 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 10 10 assert (maskVal); 11 11 -
trunk/psphot/src/psphotSourceSize.c
r20938 r21183 3 3 4 4 static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask, 5 ps MaskType maskVal, const pmModel *model, float Ro);6 7 bool psphotMaskCosmicRay_Old (pmSource *source, ps MaskType maskVal, psMaskType crMask);8 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, ps MaskType maskVal, psMaskType crMask);5 psImageMaskType maskVal, const pmModel *model, float Ro); 6 7 bool psphotMaskCosmicRay_Old (pmSource *source, psImageMaskType maskVal, psImageMaskType crMask); 8 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psImageMaskType maskVal, psImageMaskType crMask); 9 9 10 10 // we need to call this function after sources have been fitted to the PSF model and … … 21 21 22 22 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 23 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels23 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 24 24 assert (maskVal); 25 25 26 26 // bit to mask the cosmic-ray pixels 27 ps MaskType crMask = pmConfigMaskGet("CR", config); // Mask value for cosmic rays27 psImageMaskType crMask = pmConfigMaskGet("CR", config); // Mask value for cosmic rays 28 28 29 29 float CR_NSIGMA_LIMIT = psMetadataLookupF32 (&status, recipe, "PSPHOT.CR.NSIGMA.LIMIT"); … … 63 63 psF32 **resid = source->pixels->data.F32; 64 64 psF32 **weight = source->weight->data.F32; 65 ps U8 **mask = source->maskObj->data.U8;65 psImageMaskType **mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 66 66 67 67 // check for extendedness: measure the delta flux significance at the 1 sigma contour … … 191 191 // deviations? 192 192 static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask, 193 ps MaskType maskVal, const pmModel *model, float Ro)193 psImageMaskType maskVal, const pmModel *model, float Ro) 194 194 { 195 195 psF32 *PAR = model->params->data.F32; // Model parameters … … 239 239 240 240 if (yPixM >= 0 && yPixM < image->numRows && 241 !(mask && (mask->data.PS_TYPE_ MASK_DATA[yPixM][xPix] & maskVal))) {241 !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixM][xPix] & maskVal))) { 242 242 float dSigma = image->data.F32[yPixM][xPix] / sqrtf(weight->data.F32[yPixM][xPix]); 243 243 nSigma += dSigma; … … 250 250 251 251 if (yPixP >= 0 && yPixP < image->numRows && 252 !(mask && (mask->data.PS_TYPE_ MASK_DATA[yPixP][xPix] & maskVal))) {252 !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixP][xPix] & maskVal))) { 253 253 float dSigma = image->data.F32[yPixP][xPix] / sqrtf(weight->data.F32[yPixP][xPix]); 254 254 nSigma += dSigma; … … 260 260 } 261 261 262 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, ps MaskType maskVal, psMaskType crMask) {262 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psImageMaskType maskVal, psImageMaskType crMask) { 263 263 264 264 // replace the source flux … … 294 294 295 295 for (int ix = xs; ix < xe; ix++) { 296 mask->data. U8[iy][ix] |= crMask;296 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask; 297 297 } 298 298 } … … 300 300 } 301 301 302 bool psphotMaskCosmicRay_Old (pmSource *source, ps MaskType maskVal, psMaskType crMask) {302 bool psphotMaskCosmicRay_Old (pmSource *source, psImageMaskType maskVal, psImageMaskType crMask) { 303 303 304 304 source->mode |= PM_SOURCE_MODE_CR_LIMIT; … … 320 320 float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]); 321 321 if (SN > SN_LIMIT) { 322 mask->data. U8[yo][ix] |= crMask;322 mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask; 323 323 } 324 324 } … … 326 326 float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]); 327 327 if (SN > SN_LIMIT) { 328 mask->data. U8[yo][ix] |= crMask;328 mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask; 329 329 } 330 330 } … … 339 339 340 340 bool valid = false; 341 valid |= (mask->data. U8[iy+1][ix] & crMask);342 valid |= (ix > 0) ? (mask->data. U8[iy+1][ix-1] & crMask) : 0;343 valid |= (ix <= mask->numCols) ? (mask->data. U8[iy+1][ix+1] & crMask) : 0;341 valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix] & crMask); 342 valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix-1] & crMask) : 0; 343 valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix+1] & crMask) : 0; 344 344 345 345 if (!valid) continue; 346 mask->data. U8[iy][ix] |= crMask;346 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask; 347 347 } 348 348 } … … 355 355 356 356 bool valid = false; 357 valid |= (mask->data. U8[iy-1][ix] & crMask);358 valid |= (ix > 0) ? (mask->data. U8[iy-1][ix-1] & crMask) : 0;359 valid |= (ix <= mask->numCols) ? (mask->data. U8[iy-1][ix+1] & crMask) : 0;357 valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix] & crMask); 358 valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix-1] & crMask) : 0; 359 valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix+1] & crMask) : 0; 360 360 361 361 if (!valid) continue; 362 mask->data. U8[iy][ix] |= crMask;362 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask; 363 363 } 364 364 } -
trunk/psphot/src/psphotSourceStats.c
r21166 r21183 17 17 nThreads = 0; 18 18 } 19 // nThreads = 0; // XXX until testing is complete, do not thread this function20 19 21 20 // determine properties (sky, moments) of initial sources … … 144 143 145 144 // bit-masks to test for good/bad pixels 146 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");145 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 147 146 assert (maskVal); 148 147 149 148 // bit-mask to mark pixels not used in analysis 150 ps MaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");149 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 151 150 assert (markVal); 152 151 -
trunk/psphot/src/psphotSubtractBackground.c
r20453 r21183 28 28 29 29 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 30 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels30 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 31 31 assert (maskVal); 32 32 -
trunk/psphot/src/psphotTestPSF.c
r18555 r21183 111 111 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", markVal); 112 112 status = pmSourceFitModel (source, model, PM_SOURCE_FIT_EXT); 113 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_ U8(markVal));113 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_IMAGE_MASK(markVal)); 114 114 115 115 // write fitted parameters to file -
trunk/psphot/src/psphotTestSourceOutput.c
r14655 r21183 80 80 float oy = yBin*(iy + 0.5 + image->row0 - yCenter) + yResidCenter; 81 81 82 ps U8mflux = 0;82 psImageMaskType mflux = 0; 83 83 double Fo = 0.0; 84 84 double Fx = 0.0; -
trunk/psphot/src/psphotVisual.c
r20938 r21183 51 51 ALLOCATE (image.data2d[iy], float, image.Nx); 52 52 for (int ix = 0; ix < image.Nx; ix++) { 53 image.data2d[iy][ix] = inImage->data. U8[iy][ix];53 image.data2d[iy][ix] = inImage->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]; 54 54 } 55 55 } … … 813 813 814 814 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 815 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels815 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 816 816 assert (maskVal); 817 817 … … 973 973 974 974 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 975 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels975 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 976 976 assert (maskVal); 977 977 … … 1097 1097 } 1098 1098 1099 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, ps MaskType maskVal) {1099 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal) { 1100 1100 1101 1101 Graphdata graphdata; … … 1118 1118 for (int iy = 0; iy < source->pixels->numRows; iy++) { 1119 1119 for (int ix = 0; ix < source->pixels->numCols; ix++) { 1120 if (source->maskObj->data. U8[iy][ix]) {1120 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 1121 1121 // rb->data.F32[nb] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ; 1122 1122 rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ; … … 1227 1227 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 1228 1228 bool status; 1229 ps MaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels1229 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 1230 1230 assert (maskVal); 1231 1231 -
trunk/pswarp/src/pswarpLoop.c
r21178 r21183 67 67 68 68 // output mask bits 69 ps MaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT");69 psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT"); 70 70 psAssert (status, "MASK.OUTPUT was not defined"); 71 71 -
trunk/pswarp/src/pswarpPixelFraction.c
r18558 r21183 20 20 PS_ASSERT_IMAGE_NON_NULL(readout->mask, false); 21 21 PS_ASSERT_IMAGES_SIZE_EQUAL(readout->mask, readout->image, false); 22 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_ MASK, false);22 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false); 23 23 24 24 if (stats) { … … 40 40 41 41 // output mask bits 42 ps MaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT");42 psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT"); 43 43 psAssert (status, "MASK.OUTPUT was not defined"); 44 44 … … 55 55 for (int y = 0; y < numRows; y++) { 56 56 for (int x = 0; x < numCols; x++) { 57 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskValue) {57 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValue) { 58 58 numBad++; 59 59 } else { -
trunk/pswarp/src/pswarpSetMaskBits.c
r18558 r21183 10 10 bool pswarpSetMaskBits (pmConfig *config) { 11 11 12 psMaskType maskIn = 0x00; // mask for the input image 13 psMaskType markIn = 0x00; // mark for the input image 14 psMaskType maskOut = 0x00; // mask for the output image 15 psMaskType markOut = 0x00; // mark for the output image 12 psImageMaskType maskIn = 0x00; // mask for the input image 13 psImageMaskType markIn = 0x00; // mark for the input image 14 psImageMaskType maskOut = 0x00; // mask for the output image 16 15 17 16 // this function sets the required single-image mask bits … … 22 21 23 22 // mask for non-linear flat regions (default to DETECTOR if not defined) 24 ps MaskType badMask = pmConfigMaskGet("BAD.WARP", config);23 psImageMaskType badMask = pmConfigMaskGet("BAD.WARP", config); 25 24 if (!badMask) { 26 25 badMask = 0x01; … … 30 29 31 30 // mask for non-linear flat regions (default to DETECTOR if not defined) 32 ps MaskType poorMask = pmConfigMaskGet("POOR.WARP", config);31 psImageMaskType poorMask = pmConfigMaskGet("POOR.WARP", config); 33 32 if (!poorMask) { 34 33 poorMask = 0x02; … … 38 37 39 38 // search for an unset bit to use for MARK: 40 markOut = 0x80; 39 psImageMaskType markOut = 0x00; 40 psImageMaskType markTrial = 0x01; 41 41 42 int nBits = sizeof(ps MaskType) * 8;42 int nBits = sizeof(psImageMaskType) * 8; 43 43 for (int i = 0; !markOut && (i < nBits); i++) { 44 if (maskOut & markOut) {45 markOut >>= 1;46 } else {47 markOut = markOut;48 }44 if (maskOut & markTrial) { 45 markTrial <<= 1; 46 } else { 47 markOut = markTrial; 48 } 49 49 } 50 51 50 if (!markOut) { 52 psError (PS_ERR_UNKNOWN, true, "Unable to define the MARK bit mask: all bits taken!");53 return false;51 psError (PS_ERR_UNKNOWN, true, "Unable to define the MARK bit mask: all bits taken!"); 52 return false; 54 53 } 55 54 … … 63 62 // set maskOut and markOut in the psphot recipe 64 63 // NOTE: psphot works on the output images, not input images, so set the MARK and MASK correctly here 65 psMetadataAdd U8(warpRecipe, PS_LIST_TAIL, "MASK.INPUT", PS_META_REPLACE, "user-defined mask", maskIn);66 psMetadataAdd U8(warpRecipe, PS_LIST_TAIL, "MARK.INPUT", PS_META_REPLACE, "user-defined mask", markIn);67 psMetadataAdd U8(warpRecipe, PS_LIST_TAIL, "MASK.OUTPUT", PS_META_REPLACE, "user-defined mask", maskOut);68 psMetadataAdd U8(warpRecipe, PS_LIST_TAIL, "MARK.OUTPUT", PS_META_REPLACE, "user-defined mask", markOut);64 psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MASK.INPUT", PS_META_REPLACE, "user-defined mask", maskIn); 65 psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MARK.INPUT", PS_META_REPLACE, "user-defined mask", markIn); 66 psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MASK.OUTPUT", PS_META_REPLACE, "user-defined mask", maskOut); 67 psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MARK.OUTPUT", PS_META_REPLACE, "user-defined mask", markOut); 69 68 70 69 // update the psphot recipe … … 77 76 // set maskOut and markOut in the psphot recipe 78 77 // NOTE: psphot works on the output images, not input images, so set the MARK and MASK correctly here 79 psMetadataAdd U8(psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markOut);80 psMetadataAdd U8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskOut);78 psMetadataAddImageMask (psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markOut); 79 psMetadataAddImageMask (psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskOut); 81 80 82 81 return true; -
trunk/pswarp/src/pswarpTransformReadout.c
r20334 r21183 22 22 23 23 // output mask bits 24 ps MaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT");25 ps MaskType maskPoor = pmConfigMaskGet("POOR.WARP", config);26 ps MaskType maskBad = pmConfigMaskGet("BAD.WARP", config);24 psImageMaskType maskIn = psMetadataLookupImageMask(&mdok, recipe, "MASK.INPUT"); 25 psImageMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 26 psImageMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 27 27 psAssert(mdok, "MASK.INPUT was not defined"); 28 28 … … 80 80 } 81 81 if ((input->mask || maskPoor || maskBad) && !output->mask) { 82 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_ MASK);82 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_IMAGE_MASK); 83 83 psImageInit(output->mask, maskBad); 84 84 } -
trunk/pswarp/src/pswarpTransformTile.c
r19395 r21183 49 49 psF32 **outImageData = args->output->image->data.F32; 50 50 psF32 **outVarData = (args->output->weight) ? args->output->weight->data.F32 : NULL; 51 ps MaskType **outMaskData = (args->output->mask) ? args->output->mask->data.PS_TYPE_MASK_DATA : NULL;52 ps MaskType **inMaskData = (args->input->mask) ? args->input->mask->data.PS_TYPE_MASK_DATA : NULL;51 psImageMaskType **outMaskData = (args->output->mask) ? args->output->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 52 psImageMaskType **inMaskData = (args->input->mask) ? args->input->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 53 53 54 54 pswarpMap *map = args->grid->maps[args->gridX][args->gridY]; // Map for this tile … … 67 67 68 68 // Only transform those pixels requested 69 if (region && region->data. U8[y][x]) {69 if (region && region->data.PS_TYPE_IMAGE_MASK_DATA[y][x]) { 70 70 continue; 71 71 } … … 82 82 // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates 83 83 double imageValue, varValue; // Value of image and variance map 84 ps MaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask84 psImageMaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask 85 85 if (!psImageInterpolate(&imageValue, &varValue, &maskValue, xIn, yIn, args->interp)) { 86 86 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
Note:
See TracChangeset
for help on using the changeset viewer.
