IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28656


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

Location:
branches/eam_branches/ipp-20100621/psModules/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/psModules/src/detrend/pmShutterCorrection.c

    r28405 r28656  
    302302    PS_ASSERT_PTR_NON_NULL(guess, NULL);
    303303
    304     psMinimization *minInfo = psMinimizationAlloc(15, 0.1); // Minimization information
     304    psMinimization *minInfo = psMinimizationAlloc(15, 0.1, 1.0); // Minimization information
    305305
    306306    psVector *params = psVectorAlloc (3, PS_TYPE_F32); // Fitting parameters
  • branches/eam_branches/ipp-20100621/psModules/src/imcombine/pmPSFEnvelope.c

    r28643 r28656  
    416416    options->fitOptions                = pmSourceFitOptionsAlloc();
    417417    options->fitOptions->nIter         = SOURCE_FIT_ITERATIONS;
    418     options->fitOptions->tol           = 0.01;
     418    options->fitOptions->minTol        = 0.01;
     419    options->fitOptions->maxTol        = 1.00;
    419420    options->fitOptions->poissonErrors = true;
    420421    options->fitOptions->weight        = VARIANCE_VAL;
  • branches/eam_branches/ipp-20100621/psModules/src/objects/models/pmModel_SERSIC.c

    r28643 r28656  
    243243
    244244    // the other parameters depend on the guess for PAR_7
    245     if (0) {
    246     } else {
     245    if (!isfinite(PAR[PM_PAR_7])) {
    247246        PAR[PM_PAR_7]    = 0.25;
    248247        // PAR[PM_PAR_7]    = 0.125;
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmModel.c

    r28643 r28656  
    8181
    8282    for (psS32 i = 0; i < tmp->params->n; i++) {
    83         tmp->params->data.F32[i] = 0.0;
    84         tmp->dparams->data.F32[i] = 0.0;
     83        tmp->params->data.F32[i] = NAN;
     84        tmp->dparams->data.F32[i] = NAN;
    8585    }
    8686
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmModelFuncs.h

    r28643 r28656  
    4141    PM_MODEL_STATUS_OFFIMAGE     = 0x04, ///< model fit drove out of range
    4242    PM_MODEL_STATUS_BADARGS      = 0x08, ///< model fit called with invalid args
    43     PM_MODEL_STATUS_LIMITS       = 0x10  ///< model parameters hit limits
     43    PM_MODEL_STATUS_LIMITS       = 0x10, ///< model parameters hit limits
     44    PM_MODEL_STATUS_WEAK_FIT     = 0x20, ///< model fit met loose tolerance, but not tight tolerance
    4445} pmModelStatus;
    4546
  • 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
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.h

    r28643 r28656  
    1919    PM_SOURCE_FIT_EXT,
    2020    PM_SOURCE_FIT_PSF_AND_SKY,
    21     PM_SOURCE_FIT_EXT_AND_SKY
     21    PM_SOURCE_FIT_EXT_AND_SKY,
     22    PM_SOURCE_FIT_INDEX,
     23    PM_SOURCE_FIT_NO_INDEX,
    2224} pmSourceFitMode;
    2325
     
    2527    pmSourceFitMode mode;               ///< optionally fit all or a subset of parameters
    2628    float nIter;                        ///< max number of allowed iterations
    27     float tol;                          ///< convergence criterion
     29    float minTol;                       ///< convergence criterion
     30    float maxTol;                       ///< convergence criterion
     31    float maxChisqDOF;                  ///< convergence criterion
    2832    float weight;                       ///< use this weight for constant-weight fits
    2933    bool poissonErrors;                 ///< use poisson errors for fits?
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitSet.c

    r28643 r28656  
    541541    }
    542542
    543     psMinimization *myMin = psMinimizationAlloc (options->nIter, options->tol);
     543    psMinimization *myMin = psMinimizationAlloc (options->nIter, options->minTol, options->maxTol);
    544544
    545545    psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32);
Note: See TracChangeset for help on using the changeset viewer.