IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21114


Ignore:
Timestamp:
Jan 12, 2009, 7:09:07 PM (17 years ago)
Author:
Paul Price
Message:

Cleaning up. Turning off the enforced normalisation, as an experiment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090108/ppStack/src/ppStackMatch.c

    r21111 r21114  
    1717#define FAINT_SOURCE_FRAC 1.0e-4         // Set minimum flux to this fraction of faintest source flux
    1818
    19 #define TESTING                         // Enable debugging output
     19//#define TESTING                         // Enable debugging output
    2020
    2121#ifdef TESTING
     
    160160     return unbinned;
    161161}
    162 
    163 
    164 
    165 
    166 #if 0
    167 #define BG_SIZE 64                      // Large box half-size in which to measure background
    168 
    169 // Generate a background model of the readout we're matching
    170 // 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 readout
    174     int numCols = image->numCols, numRows = image->numRows; // Size of image
    175 
    176     psImage *bgImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Background image
    177     psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for measuring background
    178     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
    179 
    180     for (int i = 0; i < sources->n; i++) {
    181         pmSource *source = sources->data[i]; // Source of interest
    182         if (!source) {
    183             continue;
    184         }
    185 
    186         float xSource, ySource;         // Coordinates of source
    187         coordsFromSource(&xSource, &ySource, source);
    188 
    189         int x = xSource + 0.5, y = ySource + 0.5; // Coordinates of source
    190 
    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 interest
    195         psImage *subImage = psImageSubset(image, region); // Subimage
    196         psImage *subMask = psImageSubset(mask, region); // Subimage mask
    197         if (!psImageBackground(stats, NULL, subImage, subMask, maskVal, rng)) {
    198             // Can't do anything about it
    199             psErrorClear();
    200             continue;
    201         }
    202         psFree(subImage);
    203         psFree(subMask);
    204 
    205         float value = stats->robustMedian; // Value to set background to
    206 
    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 #endif
    223162
    224163
     
    355294            }
    356295
    357             // Generate a fake image to match to
    358             float minFlux = INFINITY;       // Minimum flux for fake image
    359             {
    360                 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for bg
    361                 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 0
    371             float maxMag = -INFINITY;   // Maximum magnitude of sources
    372             for (int i = 0; i < sources->n; i++) {
    373                 pmSource *source = sources->data[i]; // Source of interest
    374                 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 #endif
    381 
    382 
    383296#if 0
    384297            // Testing the normalisation of the fake image
     
    654567    psFree(bg);
    655568
     569
     570#if 0
    656571#define RADIUS 10                       // Radius of photometry
    657572#define MIN_ERR 0.05                    // Minimum photometric error, mag
     
    708623    psFree(ratio);
    709624    psFree(ratioMask);
     625#endif
    710626
    711627#ifdef TESTING
Note: See TracChangeset for help on using the changeset viewer.