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_QGAUSS.c

    r14344 r14652  
    2020   *****************************************************************************/
    2121
    22 # define PM_MODEL_FUNC       pmModelFunc_QGAUSS
    23 # define PM_MODEL_FLUX       pmModelFlux_QGAUSS
    24 # define PM_MODEL_GUESS      pmModelGuess_QGAUSS
    25 # define PM_MODEL_LIMITS     pmModelLimits_QGAUSS
    26 # define PM_MODEL_RADIUS     pmModelRadius_QGAUSS
    27 # define PM_MODEL_FROM_PSF   pmModelFromPSF_QGAUSS
    28 # define PM_MODEL_FIT_STATUS pmModelFitStatus_QGAUSS
     22# define PM_MODEL_FUNC            pmModelFunc_QGAUSS
     23# define PM_MODEL_FLUX            pmModelFlux_QGAUSS
     24# define PM_MODEL_GUESS           pmModelGuess_QGAUSS
     25# define PM_MODEL_LIMITS          pmModelLimits_QGAUSS
     26# define PM_MODEL_RADIUS          pmModelRadius_QGAUSS
     27# define PM_MODEL_FROM_PSF        pmModelFromPSF_QGAUSS
     28# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_QGAUSS
     29# define PM_MODEL_FIT_STATUS      pmModelFitStatus_QGAUSS
    2930
    3031psF32 PM_MODEL_FUNC (psVector *deriv,
     
    350351
    351352    // we require these two parameters to exist
    352     assert (psf->params_NEW->n > PM_PAR_YPOS);
    353     assert (psf->params_NEW->n > PM_PAR_XPOS);
    354 
    355     for (int i = 0; i < psf->params_NEW->n; i++) {
    356         if (psf->params_NEW->data[i] == NULL) {
     353    assert (psf->params->n > PM_PAR_YPOS);
     354    assert (psf->params->n > PM_PAR_XPOS);
     355
     356    for (int i = 0; i < psf->params->n; i++) {
     357        if (psf->params->data[i] == NULL) {
    357358            out[i] = in[i];
    358359        } else {
    359             psPolynomial2D *poly = psf->params_NEW->data[i];
     360            psPolynomial2D *poly = psf->params->data[i];
    360361            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    361362        }
     
    372373    // apply the model limits here: this truncates excessive extrapolation
    373374    // XXX do we need to do this still?  should we put in asserts to test?
    374     for (int i = 0; i < psf->params_NEW->n; i++) {
     375    for (int i = 0; i < psf->params->n; i++) {
    375376        // apply the limits to all components or just the psf-model parameters?
    376         if (psf->params_NEW->data[i] == NULL)
     377        if (psf->params->data[i] == NULL)
    377378            continue;
    378379
     
    390391}
    391392
     393// construct the PSF model from the FLT model and the psf
     394// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     395bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     396{
     397    psF32 *PAR = model->params->data.F32;
     398
     399    // we require these two parameters to exist
     400    assert (psf->params->n > PM_PAR_YPOS);
     401    assert (psf->params->n > PM_PAR_XPOS);
     402
     403    PAR[PM_PAR_SKY]  = 0.0;
     404    PAR[PM_PAR_I0]   = Io;
     405    PAR[PM_PAR_XPOS] = Xo;
     406    PAR[PM_PAR_YPOS] = Yo;
     407   
     408    // supply the model-fitted parameters, or copy from the input
     409    for (int i = 0; i < psf->params->n; i++) {
     410        if (i == PM_PAR_SKY) continue;
     411        if (i == PM_PAR_I0) continue;
     412        if (i == PM_PAR_XPOS) continue;
     413        if (i == PM_PAR_YPOS) continue;
     414        psPolynomial2D *poly = psf->params->data[i];
     415        assert (poly);
     416        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     417    }
     418
     419    // the 2D PSF model fits polarization terms (E0,E1,E2)
     420    // convert to shape terms (SXX,SYY,SXY)
     421    // XXX user-defined value for limit?
     422    if (!pmPSF_FitToModel (PAR, 0.1)) {
     423        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     424        return false;
     425    }
     426
     427    // apply the model limits here: this truncates excessive extrapolation
     428    // XXX do we need to do this still?  should we put in asserts to test?
     429    for (int i = 0; i < psf->params->n; i++) {
     430        // apply the limits to all components or just the psf-model parameters?
     431        if (psf->params->data[i] == NULL)
     432            continue;
     433
     434        bool status = true;
     435        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     436        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     437        if (!status) {
     438            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     439            model->flags |= PM_MODEL_STATUS_LIMITS;
     440        }
     441    }
     442    return(true);
     443}
     444
    392445bool PM_MODEL_FIT_STATUS (pmModel *model)
    393446{
     
    418471# undef PM_MODEL_RADIUS
    419472# undef PM_MODEL_FROM_PSF
     473# undef PM_MODEL_PARAMS_FROM_PSF
    420474# undef PM_MODEL_FIT_STATUS
Note: See TracChangeset for help on using the changeset viewer.