IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 17, 2007, 11:01:59 AM (19 years ago)
Author:
magnier
Message:

substantial cleanups of APIs:

changed pmModelGroup to pmModelClass

dropped the _GetFunctions, and moved the modelClass-specific functions
to functions pointers in the pmModel structure. These are assigned
when the model is allocated, based on the model type. Now, instead of
calling, for example,

modelFunc = pmModelFunc_GetFunctions(model->type)
modelFunc();

you just do:

model->modelFunc()

moved some of the support functions into pmModelUtils and
pmSourceUtils.

changed pmIsFooBar to pmFooBarTest for better api listing.

added functions to evaluate and add/subtract models applying an offset
between the image coordinate frame and the chip frame (required frame
for model parameters)

added function(s) to instatiate a pmModel from a pmPSF based on a
given coordinate and peak flux.

added a function to set the model normalization based on a source flux
value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070817/psModules/src/objects/models/pmModel_GAUSS.c

    r14220 r14544  
    1919 *****************************************************************************/
    2020
    21 # define PM_MODEL_FUNC       pmModelFunc_GAUSS
    22 # define PM_MODEL_FLUX       pmModelFlux_GAUSS
    23 # define PM_MODEL_GUESS      pmModelGuess_GAUSS
    24 # define PM_MODEL_LIMITS     pmModelLimits_GAUSS
    25 # define PM_MODEL_RADIUS     pmModelRadius_GAUSS
    26 # define PM_MODEL_FROM_PSF   pmModelFromPSF_GAUSS
    27 # define PM_MODEL_FIT_STATUS pmModelFitStatus_GAUSS
     21# define PM_MODEL_FUNC            pmModelFunc_GAUSS
     22# define PM_MODEL_FLUX            pmModelFlux_GAUSS
     23# define PM_MODEL_GUESS           pmModelGuess_GAUSS
     24# define PM_MODEL_LIMITS          pmModelLimits_GAUSS
     25# define PM_MODEL_RADIUS          pmModelRadius_GAUSS
     26# define PM_MODEL_FROM_PSF        pmModelFromPSF_GAUSS
     27# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_GAUSS
     28# define PM_MODEL_FIT_STATUS      pmModelFitStatus_GAUSS
    2829
    2930psF32 PM_MODEL_FUNC(psVector *deriv,
     
    185186
    186187// make an initial guess for parameters
    187 bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    188 {
     188bool PM_MODEL_GUESS (void *inModel, void *inSource)
     189{
     190    pmModel *model = inModel;
     191    pmSource *source = inSource;
     192
    189193    pmMoments *moments = source->moments;
    190194    psF32     *PAR  = model->params->data.F32;
     
    255259
    256260// construct the PSF model from the FLT model and the psf
    257 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf)
    258 {
     261bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF)
     262{
     263    pmModel *modelPSF = inModelPSF;
     264    pmModel *modelFLT = inModelFLT;
     265    pmPSF *psf = inPSF;
    259266
    260267    psF32 *out = modelPSF->params->data.F32;
     
    306313}
    307314
     315// construct the PSF model from the FLT model and the psf
     316// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     317bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io)
     318{
     319    pmModel *model = inModel;
     320    pmPSF *psf = inPSF;
     321
     322    psF32 *PAR = model->params->data.F32;
     323
     324    // we require these two parameters to exist
     325    assert (psf->params_NEW->n > PM_PAR_YPOS);
     326    assert (psf->params_NEW->n > PM_PAR_XPOS);
     327
     328    PAR[PM_PAR_SKY]  = 0.0;
     329    PAR[PM_PAR_I0]   = Io;
     330    PAR[PM_PAR_XPOS] = Xo;
     331    PAR[PM_PAR_YPOS] = Yo;
     332   
     333    // supply the model-fitted parameters, or copy from the input
     334    for (int i = 0; i < psf->params_NEW->n; i++) {
     335        if (i == PM_PAR_SKY) continue;
     336        psPolynomial2D *poly = psf->params_NEW->data[i];
     337        assert (poly);
     338        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     339    }
     340
     341    // the 2D PSF model fits polarization terms (E0,E1,E2)
     342    // convert to shape terms (SXX,SYY,SXY)
     343    // XXX user-defined value for limit?
     344    if (!pmPSF_FitToModel (PAR, 0.1)) {
     345        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     346        return false;
     347    }
     348
     349    // apply the model limits here: this truncates excessive extrapolation
     350    // XXX do we need to do this still?  should we put in asserts to test?
     351    for (int i = 0; i < psf->params_NEW->n; i++) {
     352        // apply the limits to all components or just the psf-model parameters?
     353        if (psf->params_NEW->data[i] == NULL)
     354            continue;
     355
     356        bool status = true;
     357        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     358        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     359        if (!status) {
     360            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     361            model->flags |= PM_MODEL_STATUS_LIMITS;
     362        }
     363    }
     364    return(true);
     365}
     366
    308367// check the status of the fitted model
    309368// this test is invalid if the parameters are derived
    310369// from the PSF model
    311 bool PM_MODEL_FIT_STATUS (pmModel *model)
    312 {
     370bool PM_MODEL_FIT_STATUS (void *inModel)
     371{
     372    pmModel *model = inModel;
    313373
    314374    psF32 dP;
     
    339399# undef PM_MODEL_RADIUS
    340400# undef PM_MODEL_FROM_PSF
     401# undef PM_MODEL_PARAMS_FROM_PSF
    341402# undef PM_MODEL_FIT_STATUS
Note: See TracChangeset for help on using the changeset viewer.