IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34226 for trunk/psphot/src


Ignore:
Timestamp:
Jul 31, 2012, 9:31:06 AM (14 years ago)
Author:
bills
Message:

If number of objects is above a recipe limit reduce the number of radial
apertures processed. Also add recipe value to cause final linear fit
for detected sources be performed first ommitting negative flux sources
followed by the fit for matched sources. Set to false for now pending
further testing

Location:
trunk/psphot/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphot.h

    r34215 r34226  
    264264bool            psphotEllipticalProfile (pmSource *source, bool RAW_RADIUS);
    265265bool            psphotEllipticalContour (pmSource *source);
     266bool            psphotLimitRadialApertures(psMetadata *recipe, long nSources);
    266267
    267268// psphotVisual functions
  • trunk/psphot/src/psphotRadialBins.c

    r28013 r34226  
    202202}
    203203
     204// If the number of sources is large, edit the recipe to remove radial bins beyond
     205// a value specified in the recipe
     206bool psphotLimitRadialApertures(psMetadata *recipe, long nSources) {
     207
     208    bool status = false;
     209    long sourceLimit = psMetadataLookupS32 (&status, recipe, "RADIAL.NUM.SOURCES.LIMIT");
     210    if (!status) {
     211        sourceLimit = 50000;
     212    }
     213    if (nSources < sourceLimit) {
     214        return true;
     215    }
     216    psF32 maxRadius = psMetadataLookupF32 (&status, recipe, "RADIAL.SOURCES.OVER.LIMIT.RADIUS");
     217    if (!status) {
     218        maxRadius = 20.0;
     219    }
     220    psLogMsg ("psphot", PS_LOG_INFO, "Number of objects: %ld is greater than limit %ld. Limiting radial annular bins to %.3f pixels\n",
     221            nSources, sourceLimit, maxRadius);
     222
     223    psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER");
     224    psVector *radMax = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER");
     225    if (!radMin || !radMin->n) {
     226        psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMin missing or empty)");
     227        return false;
     228    }
     229    if (!radMax || !radMax->n) {
     230        psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMax missing or empty)");
     231        return false;
     232    }
     233    if (radMax->n != radMin->n) {
     234        psError (PSPHOT_ERR_CONFIG, true, "length of radMin %ld and radMax %ld not equal)", radMin->n, radMax->n);
     235        return false;
     236    }
     237    int i = 0;
     238    psF32 lastRadius = 0;
     239    for (; i < radMax->n; i++) {
     240        if (radMax->data.F32[i] > maxRadius) {
     241            break;
     242        }
     243        lastRadius = radMax->data.F32[i];
     244    }
     245    if (i == radMax->n) {
     246        psLogMsg ("psphot", PS_LOG_INFO, "Radius of all bins is within the limit. lastRadius: %.3f\n", lastRadius);
     247        return true;
     248    }
     249    psLogMsg ("psphot", PS_LOG_INFO, "  radius limit exceeded at bin %d of %ld. New max radius is %.3f\n",
     250            i, radMax->n, lastRadius);
     251
     252    psVector *radMinNew = psVectorRealloc(radMin, i);
     253    if (radMinNew != radMin) {
     254        psMetadataAddVector(recipe, PS_LIST_TAIL, "RADIAL.ANNULAR.BINS.LOWER", PS_META_REPLACE, "", radMinNew);
     255        // XXX: I don't need this so I?
     256        // psFree(radMinNew);
     257    }
     258
     259    psVector *radMaxNew = psVectorRealloc(radMax, i);
     260    if (radMaxNew != radMax) {
     261        psMetadataAddVector(recipe, PS_LIST_TAIL, "RADIAL.ANNULAR.BINS.UPPER", PS_META_REPLACE, "", radMaxNew);
     262        // XXX: I don't need to free this do I?
     263        // psFree(radMaxNew);
     264    }
     265
     266    return true;
     267}
     268
    204269// the area-weighted mean radius is given by:
    205270
  • trunk/psphot/src/psphotStackReadout.c

    r34215 r34226  
    286286    }
    287287
     288    // gcc doesn't like the label to refer to a declaration so we declare this here
     289    bool splitLinearFit;
     290
    288291pass1finish:
    289292
    290 #ifdef notyet
    291     // Split the fit of detected sources from matched sources. But not yet.
    292     // NOTE: apply to ALL sources. Only include sources with postitive flux in the fit
    293     psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources)
    294 #endif
     293    splitLinearFit = psMetadataLookupBool(NULL, recipe, "PSPHOT.STACK.SPLIT.LINEAR.FIT");
     294    if (splitLinearFit) {
     295        psLogMsg ("psphot", 3, "splitting fit of detected and matched soures\n");
     296        // Fit the detected sources separately from matched that wea are about to create.
     297        // NOTE: apply to ALL sources but only include sources with postitive flux in the fit
     298        psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources)
     299    }
    295300
    296301    // generate the objects (objects unify the sources from the different images) NOTE: could
     
    300305    psMemDump("matchsources");
    301306
     307    // check the source density. If it too high change the number of radial bins
     308    // in the recipe.
     309    psphotLimitRadialApertures(recipe, objects->n);
     310
    302311    // Construct an initial model for each object, set the radius to fitRadius, set circular
    303312    // fit mask.  NOTE: only applied to sources without guess models
     
    308317    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    309318
    310 #ifdef notyet
    311     // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will
    312     // not be included in this fit.
    313     psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
    314 #else
    315     psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources)
    316 #endif
     319    if (splitLinearFit) {
     320        // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will
     321        // not be included in this fit.
     322        psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
     323    } else {
     324        // Fit all sources together
     325        psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources)
     326    }
    317327
    318328    // measure the radial profiles to the sky (only measures new objects)
Note: See TracChangeset for help on using the changeset viewer.