IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2011, 1:16:41 PM (15 years ago)
Author:
eugene
Message:

improvements to the output headers; some code organization; plug leaks; user-specified limits to input seeing ranges

Location:
trunk/ppStack
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack

    • Property svn:ignore
      •  

        old new  
        1717autom4te.cache
        1818Doxyfile
         19a.out.dSYM
    • Property svn:mergeinfo deleted
  • trunk/ppStack/src/ppStackPrepare.c

    r30620 r31158  
    1 #include "ppStack.h"
    2 
    3 #define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \
    4                           PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
    5                           PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources
     1# include "ppStack.h"
     2
     3# define RE_PHOTOMETER 0
     4
     5# define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \
     6                           PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
     7                           PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources
    68
    79bool ppStackInputPhotometer(const pmReadout *ro, const psArray *sources, const pmConfig *config)
     
    1315    psAssert(recipe, "We've thrown an error on this before.");
    1416
     17# if (RE_PHOTOMETER)
    1518    bool mdok;                          // Status of MD lookup
    1619
     
    3841    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
    3942
     43    // Measure background
    4044    psImage *image = ro->image, *mask = ro->mask; // Image and mask from readout
    41 
    42     // Measure background
    4345    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
    4446    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics
     
    5254    psFree(stats);
    5355    psFree(rng);
    54 
    55     // Photometer sources
    56     int numCols = image->numCols, numRows = image->numRows; // Size of image
     56# endif
     57
     58    // Examine the sources (photometer if RE_PHOTOMETER is set)
    5759    int numSources = sources->n; // Number of sources
    5860    int numGood = 0;            // Number of good sources
     
    6466            continue;
    6567        }
    66         float x = source->peak->xf, y = source->peak->yf; // Coordinates of source
     68
     69// This code re-measures the magnitude in the assumption that the warp analysis failed It would
     70// be better to catch and correct such cases.  In any case, we should check on the validity of
     71// this assumption (eg, compare the mean psf-ap offset) and raise an error on that?
     72
     73# if (RE_PHOTOMETER)
     74       
     75        int numCols = image->numCols, numRows = image->numRows; // Size of image
     76        float x = source->peak->xf, y = source->peak->yf; // Coordinates of source
    6777        int xCentral = x + 0.5, yCentral = y + 0.5; // Central pixel
    6878        // Range of integration
     
    96106            }
    97107        }
     108# else
     109        numGood++;
     110        maxMag = PS_MAX(maxMag, source->psfMag);
     111# endif
    98112    }
    99113    psLogMsg("ppStack", PS_LOG_INFO, "Photometered %d good sources in image; max mag %f", numGood, maxMag);
     
    217231        }
    218232    }
     233
     234    bool mdok = false;
     235    float maxFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.MAX"); // max allowed input fwhm
     236    float clipFWHMnSig = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.NSIGMA"); // sigma clipping of inputs
    219237
    220238    psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message
     
    251269        }
    252270
     271        // reject any input images which exceed the specified max FWHM
     272        if (isfinite(maxFWHM) && (options->inputSeeing->data.F32[i] > maxFWHM)) {
     273            options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_PSF;
     274            psLogMsg("ppStack", PS_LOG_INFO, "PSF FWHM for image %d is too large (%f vs %f maxFWHM) --- rejected.", i, options->inputSeeing->data.F32[i], maxFWHM);
     275        }
     276
    253277        psStringAppend(&log, "Input %d: %f\n", i, options->inputSeeing->data.F32[i]);
    254278    }
     
    257281    }
    258282    psFree(log);
     283
     284    // We should have the ability to filter the input list based on the seeing:
     285    // * reject above some max value and/or min value
     286    // * reject images out-of-line with the rest of the images
     287
     288    // measure stats
     289    psStats *fwhmStats = psStatsAlloc(PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
     290    psVectorStats (fwhmStats, options->inputSeeing, NULL, options->inputMask, 0xff);
     291    psLogMsg("ppStack", PS_LOG_INFO, "Input FWHMs : %f +/- %f", fwhmStats->clippedMean, fwhmStats->clippedStdev);
     292
     293    if (isfinite(clipFWHMnSig)) {
     294        float fwhmLimit = fwhmStats->clippedMean + clipFWHMnSig * fwhmStats->clippedStdev;
     295        fwhmLimit = isfinite(maxFWHM) ? PS_MIN (maxFWHM, fwhmLimit) : fwhmLimit;
     296        for (int i = 0; i < num; i++) {
     297            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
     298            if (options->inputSeeing->data.F32[i] > fwhmLimit) {
     299                options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_PSF;
     300                psLogMsg("ppStack", PS_LOG_INFO, "PSF FWHM for image %d is too large (%f vs %f fwhmLimit) --- rejected.", i, options->inputSeeing->data.F32[i], fwhmLimit);
     301            }
     302        }
     303    }
    259304
    260305    // Generate target PSF
Note: See TracChangeset for help on using the changeset viewer.