- Timestamp:
- Jan 7, 2009, 6:43:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081230/psphot/src/psphotMakeResiduals.c
r21087 r21090 1 1 # include "psphotInternal.h" 2 2 3 XXX this function is probably broken: fmasks is confused between Image and Vector. it is used by psVectorStats, so it must be Vector, but4 is populated by mflux, which seems to be Image..5 3 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal) { 6 4 … … 71 69 // - set output pixel, weight, and mask 72 70 73 XXX need to set these correctly based on the RECIPE values 74 const int badMask = 1; // mask bits 75 const int poorMask = 2; // from psImageInterpolate 76 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; 77 82 78 83 // determine the maximum image size from the input sources … … 105 110 psBinaryOp (weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32)); 106 111 107 // we willinterpolate the image and weight - include the mask or not?108 // XXX consider better values for the mask bits 109 psImageInterpolation *interp =110 psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);111 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); 112 117 113 118 // save the X,Y position for future reference … … 166 171 bool offImage = false; 167 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); 168 174 // This pixel is off the image 169 175 offImage = true; 170 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;171 // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);172 } 173 fluxes->data.F32[i] = flux; 174 dfluxes->data.F32[i] = dflux;175 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type? 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; 176 182 if (isnan(flux)) { 177 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;183 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask; 178 184 } 179 185 if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { … … 182 188 } 183 189 184 // skip pixels w hich are off the image...190 // skip pixels with insufficient data 185 191 bool validPixel = (SPATIAL_ORDER == 0) ? (nGoodPixel > 1) : (nGoodPixel > 3); 186 192 if (!validPixel) { … … 188 194 resid->Rx->data.F32[oy][ox] = 0.0; 189 195 resid->Ry->data.F32[oy][ox] = 0.0; 190 resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = 1;196 resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = badMask; 191 197 continue; 192 198 } … … 194 200 // measure the robust median to determine a baseline reference value 195 201 *fluxClip = *fluxClipDef; 196 psVectorStats (fluxClip, fluxes, NULL, fmasks, 0xff);202 psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal); 197 203 psErrorClear(); // clear (ignore) any outstanding errors 198 204 … … 204 210 float swing = fabs(delta) / sigma; 205 211 206 // make this a user option 212 // mask pixels which are out of range 207 213 if (swing > nSigma) { 208 214 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask; … … 214 220 // measure the desired statistic on the unclipped pixels 215 221 *fluxStats = *fluxStatsDef; 216 psVectorStats (fluxStats, fluxes, NULL, fmasks, 0xff);222 psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal); 217 223 psErrorClear(); // clear (ignore) any outstanding errors 218 224
Note:
See TracChangeset
for help on using the changeset viewer.
