IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2015, 10:05:06 PM (11 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20150616
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150616

  • branches/eam_branches/ipp-20150616/psphot/src/psphotStackUpdateReadout.c

    r38396 r38552  
    116116    // XXX NOTE : if we use the pre-20130914 psphotStackReadout code, we need to use 'false' for the
    117117    // sourcesSubtracted argument
    118     psArray *objectsOut = psphotSourceChildrenByObject (config, view, STACK_OUT, objects, true);
     118    // XXX: do this here so that the variance is availble to rebuild the models
     119    psphotStackMatchPSFsetup (config, view, STACK_OUT, STACK_RAW);
     120    psArray *objectsOut = psphotSourceChildrenByObject (config, view, STACK_OUT, STACK_RAW, objects, true);
    119121    if (!objectsOut) {
    120122        psFree(objects);
     
    135137        // this forces photometry on the undetected sources from other images
    136138
    137         // set up the FWHM vector
    138         psphotStackMatchPSFsetup (config, view, STACK_OUT, STACK_RAW);
     139//      Moved this up above
     140//      psphotStackMatchPSFsetup (config, view, STACK_OUT, STACK_RAW);
    139141        psphotDumpImages (config, view, STACK_RAW, "raw.t0");
    140142        psphotDumpImages (config, view, STACK_OUT, "out.t0");
     
    177179                // and to subtract the sources
    178180                psphotFitSourcesLinear (config, view, STACK_OUT, false, false);
     181
     182#ifdef notyet
     183            psphotRemoveAllSources (config, view, STACK_OUT, false);
     184#endif
     185
    179186                snprintf (line, 256, "%s.%d", "out.t4", entry);
    180187                psphotDumpImages (config, view, STACK_OUT, line);
     
    221228        COPY_PARAM( "MSKY_NX" );
    222229        COPY_PARAM( "MSKY_NY" );
    223         COPY_PARAM( "CHIP_SEEING" );
     230        // COPY_PARAM( "CHIP_SEEING" );
    224231}
    225232
     
    293300    maskVal |= markVal;
    294301
     302    // This code currently assumes that all extended source models are PCM.
     303    // Examine the recipe and make sure that this is true.
     304    psMetadata *allModels = psMetadataLookupMetadata (&status, recipe, "EXTENDED_SOURCE_MODELS");
     305    if (!status) {
     306        psAssert (allModels, "failed to find list of extended source models\n");
     307    }
     308    psMetadataIterator *iter = psMetadataIteratorAlloc (allModels, PS_LIST_HEAD, NULL);
     309    psMetadataItem *item = NULL;
     310    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
     311        if (item->type != PS_DATA_METADATA) {
     312            psAbort ("Invalid type for EXTENDED_SOURCE_MODEL entry %s, not a metadata folder", item->name);
     313        }
     314        psMetadata *model = (psMetadata *) item->data.md;
     315        // char *modelName = psMetadataLookupStr (&status, model, "MODEL");
     316
     317        char *convolvedWord = psMetadataLookupStr (&status, model, "PSF_CONVOLVED");
     318        if (!status || (strcasecmp (convolvedWord, "true") && strcasecmp (convolvedWord, "false"))) {
     319            psAbort ("PSF_CONVOLVED entry invalid or missing for EXTENDED_SOURCE_MODEL entry %s", item->name);
     320        }
     321        bool convolved = !strcasecmp (convolvedWord, "true");
     322        psAssert (convolved, "EXTENDED SOURCE model %s is not convolved. This code is not ready for that\n", item->name);
     323    }
     324    psFree (iter);
     325
    295326    // setup the PSF fit radius details
    296327    psphotInitRadiusPSF (recipe, readout);
     
    312343    fitOptions->poissonErrors = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS_POISSON");
    313344    if (!status) fitOptions->poissonErrors = true;
     345
    314346    int psfSize  = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE");
    315347    assert (status);
     348   
     349    // Remember these data for later
     350    psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PCM_FIT_OPTIONS", PS_DATA_UNKNOWN | PS_META_REPLACE, "pcm fit options", fitOptions);
    316351
    317352    for (int i = 0; i < sources->n; i++) {
     
    331366            // fprintf(stderr, "source %d %5d should not have a psf model 0x%08X%08X\n", index, source->seq, source->mode2, source->mode);
    332367            psFree(source->modelPSF) ;
     368            modelPSF = NULL;
     369            // At least once I saw a source with an extended model but no psf model
     370            psFree(source->modelEXT);
     371            source->modelEXT = NULL;
    333372        }
    334373
    335374        // make sure that the window radius is large enough. Should we do this regardless of whether
    336375        // or not the source is extended?
    337         if (source->modelEXT) {
    338             float fitRadius = NAN;
    339             float windowRadius = NAN;
     376        float fitRadius = NAN;
     377        float windowRadius = NAN;
     378        if (1 || source->modelEXT) {
    340379            if (!psphotSetRadiusMoments (&fitRadius, &windowRadius, readout, source, markVal)) {
    341380                psError (PSPHOT_ERR_UNKNOWN, false, "failed to set radius for ext source");
     
    387426                float modelFlux = pow(10., -0.4 * model->mag);
    388427
    389                 // XXX: We are assuming here that we only use PCM models. Should get that information from the recipe.
     428                model->fitRadius = fitRadius;
     429
     430                // XXX: We are assuming here that we only use PCM models.
     431                // I Should be getting that information from the recipe.
    390432                pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize);
    391433                if (!pcm) {
     
    394436                }
    395437                model->params->data.F32[PM_PAR_I0] = 1.0;
    396                 pmPCMMakeModel (source, model, pcm->nsigma, maskVal, psfSize);
     438                // XXX: this duplicates work that pmPCMCacheModel does
     439                // pmPCMMakeModel (source, model, pcm->nsigma, maskVal, psfSize);
    397440                float normFlux = model->class->modelFlux(model->params);
    398441                float I0 = modelFlux / normFlux;
Note: See TracChangeset for help on using the changeset viewer.