IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 27, 2009, 11:34:07 AM (17 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/ppStack/src/ppStackMatch.c

    r25406 r25624  
    1515#define SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
    1616                     PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to input sources
    17 #define FAINT_SOURCE_FRAC 1.0e-4         // Set minimum flux to this fraction of faintest source flux
     17#define NOISE_FRACTION 0.01             // Set minimum flux to this fraction of noise
    1818#define COVAR_FRAC 0.01                 // Truncation fraction for covariance matrix
    1919
     
    266266            psRegion *region = psMetadataLookupPtr(NULL, conv->analysis,
    267267                                                   PM_SUBTRACTION_ANALYSIS_REGION); // Convolution region
    268 
    269             pmSubtractionAnalysis(readout->analysis, kernels, region,
     268            pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, conv->analysis,
     269                                                                PM_SUBTRACTION_ANALYSIS_KERNEL);
     270
     271            pmSubtractionAnalysis(readout->analysis, NULL, kernels, region,
    270272                                  readout->image->numCols, readout->image->numRows);
    271273
     
    317319            pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF
    318320
     321            psStats *bg = psStatsAlloc(PS_STAT_ROBUST_STDEV); // Statistics for background
     322            psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
     323            if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) {
     324                psError(PS_ERR_UNKNOWN, false, "Can't measure background for image.");
     325                psFree(fake);
     326                psFree(optWidths);
     327                psFree(conv);
     328                psFree(bg);
     329                psFree(rng);
     330                return false;
     331            }
     332            float minFlux = NOISE_FRACTION * bg->robustStdev; // Minimum flux level for fake image
     333            psFree(rng);
     334            psFree(bg);
     335
    319336            // For the sake of stamps, remove nearby sources
    320337            psArray *stampSources = stackSourcesFilter(options->sourceLists->data[index],
     
    323340            if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows,
    324341                                          stampSources, SOURCE_MASK, NULL, NULL, options->psf,
    325                                           NAN, footprint + size, false, true)) {
     342                                          minFlux, footprint + size, false, true)) {
    326343                psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF.");
    327344                psFree(fake);
     
    369386                                                               PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel
    370387            if (kernel) {
    371                 if (!pmSubtractionMatchPrecalc(conv, NULL, readout, fake, readout->analysis,
     388                if (!pmSubtractionMatchPrecalc(NULL, conv, fake, readout, readout->analysis,
    372389                                               stride, sysError, maskVal, maskBad, maskPoor,
    373390                                               poorFrac, badFrac)) {
     
    383400                }
    384401            } else {
    385                 if (!pmSubtractionMatch(conv, NULL, readout, fake, footprint, stride, regionSize, spacing,
     402                if (!pmSubtractionMatch(NULL, conv, fake, readout, footprint, stride, regionSize, spacing,
    386403                                        threshold, stampSources, stampsName, type, size, order, widths,
    387404                                        orders, inner, ringsOrder, binning, penalty,
    388405                                        optimum, optWidths, optOrder, optThresh, iter, rej, sysError,
    389406                                        maskVal, maskBad, maskPoor, poorFrac, badFrac,
    390                                         PM_SUBTRACTION_MODE_1)) {
     407                                        PM_SUBTRACTION_MODE_2)) {
    391408                    psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
    392409                    psFree(fake);
Note: See TracChangeset for help on using the changeset viewer.