IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 22, 2007, 2:55:49 PM (19 years ago)
Author:
magnier
Message:

adjusted pmModel.h to allow pmModel to use functions which use pmModel
as an argument.

adjusted the order of the pmPSF.h entries to allow that as an argument
as well

changed pmPSF I/O functions to load/save the psf on the
chip->analysis, not the readout->analysis

fixed the modelRadius function for PGAUSS

File:
1 edited

Legend:

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

    r14544 r14612  
    2828# define PM_MODEL_FIT_STATUS      pmModelFitStatus_GAUSS
    2929
     30// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
    3031psF32 PM_MODEL_FUNC(psVector *deriv,
    3132                    const psVector *params,
     
    3940    psF32 py = Y / PAR[PM_PAR_SYY];
    4041    psF32 z  = PS_SQR(px) + PS_SQR(py) + PAR[PM_PAR_SXY]*X*Y;
     42    assert (z >= 0.0);
     43
    4144    psF32 r  = exp(-z);
    4245    psF32 q  = PAR[PM_PAR_I0]*r;
     
    6265# define AR_MAX 20.0
    6366# define AR_RATIO 0.99
     67
    6468bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta)
    6569{
     
    9498            break;
    9599        case PM_PAR_SXX:
    96             beta_lim = 0.5;
     100            beta_lim = 2.0;
    97101            break;
    98102        case PM_PAR_SYY:
    99             beta_lim = 0.5;
     103            beta_lim = 2.0;
    100104            break;
    101105        case PM_PAR_SXY:
     
    186190
    187191// make an initial guess for parameters
    188 bool PM_MODEL_GUESS (void *inModel, void *inSource)
    189 {
    190     pmModel *model = inModel;
    191     pmSource *source = inSource;
    192 
     192bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
     193{
    193194    pmMoments *moments = source->moments;
    194195    psF32     *PAR  = model->params->data.F32;
     
    259260
    260261// construct the PSF model from the FLT model and the psf
    261 bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF)
    262 {
    263     pmModel *modelPSF = inModelPSF;
    264     pmModel *modelFLT = inModelFLT;
    265     pmPSF *psf = inPSF;
    266 
     262bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf)
     263{
    267264    psF32 *out = modelPSF->params->data.F32;
    268265    psF32 *in  = modelFLT->params->data.F32;
    269266
    270267    // we require these two parameters to exist
    271     assert (psf->params_NEW->n > PM_PAR_YPOS);
    272     assert (psf->params_NEW->n > PM_PAR_XPOS);
     268    assert (psf->params->n > PM_PAR_YPOS);
     269    assert (psf->params->n > PM_PAR_XPOS);
    273270
    274271    // supply the model-fitted parameters, or copy from the input
    275     for (int i = 0; i < psf->params_NEW->n; i++) {
    276         if (psf->params_NEW->data[i] == NULL) {
     272    for (int i = 0; i < psf->params->n; i++) {
     273        if (psf->params->data[i] == NULL) {
    277274            out[i] = in[i];
    278275        } else {
    279             psPolynomial2D *poly = psf->params_NEW->data[i];
     276            psPolynomial2D *poly = psf->params->data[i];
    280277            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    281278        }
     
    296293    // apply the model limits here: this truncates excessive extrapolation
    297294    // XXX do we need to do this still?  should we put in asserts to test?
    298     for (int i = 0; i < psf->params_NEW->n; i++) {
     295    for (int i = 0; i < psf->params->n; i++) {
    299296        // apply the limits to all components or just the psf-model parameters?
    300         if (psf->params_NEW->data[i] == NULL)
     297        if (psf->params->data[i] == NULL)
    301298            continue;
    302299
     
    315312// construct the PSF model from the FLT model and the psf
    316313// XXX is this sufficiently general do be a global function, not a pmModelClass function?
    317 bool 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 
     314bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     315{
    322316    psF32 *PAR = model->params->data.F32;
    323317
    324318    // 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);
     319    assert (psf->params->n > PM_PAR_YPOS);
     320    assert (psf->params->n > PM_PAR_XPOS);
    327321
    328322    PAR[PM_PAR_SKY]  = 0.0;
     
    332326   
    333327    // supply the model-fitted parameters, or copy from the input
    334     for (int i = 0; i < psf->params_NEW->n; i++) {
     328    for (int i = 0; i < psf->params->n; i++) {
    335329        if (i == PM_PAR_SKY) continue;
    336         psPolynomial2D *poly = psf->params_NEW->data[i];
     330        if (i == PM_PAR_I0) continue;
     331        if (i == PM_PAR_XPOS) continue;
     332        if (i == PM_PAR_YPOS) continue;
     333        psPolynomial2D *poly = psf->params->data[i];
    337334        assert (poly);
    338335        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     
    349346    // apply the model limits here: this truncates excessive extrapolation
    350347    // 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++) {
     348    for (int i = 0; i < psf->params->n; i++) {
    352349        // apply the limits to all components or just the psf-model parameters?
    353         if (psf->params_NEW->data[i] == NULL)
     350        if (psf->params->data[i] == NULL)
    354351            continue;
    355352
     
    368365// this test is invalid if the parameters are derived
    369366// from the PSF model
    370 bool PM_MODEL_FIT_STATUS (void *inModel)
    371 {
    372     pmModel *model = inModel;
    373 
     367bool PM_MODEL_FIT_STATUS (pmModel *model)
     368{
    374369    psF32 dP;
    375370    bool  status;
Note: See TracChangeset for help on using the changeset viewer.