IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 22, 2007, 2:55:49 PM (19 years ago)
Author:
magnier
Message:

adjusted pmModel.h to allow pmModel to use functions which use pmModel
as an argument.

adjusted the order of the pmPSF.h entries to allow that as an argument
as well

changed pmPSF I/O functions to load/save the psf on the
chip->analysis, not the readout->analysis

fixed the modelRadius function for PGAUSS

File:
1 edited

Legend:

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

    r14323 r14612  
    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.