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/pmSourceFitModel.c

    r13932 r14544  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-21 22:58:11 $
     8 *  @version $Revision: 1.24.4.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-17 21:01:59 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030#include "pmPSF.h"
    3131#include "pmSource.h"
    32 #include "pmModelGroup.h"
     32#include "pmModelClass.h"
    3333#include "pmSourceFitModel.h"
    3434
     
    116116    psVector *dparams = model->dparams;
    117117
    118     pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
    119     if (!modelFunc)
    120         psAbort("invalid model function");
    121     pmModelLimits checkLimits = pmModelLimits_GetFunction (model->type);
    122     if (!checkLimits)
    123         psAbort("invalid model limits function");
    124 
    125118    // create the minimization constraints
    126119    psMinConstraint *constraint = psMinConstraintAlloc();
    127120    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
    128     constraint->checkLimits = checkLimits;
     121    constraint->checkLimits = model->modelLimits;
    129122
    130123    // set parameter mask based on fitting mode
     
    156149    // force the floating parameters to fall within the contraint ranges
    157150    for (int i = 0; i < params->n; i++) {
    158         checkLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);
    159         checkLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);
     151        model->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);
     152        model->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);
    160153    }
    161154
     
    174167    psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32);
    175168
    176     fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, modelFunc);
     169    fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, model->modelFunc);
    177170    for (int i = 0; i < dparams->n; i++) {
    178171        if (psTraceGetLevel("psModules.objects") >= 4) {
     
    201194            altmask->data.U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1;
    202195        }
    203         psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, modelFunc);
     196        psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model->modelFunc);
    204197        for (int i = 0; i < dparams->n; i++) {
    205198            if (!constraint->paramMask->data.U8[i])
     
    236229    return(rc);
    237230}
     231
     232# define SKIP_FIT_SET 1
     233# if (SKIP_FIT_SET)
     234
     235bool pmSourceFitSet (pmSource *source,
     236                     psArray *modelSet,
     237                     pmSourceFitMode mode,
     238                     psMaskType maskVal)
     239{
     240    psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__);
     241    PS_ASSERT_PTR_NON_NULL(source, false);
     242    PS_ASSERT_PTR_NON_NULL(source->pixels, false);
     243    PS_ASSERT_PTR_NON_NULL(source->maskObj, false);
     244    PS_ASSERT_PTR_NON_NULL(source->weight, false);
     245
     246    return true;
     247}
     248
     249# else
    238250
    239251/********************* Source Model Set Functions ***************************/
     
    255267    oneModelFunc = pmModelFunc_GetFunction (type);
    256268    oneCheckLimits = pmModelLimits_GetFunction (type);
    257     nOnePar = pmModelParameterCount (type);
     269    nOnePar = pmModelClassParameterCount (type);
    258270
    259271    onePar = psVectorAlloc (nOnePar, PS_DATA_F32);
     
    567579}
    568580
     581# endif
Note: See TracChangeset for help on using the changeset viewer.