IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26671


Ignore:
Timestamp:
Jan 22, 2010, 11:45:18 AM (16 years ago)
Author:
Paul Price
Message:

Adding scaling of kernel parameters by seeing FWHMs.

Location:
branches/eam_branches/20091201/ppStack/src
Files:
4 edited

Legend:

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

    r26543 r26671  
    316316            int optOrder = psMetadataLookupS32(&mdok, ppsub, "OPTIMUM.ORDER"); // Order for search
    317317            float poorFrac = psMetadataLookupF32(&mdok, ppsub, "POOR.FRACTION"); // Fraction for "poor"
     318
     319            bool scale = psMetadataLookupBool(NULL, recipe, "SCALE");        // Scale kernel parameters?
     320            float scaleRef = psMetadataLookupF32(NULL, recipe, "SCALE.REF"); // Reference for scaling
     321            float scaleMin = psMetadataLookupF32(NULL, recipe, "SCALE.MIN"); // Minimum for scaling
     322            float scaleMax = psMetadataLookupF32(NULL, recipe, "SCALE.MAX"); // Maximum for scaling
     323            if (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax)) {
     324                psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     325                        "Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in recipe.",
     326                        scaleRef, scaleMin, scaleMax);
     327                return false;
     328            }
     329
    318330
    319331            // These values are specified specifically for stacking
     
    410422                }
    411423            } else {
     424                // Scale the input parameters
     425                psVector *widthsCopy = psVectorCopy(NULL, widths, PS_TYPE_F32); // Copy of kernel widths
     426                if (scale && !pmSubtractionParamsScale(&size, &footprint, widthsCopy,
     427                                                       options->inputSeeing->data.F32[index],
     428                                                       options->targetSeeing, scaleRef, scaleMin, scaleMax)) {
     429                    psError(PS_ERR_UNKNOWN, false, "Unable to scale kernel parameters");
     430                    psFree(fake);
     431                    psFree(optWidths);
     432                    psFree(stampSources);
     433                    psFree(conv);
     434                    psFree(widthsCopy);
     435                    if (threads > 0) {
     436                        pmSubtractionThreadsFinalize(readout, fake);
     437                    }
     438                    return false;
     439                }
     440
    412441                if (!pmSubtractionMatch(NULL, conv, fake, readout, footprint, stride, regionSize, spacing,
    413                                         threshold, stampSources, stampsName, type, size, order, widths,
     442                                        threshold, stampSources, stampsName, type, size, order, widthsCopy,
    414443                                        orders, inner, ringsOrder, binning, penalty,
    415444                                        optimum, optWidths, optOrder, optThresh, iter, rej, sysError, skyErr,
     
    421450                    psFree(stampSources);
    422451                    psFree(conv);
     452                    psFree(widthsCopy);
    423453                    if (threads > 0) {
    424454                        pmSubtractionThreadsFinalize(readout, fake);
     
    426456                    return false;
    427457                }
     458                                              psFree(widthsCopy);
    428459            }
    429460
  • branches/eam_branches/20091201/ppStack/src/ppStackOptions.c

    r26475 r26671  
    2020    psFree(options->convVariances);
    2121    psFree(options->psf);
     22    psFree(options->inputSeeing);
    2223    psFree(options->inputMask);
    2324    psFree(options->sourceLists);
     
    5455    options->num = 0;
    5556    options->psf = NULL;
     57    options->inputSeeing = NULL;
     58    options->targetSeeing = NAN;
    5659    options->inputMask = NULL;
    5760    options->sourceLists = NULL;
  • branches/eam_branches/20091201/ppStack/src/ppStackOptions.h

    r26475 r26671  
    1818    // Prepare
    1919    pmPSF *psf;                         // Target PSF
     20    psVector *inputSeeing;              // Input seeing FWHMs
     21    float targetSeeing;                 // Target seeing FWHM
    2022    float sumExposure;                  // Sum of exposure times
    2123    psVector *inputMask;                // Mask for inputs
  • branches/eam_branches/20091201/ppStack/src/ppStackPrepare.c

    r26475 r26671  
    176176
    177177
    178         bool redoPhot = psMetadataLookupBool(NULL, recipe, "PHOT");
    179         psArray *sources = NULL;
    180 
    181         if (options->convolve || options->matchZPs || redoPhot) {
    182             pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources
    183             sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources
    184             if (!sources) {
    185                 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout.");
    186                 return NULL;
    187             }
    188             options->sourceLists->data[index] = psMemIncrRefCounter(sources);
    189         }
     178        bool redoPhot = psMetadataLookupBool(NULL, recipe, "PHOT");
     179        psArray *sources = NULL;
     180
     181        if (options->convolve || options->matchZPs || redoPhot) {
     182            pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources
     183            sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources
     184            if (!sources) {
     185                psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout.");
     186                return NULL;
     187            }
     188            options->sourceLists->data[index] = psMemIncrRefCounter(sources);
     189        }
    190190
    191191        // Re-do photometry if we don't trust the source lists
     
    194194            pmFPAfileActivate(config->files, false, NULL);
    195195            ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, index);
    196             if (options->convolve) {
    197                 pmFPAfileActivate(config->files, true, "PPSTACK.CONV.KERNEL");
    198             }
     196            if (options->convolve) {
     197                pmFPAfileActivate(config->files, true, "PPSTACK.CONV.KERNEL");
     198            }
    199199            pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File
    200200            pmFPAview *photView = ppStackFilesIterateDown(config);
     
    225225    }
    226226    psFree(fileIter);
     227
     228    psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message
     229    bool havePSFs = false;                                // Do we have any PSFs?
     230    options->inputSeeing = psVectorAlloc(num, PS_TYPE_F32);
     231    psVectorInit(options->inputSeeing, NAN);
     232    for (int i = 0; i < num; i++) {
     233        pmPSF *psf = psfs->data[i];     // PSF for image
     234        if (!psf) {
     235            continue;
     236        }
     237        havePSFs = true;
     238        float fwhm = pmPSFtoFWHM(psf, 0.5 * numCols, 0.5 * numRows); // FWHM for image
     239        psStringAppend(&log, "Input %d: %f\n", i, fwhm);
     240        options->inputSeeing->data.F32[i] = fwhm;
     241    }
     242    if (havePSFs) {
     243        psLogMsg("ppStack", PS_LOG_INFO, "%s", log);
     244    }
     245    psFree(log);
    227246
    228247    // Generate target PSF
     
    237256        psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "PSF.TARGET", PS_DATA_UNKNOWN,
    238257                         "Target PSF for stack", options->psf);
     258        options->targetSeeing = pmPSFtoFWHM(options->psf, 0.5 * numCols, 0.5 * numRows); // FWHM for target
     259        psLogMsg("ppStack", PS_LOG_INFO, "Target seeing FWHM: %f\n", options->targetSeeing);
    239260
    240261        pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPSTACK.OUTPUT"); // Output chip
Note: See TracChangeset for help on using the changeset viewer.