Changeset 20938
- Timestamp:
- Dec 7, 2008, 4:52:04 PM (17 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 4 edited
-
psphot.h (modified) (1 diff)
-
psphotFitSourcesLinear.c (modified) (1 diff)
-
psphotSourceSize.c (modified) (4 diffs)
-
psphotVisual.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.h
r20411 r20938 165 165 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources); 166 166 bool psphotVisualShowFlags (psArray *sources); 167 bool psphotVisualShowSourceSize (p sArray *sources);167 bool psphotVisualShowSourceSize (pmReadout *readout, psArray *sources); 168 168 bool psphotVisualShowResidualImage (pmReadout *readout); 169 169 bool psphotVisualPlotApResid (psArray *sources); -
trunk/psphot/src/psphotFitSourcesLinear.c
r20453 r20938 68 68 69 69 // if (source->type == PM_SOURCE_TYPE_STAR && 70 // source->mode & PM_SOURCE_MODE_SATSTAR) continue;70 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 71 71 72 72 if (final) { -
trunk/psphot/src/psphotSourceSize.c
r20878 r20938 4 4 static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask, 5 5 psMaskType maskVal, const pmModel *model, float Ro); 6 7 bool psphotMaskCosmicRay_Old (pmSource *source, psMaskType maskVal, psMaskType crMask); 8 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psMaskType maskVal, psMaskType crMask); 6 9 7 10 // we need to call this function after sources have been fitted to the PSF model and … … 157 160 // this source is thought to be a cosmic ray. flag the detection and mask the pixels 158 161 if (source->crNsigma > CR_NSIGMA_LIMIT) { 159 source->mode |= PM_SOURCE_MODE_CR_LIMIT; 160 pmPeak *peak = source->peak; 161 psAssert (peak, "NULL peak"); 162 163 // replace the source flux 164 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 165 source->mode &= ~PM_SOURCE_MODE_SUBTRACTED; 166 167 psImage *mask = source->maskView; 168 psImage *pixels = source->pixels; 169 psImage *weight = source->weight; 170 171 // XXX This should be a recipe variable 172 # define SN_LIMIT 5.0 173 174 int xo = peak->x - pixels->col0; 175 int yo = peak->y - pixels->row0; 176 177 // mark the pixels in this row to the left, then the right 178 for (int ix = xo; ix >= 0; ix--) { 179 float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]); 180 if (SN > SN_LIMIT) { 181 mask->data.U8[yo][ix] |= crMask; 182 } 183 } 184 for (int ix = xo + 1; ix < pixels->numCols; ix++) { 185 float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]); 186 if (SN > SN_LIMIT) { 187 mask->data.U8[yo][ix] |= crMask; 188 } 189 } 190 191 // for each of the neighboring rows, mark the high pixels if they have a marked neighbor 192 // first go up: 193 for (int iy = PS_MIN(yo, mask->numRows-2); iy >= 0; iy--) { 194 // mark the pixels in this row to the left, then the right 195 for (int ix = 0; ix < pixels->numCols; ix++) { 196 float SN = pixels->data.F32[iy][ix] / sqrt(weight->data.F32[iy][ix]); 197 if (SN < SN_LIMIT) continue; 198 199 bool valid = false; 200 valid |= (mask->data.U8[iy+1][ix] & crMask); 201 valid |= (ix > 0) ? (mask->data.U8[iy+1][ix-1] & crMask) : 0; 202 valid |= (ix <= mask->numCols) ? (mask->data.U8[iy+1][ix+1] & crMask) : 0; 203 204 if (!valid) continue; 205 mask->data.U8[iy][ix] |= crMask; 206 } 207 } 208 // next go down: 209 for (int iy = PS_MIN(yo+1, mask->numRows-1); iy < pixels->numRows; iy++) { 210 // mark the pixels in this row to the left, then the right 211 for (int ix = 0; ix < pixels->numCols; ix++) { 212 float SN = pixels->data.F32[iy][ix] / sqrt(weight->data.F32[iy][ix]); 213 if (SN < SN_LIMIT) continue; 214 215 bool valid = false; 216 valid |= (mask->data.U8[iy-1][ix] & crMask); 217 valid |= (ix > 0) ? (mask->data.U8[iy-1][ix-1] & crMask) : 0; 218 valid |= (ix <= mask->numCols) ? (mask->data.U8[iy-1][ix+1] & crMask) : 0; 219 220 if (!valid) continue; 221 mask->data.U8[iy][ix] |= crMask; 222 } 223 } 162 // XXX still testing... : psphotMaskCosmicRay_New (readout->mask, source, maskVal, crMask); 163 psphotMaskCosmicRay_Old (source, maskVal, crMask); 224 164 } 225 165 } … … 242 182 243 183 psphotVisualPlotSourceSize (sources); 244 psphotVisualShowSourceSize ( sources);184 psphotVisualShowSourceSize (readout, sources); 245 185 246 186 return true; … … 319 259 return nSigma; 320 260 } 261 262 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psMaskType maskVal, psMaskType crMask) { 263 264 // replace the source flux 265 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 266 source->mode &= ~PM_SOURCE_MODE_SUBTRACTED; 267 268 // flag this as a CR 269 source->mode |= PM_SOURCE_MODE_CR_LIMIT; 270 pmPeak *peak = source->peak; 271 psAssert (peak, "NULL peak"); 272 273 // grab the matching footprint 274 pmFootprint *footprint = peak->footprint; 275 if (!footprint) { 276 // if we have not footprint, use the old code to mask by isophot 277 psphotMaskCosmicRay_Old (source, maskVal, crMask); 278 return true; 279 } 280 281 if (!footprint->spans) { 282 // if we have not footprint, use the old code to mask by isophot 283 psphotMaskCosmicRay_Old (source, maskVal, crMask); 284 return true; 285 } 286 287 // mask all of the pixels covered by the spans of the footprint 288 for (int j = 1; j < footprint->spans->n; j++) { 289 pmSpan *span1 = footprint->spans->data[j]; 290 291 int iy = span1->y; 292 int xs = span1->x0; 293 int xe = span1->x1; 294 295 for (int ix = xs; ix < xe; ix++) { 296 mask->data.U8[iy][ix] |= crMask; 297 } 298 } 299 return true; 300 } 301 302 bool psphotMaskCosmicRay_Old (pmSource *source, psMaskType maskVal, psMaskType crMask) { 303 304 source->mode |= PM_SOURCE_MODE_CR_LIMIT; 305 pmPeak *peak = source->peak; 306 psAssert (peak, "NULL peak"); 307 308 psImage *mask = source->maskView; 309 psImage *pixels = source->pixels; 310 psImage *weight = source->weight; 311 312 // XXX This should be a recipe variable 313 # define SN_LIMIT 5.0 314 315 int xo = peak->x - pixels->col0; 316 int yo = peak->y - pixels->row0; 317 318 // mark the pixels in this row to the left, then the right 319 for (int ix = xo; ix >= 0; ix--) { 320 float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]); 321 if (SN > SN_LIMIT) { 322 mask->data.U8[yo][ix] |= crMask; 323 } 324 } 325 for (int ix = xo + 1; ix < pixels->numCols; ix++) { 326 float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]); 327 if (SN > SN_LIMIT) { 328 mask->data.U8[yo][ix] |= crMask; 329 } 330 } 331 332 // for each of the neighboring rows, mark the high pixels if they have a marked neighbor 333 // first go up: 334 for (int iy = PS_MIN(yo, mask->numRows-2); iy >= 0; iy--) { 335 // mark the pixels in this row to the left, then the right 336 for (int ix = 0; ix < pixels->numCols; ix++) { 337 float SN = pixels->data.F32[iy][ix] / sqrt(weight->data.F32[iy][ix]); 338 if (SN < SN_LIMIT) continue; 339 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; 344 345 if (!valid) continue; 346 mask->data.U8[iy][ix] |= crMask; 347 } 348 } 349 // next go down: 350 for (int iy = PS_MIN(yo+1, mask->numRows-1); iy < pixels->numRows; iy++) { 351 // mark the pixels in this row to the left, then the right 352 for (int ix = 0; ix < pixels->numCols; ix++) { 353 float SN = pixels->data.F32[iy][ix] / sqrt(weight->data.F32[iy][ix]); 354 if (SN < SN_LIMIT) continue; 355 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; 360 361 if (!valid) continue; 362 mask->data.U8[iy][ix] |= crMask; 363 } 364 } 365 return true; 366 } -
trunk/psphot/src/psphotVisual.c
r20594 r20938 26 26 27 27 isVisual = mode; 28 return true; 29 } 30 31 bool psphotVisualShowMask (int kapaFD, psImage *inImage, const char *name, int channel) { 32 33 KiiImage image; 34 KapaImageData data; 35 Coords coords; 36 37 strcpy (coords.ctype, "RA---TAN"); 38 39 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 40 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 41 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 42 fprintf (stderr, "failed to get background values\n"); 43 return false; 44 } 45 46 image.Nx = inImage->numCols; 47 image.Ny = inImage->numRows; 48 49 ALLOCATE (image.data2d, float *, image.Ny); 50 for (int iy = 0; iy < image.Ny; iy++) { 51 ALLOCATE (image.data2d[iy], float, image.Nx); 52 for (int ix = 0; ix < image.Nx; ix++) { 53 image.data2d[iy][ix] = inImage->data.U8[iy][ix]; 54 } 55 } 56 57 strcpy (data.name, name); 58 strcpy (data.file, name); 59 data.zero = -1; 60 data.range = 32; 61 data.logflux = 0; 62 63 KiiSetChannel (kapaFD, channel); 64 KiiNewPicture2D (kapaFD, &image, &data, &coords); 65 66 for (int iy = 0; iy < image.Ny; iy++) { 67 free (image.data2d[iy]); 68 } 69 free (image.data2d); 70 71 psFree (stats); 72 psFree (rng); 73 28 74 return true; 29 75 } … … 1336 1382 } 1337 1383 1338 bool psphotVisualShowSourceSize (p sArray *sources) {1384 bool psphotVisualShowSourceSize (pmReadout *readout, psArray *sources) { 1339 1385 1340 1386 int Noverlay, NOVERLAY; … … 1398 1444 KiiLoadOverlay (kapa, overlay, Noverlay, "blue"); 1399 1445 FREE (overlay); 1446 1447 psphotVisualShowMask (kapa, readout->mask, "mask", 2); 1400 1448 1401 1449 // pause and wait for user input:
Note:
See TracChangeset
for help on using the changeset viewer.
