IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26688


Ignore:
Timestamp:
Jan 26, 2010, 5:10:34 PM (16 years ago)
Author:
eugene
Message:

various API fixes for multi-inputs

Location:
branches/eam_branches/psphot.stack.20100120
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psphot.stack.20100120/doc/stack.txt

    r26643 r26688  
    2424    can we use the processing flags to distinguish the these cases and carry around
    2525    only a single source list?
     26
     27    * detections->peaks holds the most recently detected set of peaks
     28      detections->oldPeaks holds the previous collection
     29
     30      detections->footprints holds the full set of merged footprints,
     31      including assigned peaks from the old and new set.
    2632
    273320100107 : updates for stack processing
  • branches/eam_branches/psphot.stack.20100120/src/Makefile.am

    r25984 r26688  
    3333psphot_LDADD = libpsphot.la
    3434
    35 psphotForced_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
    36 psphotForced_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    37 psphotForced_LDADD = libpsphot.la
    38 
    39 psphotMakePSF_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
    40 psphotMakePSF_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    41 psphotMakePSF_LDADD = libpsphot.la
    42 
    43 psphotTest_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
    44 psphotTest_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    45 psphotTest_LDADD = libpsphot.la
    46 
    47 psphotMomentsStudy_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
    48 psphotMomentsStudy_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    49 psphotMomentsStudy_LDADD = libpsphot.la
     35# psphotForced_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     36# psphotForced_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     37# psphotForced_LDADD = libpsphot.la
     38#
     39# psphotMakePSF_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     40# psphotMakePSF_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     41# psphotMakePSF_LDADD = libpsphot.la
     42#
     43# psphotTest_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     44# psphotTest_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     45# psphotTest_LDADD = libpsphot.la
     46#
     47# psphotMomentsStudy_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     48# psphotMomentsStudy_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     49# psphotMomentsStudy_LDADD = libpsphot.la
    5050
    5151# psphotPetrosianStudy_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     
    6262        psphotCleanup.c
    6363
    64 # forced photometry of specified positions given a specified psf
    65 psphotForced_SOURCES = \
    66         psphotForced.c             \
    67         psphotForcedArguments.c    \
    68         psphotForcedImageLoop.c    \
    69         psphotForcedReadout.c      \
    70         psphotParseCamera.c        \
    71         psphotMosaicChip.c         \
    72         psphotCleanup.c
    73 
    74 # a psphot-variant that simply generates the PSF model
    75 psphotMakePSF_SOURCES = \
    76         psphotMakePSF.c            \
    77         psphotMakePSFArguments.c   \
    78         psphotMakePSFImageLoop.c   \
    79         psphotMakePSFReadout.c     \
    80         psphotParseCamera.c        \
    81         psphotMosaicChip.c         \
    82         psphotCleanup.c
    83 
    84 
    85 # psphot analysis of the detectability of specified positions
    86 psphotDetect_SOURCES =            \
    87         psphotDetect.c            \
    88         psphotDetectArguments.c   \
    89         psphotDetectParseCamera.c \
    90         psphotDetectImageLoop.c   \
    91         psphotDetectReadout.c     \
    92         psphotMosaicChip.c        \
    93         psphotCleanup.c
    94 
    95 psphotTest_SOURCES = \
    96         psphotTest.c
    97 
    98 psphotMomentsStudy_SOURCES = \
    99         psphotMomentsStudy.c
     64# # forced photometry of specified positions given a specified psf
     65# psphotForced_SOURCES = \
     66#         psphotForced.c             \
     67#       psphotForcedArguments.c    \
     68#       psphotForcedImageLoop.c    \
     69#       psphotForcedReadout.c      \
     70#       psphotParseCamera.c        \
     71#       psphotMosaicChip.c         \
     72#       psphotCleanup.c
     73#
     74# # a psphot-variant that simply generates the PSF model
     75# psphotMakePSF_SOURCES = \
     76#         psphotMakePSF.c            \
     77#       psphotMakePSFArguments.c   \
     78#       psphotMakePSFImageLoop.c   \
     79#       psphotMakePSFReadout.c     \
     80#       psphotParseCamera.c        \
     81#       psphotMosaicChip.c         \
     82#       psphotCleanup.c
     83#
     84#
     85# # psphot analysis of the detectability of specified positions
     86# psphotDetect_SOURCES =            \
     87#         psphotDetect.c            \
     88#       psphotDetectArguments.c   \
     89#       psphotDetectParseCamera.c \
     90#       psphotDetectImageLoop.c   \
     91#       psphotDetectReadout.c     \
     92#       psphotMosaicChip.c        \
     93#       psphotCleanup.c
     94#
     95# psphotTest_SOURCES = \
     96#         psphotTest.c
     97#
     98# psphotMomentsStudy_SOURCES = \
     99#         psphotMomentsStudy.c
    100100
    101101# psphotPetrosianStudy_SOURCES = \
  • branches/eam_branches/psphot.stack.20100120/src/psphot.h

    r26681 r26688  
    1212
    1313#define PSPHOT_RECIPE_PSF_FAKE_ALLOW "PSF.FAKE.ALLOW" // Name for recipe component permitting fake PSFs
     14
     15// pmPCMData : PSF Convolved Model data storage structure
     16typedef struct {
     17    psImage *model;
     18    psArray *dmodels;
     19    psImage *modelConv;
     20    psArray *dmodelsConv;
     21} pmPCMData;
    1422
    1523// top-level psphot functions
     
    3846// XXX test functions
    3947psArray        *psphotFakeSources (void);
    40 bool psphotMaskCosmicRayFootprintCheck (psArray *sources);
     48bool            psphotMaskCosmicRayFootprintCheck (psArray *sources);
    4149
    4250// psphotReadout functions
     51bool            psphotAddPhotcode (pmConfig *config, const pmFPAview *view);
     52bool            psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
     53
     54bool            psphotSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
     55bool            psphotSetMaskAndVarianceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     56
    4357bool            psphotModelBackground (pmConfig *config, const pmFPAview *view);
    4458bool            psphotModelBackgroundReadoutFileIndex (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    4559
    46 // Create a background model for a readout, without saving the result as a pmFPAfile on
    47 // config->files.  Otherwise identical to psphotModelBackgroundFileIndex.
    48 psImage        *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config);
    49 
    50 // worker function for above background model functions
    51 bool psphotModelBackgroundReadout(psImage *model,  // Model image
    52                                   psImage *modelStdev, // Model stdev image
    53                                   psMetadata *analysis, // Analysis metadata for outputs
    54                                   pmReadout *readout, // Readout for which to generate a background model
    55                                   psImageBinning *binning, // Binning parameters
    56                                   const pmConfig *config // Configuration
    57     );
    58 
    59 psImageBinning *psphotBackgroundBinning(const psImage *, const pmConfig *);
    60 
    61 
    62 
    6360bool            psphotSubtractBackground (pmConfig *config, const pmFPAview *view);
    64 bool            psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    65 
    66 
    67 pmDetections   *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe);
    68 
    69 bool            psphotRoughClass (pmReadout *readout, psArray *sources, psMetadata *recipe, const bool findPsfClump);
    70 bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
    71 pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
     61bool            psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     62
     63bool            psphotFindDetections (pmConfig *config, const pmFPAview *view);
     64bool            psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     65
     66bool            psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow);
     67bool            psphotSourceStatsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool setWindow);
     68
     69bool            psphotDeblendSatstars (pmConfig *config, const pmFPAview *view);
     70bool            psphotDeblendSatstarsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     71
     72bool            psphotBasicDeblend (pmConfig *config, const pmFPAview *view);
     73bool            psphotBasicDeblend (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     74
     75bool            psphotRoughClass (pmConfig *config, const pmFPAview *view);
     76bool            psphotRoughClassReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     77bool            psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *analysis, psMetadata *recipe, const bool havePSF);
     78
     79bool            psphotImageQuality (pmConfig *config, const pmFPAview *view);
     80bool            psphotImageQualityReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     81
     82bool            psphotChoosePSF (pmConfig *config, const pmFPAview *view);
     83bool            psphotChoosePSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     84
     85bool            psphotGuessModels (pmConfig *config, const pmFPAview *view);
     86bool            psphotGuessModelsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     87
     88bool            psphotMergeSources (pmConfig *config, const pmFPAview *view);
     89bool            psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     90
     91bool            psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, bool final);
     92bool            psphotFitSourcesLinearReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     93
     94bool            psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize);
     95bool            psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool getPSFsize);
     96
     97bool            psphotBlendFit (pmConfig *config, const pmFPAview *view);
     98bool            psphotBlendFitReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     99bool            psphotBlendFit_Threaded (psThreadJob *job);
     100
     101bool            psphotReplaceAllSources (pmConfig *config, const pmFPAview *view);
     102bool            psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     103
     104bool            psphotAddNoise (pmConfig *config, const pmFPAview *view);
     105bool            psphotSubNoise (pmConfig *config, const pmFPAview *view);
     106bool            psphotAddOrSubNoise (pmConfig *config, const pmFPAview *view, bool add);
     107bool            psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add);
     108
     109bool            psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view);
     110bool            psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     111
     112bool            psphotExtendedSourceFits (pmConfig *config, const pmFPAview *view);
     113bool            psphotExtendedSourceFitsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     114
     115bool            psphotApResid (pmConfig *config, const pmFPAview *view);
     116bool            psphotApResid (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     117
     118bool            psphotMagnitudes (pmConfig *config, const pmFPAview *view);
     119bool            psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     120bool            psphotMagnitudes_Threaded (psThreadJob *job);
     121
     122bool            psphotEfficiency (pmConfig *config, const pmFPAview *view);
     123bool            psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     124
     125bool            psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources);
     126bool            psphotPSFWeights_Threaded (psThreadJob *job);
     127
     128bool            psphotSkyReplace (pmConfig *config, const pmFPAview *view);
     129bool            psphotSkyReplaceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     130
     131bool            psphotSourceFreePixels (pmConfig *config, const pmFPAview *view);
     132bool            psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index);
     133
     134// in psphotSourceStats.c:
     135bool            psphotSourceStats_Threaded (psThreadJob *job);
     136bool            psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout);
     137bool            psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);
     138
     139// in psphotChoosePSF.c:
    72140bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
    73141bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
    74 bool            psphotFitSourcesLinear (pmReadout *readout, psArray *sources, const psMetadata *recipe, const pmPSF *psf, bool final);
     142
     143// in psphotGuessModel.c
     144bool            psphotGuessModel_Threaded (psThreadJob *job);
     145
     146// in psphotMergeSources.c:
     147bool            psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources);
     148psArray        *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view);
     149
     150// generate the detection structure for the supplied array of sources
     151pmDetections   *psphotDetectionsFromSources (pmConfig *config, psArray *sources);
     152
     153// generate the detection structure for the supplied array of sources
     154bool            psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf);
     155
     156// in psphotModelBackground.c:
     157// Create a background model for a readout, without saving the result as a pmFPAfile on config->files.  Otherwise identical to psphotModelBackgroundFileIndex.
     158psImage        *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config);
     159psImageBinning *psphotBackgroundBinning(const psImage *, const pmConfig *);
     160
     161// in psphotReplaceUnfit.c:
     162bool            psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe);
     163bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
    75164bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
    76 
    77 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    78165
    79166bool            psphotReplaceAllSources (psArray *sources, psMetadata *recipe);
    80167bool            psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe);
    81 
    82 bool            psphotBlendFit (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
    83 bool            psphotBlendFit_Threaded (psThreadJob *job);
    84 
    85 bool            psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout);
    86 psArray        *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections, bool setWindow);
    87 bool            psphotSourceStats_Threaded (psThreadJob *job);
    88 
    89 bool            psphotGuessModels (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
    90 bool            psphotGuessModel_Threaded (psThreadJob *job);
    91 
    92 bool            psphotMagnitudes (pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, const pmPSF *psf);
    93 bool            psphotMagnitudes_Threaded (psThreadJob *job);
    94 
    95 bool            psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources);
    96 bool            psphotPSFWeights_Threaded (psThreadJob *job);
    97 
    98 bool            psphotApResid (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);
    99 
    100 bool            psphotSkyReplace (pmConfig *config, const pmFPAview *view);
    101 bool            psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe);
    102 bool            psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe);
    103 bool            psphotEfficiency(pmConfig *config, pmReadout *readout, const pmFPAview *view, const pmPSF *psf, psMetadata *recipe, const psArray *realSources);
    104168
    105169// thread-related:
     
    115179psErrorCode     psphotCullPeaks(const psImage *img, const psImage *weight, const psMetadata *recipe, psArray *footprints);
    116180
    117 // generate the detection structure for the supplied array of sources
    118 pmDetections   *psphotDetectionsFromSources (pmConfig *config, psArray *sources);
    119 
    120 // used by ApResid
     181// in psphotApResid.c:
    121182pmTrend2D      *psphotApResidTrend (float *apResidSysErr, pmReadout *readout, int Nx, int Ny, psVector *xPos, psVector *yPos, psVector *apResid, psVector *dMag);
    122183bool            psphotApResidMags_Threaded (psThreadJob *job);
     
    125186void            psphotModelClassInit (void);
    126187bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal);
    127 bool            psphotSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
    128 bool            psphotSetMaskAndVarianceReadout (pmConfig *config, pmReadout *readout, psMetadata *recipe);
    129188void            psphotSourceFreePixels (psArray *sources);
    130 
    131 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *target, psMetadata *recipe, const bool havePSF);
    132189
    133190// functions to set the correct source pixels
     
    138195bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal);
    139196float           psphotSetRadiusEXT (pmReadout *readout, pmSource *source, psImageMaskType markVal);
    140 
    141 // output functions
    142 bool            psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
    143 bool            psphotAddPhotcode (pmConfig *config, const pmFPAview *view);
    144197
    145198bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
     
    173226bool            psphotFitSummary (void);
    174227
    175 bool            psphotMergeSources (psArray *oldSources, psArray *newSources);
    176 bool            psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources);
    177 psArray        *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view);
    178 
    179228pmPSF          *psphotLoadPSF (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
    180229bool            psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
     
    186235bool            psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize);
    187236
    188 bool            psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal);
    189 bool            psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal);
    190 bool            psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal);
    191 bool            psphotDeblendSatstars (pmReadout *readout, psArray *sources, psMetadata *recipe);
    192 bool            psphotSourceSize (pmConfig *config, pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, long first);
    193 
    194237bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal);
    195238
     
    199242
    200243// functions related to extended source analysis
    201 bool  psphotRadialProfile (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);
    202 bool  psphotRadialProfilesByAngles (pmSource *source, int Nsec, float Rmax);
    203 float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax);
    204 bool  psphotRadiiFromProfiles (pmSource *source, float fluxMin, float fluxMax);
    205 bool  psphotEllipticalProfile (pmSource *source);
    206 bool  psphotEllipticalContour (pmSource *source);
     244bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);
     245bool            psphotRadialProfilesByAngles (pmSource *source, int Nsec, float Rmax);
     246float           psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax);
     247bool            psphotRadiiFromProfiles (pmSource *source, float fluxMin, float fluxMax);
     248bool            psphotEllipticalProfile (pmSource *source);
     249bool            psphotEllipticalContour (pmSource *source);
    207250
    208251// psphotVisual functions
    209 bool psphotVisualShowImage (pmReadout *readout);
    210 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout);
    211 bool psphotVisualShowSignificance (psImage *image, float min, float max);
    212 bool psphotVisualShowPeaks (pmDetections *detections);
    213 bool psphotVisualShowFootprints (pmDetections *detections);
    214 bool psphotVisualShowMoments (psArray *sources);
    215 bool psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    216 bool psphotVisualShowRoughClass (psArray *sources);
    217 bool psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
    218 bool psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
    219 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf);
    220 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal);
    221 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources);
    222 bool psphotVisualShowFlags (psArray *sources);
    223 bool psphotVisualShowSourceSize (pmReadout *readout, psArray *sources);
    224 bool psphotVisualShowResidualImage (pmReadout *readout);
    225 bool psphotVisualPlotApResid (psArray *sources, float mean, float error);
    226 bool psphotVisualPlotChisq (psArray *sources);
    227 bool psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    228 bool psphotVisualShowPetrosians (psArray *sources);
    229 
    230 // bool psphotPetrosianAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe);
    231 // bool psphotPetrosianProfile (pmReadout *readout, pmSource *source, float skynoise);
     252bool            psphotVisualShowImage (pmReadout *readout);
     253bool            psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout);
     254bool            psphotVisualShowSignificance (psImage *image, float min, float max);
     255bool            psphotVisualShowPeaks (pmDetections *detections);
     256bool            psphotVisualShowFootprints (pmDetections *detections);
     257bool            psphotVisualShowMoments (psArray *sources);
     258bool            psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources);
     259bool            psphotVisualShowRoughClass (psArray *sources);
     260bool            psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
     261bool            psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
     262bool            psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf);
     263bool            psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal);
     264bool            psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources);
     265bool            psphotVisualShowFlags (psArray *sources);
     266bool            psphotVisualShowSourceSize (pmReadout *readout, psArray *sources);
     267bool            psphotVisualShowResidualImage (pmReadout *readout);
     268bool            psphotVisualPlotApResid (psArray *sources, float mean, float error);
     269bool            psphotVisualPlotChisq (psArray *sources);
     270bool            psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources);
     271bool            psphotVisualShowPetrosians (psArray *sources);
     272bool            psphotVisualEraseOverlays (int channel, char *overlay);
    232273
    233274bool psphotPetrosian (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);
     
    235276bool psphotPetrosianStats (pmSource *source);
    236277
    237 // XXX old versions, currently disabled
     278// currently disabled:
    238279// bool            psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
    239280// bool            psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
     
    250291//                               float petFlux, float radiusForFlux);
    251292
    252 bool psphotImageQuality (psMetadata *recipe, psArray *sources);
    253 
    254293// structures & functions to support psf-convolved model fitting
    255 
    256 // pmPCMData : PSF Convolved Model data storage structure
    257 typedef struct {
    258     psImage *model;
    259     psArray *dmodels;
    260     psImage *modelConv;
    261     psArray *dmodelsConv;
    262 } pmPCMData;
    263 
    264294
    265295// psf-convolved model fitting
     
    291321
    292322int psphotKapaOpen (void);
    293 bool psphotVisualEraseOverlays (int channel, char *overlay);
    294323bool psphotKapaClose (void);
    295324bool psphotImageBackgroundCellHistogram (psVector *values, float mean, float sigma, int ix, int iy);
     
    305334int psphotSupplementStars (psArray *stars, psArray *sources, psImageBinning *binning, int ix, int iy);
    306335
    307 
    308336pmConfig *psphotForcedArguments(int argc, char **argv);
    309337bool psphotForcedImageLoop (pmConfig *config);
  • branches/eam_branches/psphot.stack.20100120/src/psphotAddNoise.c

    r26681 r26688  
    3131}
    3232
    33 bool psphotAddOrSubNoise (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add) {
     33bool psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add) {
    3434
    3535    bool status = false;
     
    4040    // find the currently selected readout
    4141    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    42     psAssert (readout, "missing file?");
     42    psAssert (file, "missing file?");
    4343
    4444    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     
    4747    psAssert (readout->parent->concepts, "missing concepts?");
    4848
    49     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     49    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     50    psAssert (detections, "missing detections?");
     51
     52    psArray *sources = detections->allSources;
    5053    psAssert (sources, "missing sources?");
    5154
  • branches/eam_branches/psphot.stack.20100120/src/psphotApResid.c

    r26261 r26688  
    44// measure the aperture residual statistics and 2D variations
    55
    6 bool psphotApResid (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf)
     6// for now, let's store the detections on the readout->analysis for each readout
     7bool psphotApResid (pmConfig *config, const pmFPAview *view)
     8{
     9    bool status = true;
     10
     11    // select the appropriate recipe information
     12    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     13    psAssert (recipe, "missing recipe?");
     14
     15    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     16    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     17
     18    // loop over the available readouts
     19    for (int i = 0; i < num; i++) {
     20        if (!psphottApResidReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     21            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     22            return false;
     23        }
     24    }
     25    return true;
     26}
     27
     28bool psphotApResid (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe)
    729{
    830    int Nfail = 0;
     
    1335    pmSource *source;
    1436
    15     PS_ASSERT_PTR_NON_NULL(config, false);
    16     PS_ASSERT_PTR_NON_NULL(readout, false);
    17     PS_ASSERT_PTR_NON_NULL(sources, false);
    18     PS_ASSERT_PTR_NON_NULL(psf, false);
    19 
    2037    psTimerStart ("psphot.apresid");
    2138
    22     // select the appropriate recipe information
    23     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    24     assert (recipe);
     39    // find the currently selected readout
     40    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     41    psAssert (readout, "missing file?");
     42
     43    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     44    psAssert (readout, "missing readout?");
     45
     46    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     47    psAssert (detections, "missing detections?");
     48
     49    psArray *sources = detections->allSources;
     50    psAssert (sources, "missing sources?");
     51
     52    if (!sources->n) {
     53        psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping ap resid");
     54        return true;
     55    }
     56
     57    pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     58    psAssert (psf, "missing psf?");
    2559
    2660    // determine the number of allowed threads
  • branches/eam_branches/psphot.stack.20100120/src/psphotBasicDeblend.c

    r26681 r26688  
    3232    // find the currently selected readout
    3333    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    34     psAssert (readout, "missing file?");
     34    psAssert (file, "missing file?");
    3535
    3636    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    3737    psAssert (readout, "missing readout?");
    3838
    39     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     39    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     40    psAssert (detections, "missing detections?");
     41
     42    psArray *sources = detections->newSources;
    4043    psAssert (sources, "missing sources?");
    4144
  • branches/eam_branches/psphot.stack.20100120/src/psphotBlendFit.c

    r26681 r26688  
    3636    // find the currently selected readout
    3737    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    38     psAssert (readout, "missing file?");
     38    psAssert (file, "missing file?");
    3939
    4040    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    4141    psAssert (readout, "missing readout?");
    4242
    43     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     43    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     44    psAssert (detections, "missing detections?");
     45
     46    psArray *sources = detections->allSources;
    4447    psAssert (sources, "missing sources?");
    4548
     
    312315}
    313316
    314 # if (0)
    315 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources) {
    316 
    317     bool status = false;
    318     int Nfit = 0;
    319     int Npsf = 0;
    320     int Next = 0;
    321     int Nfail = 0;
    322 
    323     // bit-masks to test for good/bad pixels
    324     psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    325     assert (maskVal);
    326 
    327     // bit-mask to mark pixels not used in analysis
    328     psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    329     assert (markVal);
    330 
    331     // maskVal is used to test for rejected pixels, and must include markVal
    332     maskVal |= markVal;
    333 
    334     // S/N limit to perform full non-linear fits
    335     float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");
    336 
    337     // option to limit analysis to a specific region
    338     char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");
    339     psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region));
    340     if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined");
    341 
    342     for (int i = 0; i < sources->n; i++) {
    343         pmSource *source = sources->data[i];
    344 
    345         // skip non-astronomical objects (very likely defects)
    346         if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
    347         if (source->mode &  PM_SOURCE_MODE_CR_LIMIT) continue;
    348         if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    349         if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    350 
    351         // skip DBL second sources (ie, added by psphotFitBlob)
    352         if (source->mode &  PM_SOURCE_MODE_PAIR) continue;
    353 
    354         // limit selection to some SN limit
    355         if (source->peak->SN < FIT_SN_LIM) continue;
    356 
    357         // exclude sources outside optional analysis region
    358         if (source->peak->xf < AnalysisRegion.x0) continue;
    359         if (source->peak->yf < AnalysisRegion.y0) continue;
    360         if (source->peak->xf > AnalysisRegion.x1) continue;
    361         if (source->peak->yf > AnalysisRegion.y1) continue;
    362 
    363         // if model is NULL, we don't have a starting guess
    364         if (source->modelPSF == NULL) continue;
    365 
    366         // skip sources which are insignificant flux?
    367         // XXX this is somewhat ad-hoc
    368         if (source->modelPSF->params->data.F32[1] < 0.1) {
    369             psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",
    370                      source->modelPSF->params->data.F32[1],
    371                      source->modelPSF->params->data.F32[2],
    372                      source->modelPSF->params->data.F32[3]);
    373             continue;
    374         }
    375 
    376         // replace object in image
    377         if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {
    378             pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    379         }
    380         Nfit ++;
    381 
    382         // try fitting PSFs or extended sources depending on source->mode
    383         // these functions subtract the resulting fitted source
    384         if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
    385             if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {
    386                 source->type = PM_SOURCE_TYPE_EXTENDED;
    387                 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf);
    388                 Next ++;
    389                 continue;
    390             }
    391         } else {
    392             if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {
    393                 source->type = PM_SOURCE_TYPE_STAR;
    394                 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf);
    395                 Npsf ++;
    396                 continue;
    397             }
    398         }
    399 
    400         psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf);
    401         Nfail ++;
    402 
    403         // re-subtract the object, leave local sky
    404         pmSourceCacheModel (source, maskVal);
    405         pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    406     }
    407 
    408     // change the value of a scalar on the array (wrap this and put it in psArray.h)
    409     *nfit  = Nfit;
    410     *npsf  = Npsf;
    411     *next  = Next;
    412     *nfail = Nfail;
    413 
    414     // moments are modified by the fit; re-display
    415     psphotVisualPlotMoments (recipe, sources);
    416     psphotVisualShowResidualImage (readout);
    417 
    418     return true;
    419 }
    420 # endif
  • branches/eam_branches/psphot.stack.20100120/src/psphotChoosePSF.c

    r26681 r26688  
    3838    // find the currently selected readout
    3939    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    40     psAssert (readout, "missing file?");
     40    psAssert (file, "missing file?");
    4141
    4242    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    4343    psAssert (readout, "missing readout?");
    4444
    45     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     45    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     46    psAssert (detections, "missing detections?");
     47
     48    psArray *sources = detections->newSources;
    4649    psAssert (sources, "missing sources?");
    4750
  • branches/eam_branches/psphot.stack.20100120/src/psphotDeblendSatstars.c

    r26681 r26688  
    3131    // find the currently selected readout
    3232    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    33     psAssert (readout, "missing file?");
     33    psAssert (file, "missing file?");
    3434
    3535    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    3636    psAssert (readout, "missing readout?");
    3737
    38     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     38    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     39    psAssert (detections, "missing detections?");
     40
     41    psArray *sources = detections->newSources;
    3942    psAssert (sources, "missing sources?");
    4043
  • branches/eam_branches/psphot.stack.20100120/src/psphotEfficiency.c

    r26266 r26688  
    149149
    150150
     151bool psphotEfficiency (pmConfig *config, const pmFPAview *view)
     152{
     153    bool status = true;
     154
     155    // select the appropriate recipe information
     156    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     157    psAssert (recipe, "missing recipe?");
     158
     159    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     160    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     161
     162    // loop over the available readouts
     163    for (int i = 0; i < num; i++) {
     164        if (!psphotReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     165            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     166            return false;
     167        }
     168    }
     169    return true;
     170}
     171
    151172// Determine detection efficiency
    152 bool psphotEfficiency(pmConfig *config, pmReadout *readout, const pmFPAview *view, const pmPSF *psf,
    153                 psMetadata *recipe, const psArray *realSources)
     173bool psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe)
    154174{
     175    psTimerStart("psphot.fake");
     176
     177    // find the currently selected readout
     178    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     179    psAssert (readout, "missing file?");
     180
     181    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     182    psAssert (readout, "missing readout?");
     183
     184    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     185    psAssert (detections, "missing detections?");
     186
     187    psArray *realSources = detections->allSources;
     188    psAssert (realSources, "missing sources?");
     189
     190    // XXX do we need to skip this step if we do not have a psf?
     191    pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     192    psAssert (psf, "missing psf?");
     193
    155194    PM_ASSERT_READOUT_NON_NULL(readout, false);
    156195    PM_ASSERT_READOUT_IMAGE(readout, false);
    157196    PS_ASSERT_PTR_NON_NULL(psf, false);
    158197    PS_ASSERT_METADATA_NON_NULL(recipe, false);
    159     PS_ASSERT_ARRAY_NON_NULL(realSources, false);
    160 
    161     psTimerStart("psphot.fake");
    162198
    163199    // Collect recipe information
     
    202238    // remove all sources, adding noise for subtracted sources
    203239    psphotRemoveAllSources(realSources, recipe);
    204     //    psphotAddNoise(readout, realSources, recipe);
     240    // psphotAddNoise(readout, realSources, recipe);
    205241
    206242
  • branches/eam_branches/psphot.stack.20100120/src/psphotExtendedSourceAnalysis.c

    r25755 r26688  
    11# include "psphotInternal.h"
    22
     3// for now, let's store the detections on the readout->analysis for each readout
     4bool psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view)
     5{
     6    bool status = true;
     7
     8    // select the appropriate recipe information
     9    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     10    psAssert (recipe, "missing recipe?");
     11
     12    // perform full non-linear fits / extended source analysis?
     13    if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANALYSIS")) {
     14        psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n");
     15        return true;
     16    }
     17
     18    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     19    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     20
     21    // loop over the available readouts
     22    for (int i = 0; i < num; i++) {
     23        if (!psphotExtendedSourceAnalysisReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     24            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     25            return false;
     26        }
     27    }
     28    return true;
     29}
     30
    331// aperture-like measurements for extended sources
    4 bool psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe) {
     32bool psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) {
    533
    634    bool status;
     
    1139    int Nkron = 0;
    1240
     41    // find the currently selected readout
     42    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     43    psAssert (readout, "missing file?");
     44
     45    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     46    psAssert (readout, "missing readout?");
     47
     48    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     49    psAssert (detections, "missing detections?");
     50
     51    psArray *sources = detections->allSources;
     52    psAssert (sources, "missing sources?");
     53
     54    if (!sources->n) {
     55        psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size");
     56        return true;
     57    }
     58
    1359    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    1460    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1561    assert (maskVal);
    16 
    17     // perform full non-linear fits / extended source analysis?
    18     if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANALYSIS")) {
    19         psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n");
    20         return true;
    21     }
    2262
    2363    // XXX require petrosian analysis for non-linear fits?
  • branches/eam_branches/psphot.stack.20100120/src/psphotExtendedSourceFits.c

    r25755 r26688  
    11# include "psphotInternal.h"
    22
     3// for now, let's store the detections on the readout->analysis for each readout
     4bool psphotExtendedSourceFits (pmConfig *config, const pmFPAview *view)
     5{
     6    bool status = true;
     7
     8    // select the appropriate recipe information
     9    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     10    psAssert (recipe, "missing recipe?");
     11
     12    // perform full extended source non-linear fits?
     13    if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS")) {
     14        psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n");
     15        return true;
     16    }
     17
     18    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     19    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     20
     21    // loop over the available readouts
     22    for (int i = 0; i < num; i++) {
     23        if (!psphotExtendedSourceFitsReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     24            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     25            return false;
     26        }
     27    }
     28    return true;
     29}
     30
    331// non-linear model fitting for extended sources
    4 bool psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe) {
     32bool psphotExtendedSourceFitsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) {
    533
    634    bool status;
     
    1240    bool savePics = false;
    1341
     42    // find the currently selected readout
     43    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     44    psAssert (readout, "missing file?");
     45
     46    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     47    psAssert (readout, "missing readout?");
     48
     49    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     50    psAssert (detections, "missing detections?");
     51
     52    psArray *sources = detections->allSources;
     53    psAssert (sources, "missing sources?");
     54
     55    if (!sources->n) {
     56        psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size");
     57        return true;
     58    }
     59
    1460    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    1561    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     
    2167    // maskVal is used to test for rejected pixels, and must include markVal
    2268    maskVal |= markVal;
    23 
    24     // perform full extended source non-linear fits?
    25     if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS")) {
    26         psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n");
    27         return true;
    28     }
    2969
    3070    // select the collection of desired models
  • branches/eam_branches/psphot.stack.20100120/src/psphotFindDetections.c

    r26643 r26688  
    11# include "psphotInternal.h"
    22
     3// we store the detections on the readout->analysis for each readout this function finds new
     4// peaks and new footprints.  any old peaks are saved on oldPeaks.  the resulting footprint set
     5// contains all footprints (old and new)
     6bool psphotFindDetections (pmConfig *config, const pmFPAview *view)
     7{
     8    bool status = true;
     9
     10    // select the appropriate recipe information
     11    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     12    psAssert (recipe, "missing recipe?");
     13
     14    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     15    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     16
     17    // loop over the available readouts
     18    for (int i = 0; i < num; i++) {
     19        if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     20            psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i);
     21            return false;
     22        }
     23    }
     24    return true;
     25}
     26
    327// smooth the image, search for peaks, optionally define footprints based on the peaks
    4 bool psphotFindDetections (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
     28bool psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) {
    529
    630    bool status;
     
    1135    // find the currently selected readout
    1236    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    13     psAssert (readout, "missing file?");
     37    psAssert (file, "missing file?");
    1438
    1539    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    1640    psAssert (readout, "missing readout?");
    17 
    18     // select the appropriate recipe information
    19     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    20     psAssert (recipe, "missing recipe?");
    2141
    2242    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     
    2747    const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS");
    2848
    29     // on first pass, detections have not yet been allocated
     49    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     50    // on the initial pass, detections have not yet been allocated or saved on readout->analysis
    3051    if (!detections) {
     52        // create the container
    3153        detections = pmDetectionsAlloc();
     54       
     55        // save detections on the readout->analysis
     56        if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_PTR, "psphot detectinos", detections)) {
     57            psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     58            return false;
     59        }
     60
    3261        pass = 1;
    3362        NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); PS_ASSERT (status, NULL);
    3463        NMAX = psMetadataLookupS32 (&status, recipe, "PEAKS_NMAX"); PS_ASSERT (status, NULL);
    3564    } else {
     65        psMemIncrRefCounter(detections); // so we can free the detections below
    3666        pass = 2;
    3767        NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); PS_ASSERT (status, NULL);
     
    4171    float threshold = PS_SQR(NSIGMA_PEAK);
    4272
    43     // move the old peaks array (if it exists) to oldPeaks
    44     // XXX generically, we should be able to call this function an arbitrary number of times
     73    // move the old peaks array (if it exists) to oldPeaks XXX generically, we should be able
     74    // to call this function an arbitrary number of times the old peaks are saved so they can
     75    // be freed later -- the have to be freed after psphotFindFootprints is called below, since
     76    // they are also owned by the oldFootprints, which are in turn merged into the new
     77    // footprints.  (what about the source->peak entry?)
     78   
    4579    assert (detections->oldPeaks == NULL);
    4680    detections->oldPeaks = detections->peaks;
     
    68102        psFree (detections);
    69103        psError (PSPHOT_ERR_CONFIG, false, "failed on peak search");
    70         return NULL;
     104        return false;
    71105    }
    72106
     
    82116    psphotVisualShowFootprints (detections);
    83117
    84     // save detections on the readout->analysis
    85     if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_PTR, "psphot detectinos", detections)) {
    86         psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
    87         return NULL;
    88     }
     118    psFree (detections);
    89119
    90120    return true;
     
    94124// otherwise it only contains the new peaks.
    95125
    96 // for now, let's store the detections on the readout->analysis for each readout
    97 bool psphotFindDetections (pmConfig *config, const pmFPAview *view)
    98 {
    99     bool status = true;
    100 
    101     int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    102     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
    103 
    104     // loop over the available readouts
    105     for (int i = 0; i < num; i++) {
    106         if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i)) {
    107             psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i);
    108             return false;
    109         }
    110     }
    111     return true;
    112 }
  • branches/eam_branches/psphot.stack.20100120/src/psphotFitSourcesLinear.c

    r26681 r26688  
    4444    // find the currently selected readout
    4545    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    46     psAssert (readout, "missing file?");
     46    psAssert (file, "missing file?");
    4747
    4848    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    4949    psAssert (readout, "missing readout?");
    5050
    51     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     51    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     52    psAssert (detections, "missing detections?");
     53
     54    psArray *sources = detections->allSources;
    5255    psAssert (sources, "missing sources?");
    5356
  • branches/eam_branches/psphot.stack.20100120/src/psphotGuessModels.c

    r26681 r26688  
    2525}
    2626
    27 // construct an initial PSF model for each object
     27// construct an initial PSF model for each object (new sources only)
    2828bool psphotGuessModelsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
    2929
     
    3939    psAssert (readout, "missing readout?");
    4040
    41     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     41    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     42    psAssert (detections, "missing detections?");
     43
     44    psArray *sources = detections->newSources;
    4245    psAssert (sources, "missing sources?");
    4346
  • branches/eam_branches/psphot.stack.20100120/src/psphotImageQuality.c

    r26681 r26688  
    3131    // find the currently selected readout
    3232    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    33     psAssert (readout, "missing file?");
     33    psAssert (file, "missing file?");
    3434
    3535    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     
    4141    }
    4242
    43     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     43    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     44    psAssert (detections, "missing detections?");
     45
     46    psArray *sources = detections->newSources;
    4447    psAssert (sources, "missing sources?");
    4548
     
    123126
    124127    if (num == 0) {
    125       psWarning("Unable to find sources from which to measure image quality");
    126       return false;
     128        psLogMsg ("psphot", PS_LOG_INFO, "no valid sources for image quality, skipping");
     129        return true;
    127130    }
    128131
  • branches/eam_branches/psphot.stack.20100120/src/psphotMagnitudes.c

    r25755 r26688  
    11# include "psphotInternal.h"
    22
    3 bool psphotMagnitudes(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, const pmPSF *psf) {
     3bool psphotMagnitudes (pmConfig *config, const pmFPAview *view)
     4{
     5    bool status = true;
     6
     7    // select the appropriate recipe information
     8    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     9    psAssert (recipe, "missing recipe?");
     10
     11    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     12    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     13
     14    // loop over the available readouts
     15    for (int i = 0; i < num; i++) {
     16        if (!psphotMagnitudesReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     17            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     18            return false;
     19        }
     20    }
     21    return true;
     22}
     23
     24bool psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) {
    425
    526    bool status = false;
     
    829    psTimerStart ("psphot.mags");
    930
    10     // select the appropriate recipe information
    11     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    12     assert (recipe);
     31    // find the currently selected readout
     32    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     33    psAssert (readout, "missing file?");
     34
     35    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     36    psAssert (readout, "missing readout?");
     37
     38    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     39    psAssert (detections, "missing detections?");
     40
     41    psArray *sources = detections->allSources;
     42    psAssert (sources, "missing sources?");
     43
     44    if (!sources->n) {
     45        psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size");
     46        return true;
     47    }
     48
     49    pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     50    psAssert (psf, "missing psf?");
    1351
    1452    // determine the number of allowed threads
     
    64102
    65103            psArrayAdd(job->args, 1, cells->data[j]); // sources
    66             psArrayAdd(job->args, 1, (pmPSF*)psf);    // Casting away const
     104            psArrayAdd(job->args, 1, psf);
    67105            psArrayAdd(job->args, 1, binning);
    68106            psArrayAdd(job->args, 1, backModel);
     
    179217}
    180218
    181 # if (0)
    182 bool psphotMagnitudes_Unthreaded (int *nap, psArray *sources, pmPSF *psf, psImageBinning *binning, pmReadout *backModel, pmReadout *backStdev, pmSourcePhotometryMode photMode, psImageMaskType maskVal) {
    183 
    184     bool status;
    185     int Nap = 0;
    186 
    187     for (int i = 0; i < sources->n; i++) {
    188         pmSource *source = (pmSource *) sources->data[i];
    189         status = pmSourceMagnitudes (source, psf, photMode, maskVal);
    190         if (status && isfinite(source->apMag)) Nap ++;
    191 
    192         if (backModel) {
    193             psAssert (binning, "if backModel is defined, so should binning be");
    194             source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);
    195             if (isnan(source->sky) && false) {
    196                 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");
    197             }
    198         } else {
    199             source->sky = NAN;
    200         }
    201 
    202         if (backStdev) {
    203             psAssert (binning, "if backStdev is defined, so should binning be");
    204             source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);
    205             if (isnan(source->skyErr) && false) {
    206                 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");
    207             }
    208         } else {
    209             source->skyErr = NAN;
    210         }
    211     }
    212 
    213     // change the value of a scalar on the array (wrap this and put it in psArray.h)
    214     *nap = Nap;
    215 
    216     return true;
    217 }
    218 # endif
    219 
    220219bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources) {
    221220
  • branches/eam_branches/psphot.stack.20100120/src/psphotMergeSources.c

    r26317 r26688  
    55                         PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply for PSF sources
    66
     7// for now, let's store the detections on the readout->analysis for each readout
     8bool psphotMergeSources (pmConfig *config, const pmFPAview *view)
     9{
     10    bool status = true;
     11
     12    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     13    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     14
     15    // loop over the available readouts
     16    for (int i = 0; i < num; i++) {
     17        if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {
     18            psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i);
     19            return false;
     20        }
     21    }
     22    return true;
     23}
     24
     25// add newly selected sources to the existing list of sources
     26bool psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
     27
     28    // find the currently selected readout
     29    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     30    psAssert (file, "missing file?");
     31
     32    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     33    psAssert (readout, "missing readout?");
     34
     35    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     36    psAssert (detections, "missing detections?");
     37
     38    psArray *newSources = detections->newSources;
     39    psAssert (newSources, "missing sources?");
     40
     41    if (!detections->allSources) {
     42        detections->allSources = psArrayAllocEmpty(newSources->n);
     43    }
     44    psArray *allSources = detections->allSources;
     45
     46    for (int i = 0; i < newSources->n; i++) {
     47        pmSource *source = newSources->data[i];
     48        psArrayAdd (allSources, 100, source);
     49    }
     50
     51    // XXX free detections->newSources?
     52    return true;
     53}
     54
    755// merge the externally supplied sources with the existing sources.  mark them as having
    856// mode PM_SOURCE_MODE_EXTERNAL
     57// XXX this function needs to be updated to work with the new context of pshot inputs
    958bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources) {
    1059
     
    71120}
    72121
    73 // add newly selected sources to the existing list of sources
    74 bool psphotMergeSources (psArray *oldSources, psArray *newSources) {
    75 
    76     for (int i = 0; i < newSources->n; i++) {
    77         pmSource *source = newSources->data[i];
    78         psArrayAdd (oldSources, 100, source);
    79     }
    80     return true;
    81 }
    82 
    83122// extract the input sources corresponding to this readout
     123// XXX this function needs to be updated to work with the new context of pshot inputs
    84124psArray *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view) {
    85125
  • branches/eam_branches/psphot.stack.20100120/src/psphotModelBackground.c

    r26681 r26688  
    3232// generate the median in NxN boxes, clipping heavily
    3333// linear interpolation to generate full-scale model
    34 bool psphotModelBackgroundReadout(psImage *model,  // Model image
     34static bool psphotModelBackgroundReadout(psImage *model,  // Model image
    3535                                  psImage *modelStdev, // Model stdev image
    3636                                  psMetadata *analysis, // Analysis metadata for outputs
  • branches/eam_branches/psphot.stack.20100120/src/psphotOutput.c

    r26681 r26688  
    126126}
    127127
    128 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {
    129 
    130     pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
    131     PS_ASSERT (file, false);
    132 
    133     pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
    134 
    135     // determine PHOTCODE from fpa & view, overwrite in readout->analysis
    136     char *photcode = pmConceptsPhotcodeForView (file, view);
    137     PS_ASSERT (photcode, false);
    138 
    139     psMetadataAddStr (readout->analysis, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);
    140     psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode);
    141 
    142     psFree (photcode);
    143     return true;
    144 }
    145 
    146128bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view) {
    147129
     
    158140        }
    159141    }
     142    return true;
     143}
     144
     145bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {
     146
     147    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
     148    PS_ASSERT (file, false);
     149
     150    pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
     151
     152    // determine PHOTCODE from fpa & view, overwrite in readout->analysis
     153    char *photcode = pmConceptsPhotcodeForView (file, view);
     154    PS_ASSERT (photcode, false);
     155
     156    psMetadataAddStr (readout->analysis, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);
     157    psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode);
     158
     159    psFree (photcode);
    160160    return true;
    161161}
  • branches/eam_branches/psphot.stack.20100120/src/psphotReadout.c

    r26681 r26688  
    5151
    5252    // run a single-model test if desired (exits from here if test is run)
    53     // XXX drop this and only keep the stand-alone program?
     53    // XXX fix this in the new multi-input context (or drop this and only keep a stand-alone program)
    5454    // psphotModelTest (config, view, recipe);
    5555
    5656    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
    57     // XXX this needs to save the PSF on the chip->analysis or readout->analysis
    58     if (!psphotLoadPSF (config, view, recipe)) {
    59         // this only happens if we had a programming error in psphotLoadPSF
    60         psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
    61         return psphotReadoutCleanup (config, view);
    62     }
     57    // XXX the recipe is probably the wrong place to store those results...
     58    // XXX this is using the wrong file... fix in the new context
     59    // if (!psphotLoadPSF (config, view, recipe)) {
     60    //  // this only happens if we had a programming error in psphotLoadPSF
     61    //     psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
     62    //     return psphotReadoutCleanup (config, view);
     63    // }
    6364       
    6465    // find the detections (by peak and/or footprint) in the image.
    65     if (!psphotFindDetections (config, view)) {
     66    if (!psphotFindDetections (config, view)) { // pass 1
    6667        // this only happens if we had an error in psphotFindDetections
    6768        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
     
    6970    }
    7071
    71 XXX: // need to handle or ignore this !!
    72     if (!detections->peaks->n) {
    73         psLogMsg ("psphot", 3, "unable to find detections in this image");
    74         return psphotReadoutCleanup (config, view);
    75     }
    76 
    77     // construct sources and measure basic stats
    78     if (!psphotSourceStats (config, view, true)) {
     72    // construct sources and measure basic stats (saved on detections->newSources)
     73    if (!psphotSourceStats (config, view, true)) { // pass 1
    7974        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    8075        return psphotReadoutCleanup (config, view);
     
    8479    }
    8580
    86     // find blended neighbors of very saturated stars
     81    // find blended neighbors of very saturated stars (detections->newSources)
    8782    if (!psphotDeblendSatstars (config, view)) {
    8883        psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis");
     
    9085    }
    9186
    92     // mark blended peaks PS_SOURCE_BLEND
     87    // mark blended peaks PS_SOURCE_BLEND (detections->newSources)
    9388    if (!psphotBasicDeblend (config, view)) {
    9489        psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis");
     
    9792
    9893    // classify sources based on moments, brightness.  if a PSF model has been loaded, the PSF
    99     // clump defined for it is used not measured
    100     if (!psphotRoughClass (config, view)) {
     94    // clump defined for it is used not measured (detections->newSources)
     95    if (!psphotRoughClass (config, view)) { // pass 1
    10196        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications");
    10297        return psphotReadoutCleanup (config, view);
     
    106101    }
    107102
    108     // if we were not supplied a PSF model, determine the IQ stats here
    109     if (!psphotImageQuality (config, view)) {
    110         psLogMsg("psphot", 3, "failed to measure image quality");
     103    // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources)
     104    if (!psphotImageQuality (config, view)) { // pass 1
     105        psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality");
    111106        return psphotReadoutCleanup(config, view);
    112107    }
     
    114109    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    115110    // this step is skipped
    116     if (!psphotChoosePSF (config, view)) {
     111    if (!psphotChoosePSF (config, view)) { // pass 1
    117112        psLogMsg ("psphot", 3, "failure to construct a psf model");
    118113        return psphotReadoutCleanup (config, view);
     
    123118
    124119    // include externally-supplied sources
    125     // XXX hmm...
    126     psphotLoadExtSources (config, view, sources);
    127 
    128     // construct an initial model for each object, set the radius to fitRadius, set circular fit mask
    129     psphotGuessModels (config, view);
     120    // XXX fix this in the new multi-input context
     121    // psphotLoadExtSources (config, view, sources); // pass 1
     122
     123    // construct an initial model for each object, set the radius to fitRadius, set circular
     124    // fit mask (detections->newSources)
     125    psphotGuessModels (config, view); // pass 1
     126
     127    // merge the newly selected sources into the existing list
     128    // NOTE: merge OLD and NEW
     129    psphotMergeSources (config, view); FIX:
    130130
    131131    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    132     psphotFitSourcesLinear (config, view, FALSE);
    133 
    134     // identify CRs and extended sources
    135     psphotSourceSize (config, view);
     132    psphotFitSourcesLinear (config, view, false); // pass 1 (detections->allSources)
     133
     134    // identify CRs and extended sources (only unmeasured sources are measured)
     135    psphotSourceSize (config, view, true); // pass 1 (detections->allSources)
    136136    if (!strcasecmp (breakPt, "ENSEMBLE")) {
    137137        goto finish;
     
    140140    // non-linear PSF and EXT fit to brighter sources
    141141    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    142     psphotBlendFit (config, view);
     142    psphotBlendFit (config, view); // pass 1 (detections->allSources)
    143143
    144144    // replace all sources
    145     psphotReplaceAllSources (config, view);
     145    psphotReplaceAllSources (config, view); // pass 1 (detections->allSources)
    146146
    147147    // linear fit to include all sources (subtract again)
    148     psphotFitSourcesLinear (config, view, TRUE);
     148    // NOTE : apply to ALL sources (extended + psf)
     149    psphotFitSourcesLinear (config, view, true); // pass 2 (detections->allSources)
    149150
    150151    // if we only do one pass, skip to extended source analysis
    151     if (!strcasecmp (breakPt, "PASS1")) {
    152         goto pass1finish;
    153     }
    154     // NOTE: possibly re-measure background model here with objects subtracted
     152    if (!strcasecmp (breakPt, "PASS1")) goto pass1finish;
     153
     154    // NOTE: possibly re-measure background model here with objects subtracted / or masked
    155155
    156156    // add noise for subtracted objects
    157     psphotAddNoise (config, view);
    158 
    159     // find fainter sources (pass 2)
    160     // XXX need to distinguish old from new sources
    161     psphotFindDetections (config, view);
     157    psphotAddNoise (config, view); // pass 1 (detections->allSources)
     158
     159    // find fainter sources
     160    // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
     161    psphotFindDetections (config, view); // pass 2 (detections->peaks, detections->footprints)
    162162
    163163    // remove noise for subtracted objects (ie, return to normal noise level)
    164     // XXX this needs to operate only on the OLD sources
    165     psphotSubNoise (config, view);
     164    // NOTE: this needs to operate only on the OLD sources
     165    psphotSubNoise (config, view); // pass 1 (detections->allSources)
    166166
    167167    // define new sources based on only the new peaks
    168     // XXX need to distinguish old from new sources
    169     psphotSourceStats (config, view, false);
     168    // NOTE: new sources are saved on detections->newSources
     169    psphotSourceStats (config, view, false); // pass 2 (detections->newSources)
    170170
    171171    // set source type
    172     if (!psphotRoughClass (config, view)) {
     172    // NOTE: apply only to detections->newSources
     173    if (!psphotRoughClass (config, view)) { // pass 2 (detections->newSources)
    173174        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    174175        return psphotReadoutCleanup (config, view);
     
    176177
    177178    // create full input models, set the radius to fitRadius, set circular fit mask
    178     // XXX need to distinguish old from new sources
    179     psphotGuessModels (config, view);
     179    // NOTE: apply only to detections->newSources
     180    psphotGuessModels (config, view); // pass 2 (detections->newSources)
    180181
    181182    // replace all sources so fit below applies to all at once
    182     psphotReplaceAllSources (config, view);
     183    // NOTE: apply only to OLD sources (which have been subtracted)
     184    psphotReplaceAllSources (config, view); // pass 2
    183185
    184186    // merge the newly selected sources into the existing list
    185     // XXX old vs new????
    186 FIX:    psphotMergeSources (sources, newSources);
    187     psFree (newSources);
    188 
    189     // linear fit to all sources
    190     psphotFitSourcesLinear (config, view, TRUE);
     187    // NOTE: merge OLD and NEW
     188    psphotMergeSources (config, view); FIX: // (detections->newSources + detections->allSources -> detections->allSources)
     189
     190    // NOTE: apply to ALL sources
     191    psphotFitSourcesLinear (config, view, true); // pass 3 (detections->allSources)
    191192
    192193pass1finish:
    193194
    194195    // measure source size for the remaining sources
    195     psphotSourceSize (config, view);
    196 
    197 FIX:    psphotExtendedSourceAnalysis (readout, sources, recipe);
    198 FIX:    psphotExtendedSourceFits (readout, sources, recipe);
     196    // NOTE: applies only to NEW (unmeasured) sources
     197    psphotSourceSize (config, view, false); // pass 2 (detections->allSources)
     198
     199    psphotExtendedSourceAnalysis (config, view); // pass 1 (detections->allSources)
     200    psphotExtendedSourceFits (config, view); // pass 1 (detections->allSources)
    199201
    200202finish:
     
    204206
    205207    // measure aperture photometry corrections
    206 FIX:    if (!psphotApResid (config, readout, sources, psf)) {
     208    if (!psphotApResid (config, view)) { // pass 1 (detections->allSources)
    207209        psLogMsg ("psphot", 3, "failed on psphotApResid");
    208210        return psphotReadoutCleanup (config, view);
     
    210212
    211213    // calculate source magnitudes
    212 FIX:    psphotMagnitudes(config, readout, view, sources, psf);
    213 
    214 FIX:    if (!psphotEfficiency(config, readout, view, psf, recipe, sources)) {
     214    psphotMagnitudes(config, view); // pass 1 (detections->allSources)
     215
     216    if (!psphotEfficiency(config, view)) { // pass 1
    215217        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    216218        psErrorClear();
     
    221223
    222224    // replace background in residual image
    223 FIX:    psphotSkyReplace (config, view);
     225    psphotSkyReplace (config, view); // pass 1
    224226
    225227    // drop the references to the image pixels held by each source
    226 FIX:    psphotSourceFreePixels (sources);
     228    psphotSourceFreePixels (config, view); // pass 1
    227229
    228230    // create the exported-metadata and free local data
  • branches/eam_branches/psphot.stack.20100120/src/psphotReadoutCleanup.c

    r26681 r26688  
    5151
    5252    // when psphotReadoutCleanup is called, these are not necessarily defined
    53     psArray *sources         = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
    54     pmPSF *psf               = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     53    pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
    5554    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
    56 
     55    psArray *sources = detections->allSources;
    5756    // XXX where do we free these, in here (psMetadataRemove?)
    5857
  • branches/eam_branches/psphot.stack.20100120/src/psphotReplaceUnfit.c

    r26681 r26688  
    5353    // find the currently selected readout
    5454    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    55     psAssert (readout, "missing file?");
     55    psAssert (file, "missing file?");
    5656
    5757    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    5858    psAssert (readout, "missing readout?");
    5959
    60     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     60    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     61    psAssert (detections, "missing detections?");
     62
     63    psArray *sources = detections->allSources;
    6164    psAssert (sources, "missing sources?");
    6265
     
    99102    return true;
    100103}
    101 
    102 # if (0)
    103 // add source, if the source has been subtracted; do not modify state
    104 bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
    105 
    106     // what is current state? (true : add; false : sub)
    107     bool state = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);
    108     if (state && useState) return true;
    109 
    110     pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    111     return true;
    112 }
    113 
    114 // sub source, if the source has been added; do not modify state
    115 bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
    116 
    117     // what is current state? (true : sub; false : add)
    118     bool state = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);
    119     if (state && useState) return true;
    120 
    121     pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    122     return true;
    123 }
    124 
    125 // add or sub source to match recorded state: supply current state as true (add) or false (sub)
    126 bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal) {
    127 
    128     // what is desired state? (true : add; false : sub)
    129     bool newState = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);
    130     if (curState == newState) return true;
    131 
    132     if (curState && !newState) {
    133         pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    134     }
    135     if (newState && !curState) {
    136         pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    137     }
    138     return true;
    139 }
    140 # endif
  • branches/eam_branches/psphot.stack.20100120/src/psphotRoughClass.c

    r26681 r26688  
    3737    // find the currently selected readout
    3838    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    39     psAssert (readout, "missing file?");
     39    psAssert (file, "missing file?");
    4040
    4141    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     
    4848    }
    4949
    50     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     50    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     51    psAssert (detections, "missing detections?");
     52
     53    psArray *sources = detections->newSources;
    5154    psAssert (sources, "missing sources?");
    5255
  • branches/eam_branches/psphot.stack.20100120/src/psphotSkyReplace.c

    r21183 r26688  
    11# include "psphotInternal.h"
     2
     3bool psphotSkyReplace (pmConfig *config, const pmFPAview *view)
     4{
     5    bool status = true;
     6
     7    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     8    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     9
     10    // loop over the available readouts
     11    for (int i = 0; i < num; i++) {
     12        if (!psphotReadout (config, view, "PSPHOT.INPUT", i)) {
     13            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     14            return false;
     15        }
     16    }
     17    return true;
     18}
    219
    320// XXX make this an option?
    421// in order to  successfully replace the sky, we must define a corresponding file...
    5 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view) {
     22bool psphotSkyReplaceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
    623
    724    psTimerStart ("psphot.skyreplace");
    825
    926    // find the currently selected readout
    10     pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT");
    11     if (readout == NULL) psAbort("input not defined");
     27    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     28    psAssert (readout, "missing file?");
     29
     30    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     31    psAssert (readout, "missing readout?");
    1232
    1333    // select background pixels, from output background file, or create
  • branches/eam_branches/psphot.stack.20100120/src/psphotSourceFreePixels.c

    r12792 r26688  
    11# include "psphotInternal.h"
    22
    3 void psphotSourceFreePixels (psArray *sources) {
     3bool psphotSourceFreePixels (pmConfig *config, const pmFPAview *view)
     4{
     5    bool status = true;
    46
    5     if (!sources) return;
     7    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     8    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     9
     10    // loop over the available readouts
     11    for (int i = 0; i < num; i++) {
     12        if (!psphotSourceFreePixelsReadout (config, view, "PSPHOT.INPUT", i)) {
     13            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
     14            return false;
     15        }
     16    }
     17    return true;
     18}
     19
     20bool psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index) {
     21
     22    // find the currently selected readout
     23    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     24    psAssert (readout, "missing file?");
     25
     26    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     27    psAssert (readout, "missing readout?");
     28
     29    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     30    psAssert (detections, "missing detections?");
     31
     32    psArray *sources = detections->allSources;
     33    psAssert (sources, "missing sources?");
    634
    735    for (int i = 0; i < sources->n; i++) {
     
    937        pmSourceFreePixels (source);
    1038    }
    11     return;
     39    return true;
    1240}
  • branches/eam_branches/psphot.stack.20100120/src/psphotSourceSize.c

    r26681 r26688  
    1616
    1717// local functions:
    18 bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index);
    1918bool psphotSourceSizePSF (psphotSourceSizeOptions *options, psArray *sources, pmPSF *psf);
    2019bool psphotSourceClass (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psphotSourceSizeOptions *options);
     
    3130
    3231// for now, let's store the detections on the readout->analysis for each readout
    33 bool psphotSourceSize (pmConfig *config, const pmFPAview *view)
     32bool psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize)
    3433{
    3534    bool status = true;
     
    4443    // loop over the available readouts
    4544    for (int i = 0; i < num; i++) {
    46         if (!psphotSourceSizeReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     45        if (!psphotSourceSizeReadout (config, view, "PSPHOT.INPUT", i, recipe, getPSFsize)) {
    4746            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
    4847            return false;
     
    5251}
    5352
    54 // XXX use an internal flag to mark sources which have already been measured
    55 bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe)
     53// this function use an internal flag to mark sources which have already been measured
     54bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool getPSFsize)
    5655{
    5756    bool status;
     
    6766    psAssert (readout, "missing readout?");
    6867
    69     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     68    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     69    psAssert (detections, "missing detections?");
     70
     71    psArray *sources = detections->allSources;
    7072    psAssert (sources, "missing sources?");
    7173
     
    116118    // XXX move this to the code that generates the PSF?
    117119    // XXX store the results on pmPSF?
    118     psphotSourceSizePSF (&options, sources, psf);
     120
     121    // XXX this should only be done on the first pass (ie, if we have newSources or allSources?)
     122    if (getPSFsize) {
     123        psphotSourceSizePSF (&options, sources, psf);
     124    }
    119125
    120126    // classify the sources based on ApResid and Moments (extended sources)
     127    // NOTE: only sources not already measured !(source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED)
    121128    psphotSourceClass(readout, sources, recipe, psf, &options);
    122129
     130    // NOTE: only sources not already measured !(source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED)
    123131    psphotSourceSizeCR (readout, sources, &options);
    124132
     
    376384    for (int i = 0; i < sources->n; i++) {
    377385        pmSource *source = sources->data[i];
     386
     387        // skip source if it was already measured
     388        if (source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) {
     389            psTrace("psphot", 7, "Not calculating source size since it has already been measured\n");
     390            continue;
     391        }
    378392
    379393        // Integer position of peak
  • branches/eam_branches/psphot.stack.20100120/src/psphotSourceStats.c

    r26681 r26688  
    11# include "psphotInternal.h"
    22
    3 // convert detections to sources and measure their basic properties (moments, local sky, sky variance)
     3// convert detections to sources and measure their basic properties (moments, local sky, sky
     4// variance) Note: this function only generates sources for the new peaks (peak->assigned)
    45bool psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow)
    56{
     
    3940    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
    4041    psAssert (detections, "missing detections?");
     42    psAssert (!detections->newSources, "new sources already defined?");
    4143
    4244    // determine the number of allowed threads
     
    6769    // if there are no peaks, we save the empty source array and return
    6870    if (!peaks->n) {
    69         // save sources on the readout->analysis
    70         if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) {
    71             psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
    72             psFree(sources);
    73             return false;
    74         }
    75         psFree(sources);
     71        // save the new sources on the detection structure:
     72        detections->newSources = sources;
    7673        return true;
    7774    }
     
    103100        psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
    104101        psphotVisualShowMoments (sources);
    105         // save sources on the readout->analysis
    106         if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) {
    107             psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
    108             psFree(sources);
    109             return false;
    110         }
    111         psFree(sources);
     102        detections->newSources = sources;
    112103        return true;
    113104    }
     
    187178    psphotVisualShowMoments (sources);
    188179
    189     // save sources on the readout->analysis
    190     if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) {
    191         psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
    192         psFree(sources);
    193         return false;
    194     }
    195     psFree(sources);
     180    // save the new sources on the detection structure:
     181    detections->newSources = sources;
    196182    return true;
    197183}
     
    216202    // determine properties (sky, moments) of initial sources
    217203    float OUTER    = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
    218     if (!status) return NULL;
     204    if (!status) return false;
    219205
    220206    OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius
    221207
    222208    char *breakPt  = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    223     if (!status) return NULL;
     209    if (!status) return false;
    224210
    225211    for (int i = 0; i < sources->n; i++) {
     
    509495}
    510496
    511 
    512497// if we use the footprints, the output peaks list contains both old and new peaks,
    513498// otherwise it only contains the new peaks.
Note: See TracChangeset for help on using the changeset viewer.