IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 11, 2010, 4:20:46 PM (16 years ago)
Author:
Paul Price
Message:

Don't test the PSF just in the middle (unless that's all that matters).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmPSFEnvelope.c

    r26916 r26917  
    152152        // Test PSF
    153153        {
    154             bool goodPSF = true;                                                                // Good PSF?
    155             pmModelClassSetLimits(PM_MODEL_LIMITS_IGNORE);
    156             pmModel *model = pmModelFromPSFforXY(psf, numCols / 2.0, numRows / 2.0, PEAK_FLUX); // Test model
    157             if (!model) {
    158                 goodPSF = false;
    159             } else {
    160                 model->modelSetLimits(PM_MODEL_LIMITS_MODERATE);
    161                 for (int j = 0; j < model->params->n && goodPSF; j++) {
    162                     if (!model->modelLimits(PS_MINIMIZE_PARAM_MIN, j, model->params->data.F32, NULL) ||
    163                         !model->modelLimits(PS_MINIMIZE_PARAM_MAX, j, model->params->data.F32, NULL)) {
    164                         goodPSF = false;
     154            bool goodPSF = false;       // Is there a PSF that we can use?
     155            int xNum = PS_MAX(psf->trendNx, 1), yNum = PS_MAX(psf->trendNy, 1); // Number of positions to check
     156            for (int j = 0; j < yNum && !goodPSF; j++) {
     157                float y = ((float)j + 0.5) / (float)yNum * numRows; // Position on image
     158                for (int i = 0; i < xNum && !goodPSF; i++) {
     159                    float x = ((float)i + 0.5) / (float)xNum * numCols; // Position on image
     160                    pmModelClassSetLimits(PM_MODEL_LIMITS_IGNORE);
     161                    pmModel *model = pmModelFromPSFforXY(psf, x, y, PEAK_FLUX); // Test model
     162                    if (!model) {
     163                        continue;
     164                    }
     165                    model->modelSetLimits(PM_MODEL_LIMITS_MODERATE);
     166                    bool limits = true; // Model within limits?
     167                    for (int j = 0; j < model->params->n && limits; j++) {
     168                        if (!model->modelLimits(PS_MINIMIZE_PARAM_MIN, j, model->params->data.F32, NULL) ||
     169                            !model->modelLimits(PS_MINIMIZE_PARAM_MAX, j, model->params->data.F32, NULL)) {
     170                            limits = false;
     171                        }
     172                    }
     173                    psFree(model);
     174                    if (limits) {
     175                        goodPSF = true;
    165176                    }
    166177                }
    167                 psFree(model);
    168178            }
    169179            if (!goodPSF) {
    170                 psWarning("PSF %d is bad --- not including in envelope calculation.", i);
     180                psWarning("PSF %d is completely bad --- not including in envelope calculation.", i);
    171181                continue;
    172182            }
     
    175185        pmResiduals *resid = psf->residuals;// PSF residuals
    176186        psf->residuals = NULL;
     187        pmModelClassSetLimits(PM_MODEL_LIMITS_MODERATE);
    177188        if (!pmReadoutFakeFromSources(fakeRO, fakeSize, fakeSize, fakes, 0, xOffset, yOffset, psf,
    178189                                      NAN, radius, true, false)) {
     
    399410
    400411    pmSourceFitModelInit(SOURCE_FIT_ITERATIONS, 0.01, VARIANCE_VAL, true);
    401     pmModelClassSetLimits(PM_MODEL_LIMITS_STRICT);
     412    pmModelClassSetLimits(PM_MODEL_LIMITS_STRICT); // Important for getting a good stack target PSF
    402413
    403414    pmPSFtry *try = pmPSFtryModel(fakes, modelName, options, 0, 0xff);
Note: See TracChangeset for help on using the changeset viewer.