IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 31, 2013, 6:02:26 AM (13 years ago)
Author:
eugene
Message:

merge changes from EAM branch (update tap script for galaxies; count deblended satstars for log message; scale down EXT window a bit for speed (OK?); enable interactive mode for PCM fitting; allow NONCONVERGE extended fit models to succeed; init EXT model fits with EXT_AND_SKY just in case; extra verbosity and various experiments on the index iterations)

Location:
trunk/psphot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src

  • trunk/psphot/src/psphotExtendedSourceFits.c

    r35769 r36086  
    6565    psphotVisualShowImage(readout);
    6666
     67    // psphotSaveImage (NULL, readout->image, "test.01.fits");
     68
    6769    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
    6870    psAssert (detections, "missing detections?");
     
    123125    }
    124126
     127    // perform full extended source non-linear fits?
     128    bool isInteractive = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS_INTERACTIVE");
     129    if (!status) isInteractive = false;
     130
    125131    // Define source fitting parameters for extended source fits
    126132    pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc();
    127     fitOptions->mode           = PM_SOURCE_FIT_EXT;
     133    fitOptions->mode           = PM_SOURCE_FIT_EXT_AND_SKY;
    128134    fitOptions->saveCovariance = true;  // XXX make this a user option?
    129135    fitOptions->covarFactor    = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix
     
    134140    fitOptions->gainFactorMode   = gainFactorMode;
    135141    fitOptions->chisqConvergence = chisqConvergence;
     142    fitOptions->isInteractive    = isInteractive;
    136143
    137144    // maskVal is used to test for rejected pixels, and must include markVal
     
    296303            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
    297304
    298 // set this to 0 to run without threading
    299 # if (1)           
    300             if (!psThreadJobAddPending(job)) {
    301                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    302                 psFree(AnalysisRegion);
    303                 psFree (fitOptions);
    304                 psFree (models);
    305                 psphotSersicModelClassCleanup();
    306                 return false;
    307             }
    308 # else
    309             if (!psphotExtendedSourceFits_Threaded(job)) {
    310                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    311                 psFree(AnalysisRegion);
    312                 psFree (fitOptions);
    313                 psFree (models);
    314                 psphotSersicModelClassCleanup();
    315                 return false;
     305// XXX TEST
     306            if (!isInteractive) {
     307                if (!psThreadJobAddPending(job)) {
     308                    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     309                    psFree(AnalysisRegion);
     310                    psFree (fitOptions);
     311                    psFree (models);
     312                    psphotSersicModelClassCleanup();
     313                    return false;
     314                }
     315            } else {
     316                // run without threading
     317                if (!psphotExtendedSourceFits_Threaded(job)) {
     318                    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     319                    psFree(AnalysisRegion);
     320                    psFree (fitOptions);
     321                    psFree (models);
     322                    psphotSersicModelClassCleanup();
     323                    return false;
     324                }
     325                psScalar *scalar = NULL;
     326                scalar = job->args->data[9];
     327                Next += scalar->data.S32;
     328                scalar = job->args->data[10];
     329                Nconvolve += scalar->data.S32;
     330                scalar = job->args->data[11];
     331                NconvolvePass += scalar->data.S32;
     332                scalar = job->args->data[12];
     333                Nplain += scalar->data.S32;
     334                scalar = job->args->data[13];
     335                NplainPass += scalar->data.S32;
     336                scalar = job->args->data[14];
     337                Nfaint += scalar->data.S32;
     338                scalar = job->args->data[15];
     339                Nfail += scalar->data.S32;
     340                psFree(job->args->data[3]); // iterator allocated above
     341                psFree(job);
    316342            }
    317             psScalar *scalar = NULL;
    318             scalar = job->args->data[9];
    319             Next += scalar->data.S32;
    320             scalar = job->args->data[10];
    321             Nconvolve += scalar->data.S32;
    322             scalar = job->args->data[11];
    323             NconvolvePass += scalar->data.S32;
    324             scalar = job->args->data[12];
    325             Nplain += scalar->data.S32;
    326             scalar = job->args->data[13];
    327             NplainPass += scalar->data.S32;
    328             scalar = job->args->data[14];
    329             Nfaint += scalar->data.S32;
    330             scalar = job->args->data[15];
    331             Nfail += scalar->data.S32;
    332             psFree(job->args->data[3]); // iterator allocated above
    333             psFree(job);
    334 # endif
    335343        }
    336344
     
    378386    psphotSersicModelClassCleanup();
    379387
     388    // psphotSaveImage (NULL, readout->image, "test.02.fits");
     389
    380390    psphotVisualShowResidualImage (readout, false);
    381391
     
    521531                  psFree (source->modelFlux);
    522532                  source->modelFlux = NULL;
     533                  // if ((fabs(source->peak->xf - 2572) < 20) && (fabs(source->peak->yf - 5874) < 20)) {
     534                  //   fprintf (stderr, "test object\n");
     535                  // }
     536
    523537                  modelFit = psphotFitEXT (modelFit, readout, source, fitOptions, modelType, maskVal, markVal);
    524538                  if (!modelFit) {
     
    544558                      float Ymax = PAR[PM_PAR_YPOS] + 0.5*PAR[PM_PAR_LENGTH]*cos(PAR[PM_PAR_THETA]);
    545559
    546                       if (false && (source->peak->xf > 1100) &&
    547                           (source->peak->xf < 1400) &&
    548                           (source->peak->yf < 245)) {
     560                      if ((fabs(source->peak->xf - 2572) < 20) && (fabs(source->peak->yf - 5874) < 20)) {
    549561                          fprintf (stderr, "src vs fit : %d %d - %d %d | %f %f - %f %f\n",
    550562                                   source->pixels->col0, source->pixels->row0,
     
    579591
    580592            if (model->flags & (PM_MODEL_STATUS_BADARGS)) continue;
    581             if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue;
     593            // if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue;
    582594            if (model->flags & (PM_MODEL_STATUS_OFFIMAGE)) continue;
    583595
     
    598610          pmSourceCacheModel (source, maskVal);
    599611
     612          pmModel *model = source->modelFits->data[0];
     613          int flags = 0xffffffff;
     614          if (model) {
     615            flags = model->flags;
     616          }
     617
     618          fprintf (stderr, "failed to fit extended source model to object %d @ %f, %f (%x)\n", source->id, source->moments->Mx, source->moments->My, flags);
    600619          pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    601620
     
    615634        // cache the model flux
    616635        if (source->modelEXT->isPCM) {
     636            // fprintf (stderr, "subtract PCM extended source model for object %d @ %f, %f\n", source->id, source->moments->Mx, source->moments->My);
    617637            pmPCMCacheModel (source, maskVal, psfSize);
    618638        } else {
     639            // fprintf (stderr, "subtract non-PCM extended source model for object %d @ %f, %f\n", source->id, source->moments->Mx, source->moments->My);
    619640            pmSourceCacheModel (source, maskVal);
    620641        }
Note: See TracChangeset for help on using the changeset viewer.