IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 25, 2013, 12:08:56 PM (13 years ago)
Author:
eugene
Message:

convert SERSIC to use pmModelCP_SersicSubpix; clean up DEV and EXP versions; add pmPCMMakeModel, pmSersicKappa, pmSersicNorm functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130711/psModules/src/objects/pmPCMdata.c

    r35961 r36021  
    261261        // PSF model only fits Io, index (PAR7) -- only Io for models with < 8 params
    262262        psVectorInit (constraint->paramMask, 0);
    263         constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
     263        // constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
    264264        if (params->n == 7) {
     265            nParams = params->n;
     266        } else {
    265267            nParams = params->n - 1;
    266         } else {
    267             nParams = params->n - 2;
    268268            constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_7] = 1;
    269269        }
     
    488488}
    489489
     490// construct a realization of the source model
     491bool pmPCMMakeModel (pmSource *source, pmModel *model, psImageMaskType maskVal, int psfSize) {
     492
     493    PS_ASSERT_PTR_NON_NULL(source, false);
     494
     495    // if we already have a cached image, re-use that memory
     496    source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32);
     497    psImageInit (source->modelFlux, 0.0);
     498
     499    // modelFlux always has unity normalization (I0 = 1.0)
     500    pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);
     501
     502    // convolve the model image with the PSF
     503    if (USE_1D_GAUSS) {
     504        // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread):
     505        // * the model flux is not masked
     506        // * threading takes place above this level
     507       
     508        // define the Gauss parameters from the psf
     509        pmModel *modelPSF = source->modelPSF;
     510        psAssert (modelPSF, "psf model must be defined");
     511   
     512        psEllipseAxes axes;
     513        bool useReff = pmModelUseReff (modelPSF->type);
     514        psF32 *PAR = modelPSF->params->data.F32;
     515        pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff);
     516   
     517        float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]);
     518        float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major);
     519
     520        float sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35;
     521        float nsigma = 2.0;
     522
     523        psImageSmooth (source->modelFlux, sigma, nsigma);
     524    } else {
     525        // make sure we save a cached copy of the psf flux
     526        pmSourceCachePSF (source, maskVal);
     527
     528        // convert the cached cached psf model for this source to a psKernel
     529        psKernel *psf = pmPCMkernelFromPSF (source, psfSize);
     530        if (!psf) {
     531            // NOTE: this only happens if the source is too close to an edge
     532            model->flags |= PM_MODEL_STATUS_BADARGS;
     533            return NULL;
     534        }
     535
     536        // XXX not sure if I can place the output on top of the input
     537        psImageConvolveFFT (source->modelFlux, source->modelFlux, NULL, 0, psf);
     538    }
     539    return true;
     540}
     541
Note: See TracChangeset for help on using the changeset viewer.