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

    r14345 r14612  
    2323   *****************************************************************************/
    2424
    25 # define PM_MODEL_FUNC       pmModelFunc_SERSIC
    26 # define PM_MODEL_FLUX       pmModelFlux_SERSIC
    27 # define PM_MODEL_GUESS      pmModelGuess_SERSIC
    28 # define PM_MODEL_LIMITS     pmModelLimits_SERSIC
    29 # define PM_MODEL_RADIUS     pmModelRadius_SERSIC
    30 # define PM_MODEL_FROM_PSF   pmModelFromPSF_SERSIC
    31 # define PM_MODEL_FIT_STATUS pmModelFitStatus_SERSIC
     25# define PM_MODEL_FUNC            pmModelFunc_SERSIC
     26# define PM_MODEL_FLUX            pmModelFlux_SERSIC
     27# define PM_MODEL_GUESS           pmModelGuess_SERSIC
     28# define PM_MODEL_LIMITS          pmModelLimits_SERSIC
     29# define PM_MODEL_RADIUS          pmModelRadius_SERSIC
     30# define PM_MODEL_FROM_PSF        pmModelFromPSF_SERSIC
     31# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_SERSIC
     32# define PM_MODEL_FIT_STATUS      pmModelFitStatus_SERSIC
    3233
    3334psF32 PM_MODEL_FUNC (psVector *deriv,
     
    360361
    361362    // we require these two parameters to exist
    362     assert (psf->params_NEW->n > PM_PAR_YPOS);
    363     assert (psf->params_NEW->n > PM_PAR_XPOS);
    364 
    365     for (int i = 0; i < psf->params_NEW->n; i++) {
    366         if (psf->params_NEW->data[i] == NULL) {
     363    assert (psf->params->n > PM_PAR_YPOS);
     364    assert (psf->params->n > PM_PAR_XPOS);
     365
     366    for (int i = 0; i < psf->params->n; i++) {
     367        if (psf->params->data[i] == NULL) {
    367368            out[i] = in[i];
    368369        } else {
    369             psPolynomial2D *poly = psf->params_NEW->data[i];
     370            psPolynomial2D *poly = psf->params->data[i];
    370371            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    371372        }
     
    382383    // apply the model limits here: this truncates excessive extrapolation
    383384    // XXX do we need to do this still?  should we put in asserts to test?
    384     for (int i = 0; i < psf->params_NEW->n; i++) {
     385    for (int i = 0; i < psf->params->n; i++) {
    385386        // apply the limits to all components or just the psf-model parameters?
    386         if (psf->params_NEW->data[i] == NULL)
     387        if (psf->params->data[i] == NULL)
    387388            continue;
    388389
     
    400401}
    401402
     403// construct the PSF model from the FLT model and the psf
     404// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     405bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     406{
     407    psF32 *PAR = model->params->data.F32;
     408
     409    // we require these two parameters to exist
     410    assert (psf->params->n > PM_PAR_YPOS);
     411    assert (psf->params->n > PM_PAR_XPOS);
     412
     413    PAR[PM_PAR_SKY]  = 0.0;
     414    PAR[PM_PAR_I0]   = Io;
     415    PAR[PM_PAR_XPOS] = Xo;
     416    PAR[PM_PAR_YPOS] = Yo;
     417   
     418    // supply the model-fitted parameters, or copy from the input
     419    for (int i = 0; i < psf->params->n; i++) {
     420        if (i == PM_PAR_SKY) continue;
     421        if (i == PM_PAR_I0) continue;
     422        if (i == PM_PAR_XPOS) continue;
     423        if (i == PM_PAR_YPOS) continue;
     424        psPolynomial2D *poly = psf->params->data[i];
     425        assert (poly);
     426        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     427    }
     428
     429    // the 2D PSF model fits polarization terms (E0,E1,E2)
     430    // convert to shape terms (SXX,SYY,SXY)
     431    // XXX user-defined value for limit?
     432    if (!pmPSF_FitToModel (PAR, 0.1)) {
     433        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     434        return false;
     435    }
     436
     437    // apply the model limits here: this truncates excessive extrapolation
     438    // XXX do we need to do this still?  should we put in asserts to test?
     439    for (int i = 0; i < psf->params->n; i++) {
     440        // apply the limits to all components or just the psf-model parameters?
     441        if (psf->params->data[i] == NULL)
     442            continue;
     443
     444        bool status = true;
     445        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     446        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     447        if (!status) {
     448            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     449            model->flags |= PM_MODEL_STATUS_LIMITS;
     450        }
     451    }
     452    return(true);
     453}
     454
    402455bool PM_MODEL_FIT_STATUS (pmModel *model)
    403456{
     
    428481# undef PM_MODEL_RADIUS
    429482# undef PM_MODEL_FROM_PSF
     483# undef PM_MODEL_PARAMS_FROM_PSF
    430484# undef PM_MODEL_FIT_STATUS
Note: See TracChangeset for help on using the changeset viewer.