IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34215


Ignore:
Timestamp:
Jul 27, 2012, 11:28:57 AM (14 years ago)
Author:
bills
Message:

Add argument skipNegativeFluxSources to psphotFitSourcesLinear.
Do not enable it's use in psphotStack yet.

Location:
trunk/psphot/src
Files:
9 edited

Legend:

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

    r34136 r34215  
    101101bool            psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
    102102
    103 bool            psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final);
    104 bool            psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode);
     103bool            psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final, bool skipNegativeFluxSources);
     104bool            psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode, bool skipNegativeFluxSources);
    105105
    106106bool            psphotSourceSize (pmConfig *config, const pmFPAview *view, const char *filerule, bool getPSFsize);
  • trunk/psphot/src/psphotEfficiency.c

    r34086 r34215  
    420420
    421421    // psphotFitSourcesLinearReadout subtracts the model fits
    422     if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true, PM_SOURCE_PHOTFIT_CONST)) {
     422    if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true, PM_SOURCE_PHOTFIT_CONST, false)) {
    423423        psError(PS_ERR_UNKNOWN, false, "Unable to perform linear fit on fake sources.");
    424424        psFree(fakeSources);
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r34136 r34215  
    1313
    1414// for now, let's store the detections on the readout->analysis for each readout
    15 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final)
     15bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final, bool skipNegativeFluxSources)
    1616{
    1717    bool status = true;
     
    6666        psAssert (psf, "missing psf?");
    6767
    68         if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1)) {
     68        if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1, skipNegativeFluxSources)) {
    6969            psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
    7070            return false;
     
    8585
    8686            // rerun fit with correct fitVarMode
    87             if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarMode)) {
     87            // XXX: does skipNegativeFlux work here?
     88            if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarMode, skipNegativeFluxSources)) {
    8889                psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
    8990                return false;
     
    136137}
    137138
    138 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode) {
     139bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode, bool skipNegativeFluxSources) {
    139140    bool status;
    140141    float x;
     
    183184    float MIN_VALID_FLUX = psMetadataLookupF32(&status, recipe, "PSF_FIT_MIN_VALID_FLUX");
    184185    if (!status) {
     186        MIN_VALID_FLUX = 0.0;
     187    }
     188    if (skipNegativeFluxSources && MIN_VALID_FLUX < 0) {
    185189        MIN_VALID_FLUX = 0.0;
    186190    }
     
    258262        if (modelSum < 0.5) continue; // skip sources with no model constraint (somewhat arbitrary limit)
    259263        if (modelSum < 0.8) {
    260             fprintf (stderr, "low-sig model @ %f, %f (%f masked sum, %f sum, %f peak)\n",
     264            psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "low-sig model @ %f, %f (%f masked sum, %f sum, %f peak)\n",
    261265                     source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux);
    262266        }
    263267        if (maskedSum < 0.5) {
    264             fprintf (stderr, "worrying model @ %f, %f (%f masked sum, %f sum, %f peak)\n",
     268            psLogMsg ("psphot.ensemble",  PS_LOG_MINUTIA, "worrying model @ %f, %f (%f masked sum, %f sum, %f peak)\n",
    265269                     source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux);
    266270        }
  • trunk/psphot/src/psphotForcedReadout.c

    r33140 r34215  
    6464
    6565    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    66     psphotFitSourcesLinear (config, view, filerule, false);
     66    psphotFitSourcesLinear (config, view, filerule, false, false);
    6767
    6868    // identify CRs and extended sources
  • trunk/psphot/src/psphotReadout.c

    r34086 r34215  
    185185
    186186    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    187     psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources)
     187    psphotFitSourcesLinear (config, view, filerule, false, false); // pass 1 (detections->allSources)
    188188
    189189    // measure the radial profiles to the sky
     
    212212    // linear fit to include all sources (subtract again)
    213213    // NOTE : apply to ALL sources (extended + psf)
    214     psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources)
     214    psphotFitSourcesLinear (config, view, filerule, true, false); // pass 2 (detections->allSources)
    215215
    216216    // if we only do one pass, skip to extended source analysis
     
    261261
    262262        // NOTE: apply to ALL sources
    263         psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
     263        psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources)
    264264    }
    265265
     
    302302
    303303        // NOTE: apply to ALL sources
    304         psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
     304        psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources)
    305305    }
    306306
  • trunk/psphot/src/psphotReadoutForcedKnownSources.c

    r32996 r34215  
    4545
    4646    // linear PSF fit to source peaks
    47     psphotFitSourcesLinear (config, view, filerule, false);
     47    psphotFitSourcesLinear (config, view, filerule, false, false);
    4848
    4949    // calculate source magnitudes
  • trunk/psphot/src/psphotReadoutKnownSources.c

    r33692 r34215  
    5757
    5858    // linear PSF fit to source peaks
    59     psphotFitSourcesLinear (config, view, filerule, false);
     59    psphotFitSourcesLinear (config, view, filerule, false, false);
    6060
    6161    // measure aperture photometry corrections
  • trunk/psphot/src/psphotReadoutMinimal.c

    r33842 r34215  
    7070
    7171    // linear PSF fit to source peaks
    72     psphotFitSourcesLinear (config, view, filerule, false);
     72    psphotFitSourcesLinear (config, view, filerule, false, false);
    7373
    7474// XXX eventually, add the extended source fits here
  • trunk/psphot/src/psphotStackReadout.c

    r34135 r34215  
    187187
    188188    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    189     psphotFitSourcesLinear (config, view, STACK_SRC, false);
     189    psphotFitSourcesLinear (config, view, STACK_SRC, false, false);
    190190    psphotStackVisualFilerule(config, view, STACK_SRC);
    191191
     
    215215    // NOTE : apply to ALL sources (extended + psf)
    216216    // NOTE 2 : this function subtracts the models from the given filerule (SRC), not DET
    217     psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 2 (detections->allSources)
     217    psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 2 (detections->allSources)
    218218
    219219    // NOTE: possibly re-measure background model here with objects subtracted / or masked
     
    288288pass1finish:
    289289
     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
     295
    290296    // generate the objects (objects unify the sources from the different images) NOTE: could
    291297    // this just match the detections for the chisq image, and not bother measuring the source
     
    302308    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    303309
    304     // NOTE: apply to ALL sources
    305     psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 3 (detections->allSources)
     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
    306317
    307318    // measure the radial profiles to the sky (only measures new objects)
     
    369380
    370381            // this is necessary to get the right normalization for the new models
    371             psphotFitSourcesLinear (config, view, STACK_OUT, false);
     382            psphotFitSourcesLinear (config, view, STACK_OUT, false, false);
    372383
    373384            // measure circular, radial apertures (objects sorted by S/N)
Note: See TracChangeset for help on using the changeset viewer.