IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2007, 2:11:02 PM (19 years ago)
Author:
magnier
Message:
  • added function pointers to pmModel to provide class-dependent functions
  • dropped pmModel*_GetFunction functions (use pmModel->func functions instead)
  • added modelParamsFromPSF functions to model classes
  • changed pmModelGroup to pmModelClass
  • added pmSourceFitSet.[ch]
  • updated pmSourceFitSet to allow variable model classes
  • added functions to add/sub and eval models & sources with an offset between image and chip
  • added function to set a pmModel flux
  • added function to instatiate a pmModel from a pmPSF at a coordinate
  • moved pmPSF I/O to chip->analysis from readout->analysis
  • changed pmPSF I/O function names from *ForPSFmodel to pmPSFmodel*
  • changed pmModel.params_NEW back to pmModel.params
  • changed pmFind*Peaks to pmPeaksIn* (* = Image,Vector)
  • dropped pmCullPeaks (deprecated)
  • changed pmModelSetType to pmModelClassGetType
  • changed pmModelGetType to pmModelClassGetName
  • fixed PGAUSS implementation of modelRadius function
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/models/pmModel_RGAUSS.c

    r14323 r14652  
    2020 *****************************************************************************/
    2121
    22 # define PM_MODEL_FUNC       pmModelFunc_RGAUSS
    23 # define PM_MODEL_FLUX       pmModelFlux_RGAUSS
    24 # define PM_MODEL_GUESS      pmModelGuess_RGAUSS
    25 # define PM_MODEL_LIMITS     pmModelLimits_RGAUSS
    26 # define PM_MODEL_RADIUS     pmModelRadius_RGAUSS
    27 # define PM_MODEL_FROM_PSF   pmModelFromPSF_RGAUSS
    28 # define PM_MODEL_FIT_STATUS pmModelFitStatus_RGAUSS
     22# define PM_MODEL_FUNC            pmModelFunc_RGAUSS
     23# define PM_MODEL_FLUX            pmModelFlux_RGAUSS
     24# define PM_MODEL_GUESS           pmModelGuess_RGAUSS
     25# define PM_MODEL_LIMITS          pmModelLimits_RGAUSS
     26# define PM_MODEL_RADIUS          pmModelRadius_RGAUSS
     27# define PM_MODEL_FROM_PSF        pmModelFromPSF_RGAUSS
     28# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_RGAUSS
     29# define PM_MODEL_FIT_STATUS      pmModelFitStatus_RGAUSS
    2930
    3031psF32 PM_MODEL_FUNC (psVector *deriv,
     
    343344
    344345    // we require these two parameters to exist
    345     assert (psf->params_NEW->n > PM_PAR_YPOS);
    346     assert (psf->params_NEW->n > PM_PAR_XPOS);
    347 
    348     for (int i = 0; i < psf->params_NEW->n; i++) {
    349         if (psf->params_NEW->data[i] == NULL) {
     346    assert (psf->params->n > PM_PAR_YPOS);
     347    assert (psf->params->n > PM_PAR_XPOS);
     348
     349    for (int i = 0; i < psf->params->n; i++) {
     350        if (psf->params->data[i] == NULL) {
    350351            out[i] = in[i];
    351352        } else {
    352             psPolynomial2D *poly = psf->params_NEW->data[i];
     353            psPolynomial2D *poly = psf->params->data[i];
    353354            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    354355        }
     
    365366    // apply the model limits here: this truncates excessive extrapolation
    366367    // XXX do we need to do this still?  should we put in asserts to test?
    367     for (int i = 0; i < psf->params_NEW->n; i++) {
     368    for (int i = 0; i < psf->params->n; i++) {
    368369        // apply the limits to all components or just the psf-model parameters?
    369         if (psf->params_NEW->data[i] == NULL)
     370        if (psf->params->data[i] == NULL)
    370371            continue;
    371372
     
    383384}
    384385
     386// construct the PSF model from the FLT model and the psf
     387// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     388bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     389{
     390    psF32 *PAR = model->params->data.F32;
     391
     392    // we require these two parameters to exist
     393    assert (psf->params->n > PM_PAR_YPOS);
     394    assert (psf->params->n > PM_PAR_XPOS);
     395
     396    PAR[PM_PAR_SKY]  = 0.0;
     397    PAR[PM_PAR_I0]   = Io;
     398    PAR[PM_PAR_XPOS] = Xo;
     399    PAR[PM_PAR_YPOS] = Yo;
     400   
     401    // supply the model-fitted parameters, or copy from the input
     402    for (int i = 0; i < psf->params->n; i++) {
     403        if (i == PM_PAR_SKY) continue;
     404        if (i == PM_PAR_I0) continue;
     405        if (i == PM_PAR_XPOS) continue;
     406        if (i == PM_PAR_YPOS) continue;
     407        psPolynomial2D *poly = psf->params->data[i];
     408        assert (poly);
     409        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     410    }
     411
     412    // the 2D PSF model fits polarization terms (E0,E1,E2)
     413    // convert to shape terms (SXX,SYY,SXY)
     414    // XXX user-defined value for limit?
     415    if (!pmPSF_FitToModel (PAR, 0.1)) {
     416        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     417        return false;
     418    }
     419
     420    // apply the model limits here: this truncates excessive extrapolation
     421    // XXX do we need to do this still?  should we put in asserts to test?
     422    for (int i = 0; i < psf->params->n; i++) {
     423        // apply the limits to all components or just the psf-model parameters?
     424        if (psf->params->data[i] == NULL)
     425            continue;
     426
     427        bool status = true;
     428        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     429        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     430        if (!status) {
     431            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     432            model->flags |= PM_MODEL_STATUS_LIMITS;
     433        }
     434    }
     435    return(true);
     436}
     437
    385438bool PM_MODEL_FIT_STATUS (pmModel *model)
    386439{
     
    411464# undef PM_MODEL_RADIUS
    412465# undef PM_MODEL_FROM_PSF
     466# undef PM_MODEL_PARAMS_FROM_PSF
    413467# undef PM_MODEL_FIT_STATUS
Note: See TracChangeset for help on using the changeset viewer.