- Timestamp:
- May 27, 2008, 7:12:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSimPhotomReadout.c
r17709 r17818 1 # include "p sphotInternal.h"1 # include "ppSim.h" 2 2 3 bool p sphotReadout(pmConfig *config, const pmFPAview *view) {3 bool ppSimPhotomReadout(pmConfig *config, const pmFPAview *view) { 4 4 5 5 psTimerStart ("psphotReadout"); … … 18 18 } 19 19 20 // find the currently selected readout 21 // XXX keep this name or go with something like PPSIM.PHOT.INPUT?22 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "P SPHOT.INPUT");20 // find the currently selected readout. 21 // we always perform photometry on the mosaiced chip 22 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.CHIP"); 23 23 PS_ASSERT_PTR_NON_NULL (readout, false); 24 24 … … 27 27 28 28 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are saved in the recipe 29 // this function uses PSPHOT.PSF.LOAD as the pmFPAfile 29 30 pmPSF *psf = psphotLoadPSF (config, view, recipe); 30 31 assert (psf); … … 33 34 // PPSIM.REAL.SOURCES carries the pmSource objects (from psphot analysis or loaded externally) 34 35 psArray *realSources = psMetadataLookupPtr (NULL, readout->analysis, "PPSIM.REAL.SOURCES"); 35 psArray *fakeSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES"); 36 forceSources = ppSimLoadForceSources (config, view); 36 psArray *forceSources = ppSimLoadForceSources (config, view); 37 37 38 // replace all sources 39 psphotRemoveSources (realSources, recipe); 38 // XXX make a copy of the fake-source parameters so these can be saved independently 39 // from the measured fake-source parameters 40 psArray *injectedSources = psMetadataLookupPtr (NULL, readout->analysis, "PPSIM.SOURCES"); 41 psArray *fakeSources = psArrayAlloc (injectedSources->n); 42 for (int i = 0; i < injectedSources->n; i++) { 43 fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]); 44 } 45 46 // remove all sources 47 psphotRemoveAllSources (realSources, recipe); 40 48 41 49 // generate a background model (median, smoothed image) 42 if (!psphotModelBackground (config, view, "P SPHOT.INPUT")) {50 if (!psphotModelBackground (config, view, "PPSIM.CHIP")) { 43 51 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 44 52 } 45 if (!psphotSubtractBackground (config, view, "P SPHOT.INPUT")) {53 if (!psphotSubtractBackground (config, view, "PPSIM.CHIP")) { 46 54 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 47 55 } … … 51 59 52 60 // XXX fake sources should measure peak->x,y, force sources should not 61 psMaskType maskVal = 0xff; 53 62 psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal); 54 63 ppSimDetections (significance, recipe, fakeSources); … … 60 69 61 70 // replace all sources 62 psphotReplaceAll (realSources, recipe);71 psphotReplaceAllSources (realSources, recipe); 63 72 64 73 // construct an initial model for each object … … 67 76 psphotGuessModels (readout, forceSources, recipe, psf); 68 77 78 psArray *sources = NULL; 79 69 80 // linear fit to real + fake sources 70 psArray *sources = ppSimMergeSources (realSources, fakeSources);81 sources = ppSimMergeSources (realSources, fakeSources); 71 82 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); // XXX option to NOT subtract 72 psphotReplaceAll (sources, recipe);83 psphotReplaceAllSources (sources, recipe); 73 84 psFree (sources); // only frees the merged references 74 85 75 86 // linear fit to real + forced sources 76 psArray *sources = ppSimMergeSources (realSources, forceSources);87 sources = ppSimMergeSources (realSources, forceSources); 77 88 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); // XXX option to NOT subtract 78 psphotReplaceAll (sources, recipe);89 psphotReplaceAllSources (sources, recipe); 79 90 psFree (sources); // only frees the merged references 80 91 … … 85 96 if (!psphotApResid (readout, forceSources, recipe, psf)) { 86 97 psLogMsg ("psphot", 3, "failed on psphotApResid"); 87 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources);98 return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL); 88 99 } 89 100 90 // calculate source magnitudes 101 // calculate source magnitudes (for which set??) 91 102 pmReadout *background = psphotSelectBackground (config, view, false); 92 psphotMagnitudes(sources, recipe, psf, background); 103 psphotMagnitudes(fakeSources, recipe, psf, background); 104 psphotMagnitudes(forceSources, recipe, psf, background); 93 105 94 106 // drop the references to the image pixels held by each source 95 psphotSourceFreePixels (sources); 107 psphotSourceFreePixels (realSources); 108 psphotSourceFreePixels (fakeSources); 109 psphotSourceFreePixels (forceSources); 96 110 97 111 // create the exported-metadata and free local data 98 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 112 // XXX this places the sources on readout->analysis as PSPHOT.SOURCES. modify? 113 // (or don't supply the sources, and do this with a different function) 114 psphotReadoutCleanup(config, readout, recipe, NULL, psf, NULL); 115 116 // add forceSources to the readout (real and fake already there) 117 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FAKE.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources); 118 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FORCE.SOURCES", PS_DATA_ARRAY, "forced photometry ", forceSources); 119 psFree (forceSources); 120 return true; 99 121 }
Note:
See TracChangeset
for help on using the changeset viewer.
