Changeset 21114 for branches/pap_branch_20090108/ppStack/src/ppStackMatch.c
- Timestamp:
- Jan 12, 2009, 7:09:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_20090108/ppStack/src/ppStackMatch.c
r21111 r21114 17 17 #define FAINT_SOURCE_FRAC 1.0e-4 // Set minimum flux to this fraction of faintest source flux 18 18 19 #define TESTING // Enable debugging output19 //#define TESTING // Enable debugging output 20 20 21 21 #ifdef TESTING … … 160 160 return unbinned; 161 161 } 162 163 164 165 166 #if 0167 #define BG_SIZE 64 // Large box half-size in which to measure background168 169 // Generate a background model of the readout we're matching170 // We only need to set the background around the sources, not everywhere.171 psImage *stackBackgroundModel(pmReadout *ro, psMaskType maskVal, const psArray *sources, int size)172 {173 psImage *image = ro->image, *mask = ro->mask; // Image and mask of readout174 int numCols = image->numCols, numRows = image->numRows; // Size of image175 176 psImage *bgImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Background image177 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for measuring background178 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator179 180 for (int i = 0; i < sources->n; i++) {181 pmSource *source = sources->data[i]; // Source of interest182 if (!source) {183 continue;184 }185 186 float xSource, ySource; // Coordinates of source187 coordsFromSource(&xSource, &ySource, source);188 189 int x = xSource + 0.5, y = ySource + 0.5; // Coordinates of source190 191 int xMin = PS_MAX(x - BG_SIZE, 0), xMax = PS_MIN(x + BG_SIZE, numCols);192 int yMin = PS_MAX(y - BG_SIZE, 0), yMax = PS_MIN(y + BG_SIZE, numCols);193 194 psRegion region = psRegionSet(xMin, xMax, yMin, yMax); // Region of interest195 psImage *subImage = psImageSubset(image, region); // Subimage196 psImage *subMask = psImageSubset(mask, region); // Subimage mask197 if (!psImageBackground(stats, NULL, subImage, subMask, maskVal, rng)) {198 // Can't do anything about it199 psErrorClear();200 continue;201 }202 psFree(subImage);203 psFree(subMask);204 205 float value = stats->robustMedian; // Value to set background to206 207 int uMin = PS_MAX(x - size, 0), uMax = PS_MIN(x + size, numCols);208 int vMin = PS_MAX(y - size, 0), vMax = PS_MIN(y + size, numCols);209 210 for (int v = vMin; v < vMax; v++) {211 for (int u = uMin; u < uMax; u++) {212 bgImage->data.F32[v][u] = value;213 }214 }215 }216 217 psFree(stats);218 psFree(rng);219 220 return bgImage;221 }222 #endif223 162 224 163 … … 355 294 } 356 295 357 // Generate a fake image to match to358 float minFlux = INFINITY; // Minimum flux for fake image359 {360 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for bg361 if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal, rng)) {362 psWarning("Can't measure background for image.");363 psErrorClear();364 } else {365 minFlux = bg->robustStdev;366 }367 psFree(bg);368 }369 370 #if 0371 float maxMag = -INFINITY; // Maximum magnitude of sources372 for (int i = 0; i < sources->n; i++) {373 pmSource *source = sources->data[i]; // Source of interest374 if (source->psfMag > maxMag && source->psfMag <= MAG_IGNORE &&375 !(source->mode & SOURCE_MASK)) {376 maxMag = source->psfMag;377 }378 }379 minFlux = PS_MIN(FAINT_SOURCE_FRAC * powf(10.0, -0.4 * maxMag), minFlux);380 #endif381 382 383 296 #if 0 384 297 // Testing the normalisation of the fake image … … 654 567 psFree(bg); 655 568 569 570 #if 0 656 571 #define RADIUS 10 // Radius of photometry 657 572 #define MIN_ERR 0.05 // Minimum photometric error, mag … … 708 623 psFree(ratio); 709 624 psFree(ratioMask); 625 #endif 710 626 711 627 #ifdef TESTING
Note:
See TracChangeset
for help on using the changeset viewer.
