IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2011, 1:12:39 PM (15 years ago)
Author:
eugene
Message:

use the smoothed image for footprint culling; use a more stringent culling for saturated stars; more tweaks to get sat stars to be fitted; various updates to psphotStack; unify psphotImageLoop varients; be a bit careful about number of stars in a PSF clump

Location:
trunk/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/psphotExtendedSourceFits.c

    r30624 r31154  
    4343    int NplainPass = 0;
    4444    int Nfaint = 0;
     45    int Nfail = 0;
    4546
    4647    psTimerStart ("psphot.extended");
     
    145146
    146147    // source analysis is done in S/N order (brightest first)
    147     sources = psArraySort (sources, pmSourceSortBySN);
     148    sources = psArraySort (sources, pmSourceSortByFlux);
    148149
    149150    // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts)
     
    176177            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nplain
    177178            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for NplainPass
    178             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfain
    179 
    180             if (false && !psThreadJobAddPending(job)) {
     179            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint
     180            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
     181
     182// set this to 0 to run without threading
     183# if (1)           
     184            if (!psThreadJobAddPending(job)) {
    181185                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    182186                psFree(AnalysisRegion);
    183187                return false;
    184             } else {
    185                 if (!psphotExtendedSourceFits_Threaded(job)) {
    186                     psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    187                     psFree(AnalysisRegion);
    188                     return false;
    189                 }
    190                 psScalar *scalar = NULL;
    191                 scalar = job->args->data[7];
    192                 Next += scalar->data.S32;
    193                 scalar = job->args->data[8];
    194                 Nconvolve += scalar->data.S32;
    195                 scalar = job->args->data[9];
    196                 NconvolvePass += scalar->data.S32;
    197                 scalar = job->args->data[10];
    198                 Nplain += scalar->data.S32;
    199                 scalar = job->args->data[11];
    200                 NplainPass += scalar->data.S32;
    201                 scalar = job->args->data[12];
    202                 Nfaint += scalar->data.S32;
    203                 psFree(job);
     188            }
     189# else
     190            if (!psphotExtendedSourceFits_Threaded(job)) {
     191                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     192                psFree(AnalysisRegion);
     193                return false;
    204194            }
    205         }
     195            psScalar *scalar = NULL;
     196            scalar = job->args->data[7];
     197            Next += scalar->data.S32;
     198            scalar = job->args->data[8];
     199            Nconvolve += scalar->data.S32;
     200            scalar = job->args->data[9];
     201            NconvolvePass += scalar->data.S32;
     202            scalar = job->args->data[10];
     203            Nplain += scalar->data.S32;
     204            scalar = job->args->data[11];
     205            NplainPass += scalar->data.S32;
     206            scalar = job->args->data[12];
     207            Nfaint += scalar->data.S32;
     208            scalar = job->args->data[13];
     209            Nfail += scalar->data.S32;
     210            psFree(job);
     211# endif
     212        }
    206213
    207214        // wait for the threads to finish and manage results
     
    231238                scalar = job->args->data[12];
    232239                Nfaint += scalar->data.S32;
     240                scalar = job->args->data[13];
     241                Nfail += scalar->data.S32;
    233242            }
    234243            psFree(job);
     
    238247    psFree(AnalysisRegion);
    239248
    240     psLogMsg ("psphot", PS_LOG_INFO, "extended source analysis: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next);
     249    psLogMsg ("psphot", PS_LOG_INFO, "extended source model fits: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next);
    241250    psLogMsg ("psphot", PS_LOG_INFO, "  %d convolved models (%d passed)\n", Nconvolve, NconvolvePass);
    242251    psLogMsg ("psphot", PS_LOG_INFO, "  %d plain models (%d passed)\n", Nplain, NplainPass);
    243     psLogMsg ("psphot", PS_LOG_INFO, "  %d too faint to fit\n", Nfaint);
     252    psLogMsg ("psphot", PS_LOG_INFO, "  %d too faint to fit, %d failed\n", Nfaint, Nfail);
    244253    return true;
    245254}
     
    250259    bool status;
    251260    int Next = 0;
     261    int Nfaint = 0;
     262    int Nfail = 0;
    252263    int Nconvolve = 0;
    253264    int NconvolvePass = 0;
    254265    int Nplain = 0;
    255     int Nfaint = 0;
    256266    int NplainPass = 0;
    257267    bool savePics = false;
     
    268278    psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA);
    269279
     280    // pthread_t tid = pthread_self();     // Thread identifier
     281
    270282    // Define source fitting parameters for extended source fits
    271283    pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc();
    272     fitOptions->mode          = PM_SOURCE_FIT_EXT;
     284    fitOptions->mode           = PM_SOURCE_FIT_EXT;
     285    fitOptions->saveCovariance = true;  // XXX make this a user option?
     286    fitOptions->covarFactor    = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix
     287
    273288    // XXX for now, use the defaults for the rest:
    274289    // fitOptions->nIter         = fitIter;
     
    296311        // XXX use the parameters guessed from moments
    297312        // if (source->modelEXT == NULL) continue;
     313
     314        // fprintf (stderr, "fit %d,%d in thread %d\n", source->peak->x, source->peak->y, (int) tid);
    298315
    299316        // replace object in image
     
    366383          // limit selection to some SN limit
    367384          assert (source->peak); // how can a source not have a peak?
    368           if (source->peak->SN < SNlim) {
     385          if (sqrt(source->peak->detValue) < SNlim) {
    369386              Nfaint ++;
    370387              continue;
     
    388405              if (!modelFit) {
    389406                  psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->Mx, source->moments->My);
     407                  Nfail ++;
    390408                  continue;
    391409              }
     
    402420              if (!modelFit) {
    403421                  psTrace ("psphot", 5, "failed to fit plain model for object at %f, %f", source->moments->Mx, source->moments->My);
     422                  Nfail ++;
    404423                  continue;
    405424              }
     
    519538    scalar->data.S32 = Nfaint;
    520539
     540    scalar = job->args->data[13];
     541    scalar->data.S32 = Nfail;
     542
    521543    return true;
    522544}
Note: See TracChangeset for help on using the changeset viewer.