IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34352


Ignore:
Timestamp:
Aug 24, 2012, 12:33:06 PM (14 years ago)
Author:
bills
Message:

If psf matching fails for an input with the error PM_ERR_SMALL_AREA don't fault
just drop mark that input as NOT.PSF.MATCHED which will cause it to be skipped
for operations that need the convolved image. Change the deconvolution overlimit
to use the same flag.

Location:
trunk/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotStackMatchPSFs.c

    r34136 r34352  
    44{
    55    bool status = true;
     6
     7    psLogMsg ("psphot", PS_LOG_INFO, "--- psphotStack Match PSFs ---");
    68
    79    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "PSPHOT");
     
    4446    }
    4547
    46     // loop over the available readouts (ignore chisq image)
     48    // loop over the available readouts (ignore chisq image)psLogMsg ("psphot", PS_LOG_INFO, "--- psphot Source Stats ---");
    4749    for (int i = 0; i < num; i++) {
    4850        if (!psphotStackMatchPSFsReadout (config, view, options, i)) {
     
    5759
    5860// convolve the image to match desired PSF
    59 // XXX is this code consistent with 'convolve' = false?
     61// XXX is this code consistent with 'convolve' = false?  XXX: No
    6062bool psphotStackMatchPSFsReadout (pmConfig *config, const pmFPAview *view, psphotStackOptions *options, int index) {
    6163
    6264    psImageMaskType maskValue;
    6365    psImageMaskType markValue;
     66
     67    psLogMsg("psphot", PS_LOG_DETAIL, "-- starting PSF matching for readout %d --", index);
    6468
    6569    // get the PSPHOT.MASK value from the config
     
    102106        saveMatchData(readoutOut, options, index);
    103107    }
     108    bool notMatched = psMetadataLookupBool(NULL, readoutOut->analysis, "NOT.PSF.MATCHED");
     109    if (notMatched) {
     110        if (!readoutOut->image) {
     111            // our images got freed in the matching process. Recreate them so that they
     112            // are available when sources are copied to this readout.
     113            readoutOut->image = psImageCopy(NULL, readoutSrc->image, PS_TYPE_F32);
     114            if (readoutSrc->variance) {
     115                psFree(readoutOut->variance);
     116                readoutOut->variance = psImageCopy(NULL, readoutSrc->variance, PS_TYPE_F32);
     117            }
     118            if (readoutSrc->mask) {
     119                psFree(readoutOut->mask);
     120                readoutOut->mask = psImageCopy(NULL, readoutSrc->mask, PS_TYPE_IMAGE_MASK);
     121            }
     122        }
     123    }
    104124
    105125    // renormalize the stack variances to have sigma = 1.0
     
    111131    // save the output fwhm values in the readout->analysis.  we may have / will have multiple output PSF sizes,
    112132    // so we save this in a vector.  if the vector is not yet defined, create it
    113     // Skip this if the readout deconvolution fraction was over the limit.
     133    // Skip this if psf matching failed for this readout. For example if deconvolution fraction was over the limit.
    114134    // NOTE: fwhmValues as defined here has 1 + nMatched PSF : 0 == unmatched
    115135    psVector *fwhmValues = psVectorAllocEmpty(10, PS_TYPE_F32);
    116136    psVectorAppend(fwhmValues, NAN); // XXX this corresponds to the unmatched image set
    117137
    118     bool overLimit = psMetadataLookupBool(NULL, readoutOut->analysis, "DECONV.OVERLIMIT");
    119     if (!overLimit) {
     138    if (!notMatched) {
    120139        for (int i = 0; i < options->targetSeeing->n; i++) {
    121140            psVectorAppend(fwhmValues, options->targetSeeing->data.F32[i]);
     
    124143    psMetadataAddVector(readoutSrc->analysis, PS_LIST_TAIL, "STACK.PSF.FWHM.VALUES", PS_META_REPLACE, "PSF sizes", fwhmValues);
    125144    psMetadataAddVector(readoutOut->analysis, PS_LIST_TAIL, "STACK.PSF.FWHM.VALUES", PS_META_REPLACE, "PSF sizes", fwhmValues);
    126     psFree(fwhmValues); // drops the extra copy
     145    psFree(fwhmValues); // drops this function's reference
    127146
    128147    return true;
  • trunk/psphot/src/psphotStackMatchPSFsUtils.c

    r34136 r34352  
    280280
    281281    // Do the image matching
     282    bool rejectReadout = false;
    282283    pmSubtractionKernels *kernel = psMetadataLookupPtr(&mdok, readoutSrc->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel
    283284    if (kernel) {
     
    301302
    302303        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)) {
    303             psError(psErrorCodeLast(), false, "Unable to match images.");
    304             goto escape;
     304            int errorCode = psErrorCodeLast();
     305            if (errorCode == PM_ERR_SMALL_AREA) {
     306                // failed to match but, don't fault. Just drop this input from measurements that need the
     307                // matched readout.
     308                rejectReadout = true;
     309                psLogMsg("psphot", PS_LOG_WARN, "PSF match failed for input %d. Too few pixels.", index);
     310            } else {
     311                psError(psErrorCodeLast(), false, "Unable to match images.");
     312                goto escape;
     313            }
    305314        }
    306315    }
    307316
    308     // Reject image completely if the maximum deconvolution fraction exceeds the limit
     317    // If the maximum deconvolution fraction exceeds the limit, reject this input for analyses that require PSF matching
    309318    float deconvLimit = psMetadataLookupF32(NULL, stackRecipe, "DECONV.LIMIT"); // Limit on deconvolution fraction
    310319    float deconv = psMetadataLookupF32(NULL, readoutOut->analysis, PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction
    311320    if (deconv > deconvLimit) {
    312 #if (1)
    313         // XXX: don't reject the image set
    314         psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image for matched psf analysis%d\n", deconv, deconvLimit, index);
    315         psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "DECONV.OVERLIMIT", PS_META_REPLACE, "", true);
    316 #else
    317         psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image %d\n", deconv, deconvLimit, index);
    318         goto escape;
    319 #endif
     321        rejectReadout = true;
     322        psLogMsg("psphot", PS_LOG_WARN, "Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image for matched psf analysis%d\n", deconv, deconvLimit, index);
     323    }
     324   
     325    if (rejectReadout) {
     326        psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "NOT.PSF.MATCHED", PS_META_REPLACE, "", true);
    320327    } else {
    321         psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "DECONV.OVERLIMIT", PS_META_REPLACE, "", false);
    322     }
    323 
     328        psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "NOT.PSF.MATCHED", PS_META_REPLACE, "", false);
     329    }
    324330    // save the PSF on the new readout->analysis:
    325331    // if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot psf model", options->psf)) {
     
    470476}
    471477
    472 // Set input to be skipped if the decovolution fraction was overlimit. Use for radial apertures
    473 // This interface can be potentiall be extended for other uses
     478// Set input to be skipped if the analysis reports that psf matching has failed for some reason.
     479// For exmaple if decovolution fraction was overlimit or the bad fraction was too high.
     480//
    474481bool psphotStackSetInputsToSkip(pmConfig *config, const pmFPAview *view, const char *filerule, bool set) {
    475482    int num = psphotFileruleCount(config, filerule);
     
    487494        psAssert (readout, "missing readout?");
    488495        if (set) {
    489             bool overLimit = psMetadataLookupBool(&status, readout->analysis, "DECONV.OVERLIMIT");
    490             psMetadataAddBool(readout->analysis, PS_LIST_TAIL, "PSPHOT.SKIP.INPUT", PS_META_REPLACE, "Skip analysis", overLimit);
     496            bool notMatched = psMetadataLookupBool(&status, readout->analysis, "NOT.PSF.MATCHED");
     497            psMetadataAddBool(readout->analysis, PS_LIST_TAIL, "PSPHOT.SKIP.INPUT", PS_META_REPLACE, "Skip analysis", notMatched);
    491498        } else {
    492499            psMetadataAddBool(readout->analysis, PS_LIST_TAIL, "PSPHOT.SKIP.INPUT", PS_META_REPLACE, "Skip analysis", false);
Note: See TracChangeset for help on using the changeset viewer.