IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10198


Ignore:
Timestamp:
Nov 26, 2006, 12:24:45 PM (19 years ago)
Author:
magnier
Message:

removed old model components of pmPSFtry (are kept in the sources array)

added 'applyWeight' parameter to pmPSFFromPSFtry and pmPSFtryModel : this
turns on/off the measured parameter weights when setting the 2D model. off
is probably better to avoid biasing to much to the brightest sources

changed test output to trace options rather than #defs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSFtry.c

    r10103 r10198  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-11-20 20:37:50 $
     7 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-11-26 22:24:45 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646    psFree (test->psf);
    4747    psFree (test->sources);
    48     // psFree (test->modelEXT);
    49     // psFree (test->modelPSF);
    5048    psFree (test->metric);
    5149    psFree (test->metricErr);
     
    7371    test->fitMag    = psVectorAlloc (sources->n, PS_TYPE_F64);
    7472    test->mask      = psVectorAlloc (sources->n, PS_TYPE_U8);
    75     // test->modelEXT  = psArrayAlloc (sources->n);
    76     // test->modelPSF  = psArrayAlloc (sources->n);
    7773
    7874    test->sources   = psArrayAlloc (sources->n);
     
    8379        test->metricErr->data.F64[i] = 0;
    8480        test->fitMag->data.F64[i] = 0;
    85         // test->modelEXT->data[i] = NULL;
    86         // test->modelPSF->data[i] = NULL;
    8781    }
    8882
     
    10195
    10296// generate a pmPSFtry with a copy of the test PSF sources
    103 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask)
     97pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights)
    10498{
    10599    bool status;
     
    140134            continue;
    141135        }
    142         // XXX is this still needed?
    143         // psfTry->modelEXT->data[i] = psMemIncrRefCounter (source->modelEXT);
    144136        Next ++;
    145137    }
     
    148140
    149141    // stage 2: construct a psf (pmPSF) from this collection of model fits
    150     pmPSFFromPSFtry (psfTry);
     142    pmPSFFromPSFtry (psfTry, applyWeights);
    151143
    152144    // stage 3: refit with fixed shape parameters
     
    168160        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK);
    169161        status = pmSourceFitModel (source, source->modelPSF, PM_SOURCE_FIT_PSF);
    170         // pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);
    171162        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(PM_MASK_MARK));
    172163
     
    176167            continue;
    177168        }
    178 
    179         // otherwise, save the resulting model
    180         // psfTry->modelPSF->data[i] = psMemIncrRefCounter (source->modelPSF);
    181169
    182170        // XXX : use a different aperture radius from the fit radius?
     
    292280
    293281    // XXX test dump of fitted model (dump when tracing?)
    294     if (1) {
     282    if (psTraceGetLevel("psModules.objects") >= 4) {
    295283        FILE *f = fopen ("resid.dat", "w");
    296284        psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux);
     
    343331Note: some of the array entries may be NULL (failed fits); ignore them.
    344332 *****************************************************************************/
    345 bool pmPSFFromPSFtry (pmPSFtry *psfTry)
     333bool pmPSFFromPSFtry (pmPSFtry *psfTry, bool applyWeight)
    346334{
    347335    pmPSF *psf = psfTry->psf;
     
    351339    psVector *y  = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
    352340    psVector *z  = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
    353     psVector *dz = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
     341
     342    psVector *dz = NULL;
     343    if (applyWeight) {
     344        dz = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
     345    }
    354346
    355347    // construct the x,y terms
     
    388380
    389381            z->data.F64[j] = source->modelEXT->params->data.F32[i];
    390             dz->data.F64[j] = source->modelEXT->dparams->data.F32[i];
    391             // dz->data.F64[j] = 1; // use the model-fitted error? or S/N?
     382            if (applyWeight) {
     383                dz->data.F64[j] = source->modelEXT->dparams->data.F32[i];
     384            }
    392385
    393386            // for SXY, we actually fit SXY / (SXX^-2  + SYY^-2)
     
    396389            }
    397390        }
    398         // XXX does psfTry->mask need to be init to 0 and set to 1 above?
    399         if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, dz, x, y)) {
     391
     392        // fit the collection of measured parameters to the PSF 2D model
     393        // the mask is carried from previous steps and updated with this operation
     394        // the weight is either the parameter error or NULL, depending on 'applyWeights'
     395        if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, NULL, x, y)) {
    400396            psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i);
    401397            return false;
    402398        }
    403         // psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (PSF param %d)\n", Nkeep, psfTry->mask->n, i);
    404     }
    405 
    406     // XXX test dump of star parameters vs position (compare with fitted values)
    407     if (1) {
     399    }
     400
     401    // test dump of star parameters vs position (compare with fitted values)
     402    if (psTraceGetLevel("psModules.objects") >= 4) {
    408403        FILE *f = fopen ("params.dat", "w");
    409404
Note: See TracChangeset for help on using the changeset viewer.