IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14545


Ignore:
Timestamp:
Aug 17, 2007, 11:27:05 AM (19 years ago)
Author:
eugene
Message:

changed APIs pmIsFooBar to pmFooBarTest

changed pmModelGroup to pmModelClass (and rationalized some names)

using pmModelPSFforXY for clearer code

using new pmModel member functions for limits, etc

Location:
branches/eam_branch_20070817/psphot/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070817/psphot/src/models/pmModel_STRAIL.c

    r11702 r14545  
    1212*****************************************************************************/
    1313 
    14 # define PM_MODEL_FUNC       pmModelFunc_STRAIL
    15 # define PM_MODEL_FLUX       pmModelFlux_STRAIL
    16 # define PM_MODEL_GUESS      pmModelGuess_STRAIL
    17 # define PM_MODEL_LIMITS     pmModelLimits_STRAIL
    18 # define PM_MODEL_RADIUS     pmModelRadius_STRAIL
    19 # define PM_MODEL_FROM_PSF   pmModelFromPSF_STRAIL
    20 # define PM_MODEL_FIT_STATUS pmModelFitStatus_STRAIL
     14# define PM_MODEL_FUNC            pmModelFunc_STRAIL
     15# define PM_MODEL_FLUX            pmModelFlux_STRAIL
     16# define PM_MODEL_GUESS           pmModelGuess_STRAIL
     17# define PM_MODEL_LIMITS          pmModelLimits_STRAIL
     18# define PM_MODEL_RADIUS          pmModelRadius_STRAIL
     19# define PM_MODEL_FROM_PSF        pmModelFromPSF_STRAIL
     20# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_STRAIL
     21# define PM_MODEL_FIT_STATUS      pmModelFitStatus_STRAIL
    2122
    2223psF32 PM_MODEL_FUNC(psVector *deriv,
     
    474475 
    475476//fixed I think...no good way of guessing as far as I can tell
    476 bool PM_MODEL_GUESS (pmModel *model, pmSource *source) {
    477  
     477bool PM_MODEL_GUESS (void *inModel, void *inSource)
     478{
     479    pmModel *model = inModel;
     480    pmSource *source = inSource;
     481
    478482    pmMoments *Smoments = source->moments;
    479483    psF32     *params  = model->params->data.F32;
     
    516520 
    517521//fixed
    518 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf) {
     522bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF)
     523{
     524    pmModel *modelPSF = inModelPSF;
     525    pmModel *modelFLT = inModelFLT;
     526    pmPSF *psf = inPSF;
    519527 
    520528    psF32 *out = modelPSF->params->data.F32;
     
    535543}
    536544 
     545// construct the PSF model from the FLT model and the psf
     546// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     547bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io)
     548{
     549    pmModel *model = inModel;
     550    pmPSF *psf = inPSF;
     551
     552    psF32 *PAR = model->params->data.F32;
     553
     554    // we require these two parameters to exist
     555    assert (psf->params_NEW->n > PM_PAR_YPOS);
     556    assert (psf->params_NEW->n > PM_PAR_XPOS);
     557
     558    PAR[PM_PAR_SKY]  = 0.0;
     559    PAR[PM_PAR_I0]   = Io;
     560    PAR[PM_PAR_XPOS] = Xo;
     561    PAR[PM_PAR_YPOS] = Yo;
     562   
     563    // supply the model-fitted parameters, or copy from the input
     564    for (int i = 0; i < psf->params_NEW->n; i++) {
     565        if (i == PM_PAR_SKY) continue;
     566        psPolynomial2D *poly = psf->params_NEW->data[i];
     567        assert (poly);
     568        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     569    }
     570
     571    // the 2D PSF model fits polarization terms (E0,E1,E2)
     572    // convert to shape terms (SXX,SYY,SXY)
     573    // XXX user-defined value for limit?
     574    if (!pmPSF_FitToModel (PAR, 0.1)) {
     575        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     576        return false;
     577    }
     578
     579    // apply the model limits here: this truncates excessive extrapolation
     580    // XXX do we need to do this still?  should we put in asserts to test?
     581    for (int i = 0; i < psf->params_NEW->n; i++) {
     582        // apply the limits to all components or just the psf-model parameters?
     583        if (psf->params_NEW->data[i] == NULL)
     584            continue;
     585
     586        bool status = true;
     587        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     588        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     589        if (!status) {
     590            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     591            model->flags |= PM_MODEL_STATUS_LIMITS;
     592        }
     593    }
     594    return(true);
     595}
     596
    537597//done I think
    538 bool PM_MODEL_FIT_STATUS (pmModel *model) {
     598bool PM_MODEL_FIT_STATUS (void *inModel)
     599{
     600    pmModel *model = inModel;
    539601 
    540602    psF32 dP;
     
    566628# undef PM_MODEL_RADIUS
    567629# undef PM_MODEL_FROM_PSF
     630# undef PM_MODEL_PARAMS_FROM_PSF
    568631# undef PM_MODEL_FIT_STATUS
  • branches/eam_branch_20070817/psphot/src/models/pmModel_TEST1.c

    r11702 r14545  
    1616 *****************************************************************************/
    1717
    18 # define PM_MODEL_FUNC       pmModelFunc_TEST1
    19 # define PM_MODEL_FLUX       pmModelFlux_TEST1
    20 # define PM_MODEL_GUESS      pmModelGuess_TEST1
    21 # define PM_MODEL_LIMITS     pmModelLimits_TEST1
    22 # define PM_MODEL_RADIUS     pmModelRadius_TEST1
    23 # define PM_MODEL_FROM_PSF   pmModelFromPSF_TEST1
    24 # define PM_MODEL_FIT_STATUS pmModelFitStatus_TEST1
    25 
    26 // XXX consider changing to form PAR[SXY]*(1/PAR[SXX]^2 + 1/PAR[SYY]^2)*X*Y
    27 // this would provide natural limits on PAR[SXY] of -0.25 : +0.25
     18# define PM_MODEL_FUNC            pmModelFunc_TEST1
     19# define PM_MODEL_FLUX            pmModelFlux_TEST1
     20# define PM_MODEL_GUESS           pmModelGuess_TEST1
     21# define PM_MODEL_LIMITS          pmModelLimits_TEST1
     22# define PM_MODEL_RADIUS          pmModelRadius_TEST1
     23# define PM_MODEL_FROM_PSF        pmModelFromPSF_TEST1
     24# define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_TEST1
     25# define PM_MODEL_FIT_STATUS      pmModelFitStatus_TEST1
    2826
    2927// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
    3028psF32 PM_MODEL_FUNC(psVector *deriv,
    31                          const psVector *params,
    32                          const psVector *pixcoord)
     29                    const psVector *params,
     30                    const psVector *pixcoord)
    3331{
    3432    psF32 *PAR = params->data.F32;
     
    125123
    126124// make an initial guess for parameters
    127 bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    128 {
     125bool PM_MODEL_GUESS (void *inModel, void *inSource)
     126{
     127    pmModel *model = inModel;
     128    pmSource *source = inSource;
    129129
    130130    pmMoments *moments = source->moments;
     
    160160    norm = 0.0;
    161161
    162     # define DZ 0.25
     162# define DZ 0.25
    163163
    164164    float f0 = 1.0;
     
    207207}
    208208
    209 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf)
    210 {
     209bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF)
     210{
     211    pmModel *modelPSF = inModelPSF;
     212    pmModel *modelFLT = inModelFLT;
     213    pmPSF *psf = inPSF;
    211214
    212215    psF32 *out = modelPSF->params->data.F32;
     
    232235}
    233236
     237// construct the PSF model from the FLT model and the psf
     238// XXX is this sufficiently general do be a global function, not a pmModelClass function?
     239bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io)
     240{
     241    pmModel *model = inModel;
     242    pmPSF *psf = inPSF;
     243
     244    psF32 *PAR = model->params->data.F32;
     245
     246    // we require these two parameters to exist
     247    assert (psf->params_NEW->n > PM_PAR_YPOS);
     248    assert (psf->params_NEW->n > PM_PAR_XPOS);
     249
     250    PAR[PM_PAR_SKY]  = 0.0;
     251    PAR[PM_PAR_I0]   = Io;
     252    PAR[PM_PAR_XPOS] = Xo;
     253    PAR[PM_PAR_YPOS] = Yo;
     254   
     255    // supply the model-fitted parameters, or copy from the input
     256    for (int i = 0; i < psf->params_NEW->n; i++) {
     257        if (i == PM_PAR_SKY) continue;
     258        psPolynomial2D *poly = psf->params_NEW->data[i];
     259        assert (poly);
     260        PAR[i] = psPolynomial2DEval(poly, Xo, Yo);
     261    }
     262
     263    // the 2D PSF model fits polarization terms (E0,E1,E2)
     264    // convert to shape terms (SXX,SYY,SXY)
     265    // XXX user-defined value for limit?
     266    if (!pmPSF_FitToModel (PAR, 0.1)) {
     267        psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
     268        return false;
     269    }
     270
     271    // apply the model limits here: this truncates excessive extrapolation
     272    // XXX do we need to do this still?  should we put in asserts to test?
     273    for (int i = 0; i < psf->params_NEW->n; i++) {
     274        // apply the limits to all components or just the psf-model parameters?
     275        if (psf->params_NEW->data[i] == NULL)
     276            continue;
     277
     278        bool status = true;
     279        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL);
     280        status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL);
     281        if (!status) {
     282            psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo);
     283            model->flags |= PM_MODEL_STATUS_LIMITS;
     284        }
     285    }
     286    return(true);
     287}
     288
    234289// XXX double-check these definitions below
    235290// this test is invalid if the parameters are derived
    236291// from the PSF model
    237 bool PM_MODEL_FIT_STATUS (pmModel *model)
    238 {
     292bool PM_MODEL_FIT_STATUS (void *inModel)
     293{
     294    pmModel *model = inModel;
    239295
    240296    psF32 dP;
     
    265321# undef PM_MODEL_RADIUS
    266322# undef PM_MODEL_FROM_PSF
     323# undef PM_MODEL_PARAMS_FROM_PSF
    267324# undef PM_MODEL_FIT_STATUS
  • branches/eam_branch_20070817/psphot/src/pmFootprint.c

    r14335 r14545  
    2929}
    3030
    31 bool pmIsSpan(const psPtr ptr)
     31bool pmSpanTest(const psPtr ptr)
    3232{
    3333    return (psMemGetDeallocator(ptr) == (psFreeFunc)spanFree);
     
    115115}
    116116
    117 bool pmIsFootprint(const psPtr ptr) {
     117bool pmFootprintTest(const psPtr ptr) {
    118118    return (psMemGetDeallocator(ptr) == (psFreeFunc)footprintFree);
    119119}
     
    762762   // Set stop bits from peaks list
    763763   //
    764    assert (peaks == NULL || peaks->n == 0 || pmIsPeak(peaks->data[0]));
     764   assert (peaks == NULL || peaks->n == 0 || pmPeakTest(peaks->data[0]));
    765765   if (peaks != NULL) {
    766766       for (int i = 0; i < peaks->n; i++) {
     
    859859   }
    860860   const pmFootprint *fp = footprints->data[0];
    861    assert(pmIsFootprint((const psPtr)fp));
     861   assert(pmFootprintTest((const psPtr)fp));
    862862   const int numCols = fp->region.x1 - fp->region.x0 + 1;
    863863   const int numRows = fp->region.y1 - fp->region.y0 + 1;
     
    884884psImage *pmSetFootprintID(const pmFootprint *fp, // the footprint to insert
    885885                          const int id) {       // the desired ID
    886    assert(fp != NULL && pmIsFootprint((const psPtr)fp));
     886   assert(fp != NULL && pmFootprintTest((const psPtr)fp));
    887887   const int numCols = fp->region.x1 - fp->region.x0 + 1;
    888888   const int numRows = fp->region.y1 - fp->region.y0 + 1;
     
    910910psArray *pmGrowFootprintArray(const psArray *footprints, // footprints to grow
    911911                              int r) {  // how much to grow each footprint
    912     assert (footprints->n == 0 || pmIsFootprint(footprints->data[0]));
     912    assert (footprints->n == 0 || pmFootprintTest(footprints->data[0]));
    913913
    914914    if (footprints->n == 0) {           // we don't know the size of the footprint's region
     
    964964                                const psArray *footprints2, // the other set
    965965                                const int includePeaks) { // which peaks to set? 0x1 => footprints1, 0x2 => 2
    966     assert (footprints1->n == 0 || pmIsFootprint(footprints1->data[0]));
    967     assert (footprints2->n == 0 || pmIsFootprint(footprints2->data[0]));
     966    assert (footprints1->n == 0 || pmFootprintTest(footprints1->data[0]));
     967    assert (footprints2->n == 0 || pmFootprintTest(footprints2->data[0]));
    968968
    969969    if (footprints1->n == 0 || footprints2->n == 0) {           // nothing to do but put copies on merged
     
    10321032                          const psArray *peaks) { // the pmPeaks
    10331033    assert (footprints != NULL);
    1034     assert (footprints->n == 0 || pmIsFootprint(footprints->data[0]));
     1034    assert (footprints->n == 0 || pmFootprintTest(footprints->data[0]));
    10351035    assert (peaks != NULL);
    1036     assert (peaks->n == 0 || pmIsPeak(peaks->data[0]));
     1036    assert (peaks->n == 0 || pmPeakTest(peaks->data[0]));
    10371037   
    10381038    if (footprints->n == 0) {
     
    12221222psArray *pmFootprintArrayToPeaks(const psArray *footprints) {
    12231223   assert(footprints != NULL);
    1224    assert(footprints->n == 0 || pmIsFootprint(footprints->data[0]));
     1224   assert(footprints->n == 0 || pmFootprintTest(footprints->data[0]));
    12251225
    12261226   int npeak = 0;
  • branches/eam_branch_20070817/psphot/src/pmFootprint.h

    r13442 r14545  
    1111
    1212pmSpan *pmSpanAlloc(int y, int x1, int x2);
    13 bool pmIsSpan(const psPtr ptr);
     13bool pmSpanTest(const psPtr ptr);
    1414int pmSpanSortByYX (const void **a, const void **b);
    1515
     
    2525
    2626pmFootprint *pmFootprintAlloc(int nspan, const psImage *img);
    27 bool pmIsFootprint(const psPtr ptr);
     27bool pmFootprintTest(const psPtr ptr);
    2828
    2929pmFootprint *pmFootprintNormalize(pmFootprint *fp);
  • branches/eam_branch_20070817/psphot/src/psphot.c

    r14005 r14545  
    1111    pmErrorRegister();                  // register psModule's error codes/messages
    1212    psphotErrorRegister();              // register our error codes/messages
    13     psphotModelGroupInit ();            // load implementation-specific models
     13    psphotModelClassInit ();            // load implementation-specific models
    1414
    1515    // load command-line arguments, options, and system config data
  • branches/eam_branch_20070817/psphot/src/psphot.h

    r14338 r14545  
    5151
    5252// basic support functions
    53 void            psphotModelGroupInit (void);
     53void            psphotModelClassInit (void);
    5454int             pmPeakSortBySN (const void **a, const void **b);
    5555int             pmPeakSortByY (const void **a, const void **b);
  • branches/eam_branch_20070817/psphot/src/psphotChoosePSF.c

    r13900 r14545  
    295295    }
    296296
    297     char *modelName = pmModelGetType (psf->type);
     297    char *modelName = pmModelClassGetName (psf->type);
    298298    psLogMsg ("psphot.pspsf", PS_LOG_INFO, "select psf model: %f sec\n", psTimerMark ("psphot"));
    299299    psLogMsg ("psphot.pspsf", PS_LOG_INFO, "psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid);
     
    315315    PS_ASSERT_PTR_NON_NULL(image, false);
    316316
    317     pmModel *modelEXT = pmModelAlloc (psf->type);
    318     PS_ASSERT_PTR_NON_NULL(modelEXT, false);
    319 
    320     // make a model with unit central intensity at the image center
    321     modelEXT->params->data.F32[PM_PAR_SKY] = 0;
    322     modelEXT->params->data.F32[PM_PAR_I0] = 1;
    323     modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*image->numCols;
    324     modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*image->numRows;
    325 
    326     // construct a PSF model at this coordinate
    327     pmModel *modelPSF = pmModelFromPSF (modelEXT, psf);
     317    // construct a normalized PSF model at this coordinate (Io = 1.0)
     318    pmModel *modelPSF = pmModelFromPSFforXY (psf, 0.5*image->numCols, 0.5*image->numRows, 1.0);
    328319    if (modelPSF == NULL) {
    329320        psError(PSPHOT_ERR_PSF, false, "Failed to estimate PSF model at image centre");
    330         psFree(modelEXT);
    331321        return false;
    332322    }
    333323
    334     // get the correct model-radius function
    335     pmModelRadius modelRadiusFunc = pmModelRadius_GetFunction (psf->type);
    336 
    337324    // get the model full-width at half-max
    338     psF64 FWHM_X = 2*modelRadiusFunc (modelPSF->params, 0.5);
     325    psF64 FWHM_X = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
    339326
    340327    // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
     
    351338    psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", psf->nPSFstars);
    352339    psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", true);
    353 
    354     psFree (modelEXT);
    355340    psFree (modelPSF);
    356341
  • branches/eam_branch_20070817/psphot/src/psphotCleanup.c

    r12805 r14545  
    77    psTimerStop ();
    88    psMemCheckCorruption (stderr, true);
    9     pmModelGroupCleanup ();
     9    pmModelClassCleanup ();
    1010    psTimeFinalize ();
    1111    pmConceptsDone ();
  • branches/eam_branch_20070817/psphot/src/psphotEvalFLT.c

    r13804 r14545  
    3737    }
    3838
    39     keep = pmModelFitStatus (model);
     39    keep = model->modelFitStatus(model);
    4040    if (keep) return true;
    4141
  • branches/eam_branch_20070817/psphot/src/psphotFakeSources.c

    r12792 r14545  
    2323        source->type = PM_SOURCE_TYPE_STAR;
    2424
    25         pmModelType modelType = pmModelSetType ("PS_MODEL_QGAUSS");
     25        pmModelType modelType = pmModelClassGetType ("PS_MODEL_QGAUSS");
    2626        source->modelPSF = pmSourceModelGuess (source, modelType);
    2727        sources->data[i] = source;
  • branches/eam_branch_20070817/psphot/src/psphotFindPeaks.c

    r13900 r14545  
    9595
    9696    // find the peaks in the smoothed image
    97     psArray *peaks = pmFindImagePeaks (smooth_im, threshold);
     97    psArray *peaks = pmPeaksInImage (smooth_im, threshold);
    9898    if (peaks == NULL) {
    9999        // XXX this may also be due to a programming or config error
  • branches/eam_branch_20070817/psphot/src/psphotGrowthCurve.c

    r13900 r14545  
    1414    float radius;
    1515
    16     // create template model
    17     pmModel *modelRef = pmModelAlloc(psf->type);
    18 
    1916    // use the center of the center pixel of the image
    2017    xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5;
     
    2320    dy = psf->growth->maxRadius + 1;
    2421
    25     // assign the x and y coords to the image center
    26     // create an object with center intensity of 1000
    27     modelRef->params->data.F32[PM_PAR_SKY] = 0;
    28     modelRef->params->data.F32[PM_PAR_I0] = 1000;
    29     modelRef->params->data.F32[PM_PAR_XPOS] = xc;
    30     modelRef->params->data.F32[PM_PAR_YPOS] = yc;
    31 
    32     // create modelPSF from this model
    33     pmModel *model = pmModelFromPSF (modelRef, psf);
     22    // create normalized model object at xc,yc
     23    pmModel *model = pmModelFromPSFforXY (psf, xc, yc, 1.0);
    3424
    3525    // measure the fitMag for this model
     
    7666    psFree (mask);
    7767    psFree (model);
    78     psFree (modelRef);
    7968
    8069    return true;
  • branches/eam_branch_20070817/psphot/src/psphotModelGroupInit.c

    r12792 r14545  
    77# include "models/pmModel_STRAIL.c"
    88
    9 static pmModelGroup userModels[] = {
    10     {"PS_MODEL_TEST1", 7, pmModelFunc_TEST1,  pmModelFlux_TEST1,  pmModelRadius_TEST1,  pmModelLimits_TEST1,  pmModelGuess_TEST1, pmModelFromPSF_TEST1, pmModelFitStatus_TEST1},
    11     {"PS_MODEL_STRAIL", 9, pmModelFunc_STRAIL,  pmModelFlux_STRAIL,  pmModelRadius_STRAIL,  pmModelLimits_STRAIL,  pmModelGuess_STRAIL, pmModelFromPSF_STRAIL, pmModelFitStatus_STRAIL},
     9static pmModelClass userModels[] = {
     10    {"PS_MODEL_TEST1", 7, pmModelFunc_TEST1,  pmModelFlux_TEST1,  pmModelRadius_TEST1,  pmModelLimits_TEST1,  pmModelGuess_TEST1, pmModelFromPSF_TEST1, pmModelParamsFromPSF_TEST1, pmModelFitStatus_TEST1},
     11    {"PS_MODEL_STRAIL", 9, pmModelFunc_STRAIL,  pmModelFlux_STRAIL,  pmModelRadius_STRAIL,  pmModelLimits_STRAIL,  pmModelGuess_STRAIL, pmModelFromPSF_STRAIL, pmModelParamsFromPSF_STRAIL, pmModelFitStatus_STRAIL},
    1212};
    1313
    14 void psphotModelGroupInit (void)
     14void psphotModelClassInit (void)
    1515{
    1616
    17     // if pmModelGroupInit returns false, we have already init'ed
    18     if (!pmModelGroupInit ()) return;
     17    // if pmModelClassInit returns false, we have already init'ed
     18    if (!pmModelClassInit ()) return;
    1919
    20     int Nmodels = sizeof (userModels) / sizeof (pmModelGroup);
     20    int Nmodels = sizeof (userModels) / sizeof (pmModelClass);
    2121    for (int i = 0; i < Nmodels; i++) {
    22         pmModelGroupAdd (&userModels[i]);
     22        pmModelClassAdd (&userModels[i]);
    2323    }
    2424    return;
  • branches/eam_branch_20070817/psphot/src/psphotModelTest.c

    r14348 r14545  
    8989            modelName = item->data.V;
    9090        }
    91         modelType = pmModelSetType (modelName);
     91        modelType = pmModelClassGetType (modelName);
    9292        if (modelType < 0) psAbort("unknown model %s", modelName);
    9393        source->type = PM_SOURCE_TYPE_EXTENDED;
     
    118118            modelName = item->data.V;
    119119        }
    120         modelType = pmModelSetType (modelName);
     120        modelType = pmModelClassGetType (modelName);
    121121        if (modelType < 0) psAbort("unknown model %s", modelName);
    122122        source->type = PM_SOURCE_TYPE_EXTENDED;
     
    148148
    149149    // if any parameters are defined by the user, take those values
    150     int nParams = pmModelParameterCount (modelType);
     150    int nParams = pmModelClassParameterCount (modelType);
    151151    psF32 *params = model->params->data.F32;
    152152    params[PM_PAR_XPOS] = xObj; // XXX use the user-supplied value,
  • branches/eam_branch_20070817/psphot/src/psphotPSFConvModel.c

    r14348 r14545  
    5858    psVector *dparams = modelConv->dparams;
    5959
    60     // get the model function for this model
    61     pmModelFunc modelFunc = pmModelFunc_GetFunction (modelConv->type);
    62     if (!modelFunc)
    63         psAbort("invalid model function");
    64 
    65     // get the limits function for this model
    66     pmModelLimits checkLimits = pmModelLimits_GetFunction (modelConv->type);
    67     if (!checkLimits)
    68         psAbort("invalid model limits function");
    69 
    7060    // create the minimization constraints
    7161    psMinConstraint *constraint = psMinConstraintAlloc();
    7262    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
    73     constraint->checkLimits = checkLimits;
     63    constraint->checkLimits = modelConv->modelLimits;
    7464
    7565    // set parameter mask based on fitting mode
     
    8171    // force the floating parameters to fall within the contraint ranges
    8272    for (int i = 0; i < params->n; i++) {
    83         checkLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);
    84         checkLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);
     73        modelConv->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);
     74        modelConv->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);
    8575    }
    8676
     
    9080    psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32);
    9181
    92     bool fitStatus = psphotModelWithPSF_LMM (myMin, covar, params, constraint, source, psf, modelFunc);
     82    bool fitStatus = psphotModelWithPSF_LMM (myMin, covar, params, constraint, source, psf, modelConv->modelFunc);
    9383    for (int i = 0; i < dparams->n; i++) {
    9484        if (psTraceGetLevel("psphot") >= 4) {
  • branches/eam_branch_20070817/psphot/src/psphotPSFResiduals.c

    r12792 r14545  
    1212    if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
    1313
    14     // XXX if a source is faint, it will not have moments measured.
    15     // it must be modelled as a PSF.  In this case, we need to use
    16     // the peak centroid to get the coordinates and get the peak flux
    17     // from the image?
    18 
    19     // use the source moments, etc to guess basic model parameters
    20     pmModel *modelEXT = pmSourceModelGuess (source, psf->type);
    21    
    22     // XXX put this in a function of its own..
    23     if (modelEXT == NULL) {
    24         psErrorClear (); // XXX need to clear the error from failing the model
    25         modelEXT = pmModelAlloc(psf->type);
    26         psF32 *PAR = modelEXT->params->data.F32;
    27         PAR[PM_PAR_SKY]  = 0;
    28         // XXX get this from the image pixels
    29         PAR[PM_PAR_I0]   = source->peak->flux;
    30         PAR[PM_PAR_XPOS] = source->peak->xf;
    31         PAR[PM_PAR_YPOS] = source->peak->yf;
     14    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     15        Xo = source->moments->x;
     16        Yo = source->moments->y;
     17        Io = source->peak->flux;
    3218    } else {
    33         // these valuse are set in pmSourceModelGuess, should this rule be in there as well?
    34         if (source->mode &  PM_SOURCE_MODE_SATSTAR) {
    35             modelEXT->params->data.F32[PM_PAR_XPOS] = source->moments->x;
    36             modelEXT->params->data.F32[PM_PAR_YPOS] = source->moments->y;
    37         } else {
    38             modelEXT->params->data.F32[PM_PAR_XPOS] = source->peak->xf;
    39             modelEXT->params->data.F32[PM_PAR_YPOS] = source->peak->yf;
    40         }
     19        Xo = source->peak->xf;
     20        Yo = source->peak->yf;
     21        Io = source->peak->flux;
    4122    }
    4223
    4324    // set PSF parameters for this model (apply 2D shape model)
    44     pmModel *modelPSF = pmModelFromPSF (modelEXT, psf);
    45     psFree (modelEXT);
     25    pmModel *modelPSF = pmModelFromPSFforXY (psf, Xo, Yo, Io);
    4626
    4727    // XXX need to define the guess flux?
  • branches/eam_branch_20070817/psphot/src/psphotRadiusChecks.c

    r13035 r14545  
    66static float PSF_FIT_RADIUS = 0;        // radius to use in fitting (ignored if <= 0,
    77                                        // and a per-object radius is calculated)
    8 static pmModelRadius modelRadiusPSF;
    98
    109bool psphotInitRadiusPSF(const psMetadata *recipe,
     
    1716    PSF_FIT_RADIUS =  psMetadataLookupF32(&status, recipe, "PSF_FIT_RADIUS");
    1817
    19     // this function specifies the radius at this the model hits the given flux
    20     modelRadiusPSF       = pmModelRadius_GetFunction (type);
    2118    return true;
    2219}
     
    3431    if (radiusFit <= 0) {               // use fixed radius
    3532        if (moments == NULL) {
    36             radiusFit = modelRadiusPSF(model->params, PSF_FIT_NSIGMA*moments->dSky);
     33            radiusFit = model->modelRadius(model->params, PSF_FIT_NSIGMA*moments->dSky);
    3734        } else {
    38             radiusFit = modelRadiusPSF(model->params, 1.0);
     35            radiusFit = model->modelRadius(model->params, 1.0);
    3936        }
    4037    }
     
    6259
    6360    // set the fit radius based on the object flux limit and the model
    64     model->radiusFit = (RADIUS_TYPE) (modelRadiusPSF (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING);
     61    model->radiusFit = (RADIUS_TYPE) (model->modelRadius (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING);
    6562    if (isnan(model->radiusFit)) psAbort("error in radius");
    6663       
     
    7875static float EXT_FIT_NSIGMA;
    7976static float EXT_FIT_PADDING;
    80 static pmModelRadius modelRadiusEXT;
    8177
    8278bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type) {
     
    8783    EXT_FIT_PADDING  = psMetadataLookupF32 (&status, recipe, "EXT_FIT_PADDING");
    8884
    89     // this function specifies the radius at this the model hits the given flux
    90     modelRadiusEXT       = pmModelRadius_GetFunction (type);
    9185    return true;
    9286}
     
    10195
    10296    // set the fit radius based on the object flux limit and the model
    103     model->radiusFit = (RADIUS_TYPE) (modelRadiusEXT (model->params, EXT_FIT_NSIGMA*moments->dSky) + EXT_FIT_PADDING);
     97    model->radiusFit = (RADIUS_TYPE) (model->modelRadius (model->params, EXT_FIT_NSIGMA*moments->dSky) + EXT_FIT_PADDING);
    10498    if (isnan(model->radiusFit)) psAbort("error in radius");
    10599
  • branches/eam_branch_20070817/psphot/src/psphotSourceFits.c

    r13900 r14545  
    195195    // extended source model descriptions
    196196    char *modelNameEXT = psMetadataLookupStr (&status, recipe, "EXT_MODEL");
    197     modelTypeEXT = pmModelSetType (modelNameEXT);
     197    modelTypeEXT = pmModelClassGetType (modelNameEXT);
    198198    psphotInitRadiusEXT (recipe, modelTypeEXT);
    199199
  • branches/eam_branch_20070817/psphot/src/psphotTestSourceOutput.c

    r12950 r14545  
    2121    psVector *x = psVectorAlloc(2, PS_TYPE_F32);
    2222    psVector *params = model->params;
    23     pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
    2423    psS32 imageCol;
    2524    psS32 imageRow;
     
    6867            // set the appropriate pixel value for this coordinate
    6968            if (mode & PSPHOT_ADD_MODEL) {
    70                 pixelValue = modelFunc (NULL, params, x) - skyValue;
     69                pixelValue = model->modelFunc (NULL, params, x) - skyValue;
    7170            } else {
    7271                pixelValue = 0.0;
Note: See TracChangeset for help on using the changeset viewer.