IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14612


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

Location:
branches/eam_branch_20070817/psModules/src/objects
Files:
36 edited

Legend:

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

    r14544 r14612  
    2828# define PM_MODEL_FIT_STATUS      pmModelFitStatus_GAUSS
    2929
     30// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
    3031psF32 PM_MODEL_FUNC(psVector *deriv,
    3132                    const psVector *params,
     
    3940    psF32 py = Y / PAR[PM_PAR_SYY];
    4041    psF32 z  = PS_SQR(px) + PS_SQR(py) + PAR[PM_PAR_SXY]*X*Y;
     42    assert (z >= 0.0);
     43
    4144    psF32 r  = exp(-z);
    4245    psF32 q  = PAR[PM_PAR_I0]*r;
     
    6265# define AR_MAX 20.0
    6366# define AR_RATIO 0.99
     67
    6468bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta)
    6569{
     
    9498            break;
    9599        case PM_PAR_SXX:
    96             beta_lim = 0.5;
     100            beta_lim = 2.0;
    97101            break;
    98102        case PM_PAR_SYY:
    99             beta_lim = 0.5;
     103            beta_lim = 2.0;
    100104            break;
    101105        case PM_PAR_SXY:
     
    186190
    187191// make an initial guess for parameters
    188 bool PM_MODEL_GUESS (void *inModel, void *inSource)
    189 {
    190     pmModel *model = inModel;
    191     pmSource *source = inSource;
    192 
     192bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
     193{
    193194    pmMoments *moments = source->moments;
    194195    psF32     *PAR  = model->params->data.F32;
     
    259260
    260261// construct the PSF model from the FLT model and the psf
    261 bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF)
    262 {
    263     pmModel *modelPSF = inModelPSF;
    264     pmModel *modelFLT = inModelFLT;
    265     pmPSF *psf = inPSF;
    266 
     262bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf)
     263{
    267264    psF32 *out = modelPSF->params->data.F32;
    268265    psF32 *in  = modelFLT->params->data.F32;
    269266
    270267    // we require these two parameters to exist
    271     assert (psf->params_NEW->n > PM_PAR_YPOS);
    272     assert (psf->params_NEW->n > PM_PAR_XPOS);
     268    assert (psf->params->n > PM_PAR_YPOS);
     269    assert (psf->params->n > PM_PAR_XPOS);
    273270
    274271    // supply the model-fitted parameters, or copy from the input
    275     for (int i = 0; i < psf->params_NEW->n; i++) {
    276         if (psf->params_NEW->data[i] == NULL) {
     272    for (int i = 0; i < psf->params->n; i++) {
     273        if (psf->params->data[i] == NULL) {
    277274            out[i] = in[i];
    278275        } else {
    279             psPolynomial2D *poly = psf->params_NEW->data[i];
     276            psPolynomial2D *poly = psf->params->data[i];
    280277            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    281278        }
     
    296293    // apply the model limits here: this truncates excessive extrapolation
    297294    // XXX do we need to do this still?  should we put in asserts to test?
    298     for (int i = 0; i < psf->params_NEW->n; i++) {
     295    for (int i = 0; i < psf->params->n; i++) {
    299296        // apply the limits to all components or just the psf-model parameters?
    300         if (psf->params_NEW->data[i] == NULL)
     297        if (psf->params->data[i] == NULL)
    301298            continue;
    302299
     
    315312// construct the PSF model from the FLT model and the psf
    316313// XXX is this sufficiently general do be a global function, not a pmModelClass function?
    317 bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io)
    318 {
    319     pmModel *model = inModel;
    320     pmPSF *psf = inPSF;
    321 
     314bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     315{
    322316    psF32 *PAR = model->params->data.F32;
    323317
    324318    // we require these two parameters to exist
    325     assert (psf->params_NEW->n > PM_PAR_YPOS);
    326     assert (psf->params_NEW->n > PM_PAR_XPOS);
     319    assert (psf->params->n > PM_PAR_YPOS);
     320    assert (psf->params->n > PM_PAR_XPOS);
    327321
    328322    PAR[PM_PAR_SKY]  = 0.0;
     
    332326   
    333327    // supply the model-fitted parameters, or copy from the input
    334     for (int i = 0; i < psf->params_NEW->n; i++) {
     328    for (int i = 0; i < psf->params->n; i++) {
    335329        if (i == PM_PAR_SKY) continue;
    336         psPolynomial2D *poly = psf->params_NEW->data[i];
     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];
    337334        assert (poly);
    338335        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     
    349346    // apply the model limits here: this truncates excessive extrapolation
    350347    // XXX do we need to do this still?  should we put in asserts to test?
    351     for (int i = 0; i < psf->params_NEW->n; i++) {
     348    for (int i = 0; i < psf->params->n; i++) {
    352349        // apply the limits to all components or just the psf-model parameters?
    353         if (psf->params_NEW->data[i] == NULL)
     350        if (psf->params->data[i] == NULL)
    354351            continue;
    355352
     
    368365// this test is invalid if the parameters are derived
    369366// from the PSF model
    370 bool PM_MODEL_FIT_STATUS (void *inModel)
    371 {
    372     pmModel *model = inModel;
    373 
     367bool PM_MODEL_FIT_STATUS (pmModel *model)
     368{
    374369    psF32 dP;
    375370    bool  status;
  • branches/eam_branch_20070817/psModules/src/objects/models/pmModel_PGAUSS.c

    r14220 r14612  
    1919 *****************************************************************************/
    2020
    21 # define PM_MODEL_FUNC       pmModelFunc_PGAUSS
    22 # define PM_MODEL_FLUX       pmModelFlux_PGAUSS
    23 # define PM_MODEL_GUESS      pmModelGuess_PGAUSS
    24 # define PM_MODEL_LIMITS     pmModelLimits_PGAUSS
    25 # define PM_MODEL_RADIUS     pmModelRadius_PGAUSS
    26 # define PM_MODEL_FROM_PSF   pmModelFromPSF_PGAUSS
    27 # define PM_MODEL_FIT_STATUS pmModelFitStatus_PGAUSS
     21# define PM_MODEL_FUNC            pmModelFunc_PGAUSS
     22# define PM_MODEL_FLUX            pmModelFlux_PGAUSS
     23# define PM_MODEL_GUESS           pmModelGuess_PGAUSS
     24# define PM_MODEL_LIMITS          pmModelLimits_PGAUSS
     25# define PM_MODEL_RADIUS          pmModelRadius_PGAUSS
     26# define PM_MODEL_FROM_PSF        pmModelFromPSF_PGAUSS
     27# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_PGAUSS
     28# define PM_MODEL_FIT_STATUS      pmModelFitStatus_PGAUSS
    2829
    2930// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     
    6667# define AR_RATIO 0.99
    6768
    68 // we constraint limits by the min valid minor axis:
    69 # define MIN_MINOR_AXIS 0.5
    70 
    71 // f3 = (s_b^-2 - s_a^-2); F3_SQ_MAX is MIN_MINOR_AXIS^-4
    72 # define F3_SQ_MAX 16.0
    73 
    74 static float saveParams[8];
    75 
    7669bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta)
    7770{
     
    150143            psAbort("invalid parameter %d for param min test", nParam);
    151144        }
    152         saveParams[nParam] = params[nParam];
    153145        if (params[nParam] < params_min) {
    154146            params[nParam] = params_min;
     
    184176            psAbort("invalid parameter %d for param max test", nParam);
    185177        }
    186         saveParams[nParam] = params[nParam];
    187178        if (params[nParam] > params_max) {
    188179            params[nParam] = params_max;
     
    263254psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux)
    264255{
     256    psF64 z, f;
     257    int Nstep = 0;
    265258    psEllipseShape shape;
    266259
     
    280273    // this estimates the radius assuming f(z) is roughly exp(-z)
    281274    psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
    282     psF64 radius = axes.major * sqrt (2.0 * log(PAR[PM_PAR_I0] / flux));
     275    psF64 sigma = axes.major;
     276
     277    psF64 limit = flux / PAR[PM_PAR_I0];
     278
     279    // use the fact that f is monotonically decreasing
     280    z = 0;
     281    Nstep = 0;
     282
     283    // choose a z value guaranteed to be beyond our limit
     284    float z0 = pow((1.0 / limit), (1.0 / 3.0));
     285    float z1 = (1.0 / limit);
     286    z1 = PS_MAX (z0, z1);
     287    z0 = 0.0;
     288
     289    // perform a type of bisection to find the value
     290    float f0 = 1.0 / (1 + z0 + z0*z0/2.0 + z0*z0*z0/6.0);
     291    float f1 = 1.0 / (1 + z1 + z1*z1/2.0 + z1*z1*z1/6.0);
     292    while ((Nstep < 10) && (fabs(z1 - z0) > 0.5)) {
     293        z = 0.5*(z0 + z1);
     294        f = 1.0 / (1 + z + z*z/2.0 + z*z*z/6.0);
     295        if (f > limit) {
     296            z0 = z;
     297            f0 = f;
     298        } else {
     299            z1 = z;
     300            f1 = f;
     301        }
     302        Nstep ++;
     303    }
     304    psF64 radius = sigma * sqrt (2.0 * z);
     305
     306    // psF64 radius = axes.major * sqrt (2.0 * log(PAR[PM_PAR_I0] / flux));
    283307
    284308    if (isnan(radius))
     
    297321
    298322    // we require these two parameters to exist
    299     assert (psf->params_NEW->n > PM_PAR_YPOS);
    300     assert (psf->params_NEW->n > PM_PAR_XPOS);
    301 
    302     for (int i = 0; i < psf->params_NEW->n; i++) {
    303         if (psf->params_NEW->data[i] == NULL) {
     323    assert (psf->params->n > PM_PAR_YPOS);
     324    assert (psf->params->n > PM_PAR_XPOS);
     325
     326    for (int i = 0; i < psf->params->n; i++) {
     327        if (psf->params->data[i] == NULL) {
    304328            out[i] = in[i];
    305329        } else {
    306             psPolynomial2D *poly = psf->params_NEW->data[i];
     330            psPolynomial2D *poly = psf->params->data[i];
    307331            out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);
    308332        }
     
    322346    // apply the model limits here: this truncates excessive extrapolation
    323347    // XXX do we need to do this still?  should we put in asserts to test?
    324     for (int i = 0; i < psf->params_NEW->n; i++) {
     348    for (int i = 0; i < psf->params->n; i++) {
    325349        // apply the limits to all components or just the psf-model parameters?
    326         if (psf->params_NEW->data[i] == NULL)
     350        if (psf->params->data[i] == NULL)
    327351            continue;
    328352
     
    339363}
    340364
     365// construct the PSF model from the FLT model and the psf
     366// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     367bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io)
     368{
     369    psF32 *PAR = model->params->data.F32;
     370
     371    // we require these two parameters to exist
     372    assert (psf->params->n > PM_PAR_YPOS);
     373    assert (psf->params->n > PM_PAR_XPOS);
     374
     375    PAR[PM_PAR_SKY]  = 0.0;
     376    PAR[PM_PAR_I0]   = Io;
     377    PAR[PM_PAR_XPOS] = Xo;
     378    PAR[PM_PAR_YPOS] = Yo;
     379   
     380    // supply the model-fitted parameters, or copy from the input
     381    for (int i = 0; i < psf->params->n; i++) {
     382        if (i == PM_PAR_SKY) continue;
     383        if (i == PM_PAR_I0) continue;
     384        if (i == PM_PAR_XPOS) continue;
     385        if (i == PM_PAR_YPOS) continue;
     386        psPolynomial2D *poly = psf->params->data[i];
     387        assert (poly);
     388        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     389    }
     390
     391    // the 2D PSF model fits polarization terms (E0,E1,E2)
     392    // convert to shape terms (SXX,SYY,SXY)
     393    // XXX user-defined value for limit?
     394    if (!pmPSF_FitToModel (PAR, 0.1)) {
     395        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     396        return false;
     397    }
     398
     399    // apply the model limits here: this truncates excessive extrapolation
     400    // XXX do we need to do this still?  should we put in asserts to test?
     401    for (int i = 0; i < psf->params->n; i++) {
     402        // apply the limits to all components or just the psf-model parameters?
     403        if (psf->params->data[i] == NULL)
     404            continue;
     405
     406        bool status = true;
     407        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     408        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     409        if (!status) {
     410            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     411            model->flags |= PM_MODEL_STATUS_LIMITS;
     412        }
     413    }
     414    return(true);
     415}
     416
    341417bool PM_MODEL_FIT_STATUS (pmModel *model)
    342418{
     
    367443# undef PM_MODEL_RADIUS
    368444# undef PM_MODEL_FROM_PSF
     445# undef PM_MODEL_PARAMS_FROM_PSF
    369446# undef PM_MODEL_FIT_STATUS
  • branches/eam_branch_20070817/psModules/src/objects/models/pmModel_QGAUSS.c

    r14344 r14612  
    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
  • 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
  • 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
  • branches/eam_branch_20070817/psModules/src/objects/pmGrowthCurve.c

    r12949 r14612  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-04-21 19:47:14 $
     7 *  @version $Revision: 1.10.8.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-08-23 00:55:49 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "pmMoments.h"
    2424#include "pmResiduals.h"
     25#include "pmGrowthCurve.h"
     26#include "pmPSF.h"
    2527#include "pmModel.h"
    2628#include "pmSource.h"
    27 #include "pmGrowthCurve.h"
    28 #include "pmPSF.h"
    2929#include "psVectorBracket.h"
    3030
  • branches/eam_branch_20070817/psModules/src/objects/pmModel.c

    r14544 r14612  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.13.6.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-17 21:01:59 $
     8 *  @version $Revision: 1.13.6.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121#include <string.h>
    2222#include <pslib.h>
     23#include "pmHDU.h"
     24#include "pmFPA.h"
    2325#include "pmResiduals.h"
     26#include "pmGrowthCurve.h"
     27#include "pmPSF.h"
    2428#include "pmModel.h"
    2529#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmModel.h

    r14546 r14612  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.11.6.2 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-08-20 01:58:16 $
     7 * @version $Revision: 1.11.6.3 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-08-23 00:55:49 $
    99 *
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1414# define PM_MODEL_H
    1515
    16 # define TMP_PSF_TYPE void
    17 # define TMP_MODEL_TYPE void
    18 # define TMP_SOURCE_TYPE void
    19 
    2016/// @addtogroup Objects Object Detection / Analysis Functions
    2117/// @{
     
    2319/* pointers for the functions types below are supplied to each pmModel, and can be used by
    2420   the programmer without needing to know the model class */
    25 
    26 // type of model carried by the pmModel structure
    27 typedef int pmModelType;
    2821
    2922typedef enum {
     
    4841} pmModelOpMode;
    4942
     43typedef struct pmModel pmModel;
     44typedef struct pmSource pmSource;
     45
    5046//  This function is the model chi-square minimization function for this model.
    5147typedef psMinimizeLMChi2Func pmModelFunc;
     
    6359//  This function provides the model guess parameters based on the details of
    6460//  the given source.
    65 typedef bool (*pmModelGuessFunc)(TMP_MODEL_TYPE *model, TMP_SOURCE_TYPE *source);
     61typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source);
    6662
    6763//  This function constructs the PSF model for the given source based on the
    6864//  supplied psf and the EXT model for the object.
    69 typedef bool (*pmModelFromPSFFunc)(TMP_MODEL_TYPE *modelPSF, TMP_MODEL_TYPE *modelEXT, TMP_PSF_TYPE *psf);
     65typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelEXT, pmPSF *psf);
    7066
    7167//  This function sets the model parameters based on the PSF for a given coordinate and central
    7268//  intensity
    73 typedef bool (*pmModelParamsFromPSF)(TMP_MODEL_TYPE *model, TMP_PSF_TYPE *psf, float Xo, float Yo, float Io);
     69typedef bool (*pmModelParamsFromPSF)(pmModel *model, pmPSF *psf, float Xo, float Yo, float Io);
    7470
    7571//  This function returns the success / failure status of the given model fit
    76 typedef bool (*pmModelFitStatusFunc)(TMP_MODEL_TYPE *model);
     72typedef bool (*pmModelFitStatusFunc)(pmModel *model);
    7773
    7874/** pmModel data structure
     
    8581 *
    8682 */
    87 typedef struct
    88 {
     83struct pmModel {
    8984    pmModelType type;                   ///< Model to be used.
    9085    psVector *params;                   ///< Paramater values.
     
    107102    pmModelParamsFromPSF modelParamsFromPSF;
    108103    pmModelFitStatusFunc modelFitStatus;
    109 } pmModel;
     104};
    110105
    111106/** Symbolic names for the elements of [d]params
  • branches/eam_branch_20070817/psModules/src/objects/pmModelClass.c

    r14544 r14612  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-17 21:01:59 $
     8 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "pmPeaks.h"
    2626#include "pmMoments.h"
     27#include "pmResiduals.h"
    2728#include "pmGrowthCurve.h"
    28 #include "pmResiduals.h"
     29#include "pmPSF.h"
    2930#include "pmModel.h"
    30 #include "pmPSF.h"
    3131#include "pmSource.h"
    3232#include "pmModelClass.h"
     
    4545static pmModelClass defaultModels[] = {
    4646    {"PS_MODEL_GAUSS",        7, pmModelFunc_GAUSS,   pmModelFlux_GAUSS,   pmModelRadius_GAUSS,   pmModelLimits_GAUSS,   pmModelGuess_GAUSS,  pmModelFromPSF_GAUSS,  pmModelParamsFromPSF_GAUSS,  pmModelFitStatus_GAUSS},
    47 //    {"PS_MODEL_PGAUSS",       7, pmModelFunc_PGAUSS,  pmModelFlux_PGAUSS,  pmModelRadius_PGAUSS,  pmModelLimits_PGAUSS,  pmModelGuess_PGAUSS, pmModelFromPSF_PGAUSS, pmModelParamsFromPSF_PGAUSS, pmModelFitStatus_PGAUSS},
    48 //    {"PS_MODEL_QGAUSS",       8, pmModelFunc_QGAUSS,  pmModelFlux_QGAUSS,  pmModelRadius_QGAUSS,  pmModelLimits_QGAUSS,  pmModelGuess_QGAUSS, pmModelFromPSF_QGAUSS, pmModelParamsFromPSF_QGAUSS, pmModelFitStatus_QGAUSS},
    49 //    {"PS_MODEL_RGAUSS",       8, pmModelFunc_RGAUSS,  pmModelFlux_RGAUSS,  pmModelRadius_RGAUSS,  pmModelLimits_RGAUSS,  pmModelGuess_RGAUSS, pmModelFromPSF_RGAUSS, pmModelParamsFromPSF_RGAUSS, pmModelFitStatus_RGAUSS},
    50 //    {"PS_MODEL_SERSIC",       8, pmModelFunc_SERSIC,  pmModelFlux_SERSIC,  pmModelRadius_SERSIC,  pmModelLimits_SERSIC,  pmModelGuess_SERSIC, pmModelFromPSF_SERSIC, pmModelParamsFromPSF_SERSIC, pmModelFitStatus_SERSIC}
     47    {"PS_MODEL_PGAUSS",       7, pmModelFunc_PGAUSS,  pmModelFlux_PGAUSS,  pmModelRadius_PGAUSS,  pmModelLimits_PGAUSS,  pmModelGuess_PGAUSS, pmModelFromPSF_PGAUSS, pmModelParamsFromPSF_PGAUSS, pmModelFitStatus_PGAUSS},
     48    {"PS_MODEL_QGAUSS",       8, pmModelFunc_QGAUSS,  pmModelFlux_QGAUSS,  pmModelRadius_QGAUSS,  pmModelLimits_QGAUSS,  pmModelGuess_QGAUSS, pmModelFromPSF_QGAUSS, pmModelParamsFromPSF_QGAUSS, pmModelFitStatus_QGAUSS},
     49    {"PS_MODEL_RGAUSS",       8, pmModelFunc_RGAUSS,  pmModelFlux_RGAUSS,  pmModelRadius_RGAUSS,  pmModelLimits_RGAUSS,  pmModelGuess_RGAUSS, pmModelFromPSF_RGAUSS, pmModelParamsFromPSF_RGAUSS, pmModelFitStatus_RGAUSS},
     50    {"PS_MODEL_SERSIC",       8, pmModelFunc_SERSIC,  pmModelFlux_SERSIC,  pmModelRadius_SERSIC,  pmModelLimits_SERSIC,  pmModelGuess_SERSIC, pmModelFromPSF_SERSIC, pmModelParamsFromPSF_SERSIC, pmModelFitStatus_SERSIC}
    5151};
    5252
  • branches/eam_branch_20070817/psModules/src/objects/pmModelGroup.c

    r14544 r14612  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.17.4.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-17 21:01:59 $
     8 *  @version $Revision: 1.17.4.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828#include "pmResiduals.h"
    2929#include "pmModel.h"
    30 // #include "pmResiduals.h"
    31 // #include "pmPSF.h"
    32 // #include "pmSource.h"
    3330#include "pmModelGroup.h"
    3431#include "pmErrorCodes.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmModelUtils.c

    r14544 r14612  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-08-17 21:01:59 $
     7 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-08-23 00:55:49 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222#include "pmHDU.h"
    2323#include "pmFPA.h"
     24#include "pmResiduals.h"
    2425#include "pmGrowthCurve.h"
    25 #include "pmResiduals.h"
     26#include "pmPSF.h"
    2627#include "pmModel.h"
    27 #include "pmPSF.h"
    2828#include "pmErrorCodes.h"
    2929#include "pmModelUtils.h"
     30
     31/*****************************************************************************
     32pmModelFromPSF (*modelEXT, *psf):  use the model position parameters to
     33construct a realization of the PSF model at the object coordinates
     34 *****************************************************************************/
     35pmModel *pmModelFromPSF (pmModel *modelEXT, pmPSF *psf)
     36{
     37    // allocate a new pmModel to hold the PSF version
     38    pmModel *modelPSF = pmModelAlloc (psf->type);
     39
     40    // set model parameters for this source based on PSF information
     41    if (!modelEXT->modelFromPSF (modelPSF, modelEXT, psf)) {
     42        psError(PM_ERR_PSF, false, "Failed to set model params from PSF");
     43        psFree(modelPSF);
     44        return NULL;
     45    }
     46    // XXX note that model->residuals is just a reference
     47    modelPSF->residuals = psf->residuals;
     48
     49    return (modelPSF);
     50}
    3051
    3152// instantiate a model for the PSF at this location with peak flux
  • branches/eam_branch_20070817/psModules/src/objects/pmModelUtils.h

    r14544 r14612  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-08-17 21:01:59 $
     7 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-08-23 00:55:49 $
    99 * Copyright 2007 IfA, University of Hawaii
    1010 */
     
    1515/// @addtogroup Objects Object Detection / Analysis Functions
    1616/// @{
     17
     18/**
     19 *
     20 * This function constructs a pmModel instance based on the pmPSF description
     21 * of the PSF. The input is a pmModel with at least the values of the centroid
     22 * coordinates (possibly normalization if this is needed) defined. The values of
     23 * the PSF-dependent parameters are specified for the specific realization based
     24 * on the coordinates of the object.
     25 *
     26 */
     27pmModel *pmModelFromPSF(
     28    pmModel *model,                     ///< Add comment
     29    pmPSF *psf                          ///< Add comment
     30);
    1731
    1832pmModel *pmModelFromPSFforXY (
     
    2842    );
    2943
     44
     45
    3046/// @}
    3147# endif /* PM_MODEL_UTILS_H */
  • branches/eam_branch_20070817/psModules/src/objects/pmPSF.c

    r14544 r14612  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.25.6.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-17 21:01:59 $
     8 *  @version $Revision: 1.25.6.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828#include "pmMoments.h"
    2929#include "pmResiduals.h"
     30#include "pmGrowthCurve.h"
     31#include "pmPSF.h"
    3032#include "pmModel.h"
    3133#include "pmSource.h"
    32 #include "pmGrowthCurve.h"
    33 #include "pmPSF.h"
    3434#include "pmModelClass.h"
     35#include "pmModelUtils.h"
    3536#include "pmSourcePhotometry.h"
    3637#include "pmFPAMaskWeight.h"
     
    7475    psFree (psf->ApTrend);
    7576    psFree (psf->growth);
    76     psFree (psf->params_NEW);
     77    psFree (psf->params);
    7778    psFree (psf->residuals);
    7879    return;
     
    103104    psf->skyBias  = 0.0;
    104105    psf->skySat   = 0.0;
     106    psf->nPSFstars  = 0;
     107    psf->nApResid   = 0;
    105108    psf->poissonErrors = poissonErrors;
    106109
     
    129132        return(NULL);
    130133    }
    131     psf->params_NEW = psArrayAlloc(Nparams);
     134    psf->params = psArrayAlloc(Nparams);
    132135
    133136    // the order of the PSF parameter (X,Y) fits is determined by the psfTrendMask polynomial
     
    139142
    140143    if (psfTrendMask) {
    141         for (int i = 0; i < psf->params_NEW->n; i++) {
     144        for (int i = 0; i < psf->params->n; i++) {
    142145            if (i == PM_PAR_SKY)
    143146                continue;
     
    155158                }
    156159            }
    157             psf->params_NEW->data[i] = param;
     160            psf->params->data[i] = param;
    158161        }
    159162    }
     
    161164    psMemSetDeallocator(psf, (psFreeFunc) pmPSFFree);
    162165    return(psf);
    163 }
    164 
    165 /*****************************************************************************
    166 pmModelFromPSF (*modelEXT, *psf):  use the model position parameters to
    167 construct a realization of the PSF model at the object coordinates
    168  *****************************************************************************/
    169 pmModel *pmModelFromPSF (pmModel *modelEXT, pmPSF *psf)
    170 {
    171     // allocate a new pmModel to hold the PSF version
    172     pmModel *modelPSF = pmModelAlloc (psf->type);
    173 
    174     // set model parameters for this source based on PSF information
    175     if (!modelEXT->modelFromPSF (modelPSF, modelEXT, psf)) {
    176         psError(PM_ERR_PSF, false, "Failed to set model params from PSF");
    177         psFree(modelPSF);
    178         return NULL;
    179     }
    180     // XXX note that model->residuals is just a reference
    181     modelPSF->residuals = psf->residuals;
    182 
    183     return (modelPSF);
    184166}
    185167
     
    333315    pmPSF *psf = pmPSFAlloc (type, true, psfTrend);
    334316
    335     psVector *par = psVectorAlloc (psf->params_NEW->n, PS_TYPE_F32);
     317    psVector *par = psVectorAlloc (psf->params->n, PS_TYPE_F32);
    336318    par->data.F32[PM_PAR_SXX] = sxx;
    337319    par->data.F32[PM_PAR_SYY] = syy;
     
    342324    // set the psf shape parameters
    343325    psPolynomial2D *poly = NULL;
    344     poly = psf->params_NEW->data[PM_PAR_E0];
     326    poly = psf->params->data[PM_PAR_E0];
    345327    poly->coeff[0][0] = pol.e0;
    346328
    347     poly = psf->params_NEW->data[PM_PAR_E1];
     329    poly = psf->params->data[PM_PAR_E1];
    348330    poly->coeff[0][0] = pol.e1;
    349331
    350     poly = psf->params_NEW->data[PM_PAR_E2];
     332    poly = psf->params->data[PM_PAR_E2];
    351333    poly->coeff[0][0] = pol.e2;
    352334
    353     for (int i = PM_PAR_SXY + 1; i < psf->params_NEW->n; i++) {
    354         poly = psf->params_NEW->data[i];
     335    for (int i = PM_PAR_SXY + 1; i < psf->params->n; i++) {
     336        poly = psf->params->data[i];
    355337        poly->coeff[0][0] = (psF32)va_arg(ap, psF64);
    356338    }
  • branches/eam_branch_20070817/psModules/src/objects/pmPSF.h

    r13898 r14612  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-06-20 02:22:26 $
     8 * @version $Revision: 1.14.6.1 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-08-23 00:55:49 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    1616/// @addtogroup Objects Object Detection / Analysis Functions
    1717/// @{
     18
     19// type of model carried by the pmModel structure
     20typedef int pmModelType;
    1821
    1922typedef enum {
     
    4447typedef struct
    4548{
    46     pmModelType type;   ///< PSF Model in use
    47     psArray *params_NEW;   ///< Model parameters (psPolynomial2D)
    48     // XXXXX I am changing params: we will allocate elements for the
    49     // unfitted elements (So, Io, Xo, Yo) and leave them as NULL
    50     // I am using a new name to catch all refs to params with gcc
     49    pmModelType type;                   ///< PSF Model in use
     50    psArray *params;                    ///< Model parameters (psPolynomial2D)
    5151    psPolynomial1D *ChiTrend;         ///< Chisq vs flux fit (correction for systematic errors)
    5252    psPolynomial4D *ApTrend;            ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst))
     
    7979);
    8080
    81 /**
    82  *
    83  * This function constructs a pmModel instance based on the pmPSF description
    84  * of the PSF. The input is a pmModel with at least the values of the centroid
    85  * coordinates (possibly normalization if this is needed) defined. The values of
    86  * the PSF-dependent parameters are specified for the specific realization based
    87  * on the coordinates of the object.
    88  *
    89  */
    90 pmModel *pmModelFromPSF(
    91     pmModel *model,                     ///< Add comment
    92     pmPSF *psf                          ///< Add comment
    93 );
    94 
    9581bool pmPSFMaskApTrend (psPolynomial4D *trend, pmPSFApTrendOptions option);
    9682
  • branches/eam_branch_20070817/psModules/src/objects/pmPSF_IO.c

    r14544 r14612  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.20.4.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-17 21:01:59 $
     8 *  @version $Revision: 1.20.4.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040#include "pmGrowthCurve.h"
    4141#include "pmResiduals.h"
     42#include "pmPSF.h"
    4243#include "pmModel.h"
    43 #include "pmPSF.h"
    4444#include "pmPSF_IO.h"
    4545#include "pmSource.h"
     
    4747#include "pmSourceIO.h"
    4848
    49 bool pmFPAviewCheckDataStatusForPSFmodel (const pmFPAview *view, const pmFPAfile *file)
     49bool pmPSFmodelCheckDataStatusForView (const pmFPAview *view, const pmFPAfile *file)
    5050{
    5151    pmFPA *fpa = file->fpa;
    5252
    5353    if (view->chip == -1) {
    54         bool exists = pmFPACheckDataStatusForPSFmodel (fpa);
     54        bool exists = pmPSFmodelCheckDataStatusForFPA (fpa);
    5555        return exists;
    5656    }
     
    6262
    6363    if (view->cell == -1) {
    64         bool exists = pmChipCheckDataStatusForPSFmodel (chip);
     64        bool exists = pmPSFmodelCheckDataStatusForChip (chip);
    6565        return exists;
    6666    }
     
    6969        return false;
    7070    }
    71     pmCell *cell = chip->cells->data[view->cell];
    72 
    73     if (view->readout == -1) {
    74         bool exists = pmCellCheckDataStatusForPSFmodel (cell);
    75         return exists;
    76     }
    77 
    78     if (view->readout >= cell->readouts->n) {
    79         psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouds->n == %ld", view->readout, cell->readouts->n);
    80         return false;
    81     }
    82     pmReadout *readout = cell->readouts->data[view->readout];
    83 
    84     return pmReadoutCheckDataStatusForPSFmodel (readout);
    85 }
    86 
    87 bool pmFPACheckDataStatusForPSFmodel (const pmFPA *fpa) {
     71    psError(PS_ERR_IO, false, "PSF only valid at the chip level");
     72    return false;
     73}
     74
     75bool pmPSFmodelCheckDataStatusForFPA (const pmFPA *fpa) {
    8876
    8977    for (int i = 0; i < fpa->chips->n; i++) {
    9078        pmChip *chip = fpa->chips->data[i];
    9179        if (!chip) continue;
    92         if (pmChipCheckDataStatusForPSFmodel (chip)) return true;
     80        if (pmPSFmodelCheckDataStatusForChip (chip)) return true;
    9381    }
    9482    return false;
    9583}
    9684
    97 bool pmChipCheckDataStatusForPSFmodel (const pmChip *chip) {
    98 
    99     for (int i = 0; i < chip->cells->n; i++) {
    100         pmCell *cell = chip->cells->data[i];
    101         if (!cell) continue;
    102         if (pmCellCheckDataStatusForPSFmodel (cell)) return true;
    103     }
    104     return false;
    105 }
    106 
    107 bool pmCellCheckDataStatusForPSFmodel (const pmCell *cell) {
    108 
    109     for (int i = 0; i < cell->readouts->n; i++) {
    110         pmReadout *readout = cell->readouts->data[i];
    111         if (!readout) continue;
    112         if (pmReadoutCheckDataStatusForPSFmodel (readout)) return true;
    113     }
    114     return false;
    115 }
    116 
    117 bool pmReadoutCheckDataStatusForPSFmodel (const pmReadout *readout) {
     85bool pmPSFmodelCheckDataStatusForChip (const pmChip *chip) {
    11886
    11987    bool status;
    12088
    12189    // select the psf of interest
    122     pmPSF *psf = psMetadataLookupPtr(&status, readout->analysis, "PSPHOT.PSF");
     90    pmPSF *psf = psMetadataLookupPtr(&status, chip->analysis, "PSPHOT.PSF");
    12391    return psf ? true : false;
    12492}
    12593
    126 bool pmFPAviewWritePSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     94bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    12795{
    12896
     
    13098
    13199    if (view->chip == -1) {
    132         if (!pmFPAWritePSFmodel(fpa, view, file, config)) {
     100        if (!pmPSFmodelWriteFPA(fpa, view, file, config)) {
    133101            psError(PS_ERR_IO, false, "Failed to write PSF for fpa");
    134102            return false;
     
    143111
    144112    if (view->cell == -1) {
    145         if (!pmChipWritePSFmodel (chip, view, file, config)) {
     113        if (!pmPSFmodelWriteChip (chip, view, file, config)) {
    146114            psError(PS_ERR_IO, false, "Failed to write PSF for chip");
    147115            return false;
     
    150118    }
    151119
    152     if (view->cell >= chip->cells->n) {
    153         return false;
    154     }
    155     pmCell *cell = chip->cells->data[view->cell];
    156 
    157     if (view->readout == -1) {
    158         if (!pmCellWritePSFmodel (cell, view, file, config)) {
    159             psError(PS_ERR_IO, false, "Failed to write PSF for cell");
    160             return false;
    161         }
    162         return true;
    163     }
    164 
    165     if (view->readout >= cell->readouts->n) {
    166         return false;
    167     }
    168     pmReadout *readout = cell->readouts->data[view->readout];
    169 
    170     if (!pmReadoutWritePSFmodel (readout, view, file, config)) {
    171         psError(PS_ERR_IO, false, "Failed to write PSF for readout");
    172         return false;
    173     }
    174     return true;
     120    psError(PS_ERR_IO, false, "PSF must be written at the chip level");
     121    return false;
    175122}
    176123
    177124// read in all chip-level PSFmodel files for this FPA
    178 bool pmFPAWritePSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     125bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    179126{
    180127
    181128    for (int i = 0; i < fpa->chips->n; i++) {
    182129        pmChip *chip = fpa->chips->data[i];
    183         if (!pmChipWritePSFmodel (chip, view, file, config)) {
     130        if (!pmPSFmodelWriteChip (chip, view, file, config)) {
    184131            psError(PS_ERR_IO, false, "Failed to write PSF for %dth chip", i);
    185132            return false;
     
    190137
    191138// read in all cell-level PSFmodel files for this chip
    192 bool pmChipWritePSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    193 {
    194     for (int i = 0; i < chip->cells->n; i++) {
    195         pmCell *cell = chip->cells->data[i];
    196         if (!pmCellWritePSFmodel (cell, view, file, config)) {
    197             psError(PS_ERR_IO, false, "Failed to write PSF for %dth cell", i);
    198             return false;
    199         }
     139bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     140{
     141    if (!pmPSFmodelWrite (chip->analysis, view, file, config)) {
     142        psError(PS_ERR_IO, false, "Failed to write PSF for chip");
     143        return false;
    200144    }
    201145    return true;
    202146}
    203147
    204 // read in all readout-level PSFmodel files for this cell
    205 bool pmCellWritePSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    206 {
    207     for (int i = 0; i < cell->readouts->n; i++) {
    208         pmReadout *readout = cell->readouts->data[i];
    209         if (!pmReadoutWritePSFmodel (readout, view, file, config)) {
    210             psError(PS_ERR_IO, false, "Failed to write PSF for %dth readout", i);
    211             return false;
    212         }
    213     }
    214     return true;
    215 }
    216 
    217 // for each Readout (ie, analysed image), we write out
     148// for a pmPSF supplied on the analysis metadata, we write out
    218149// - image header        : FITS Image NAXIS = 0
    219150// - psf table (+header) : FITS Table
    220151// - psf resid (+header) : FITS Image
    221152// if needed, we also write out a PHU blank header
    222 bool pmReadoutWritePSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     153bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    223154{
    224155    bool status;
    225156    pmHDU *hdu;
    226157    char *headName, *tableName, *residName;
     158
     159    if (!analysis) return false;
    227160
    228161    // write a PHU? (only if input image is MEF)
     
    300233
    301234    // select the psf of interest
    302     pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     235    pmPSF *psf = psMetadataLookupPtr (&status, analysis, "PSPHOT.PSF");
    303236    if (!psf) {
    304         psError(PS_ERR_UNKNOWN, true, "missing PSF for this readout");
     237        psError(PS_ERR_UNKNOWN, true, "missing PSF for this analysis metadata");
    305238        psFree (tableName);
    306239        psFree (residName);
     
    324257        for (int i = 0; i < nPar; i++) {
    325258            char name[9];
    326             psPolynomial2D *poly = psf->params_NEW->data[i];
     259            psPolynomial2D *poly = psf->params->data[i];
    327260            if (poly == NULL) continue;
    328261            snprintf (name, 9, "PAR%02d_NX", i);
     
    344277        psArray *psfTable = psArrayAllocEmpty (100);
    345278        for (int i = 0; i < nPar; i++) {
    346             psPolynomial2D *poly = psf->params_NEW->data[i];
     279            psPolynomial2D *poly = psf->params->data[i];
    347280            if (poly == NULL) continue; // skip unset parameters (eg, XPOS)
    348281            for (int ix = 0; ix <= poly->nX; ix++) {
     
    445378
    446379// if this file needs to have a PHU written out, write one
    447 bool pmPSF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
     380bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) {
    448381
    449382    // not needed if already written
     
    487420}
    488421
    489 bool pmFPAviewReadPSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     422bool pmPSFmodelReadForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    490423{
    491424
     
    493426
    494427    if (view->chip == -1) {
    495         return pmFPAReadPSFmodel(fpa, view, file, config);
     428        return pmPSFmodelReadFPA(fpa, view, file, config);
    496429    }
    497430
     
    502435
    503436    if (view->cell == -1) {
    504         return pmChipReadPSFmodel(chip, view, file, config);
    505     }
    506 
    507     if (view->cell >= chip->cells->n) {
    508         psAbort("Programming error: view does not apply to FPA.");
    509     }
    510     pmCell *cell = chip->cells->data[view->cell];
    511 
    512     if (view->readout == -1) {
    513         return pmCellReadPSFmodel(cell, view, file, config);
    514     }
    515 
    516     if (view->readout >= cell->readouts->n) {
    517         psAbort("Programming error: view does not apply to FPA.");
    518     }
    519     pmReadout *readout = cell->readouts->data[view->readout];
    520 
    521     return pmReadoutReadPSFmodel(readout, view, file, config);
     437        return pmPSFmodelReadChip(chip, view, file, config);
     438    }
     439
     440    psError(PS_ERR_IO, false, "PSF must be read at the chip level");
     441    return false;
    522442}
    523443
    524444// read in all chip-level PSFmodel files for this FPA
    525 bool pmFPAReadPSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     445bool pmPSFmodelReadFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    526446{
    527447    bool success = true;                // Was everything successful?
    528448    for (int i = 0; i < fpa->chips->n; i++) {
    529449        pmChip *chip = fpa->chips->data[i];
    530         success &= pmChipReadPSFmodel(chip, view, file, config);
     450        success &= pmPSFmodelReadChip(chip, view, file, config);
    531451    }
    532452    return success;
     
    534454
    535455// read in all cell-level PSFmodel files for this chip
    536 bool pmChipReadPSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    537 {
    538     bool success = true;                // Was everything successful?
    539     for (int i = 0; i < chip->cells->n; i++) {
    540         pmCell *cell = chip->cells->data[i];
    541         success &= pmCellReadPSFmodel (cell, view, file, config);
    542     }
    543     return success;
    544 }
    545 
    546 // read in all readout-level PSFmodel files for this cell
    547 bool pmCellReadPSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    548 {
    549     bool success = true;                // Was everything successful?
    550     for (int i = 0; i < cell->readouts->n; i++) {
    551         pmReadout *readout = cell->readouts->data[i];
    552         success &= pmReadoutReadPSFmodel(readout, view, file, config);
    553     }
    554     return success;
     456bool pmPSFmodelReadChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     457{
     458    if (!pmPSFmodelRead (chip->analysis, view, file, config)) {
     459        psError(PS_ERR_IO, false, "Failed to write PSF for chip");
     460        return false;
     461    }
     462    return true;
    555463}
    556464
    557465// for each Readout (ie, analysed image), we write out: header + table with PSF model parameters,
    558466// and header + image for the PSF residual images
    559 bool pmReadoutReadPSFmodel(pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     467bool pmPSFmodelRead (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    560468{
    561469    bool status;
     
    627535            return false;
    628536        }
    629         psf->params_NEW->data[i] = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXorder, nYorder);
     537        psf->params->data[i] = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXorder, nYorder);
    630538    }
    631539
     
    650558        // XXX sanity check here
    651559
    652         psPolynomial2D *poly = psf->params_NEW->data[iPar];
     560        psPolynomial2D *poly = psf->params->data[iPar];
    653561        if (poly == NULL) {
    654562            psError(PS_ERR_UNKNOWN, true, "values for parameter %d, but missing NX", iPar);
     
    698606    }
    699607
    700     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
     608    psMetadataAdd (analysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
    701609    psFree (psf);
    702610
     
    708616}
    709617
    710 /************ old support functions, deprecate? **************/
    711 
     618// create a psMetadata representation (human-readable) of a psf model
    712619psMetadata *pmPSFtoMetadata (psMetadata *metadata, pmPSF *psf)
    713620{
     
    724631
    725632    for (int i = 0; i < nPar; i++) {
    726         psPolynomial2D *poly = psf->params_NEW->data[i];
     633        psPolynomial2D *poly = psf->params->data[i];
    727634        if (poly == NULL)
    728635            continue;
     
    742649}
    743650
     651// parse a psMetadata representation (human-readable) of a psf model
    744652pmPSF *pmPSFfromMetadata (psMetadata *metadata)
    745653{
     
    770678            continue;
    771679        psPolynomial2D *poly = psPolynomial2DfromMetadata (folder);
    772         psFree (psf->params_NEW->data[i]);
    773         psf->params_NEW->data[i] = poly;
     680        psFree (psf->params->data[i]);
     681        psf->params->data[i] = poly;
    774682    }
    775683    sprintf (keyword, "APTREND");
     
    789697    return (psf);
    790698}
    791 
    792 // read in all readout-level Objects files for this cell
    793 bool pmReadoutWritePSFmodel_Config (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    794 {
    795     bool status;
    796     char *filename;
    797     char *realname;
    798 
    799     pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
    800 
    801     switch (file->type) {
    802       case PM_FPA_FILE_PSF:
    803         filename = pmFPAfileNameFromRule (file->filerule, file, view);
    804         bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
    805         realname = pmConfigConvertFilename (filename, config, create);
    806 
    807         psMetadata *psfData = pmPSFtoMetadata (NULL, psf);
    808         psMetadataConfigWrite (psfData, realname);
    809         psFree (psfData);
    810         psFree (realname);
    811         psFree (filename);
    812         return true;
    813 
    814       default:
    815         fprintf (stderr, "warning: type mismatch\n");
    816         break;
    817     }
    818     return false;
    819 }
    820 
    821 // read in all readout-level Objects files for this cell
    822 bool pmReadoutReadPSFmodel_Config (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
    823 {
    824 
    825     unsigned int Nfail;
    826     char *filename;
    827     char *realname;
    828 
    829     switch (file->type) {
    830       case PM_FPA_FILE_PSF:
    831         filename = pmFPAfileNameFromRule (file->filerule, file, view);
    832         bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
    833         realname = pmConfigConvertFilename (filename, config, create);
    834 
    835         psMetadata *psfData = psMetadataConfigRead(NULL, &Nfail, realname, FALSE);
    836         pmPSF *psf = pmPSFfromMetadata (psfData);
    837         psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN, "psphot psf", psf);
    838 
    839         psFree (psf);
    840         psFree (psfData);
    841         psFree (realname);
    842         psFree (filename);
    843 
    844         return true;
    845 
    846       default:
    847         fprintf (stderr, "warning: type mismatch\n");
    848         break;
    849     }
    850     return false;
    851 }
    852 
  • branches/eam_branch_20070817/psModules/src/objects/pmPSF_IO.h

    r14207 r14612  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-07-14 03:20:22 $
     8 * @version $Revision: 1.8.4.1 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-08-23 00:55:49 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    1717/// @{
    1818
     19bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     20bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     21bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     22bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     23
     24bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     25
     26bool pmPSFmodelReadForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     27bool pmPSFmodelReadFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     28bool pmPSFmodelReadChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     29bool pmPSFmodelRead (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
     30
     31bool pmPSFmodelCheckDataStatusForView (const pmFPAview *view, const pmFPAfile *file);
     32bool pmPSFmodelCheckDataStatusForFPA (const pmFPA *fpa);
     33bool pmPSFmodelCheckDataStatusForChip (const pmChip *chip);
     34
    1935psMetadata *pmPSFtoMetadata (psMetadata *metadata, pmPSF *psf);
    2036pmPSF *pmPSFfromMetadata (psMetadata *metadata);
    21 bool pmFPAviewWritePSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    22 bool pmFPAWritePSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    23 bool pmChipWritePSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    24 bool pmCellWritePSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    25 bool pmReadoutWritePSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    26 
    27 bool pmPSF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    28 
    29 bool pmFPAviewReadPSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    30 bool pmFPAReadPSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    31 bool pmChipReadPSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    32 bool pmCellReadPSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    33 bool pmReadoutReadPSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
    34 
    35 bool pmFPAviewCheckDataStatusForPSFmodel (const pmFPAview *view, const pmFPAfile *file);
    36 bool pmFPACheckDataStatusForPSFmodel (const pmFPA *fpa);
    37 bool pmChipCheckDataStatusForPSFmodel (const pmChip *chip);
    38 bool pmCellCheckDataStatusForPSFmodel (const pmCell *cell);
    39 bool pmReadoutCheckDataStatusForPSFmodel (const pmReadout *readout);
    4037
    4138/// @}
  • branches/eam_branch_20070817/psModules/src/objects/pmPSFtry.c

    r14544 r14612  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.43.6.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-08-17 21:01:59 $
     7 *  @version $Revision: 1.43.6.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-08-23 00:55:49 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "pmMoments.h"
    2424#include "pmResiduals.h"
     25#include "pmGrowthCurve.h"
     26#include "pmPSF.h"
    2527#include "pmModel.h"
    2628#include "pmSource.h"
    2729#include "pmSourceUtils.h"
    28 #include "pmGrowthCurve.h"
    29 #include "pmPSF.h"
    3030#include "pmPSFtry.h"
    3131#include "pmModelClass.h"
     32#include "pmModelUtils.h"
    3233#include "pmSourceFitModel.h"
    3334#include "pmSourcePhotometry.h"
     
    413414    // This way, the parameters masked by one of the fits will be applied to the others
    414415    for (int i = 0; i < stats->clipIter; i++) {
    415         psVectorClipFitPolynomial2D (psf->params_NEW->data[PM_PAR_E0], stats, psfTry->mask, 0xff, e0, dz, x, y);
     416        psVectorClipFitPolynomial2D (psf->params->data[PM_PAR_E0], stats, psfTry->mask, 0xff, e0, dz, x, y);
    416417        psTrace ("psModules.pmPSFtry", 4, "clipped E0 : keeping %ld of %ld\n", stats->clippedNvalues, e0->n);
    417         psVectorClipFitPolynomial2D (psf->params_NEW->data[PM_PAR_E1], stats, psfTry->mask, 0xff, e1, dz, x, y);
     418        psVectorClipFitPolynomial2D (psf->params->data[PM_PAR_E1], stats, psfTry->mask, 0xff, e1, dz, x, y);
    418419        psTrace ("psModules.pmPSFtry", 4, "clipped E1 : keeping %ld of %ld\n", stats->clippedNvalues, e1->n);
    419         psVectorClipFitPolynomial2D (psf->params_NEW->data[PM_PAR_E2], stats, psfTry->mask, 0xff, e2, dz, x, y);
     420        psVectorClipFitPolynomial2D (psf->params->data[PM_PAR_E2], stats, psfTry->mask, 0xff, e2, dz, x, y);
    420421        psTrace ("psModules.pmPSFtry", 4, "clipped E2 : keeping %ld of %ld\n", stats->clippedNvalues, e2->n);
    421422    }
     
    437438
    438439    // skip the unfitted parameters (X, Y, Io, Sky) and the shape parameters (SXX, SYY, SXY)
    439     for (int i = 0; i < psf->params_NEW->n; i++) {
     440    for (int i = 0; i < psf->params->n; i++) {
    440441        switch (i) {
    441442          case PM_PAR_SKY:
     
    462463        // the mask is carried from previous steps and updated with this operation
    463464        // the weight is either the flux error or NULL, depending on 'applyWeights'
    464         if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, NULL, x, y)) {
     465        if (!psVectorClipFitPolynomial2D(psf->params->data[i], stats, psfTry->mask, 0xff, z, NULL, x, y)) {
    465466            psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i);
    466467            psFree(stats);
     
    490491            fprintf (f, "%f %f : ", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
    491492
    492             for (int i = 0; i < psf->params_NEW->n; i++) {
    493                 if (psf->params_NEW->data[i] == NULL)
     493            for (int i = 0; i < psf->params->n; i++) {
     494                if (psf->params->data[i] == NULL)
    494495                    continue;
    495496                fprintf (f, "%f %f : ", model->params->data.F32[i], modelPSF->params->data.F32[i]);
  • branches/eam_branch_20070817/psModules/src/objects/pmSource.c

    r14546 r14612  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.34.2.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-20 01:58:16 $
     8 *  @version $Revision: 1.34.2.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "pmMoments.h"
    2828#include "pmResiduals.h"
     29#include "pmGrowthCurve.h"
     30#include "pmPSF.h"
    2931#include "pmModel.h"
    3032#include "pmSource.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSource.h

    r14546 r14612  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.16.2.2 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2007-08-20 01:58:16 $
     5 * @version $Revision: 1.16.2.3 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2007-08-23 00:55:49 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    5757 *
    5858 */
    59 typedef struct
    60 {
     59struct pmSource {
    6160    const int id;                       ///< Unique ID for object
    6261    pmPeak *peak;                       ///< Description of peak pixel.
     
    8180    psRegion region;                    ///< area on image covered by selected pixels
    8281    float sky, skyErr;                  ///< The sky and its error at the center of the object
    83 }
    84 pmSource;
     82};
    8583
    8684/** pmPSFClump data structure
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceContour.c

    r12949 r14612  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-04-21 19:47:14 $
     8 *  @version $Revision: 1.7.8.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "pmMoments.h"
    2727#include "pmResiduals.h"
     28#include "pmGrowthCurve.h"
     29#include "pmPSF.h"
    2830#include "pmModel.h"
    2931#include "pmSource.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceFitModel.c

    r14546 r14612  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.24.4.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-20 01:58:16 $
     8 *  @version $Revision: 1.24.4.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "pmGrowthCurve.h"
    2828#include "pmResiduals.h"
     29#include "pmPSF.h"
    2930#include "pmModel.h"
    30 #include "pmPSF.h"
    3131#include "pmSource.h"
    3232#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceFitSet.c

    r14546 r14612  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.3.2.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-20 01:58:16 $
     8 *  @version $Revision: 1.3.2.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "pmGrowthCurve.h"
    2828#include "pmResiduals.h"
     29#include "pmPSF.h"
    2930#include "pmModel.h"
    30 #include "pmPSF.h"
    3131#include "pmSource.h"
    3232#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.45.4.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.45.4.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434#include "pmGrowthCurve.h"
    3535#include "pmResiduals.h"
     36#include "pmPSF.h"
    3637#include "pmModel.h"
    37 #include "pmPSF.h"
    3838#include "pmSource.h"
    3939#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_CMP.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.29.8.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.29.8.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_OBJ.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.13.8.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.13.8.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_PS1_DEV_0.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.10.8.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.10.8.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_RAW.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.15.8.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.15.8.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_SMPDATA.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.9.8.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.9.8.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030#include "pmPeaks.h"
    3131#include "pmMoments.h"
     32#include "pmResiduals.h"
    3233#include "pmGrowthCurve.h"
    33 #include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_SX.c

    r14544 r14612  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.11.8.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.11.8.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourcePhotometry.c

    r14544 r14612  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.28.6.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-08-17 21:01:59 $
     5 *  @version $Revision: 1.28.6.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-08-23 00:55:49 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "pmGrowthCurve.h"
    2727#include "pmResiduals.h"
     28#include "pmPSF.h"
    2829#include "pmModel.h"
    29 #include "pmPSF.h"
    3030#include "pmSource.h"
    3131#include "pmModelClass.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourcePlotApResid.c

    r13473 r14612  
    44 *  @author EAM, IfA
    55 *
    6  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-05-22 21:45:48 $
     6 *  @version $Revision: 1.2.6.1 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-08-23 00:55:49 $
    88 *  Copyright 2006 IfA, University of Hawaii
    99 */
     
    2727#include "pmPeaks.h"
    2828#include "pmMoments.h"
     29#include "pmResiduals.h"
    2930#include "pmGrowthCurve.h"
    30 #include "pmResiduals.h"
     31#include "pmPSF.h"
    3132#include "pmModel.h"
    32 #include "pmPSF.h"
    3333#include "pmSource.h"
    3434#include "pmSourcePlots.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourcePlotMoments.c

    r13473 r14612  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-05-22 21:45:48 $
     7 *  @version $Revision: 1.7.6.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-08-23 00:55:49 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmSourcePlots.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourcePlotPSFModel.c

    r13473 r14612  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-05-22 21:45:48 $
     7 *  @version $Revision: 1.9.6.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-08-23 00:55:49 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    3232#include "pmGrowthCurve.h"
    3333#include "pmResiduals.h"
     34#include "pmPSF.h"
    3435#include "pmModel.h"
    35 #include "pmPSF.h"
    3636#include "pmSource.h"
    3737#include "pmSourcePlots.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceSky.c

    r13898 r14612  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-20 02:22:26 $
     8 *  @version $Revision: 1.13.6.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "pmMoments.h"
    2828#include "pmResiduals.h"
     29#include "pmGrowthCurve.h"
     30#include "pmPSF.h"
    2931#include "pmModel.h"
    3032#include "pmSource.h"
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceUtils.c

    r14546 r14612  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-20 01:58:16 $
     8 *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-08-23 00:55:49 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "pmMoments.h"
    2828#include "pmResiduals.h"
     29#include "pmGrowthCurve.h"
     30#include "pmPSF.h"
    2931#include "pmModel.h"
    3032#include "pmSource.h"
     
    6062}
    6163
    62 pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout, pmSourceType type) {
     64pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout, float radius, pmSourceType type) {
    6365
    6466    pmSource *source = pmSourceAlloc ();
     
    7577        psAbort ("invalid source type");
    7678    }
     79    source->type = type;
    7780
    7881    pmCell *cell = readout->parent;
     
    8992    int yParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
    9093
    91     // XXX whose binning?
    92     int xBin = psMetadataLookupS32(NULL, cell->concepts, "CELL.XBIN"); // Binning in x and y
    93     int yBin = psMetadataLookupS32(NULL, cell->concepts, "CELL.YBIN"); // Binning in x and y
     94    // XXX fix the binning : currently not selected from concepts
     95    // int xBin = psMetadataLookupS32(NULL, cell->concepts, "CELL.XBIN"); // Binning in x and y
     96    // int yBin = psMetadataLookupS32(NULL, cell->concepts, "CELL.YBIN"); // Binning in x and y
     97    int xBin = 1;
     98    int yBin = 1;
    9499
    95100    // Position on the cell
     
    101106    // float yReadout = CELL_TO_READOUT(yCell, y0Readout);
    102107   
    103     float radius = 5.0; // XXX need to define the radius in some rational way
    104 
    105108    pmSourceDefinePixels (source, readout, xCell, yCell, radius);
    106109
  • branches/eam_branch_20070817/psModules/src/objects/pmSourceUtils.h

    r14544 r14612  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-08-17 21:01:59 $
     7 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-08-23 00:55:49 $
    99 * Copyright 2007 IfA, University of Hawaii
    1010 */
     
    3333  pmModel *model,
    3434  pmReadout *readout,
     35  float radius,
    3536  pmSourceType type
    3637  );
Note: See TracChangeset for help on using the changeset viewer.