IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36327


Ignore:
Timestamp:
Nov 30, 2013, 1:35:54 PM (13 years ago)
Author:
eugene
Message:

add a number of additional flag bits, esp for model fitting

Location:
branches/eam_branches/ipp-20130904/psphot/src
Files:
6 edited

Legend:

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

    r32348 r36327  
    6464        psFree (y);
    6565        psFree (yErr);
     66        source->mode2 |= PM_SOURCE_MODE2_ELPROF_FEW_PTS;
    6667        return false;
    6768    }
  • branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c

    r36318 r36327  
    445445    // psTraceSetLevel ("psLib.math.psMinimizeLMChi2_Alt", 5);
    446446
     447    pmModelStatus badModel = PM_MODEL_STATUS_NONE;
     448    badModel |= PM_MODEL_STATUS_BADARGS;
     449    badModel |= PM_MODEL_STATUS_OFFIMAGE;
     450    badModel |= PM_MODEL_STATUS_NAN_CHISQ;
     451    badModel |= PM_MODEL_SERSIC_PCM_FAIL_GUESS;
     452    badModel |= PM_MODEL_SERSIC_PCM_FAIL_GRID;
     453    badModel |= PM_MODEL_PCM_FAIL_GUESS;
     454
    447455    // choose the sources of interest
    448456    for (int i = 0; i < sources->n; i++) {
     
    532540          }
    533541
     542          source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_RUN;
     543
    534544          // check on the model type
    535545          pmModelType modelType = psMetadataLookupS32 (&status, model, "MODEL_TYPE");
     
    548558                  psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->Mx, source->moments->My);
    549559                  Nfail ++;
     560                  source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_FAIL;
    550561                  continue;
    551562              }
     
    553564                       source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter);
    554565              Nconvolve ++;
    555               if (!(modelFit->flags & (PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE))) {
     566              if (!(modelFit->flags & badModel)) {
    556567                  NconvolvePass ++;
    557568                  source->mode |= PM_SOURCE_MODE_EXTENDED_FIT;
     
    567578                      Nfail ++;
    568579                      doneFits = true;
     580                      source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_FAIL;
    569581                      continue;
    570582                  }
    571583                  psTrace ("psphot", 4, "fit plain model for %f, %f : %s chisq = %f (npix: %d, niter: %d)\n", source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter);
    572584                  Nplain ++;
    573                   if (!(modelFit->flags & (PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE))) {
     585                  if (!(modelFit->flags & badModel)) {
    574586                      NplainPass ++;
    575587                      source->mode |= PM_SOURCE_MODE_EXTENDED_FIT;
     
    595607                          fprintf (stderr, "update window : %f %f : %f -> %f\n", source->peak->xf, source->peak->yf, fitRadius, 2*fitRadius);
    596608                          psphotSetWindowTrail (&fitRadius, &windowRadius, readout, source, markVal, fitRadius*2.0);
     609                          source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_RETRY;
    597610                      }
    598611                  }
     
    600613          }
    601614          // XXX really need to do this in a cleaner way:
     615          // XXX I'm not sure I can get to this statement with a null modelFit
    602616          if (!modelFit) continue;
    603617
     
    615629            pmModel *model = source->modelFits->data[i];
    616630
     631            // skip the really bad fits
    617632            if (!(model->flags & PM_MODEL_STATUS_FITTED)) continue;
    618 
    619             if (model->flags & (PM_MODEL_STATUS_BADARGS)) continue;
     633            if (model->flags & badModel) continue;
     634
    620635            // if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue;
    621             if (model->flags & (PM_MODEL_STATUS_OFFIMAGE)) continue;
    622636
    623637            if ((minModel < 0) || (model->chisq < minChisq)) {
     
    646660          pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    647661
     662          source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_NONE;
    648663          continue;
    649664        }
  • branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianRadialBins.c

    r36198 r36327  
    186186        psFree(values);
    187187        psFree(stats);
     188        source->mode2 |= PM_SOURCE_MODE2_PETRO_RADBIN_NAN_CENTER;
    188189        return true;
    189190    }
  • branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianStats.c

    r36198 r36327  
    2121    if (!profile->binSB) {
    2222        psLogMsg ("psphot", PS_LOG_DETAIL, "no petrosian profile, skipping source %f, %f", source->peak->xf, source->peak->yf);
     23        source->mode2 |= PM_SOURCE_MODE2_PETRO_NO_PROFILE;
    2324        return true;
    2425    }
     
    118119                petRadius    = InterpolateValues     (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO);
    119120                petRadiusErr = InterpolateValuesErrX (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO, 0.0, petRatioErr->data.F32[nOut]);
     121                source->mode2 |= PM_SOURCE_MODE2_PETRO_RATIO_ZEROBIN;
    120122            } else {
    121123              // petRadius    = InterpolateValues     (petRatio->data.F32[nOut-1], refRadius->data.F32[nOut-1], petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO);
    122124              if (nOut > 1) {
    123                 petRadius    = InterpolateValuesQuadratic (&petRatio->data.F32[nOut-2],   &refRadius->data.F32[nOut-2],   PETROSIAN_RATIO);
     125                petRadius    = InterpolateValuesQuadratic (&petRatio->data.F32[nOut-2], &refRadius->data.F32[nOut-2],   PETROSIAN_RATIO);
    124126              } else {
    125127                petRadius    = InterpolateValuesQuadratic (&petRatio->data.F32[nOut-3], &refRadius->data.F32[nOut-3], PETROSIAN_RATIO);
     
    158160            fprintf (stderr, "nan pet radius\n");
    159161        }
     162        source->mode2 |= PM_SOURCE_MODE2_PETRO_INSIG_RATIO;
    160163    }
    161164
     
    190193    bool found50 = false;
    191194    bool found90 = false;
     195
    192196    // XXX use bisection to do this faster:
    193197    for (int i = 0; !(found50 && found90) && i < refRadius->n; i++) {
  • branches/eam_branches/ipp-20130904/psphot/src/psphotRadialBins.c

    r34226 r36327  
    4444    psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER");
    4545    psVector *radMax = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER");
    46     if (!radMin || !radMin->n) {
    47         psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMin missing or empty)");
    48         return false;
    49     }
    50     if (!radMax || !radMax->n) {
    51         psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMax missing or empty)");
    52         return false;
    53     }
     46    psAssert (radMin, "RADIAL.ANNULAR.BINS.LOWER is missing from recipe");
     47    psAssert (radMin->n, "RADIAL.ANNULAR.BINS.LOWER is empty in recipe");
     48    psAssert (radMax, "RADIAL.ANNULAR.BINS.UPPER is missing from recipe");
     49    psAssert (radMax->n, "RADIAL.ANNULAR.BINS.UPPER is empty in recipe");
    5450
    5551    psVector *binSB      = psVectorAllocEmpty(radMin->n, PS_TYPE_F32); // surface brightness of radial bin
     
    161157        psFree(values);
    162158        psFree(stats);
     159        source->mode2 |= PM_SOURCE_MODE2_RADBIN_NAN_CENTER;
    163160        return true;
    164161    }
  • branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c

    r36325 r36327  
    582582    maskVal |= markVal;
    583583
    584     // allocate the model
     584    // allocate the model (this can only fail on a config error)
    585585    pmModel *model = pmModelAlloc(modelType);
    586     if (!model) {
    587         return NULL;
    588     }
     586    psAssert (model, "invalid extended model name");
    589587
    590588    float t1, t2, t3, t4, t5;
     
    622620        if (!psphotSersicModelGuessPCM (pcm, source, maskVal, psfSize)) {
    623621            psFree (pcm);
    624             model->flags |= PM_MODEL_STATUS_BADARGS;
     622            model->flags |= PM_MODEL_SERSIC_PCM_FAIL_GUESS;
    625623            return model;
    626624        }
     
    631629        if (!psphotFitSersicShapeAndIndexGridAuto (pcm, readout, source, &options, maskVal, markVal, psfSize)) {
    632630            psFree (pcm);
    633             model->flags |= PM_MODEL_STATUS_BADARGS;
     631            model->flags |= PM_MODEL_SERSIC_PCM_FAIL_GRID;
    634632            psError(PS_ERR_UNKNOWN, true, "Failed to find a index & shape");
    635633            psErrorClear (); // clear the polynomial error
     
    640638        if (!pmSourceModelGuessPCM (pcm, source, maskVal, markVal)) {
    641639            psFree (pcm);
    642             model->flags |= PM_MODEL_STATUS_BADARGS;
     640            model->flags |= PM_MODEL_PCM_FAIL_GUESS;
    643641            return model;
    644642        }
Note: See TracChangeset for help on using the changeset viewer.