IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17255


Ignore:
Timestamp:
Mar 31, 2008, 3:46:38 PM (18 years ago)
Author:
Paul Price
Message:

Adding renormalisation of variance maps.

Location:
trunk/ppStack/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStack.h

    r16991 r17255  
    6363                  const pmReadout *sourcesRO, ///< Readout with sources
    6464                  const pmPSF *psf,     ///< Target PSF
     65                  psRandom *rng,        ///< Random number generator
    6566                  const pmConfig *config ///< Configuration
    6667    );
  • trunk/ppStack/src/ppStackArguments.c

    r17006 r17255  
    8383}
    8484
     85// Get a statistic name from the command-line or recipe, and add the enum to the arguments
     86#define VALUE_ARG_RECIPE_STAT(ARGNAME, RECIPENAME) { \
     87    const char *stat = psMetadataLookupStr(NULL, arguments, ARGNAME); \
     88    if (!stat) { \
     89        stat = psMetadataLookupStr(NULL, recipe, RECIPENAME); \
     90        if (!stat) { \
     91            psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find %s in recipe %s", \
     92                    RECIPENAME, PPSTACK_RECIPE); \
     93            goto ERROR; \
     94        } \
     95    } \
     96    psMetadataAddS32(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, psStatsOptionFromString(stat)); \
     97}
     98
    8599// Get a string value from the command-line and add it to the target
    86100static bool valueArgStr(psMetadata *arguments, // Command-line arguments
     
    141155    psMetadataAddBool(arguments, PS_LIST_TAIL, "-variance", 0, "Use variance for rejection?", false);
    142156    psMetadataAddBool(arguments, PS_LIST_TAIL, "-safe", 0, "Play safe with small numbers of pixels to combine?", false);
     157    psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise variance maps?", false);
     158    psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-mean", 0, "Statistic for mean in renormalisation", NULL);
     159    psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-stdev", 0, "Statistic for stdev in renormalisation", NULL);
     160    psMetadataAddS32(arguments, PS_LIST_TAIL, "-renorm-width", 0, "Width of renormalisation boxes", 0);
    143161    psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-image", 0, "Suffix for temporary images", NULL);
    144162    psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-mask", 0, "Suffix for temporary masks", NULL);
     
    208226    }
    209227
     228    if (psMetadataLookupBool(NULL, arguments, "-renorm") ||
     229        psMetadataLookupBool(NULL, recipe, "RENORM")) {
     230        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise variance maps?", true);
     231    }
     232    VALUE_ARG_RECIPE_INT("-renorm-width", "RENORM.WIDTH", S32, 0);
     233    VALUE_ARG_RECIPE_STAT("-renorm-mean", "RENORM.MEAN");
     234    VALUE_ARG_RECIPE_STAT("-renorm-stdev", "RENORM.STDEV");
     235
    210236    valueArgRecipeStr(arguments, recipe, "-temp-image",  "TEMP.IMAGE",  config->arguments);
    211237    valueArgRecipeStr(arguments, recipe, "-temp-mask",   "TEMP.MASK",   config->arguments);
     
    218244    }
    219245
    220 
    221246    psTrace("ppStack", 1, "Done reading command-line arguments\n");
    222247    psFree(arguments);
     
    227252    return false;
    228253}
    229 
    230 
  • trunk/ppStack/src/ppStackLoop.c

    r17016 r17255  
    306306    psArray *subKernels = psArrayAlloc(num); // Subtraction kernels --- required in the stacking
    307307    psArray *subRegions = psArrayAlloc(num); // Subtraction regions --- required in the stacking
     308    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
    308309    for (int i = 0; i < num; i++) {
    309310        psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);
     
    315316            psFree(sources);
    316317            psFree(targetPSF);
     318            psFree(rng);
    317319            return false;
    318320        }
     
    323325        // Background subtraction, scaling and normalisation is performed automatically by the image matching
    324326        psArray *regions = NULL, *kernels = NULL; // Regions and kernels used in subtraction
    325         if (!ppStackMatch(readout, &regions, &kernels, sources, targetPSF, config)) {
     327        if (!ppStackMatch(readout, &regions, &kernels, sources, targetPSF, rng, config)) {
    326328            psError(PS_ERR_UNKNOWN, false, "Unable to match image %d --- ignoring.", i);
    327329            psFree(sources);
    328330            psFree(targetPSF);
     331            psFree(rng);
    329332            return false;
    330333        }
     
    345348    psFree(sources);
    346349    psFree(targetPSF);
     350    psFree(rng);
    347351
    348352
  • trunk/ppStack/src/ppStackMatch.c

    r17031 r17255  
    1616
    1717bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels,
    18                   const pmReadout *sourcesRO, const pmPSF *psf, const pmConfig *config)
     18                  const pmReadout *sourcesRO, const pmPSF *psf, psRandom *rng, const pmConfig *config)
    1919{
    2020    assert(readout);
     
    3030    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe
    3131    int size = psMetadataLookupS32(NULL, recipe, "KERNEL.SIZE"); // Kernel half-size
     32    psMaskType maskBad = pmConfigMask(psMetadataLookupStr(NULL, recipe, "MASK.BAD"), config); // Value to mask
     33    bool mdok;                          // Status of MD lookup
     34    bool renorm = psMetadataLookupBool(&mdok, recipe, "RENORM"); // Renormalise variances?
     35    psStatsOptions renormMean = psMetadataLookupS32(&mdok, recipe, "RENORM.MEAN"); // Statistic for mean
     36    psStatsOptions renormStdev = psMetadataLookupS32(&mdok, recipe, "RENORM.STDEV"); // Statistic for stdev
     37    int renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width for renormalisation box
     38
     39    // Renormalise the variances if desired
     40    if (renorm && !pmReadoutWeightRenorm(readout, maskBad, renormMean, renormStdev, renormWidth, rng)) {
     41        psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
     42        psFree(output);
     43        return false;
     44    }
    3245
    3346#ifndef NO_CONVOLUTION
    34     bool mdok;                          // Status of MD lookup
    3547    int order = psMetadataLookupS32(NULL, recipe, "SPATIAL.ORDER"); // Spatial polynomial order
    3648    float regionSize = psMetadataLookupF32(NULL, recipe, "REGION.SIZE"); // Size of iso-kernel regs
     
    4759    int ringsOrder = psMetadataLookupS32(NULL, recipe, "RINGS.ORDER"); // RINGS polynomial order
    4860    int binning = psMetadataLookupS32(NULL, recipe, "SPAM.BINNING"); // Binning for SPAM kernel
    49     psMaskType maskBad = pmConfigMask(psMetadataLookupStr(NULL, recipe, "MASK.BAD"),
    50                                       config); // Value to mask
    5161    psMaskType maskBlank = pmConfigMask(psMetadataLookupStr(NULL, recipe, "MASK.BLANK"),
    5262                                        config); // Mask for blank reg.
Note: See TracChangeset for help on using the changeset viewer.