IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 25, 2013, 11:51:42 AM (13 years ago)
Author:
eugene
Message:

new fitting tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c

    r36310 r36311  
    2121
    2222bool psphotPCMfitCheckSize (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, float psfSize);
     23bool psphotPCMfitRetry (pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal, float psfSize);
    2324
    2425bool psphotFitInit (int nThreads) {
     
    652653    if (TIMING) { t4 = psTimerMark ("psphotFitPCM"); }
    653654
    654     psphotPCMfitCheckSize (pcm, source, maskVal, psfSize);
     655    if (pcm->modelConv->nIter == fitOptions->nIter) {
     656        psphotPCMfitRetry (pcm, source, &options, maskVal, markVal, psfSize);
     657    }
     658    // psphotPCMfitCheckSize (pcm, source, maskVal, psfSize);
    655659    if (TIMING) { t5 = psTimerMark ("psphotFitPCM"); }
    656660
     
    13251329            rMin = dref;
    13261330        }
    1327         // fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin);
     1331        fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin);
    13281332    }
    13291333
     
    13441348}
    13451349
     1350// we have an initial fit, check to see if the current size is besst
     1351bool psphotPCMfitRetry (pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal, float psfSize) {
     1352
     1353    // PAR is already at my current best guess
     1354    psF32 *PAR = pcm->modelConv->params->data.F32;
     1355
     1356    // store best guess as a shape
     1357    psEllipseAxes centerAxes;
     1358    pmModelParamsToAxes (&centerAxes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
     1359
     1360    // retry with axes smaller by 1 pixel
     1361    psEllipseAxes guessAxes;
     1362    guessAxes.major = centerAxes.major - 0.08;
     1363    guessAxes.minor = guessAxes.major * centerAxes.minor / centerAxes.major;
     1364    guessAxes.theta = centerAxes.theta;
     1365
     1366    if (!isfinite(guessAxes.major)) return false;
     1367    if (!isfinite(guessAxes.minor)) return false;
     1368    if (!isfinite(guessAxes.theta)) return false;
     1369
     1370    // convert the major,minor,theta to shape parameters for an Reff-like model
     1371    pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], guessAxes, true);
     1372
     1373    // generated the modelFlux
     1374    pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);
     1375       
     1376    float YY = 0.0;
     1377    float YM = 0.0;
     1378    float MM = 0.0;
     1379    bool usePoisson = false;
     1380
     1381    for (int iy = 0; iy < source->pixels->numRows; iy++) {
     1382        for (int ix = 0; ix < source->pixels->numCols; ix++) {
     1383            // skip masked points
     1384            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) {
     1385                continue;
     1386            }
     1387            // skip zero-variance points
     1388            if (source->variance->data.F32[iy][ix] == 0) {
     1389                continue;
     1390            }
     1391            // skip nan value points
     1392            if (!isfinite(source->pixels->data.F32[iy][ix])) {
     1393                continue;
     1394            }
     1395
     1396            float fy = source->pixels->data.F32[iy][ix];
     1397            float fm = source->modelFlux->data.F32[iy][ix];
     1398            float wt = (usePoisson) ? 1.0 / source->variance->data.F32[iy][ix] : 1.0;
     1399
     1400            YY += PS_SQR(fy) * wt;
     1401            YM += fm * fy * wt;
     1402            MM += PS_SQR(fm) * wt;
     1403        }
     1404    }
     1405
     1406    float Io = YM / MM;
     1407    PAR[PM_PAR_I0] = Io;
     1408
     1409    pmSourceFitPCM (pcm, source, fitOptions, maskVal, markVal, psfSize);  // NOTE : 1687 allocs in here
     1410
     1411    return true;
     1412}
     1413
     1414
Note: See TracChangeset for help on using the changeset viewer.