IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 11, 2010, 3:19:38 PM (16 years ago)
Author:
eugene
Message:

add maxTol and maxChisqDOF to psMin to allow for better control over fit success and convergence; add options to fit only index or without index

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c

    r28643 r28656  
    4444void pmSourceFitOptionsFree(pmSourceFitOptions *opt)
    4545{
    46         return;
     46    return;
    4747}
    4848
     
    5353
    5454    opt->mode = PM_SOURCE_FIT_PSF;
    55     opt->nIter = 15;
    56     opt->tol = 0.1;
    57     opt->weight = 1.0;
     55    opt->nIter  = 15;
     56    opt->minTol = 0.01;
     57    opt->maxTol = 1.00;
     58    opt->weight = 1.00;
     59    opt->maxChisqDOF = NAN;
    5860    opt->poissonErrors = true;
    5961
     
    103105            // skip nan values in image
    104106            if (!isfinite(source->variance->data.F32[i][j])) {
    105               fprintf (stderr, "impossible! %x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal);
    106               continue;
     107                fprintf (stderr, "impossible! %x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal);
     108                continue;
    107109            }
    108110
     
    142144    int nParams = 0;
    143145    switch (options->mode) {
    144     case PM_SOURCE_FIT_NORM:
     146      case PM_SOURCE_FIT_NORM:
    145147        // NORM-only model fits only source normalization (Io)
    146148        nParams = 1;
     
    148150        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0;
    149151        break;
    150     case PM_SOURCE_FIT_PSF:
     152      case PM_SOURCE_FIT_PSF:
    151153        // PSF model only fits x,y,Io
    152154        nParams = 3;
     
    156158        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_YPOS] = 0;
    157159        break;
    158     case PM_SOURCE_FIT_EXT:
     160      case PM_SOURCE_FIT_EXT:
    159161        // EXT model fits all params (except sky)
    160162        nParams = params->n - 1;
     
    162164        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
    163165        break;
    164     default:
    165         psAbort("invalid fitting mode");
     166      case PM_SOURCE_FIT_INDEX:
     167        // PSF model only fits Io, index (PAR7) -- only Io for models with < 8 params
     168        psVectorInit (constraint->paramMask, 1);
     169        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0;
     170        if (params->n == 7) {
     171            nParams = 1;
     172        } else {
     173            nParams = 2;
     174            constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_7] = 0;
     175        }
     176        break;
     177      case PM_SOURCE_FIT_NO_INDEX:
     178        // PSF model only fits Io, index (PAR7) -- only Io for models with < 8 params
     179        psVectorInit (constraint->paramMask, 0);
     180        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
     181        if (params->n == 7) {
     182            nParams = params->n - 1;
     183        } else {
     184            nParams = params->n - 2;
     185            constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_7] = 1;
     186        }
     187        break;
     188      default:
     189        psAbort("invalid fitting mode");
    166190    }
    167191    // force the floating parameters to fall within the contraint ranges
    168192    for (int i = 0; i < params->n; i++) {
    169         model->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);
    170         model->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);
     193        model->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);
     194        model->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);
    171195    }
    172196
     
    181205    }
    182206
    183     psMinimization *myMin = psMinimizationAlloc (options->nIter, options->tol);
     207    psMinimization *myMin = psMinimizationAlloc (options->nIter, options->minTol, options->maxTol);
    184208
    185209    psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32);
     
    202226    model->flags |= PM_MODEL_STATUS_FITTED;
    203227    if (!fitStatus) model->flags |= PM_MODEL_STATUS_NONCONVERGE;
     228    if (myMin->lastDelta > myMin->minTol) model->flags |= PM_MODEL_STATUS_WEAK_FIT;
    204229
    205230    // get the Gauss-Newton distance for fixed model parameters
Note: See TracChangeset for help on using the changeset viewer.