IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 8, 2010, 1:55:26 PM (16 years ago)
Author:
eugene
Message:

working on psphotStack psf matching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psphot.20100506/src/psphotStackMatchPSFsUtils.c

    r27883 r27884  
    259259
    260260// perform the bulk of the PSF-matching
    261 bool matchKernel(pmConfig *config, pmReadout *readoutCnv, pmReadout *readoutRaw, psphotStackOptions *options, int index) {
     261bool matchKernel(pmConfig *config, pmReadout *readoutOut, pmReadout *readoutSrc, psphotStackOptions *options, int index) {
    262262
    263263    bool mdok;
     
    338338    stampSources = stackSourcesFilter(options->sourceLists->data[index], footprint); // Filtered list of sources
    339339
    340     fake = makeFakeReadout(config, readoutRaw, stampSources, options->psf, maskVal | maskBad, footprint + size);
     340    fake = makeFakeReadout(config, readoutSrc, stampSources, options->psf, maskVal | maskBad, footprint + size);
    341341    if (!fake) goto escape;
    342342
    343     dumpImage(fake, readoutRaw, index, "fake");
    344     dumpImage(readoutRaw,  readoutRaw, index, "real");
     343    dumpImage(fake, readoutSrc, index, "fake");
     344    dumpImage(readoutSrc,  readoutSrc, index, "real");
    345345
    346346    if (threads) pmSubtractionThreadsInit();
    347347
    348348    // Do the image matching
    349     pmSubtractionKernels *kernel = psMetadataLookupPtr(&mdok, readoutRaw->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel
     349    pmSubtractionKernels *kernel = psMetadataLookupPtr(&mdok, readoutSrc->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel
    350350    if (kernel) {
    351         if (!pmSubtractionMatchPrecalc(NULL, readoutCnv, fake, readoutRaw, readoutRaw->analysis, stride, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac)) {
     351        if (!pmSubtractionMatchPrecalc(NULL, readoutOut, fake, readoutSrc, readoutSrc->analysis, stride, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac)) {
    352352            psError(psErrorCodeLast(), false, "Unable to convolve images.");
    353353            goto escape;
     
    361361        }
    362362
    363         if (!pmSubtractionMatch(NULL, readoutCnv, fake, readoutRaw, footprint, stride, regionSize, spacing, threshold, stampSources, stampsName, type, size, order, widthsCopy, orders, inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, normFrac, sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) {
     363        if (!pmSubtractionMatch(NULL, readoutOut, fake, readoutSrc, footprint, stride, regionSize, spacing, threshold, stampSources, stampsName, type, size, order, widthsCopy, orders, inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, normFrac, sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) {
    364364            psError(psErrorCodeLast(), false, "Unable to match images.");
    365365            goto escape;
     
    369369    // Reject image completely if the maximum deconvolution fraction exceeds the limit
    370370    float deconvLimit = psMetadataLookupF32(NULL, stackRecipe, "DECONV.LIMIT"); // Limit on deconvolution fraction
    371     float deconv = psMetadataLookupF32(NULL, readoutCnv->analysis, PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction
     371    float deconv = psMetadataLookupF32(NULL, readoutOut->analysis, PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction
    372372    if (deconv > deconvLimit) {
    373373        psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image %d\n", deconv, deconvLimit, index);
     
    375375    }
    376376
    377     dumpImage(readoutCnv, readoutRaw, index, "conv");
    378     dumpImageDiff(readoutCnv, fake, readoutRaw, index, "diff");
     377    dumpImage(readoutOut, readoutSrc, index, "conv");
     378    dumpImageDiff(readoutOut, fake, readoutSrc, index, "diff");
    379379
    380380    psFree(fake);
     
    542542
    543543// generate a fake readout against which to PSF match
    544 pmReadout *makeFakeReadout(pmConfig *config, pmReadout *readoutRaw, psArray *sources, pmPSF *psf, psImageMaskType maskVal, int fullSize) {
     544pmReadout *makeFakeReadout(pmConfig *config, pmReadout *readoutSrc, psArray *sources, pmPSF *psf, psImageMaskType maskVal, int fullSize) {
    545545
    546546    pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF
     
    548548    psStats *bg = psStatsAlloc(PS_STAT_ROBUST_STDEV); // Statistics for background
    549549    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
    550     if (!psImageBackground(bg, NULL, readoutRaw->image, readoutRaw->mask, maskVal, rng)) {
     550    if (!psImageBackground(bg, NULL, readoutSrc->image, readoutSrc->mask, maskVal, rng)) {
    551551        psError(PSPHOT_ERR_DATA, false, "Can't measure background for image.");
    552552        psFree(fake);
     
    560560
    561561    bool oldThreads = pmReadoutFakeThreads(true); // Old threading state
    562     if (!pmReadoutFakeFromSources(fake, readoutRaw->image->numCols, readoutRaw->image->numRows, sources, SOURCE_MASK, NULL, NULL, psf, minFlux, fullSize, false, true)) {
     562    if (!pmReadoutFakeFromSources(fake, readoutSrc->image->numCols, readoutSrc->image->numRows, sources, SOURCE_MASK, NULL, NULL, psf, minFlux, fullSize, false, true)) {
    563563        psError(PSPHOT_ERR_DATA, false, "Unable to generate fake image with target PSF.");
    564564        psFree(fake);
     
    567567    pmReadoutFakeThreads(oldThreads);
    568568
    569     fake->mask = psImageCopy(NULL, readoutRaw->mask, PS_TYPE_IMAGE_MASK);
     569    fake->mask = psImageCopy(NULL, readoutSrc->mask, PS_TYPE_IMAGE_MASK);
    570570
    571571    // Add the background into the target image
    572     psImage *bgImage = stackBackgroundModel(readoutRaw, config); // Image of background
     572    psImage *bgImage = stackBackgroundModel(readoutSrc, config); // Image of background
    573573    psBinaryOp(fake->image, fake->image, "+", bgImage);
    574574    psFree(bgImage);
Note: See TracChangeset for help on using the changeset viewer.