Changeset 21366 for trunk/psphot/src/psphotMakeResiduals.c
- Timestamp:
- Feb 5, 2009, 5:03:33 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotMakeResiduals.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotMakeResiduals.c
r21183 r21366 58 58 // for each input source: 59 59 // - construct a residual image, renormalized 60 // - construct a renormalized weightimage60 // - construct a renormalized variance image 61 61 // - construct a new mask image 62 62 63 63 // construct the output residual table (Nx*DX,Ny*DY) 64 64 // for each output pixel: 65 // - construct a histogram of the values & weights (interpolate to the common pixel coordinate)65 // - construct a histogram of the values & variances (interpolate to the common pixel coordinate) 66 66 // - measure the robust median & sigma 67 67 // - reject (mask) input pixels which are outliers 68 68 // - re-measure the robust median & sigma 69 // - set output pixel, weight, and mask69 // - set output pixel, variance, and mask 70 70 71 71 // these mask values do not correspond to the recipe values: they … … 76 76 // psVectorStats 77 77 78 const psImageMaskType badMask = 0x01; // mask bits79 const psImageMaskType poorMask = 0x02; // from psImageInterpolate80 const psImageMaskType clippedMask = 0x04; // mask bit set for clipped values78 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 81 const psVectorMaskType fmaskVal = badMask | poorMask | clippedMask; 82 82 … … 101 101 102 102 psImage *image = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 103 psImage * weight = psImageCopy (NULL, source->weight, PS_TYPE_F32);103 psImage *variance = psImageCopy (NULL, source->variance, PS_TYPE_F32); 104 104 psImage *mask = psImageCopy (NULL, source->maskView, PS_TYPE_IMAGE_MASK); 105 105 pmModelSub (image, mask, model, PM_MODEL_OP_FUNC, maskVal); 106 106 107 // re-normalize image and weight107 // re-normalize image and variance 108 108 float Io = model->params->data.F32[PM_PAR_I0]; 109 109 psBinaryOp (image, image, "/", psScalarAlloc(Io, PS_TYPE_F32)); 110 psBinaryOp ( weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32));111 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);110 psBinaryOp (variance, variance, "/", psScalarAlloc(Io*Io, PS_TYPE_F32)); 111 112 // we interpolate the image and variance - include the mask or not? 113 // XXX why not the mask? 114 // psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, mask, maskVal, 0.0, 0.0, badMask, poorMask, 0.0, 0); 115 psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0); 116 116 psArrayAdd (input, 100, interp); 117 117 … … 128 128 psFree (mask); 129 129 psFree (image); 130 psFree ( weight);130 psFree (variance); 131 131 psFree (interp); 132 132 } … … 176 176 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask; 177 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;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; 182 182 if (isnan(flux)) { 183 183 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask; … … 204 204 205 205 // mark input pixels which are more than N sigma from the median 206 int nKeep = 0;206 int nKeep = 0; 207 207 for (int i = 0; i < fluxes->n; i++) { 208 208 float delta = fluxes->data.F32[i] - fluxClip->robustMedian; … … 210 210 float swing = fabs(delta) / sigma; 211 211 212 // mask pixels which are out of range212 // mask pixels which are out of range 213 213 if (swing > nSigma) { 214 214 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask; 215 215 } 216 if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++;216 if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++; 217 217 } 218 218 … … 225 225 resid->Ro->data.F32[oy][ox] = psStatsGetValue(fluxStats, statOption); 226 226 resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0; 227 //resid-> weight->data.F32[oy][ox] = fluxStats->sampleStdev;227 //resid->variance->data.F32[oy][ox] = fluxStats->sampleStdev; 228 228 229 229 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) { … … 231 231 } 232 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]);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]); 234 234 235 235 } else { … … 268 268 269 269 float dRo = sqrt(A->data.F32[0][0]); 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]);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]); 272 272 273 273 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*dRo/sqrt(nKeep)) { 274 274 resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = 1; 275 275 } 276 //resid-> weight->data.F32[oy][ox] = XXX;276 //resid->variance->data.F32[oy][ox] = XXX; 277 277 } 278 278 } … … 301 301 psphotSaveImage (NULL, resid->Rx, "resid.rx.fits"); 302 302 psphotSaveImage (NULL, resid->Ry, "resid.ry.fits"); 303 psphotSaveImage (NULL, resid-> weight, "resid.wt.fits");303 psphotSaveImage (NULL, resid->variance, "resid.wt.fits"); 304 304 psphotSaveImage (NULL, resid->mask, "resid.mk.fits"); 305 305 }
Note:
See TracChangeset
for help on using the changeset viewer.
