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

    r14220 r14652  
    1919 *****************************************************************************/
    2020
    21 # define PM_MODEL_FUNC       pmModelFunc_GAUSS
    22 # define PM_MODEL_FLUX       pmModelFlux_GAUSS
    23 # define PM_MODEL_GUESS      pmModelGuess_GAUSS
    24 # define PM_MODEL_LIMITS     pmModelLimits_GAUSS
    25 # define PM_MODEL_RADIUS     pmModelRadius_GAUSS
    26 # define PM_MODEL_FROM_PSF   pmModelFromPSF_GAUSS
    27 # define PM_MODEL_FIT_STATUS pmModelFitStatus_GAUSS
    28 
     21# define PM_MODEL_FUNC            pmModelFunc_GAUSS
     22# define PM_MODEL_FLUX            pmModelFlux_GAUSS
     23# define PM_MODEL_GUESS           pmModelGuess_GAUSS
     24# define PM_MODEL_LIMITS          pmModelLimits_GAUSS
     25# define PM_MODEL_RADIUS          pmModelRadius_GAUSS
     26# define PM_MODEL_FROM_PSF        pmModelFromPSF_GAUSS
     27# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_GAUSS
     28# define PM_MODEL_FIT_STATUS      pmModelFitStatus_GAUSS
     29
     30// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
    2931psF32 PM_MODEL_FUNC(psVector *deriv,
    3032                    const psVector *params,
     
    3840    psF32 py = Y / PAR[PM_PAR_SYY];
    3941    psF32 z  = PS_SQR(px) + PS_SQR(py) + PAR[PM_PAR_SXY]*X*Y;
     42    assert (z >= 0.0);
     43
    4044    psF32 r  = exp(-z);
    4145    psF32 q  = PAR[PM_PAR_I0]*r;
     
    6165# define AR_MAX 20.0
    6266# define AR_RATIO 0.99
     67
    6368bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta)
    6469{
     
    9398            break;
    9499        case PM_PAR_SXX:
    95             beta_lim = 0.5;
     100            beta_lim = 2.0;
    96101            break;
    97102        case PM_PAR_SYY:
    98             beta_lim = 0.5;
     103            beta_lim = 2.0;
    99104            break;
    100105        case PM_PAR_SXY:
     
    257262bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf)
    258263{
    259 
    260264    psF32 *out = modelPSF->params->data.F32;
    261265    psF32 *in  = modelFLT->params->data.F32;
    262266
    263267    // we require these two parameters to exist
    264     assert (psf->params_NEW->n > PM_PAR_YPOS);
    265     assert (psf->params_NEW->n > PM_PAR_XPOS);
     268    assert (psf->params->n > PM_PAR_YPOS);
     269    assert (psf->params->n > PM_PAR_XPOS);
    266270
    267271    // supply the model-fitted parameters, or copy from the input
    268     for (int i = 0; i < psf->params_NEW->n; i++) {
    269         if (psf->params_NEW->data[i] == NULL) {
     272    for (int i = 0; i < psf->params->n; i++) {
     273        if (psf->params->data[i] == NULL) {
    270274            out[i] = in[i];
    271275        } else {
    272             psPolynomial2D *poly = psf->params_NEW->data[i];
     276            psPolynomial2D *poly = psf->params->data[i];
    273277            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    274278        }
     
    289293    // apply the model limits here: this truncates excessive extrapolation
    290294    // XXX do we need to do this still?  should we put in asserts to test?
    291     for (int i = 0; i < psf->params_NEW->n; i++) {
     295    for (int i = 0; i < psf->params->n; i++) {
    292296        // apply the limits to all components or just the psf-model parameters?
    293         if (psf->params_NEW->data[i] == NULL)
     297        if (psf->params->data[i] == NULL)
    294298            continue;
    295299
     
    306310}
    307311
     312// construct the PSF model from the FLT model and the psf
     313// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     314bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     315{
     316    psF32 *PAR = model->params->data.F32;
     317
     318    // we require these two parameters to exist
     319    assert (psf->params->n > PM_PAR_YPOS);
     320    assert (psf->params->n > PM_PAR_XPOS);
     321
     322    PAR[PM_PAR_SKY]  = 0.0;
     323    PAR[PM_PAR_I0]   = Io;
     324    PAR[PM_PAR_XPOS] = Xo;
     325    PAR[PM_PAR_YPOS] = Yo;
     326   
     327    // supply the model-fitted parameters, or copy from the input
     328    for (int i = 0; i < psf->params->n; i++) {
     329        if (i == PM_PAR_SKY) continue;
     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];
     334        assert (poly);
     335        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     336    }
     337
     338    // the 2D PSF model fits polarization terms (E0,E1,E2)
     339    // convert to shape terms (SXX,SYY,SXY)
     340    // XXX user-defined value for limit?
     341    if (!pmPSF_FitToModel (PAR, 0.1)) {
     342        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     343        return false;
     344    }
     345
     346    // apply the model limits here: this truncates excessive extrapolation
     347    // XXX do we need to do this still?  should we put in asserts to test?
     348    for (int i = 0; i < psf->params->n; i++) {
     349        // apply the limits to all components or just the psf-model parameters?
     350        if (psf->params->data[i] == NULL)
     351            continue;
     352
     353        bool status = true;
     354        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     355        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     356        if (!status) {
     357            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     358            model->flags |= PM_MODEL_STATUS_LIMITS;
     359        }
     360    }
     361    return(true);
     362}
     363
    308364// check the status of the fitted model
    309365// this test is invalid if the parameters are derived
     
    311367bool PM_MODEL_FIT_STATUS (pmModel *model)
    312368{
    313 
    314369    psF32 dP;
    315370    bool  status;
     
    339394# undef PM_MODEL_RADIUS
    340395# undef PM_MODEL_FROM_PSF
     396# undef PM_MODEL_PARAMS_FROM_PSF
    341397# undef PM_MODEL_FIT_STATUS
Note: See TracChangeset for help on using the changeset viewer.