- Timestamp:
- Jun 4, 2008, 1:52:32 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSimPhotomReadout.c
r17851 r17901 1 1 # include "ppSim.h" 2 3 psArray *ppSimSelectSources (pmConfig *config, const pmFPAview *view, const char *filename) { 4 5 pmReadout *readout = pmFPAfileThisReadout (config->files, view, filename); 6 PS_ASSERT_PTR_NON_NULL (readout, NULL); 7 8 psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES"); 9 return sources; 10 } 11 12 bool ppSimDefinePixels (psArray *sources, pmReadout *readout, psMetadata *recipe) { 13 14 bool status; 15 16 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 17 if (!status) return NULL; 18 19 for (int i = 0; i < sources->n; i++) { 20 pmSource *source = sources->data[i]; 21 22 // allocate image, weight, mask arrays for each peak (square of radius OUTER) 23 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 24 } 25 return true; 26 } 2 27 3 28 bool ppSimPhotomReadout(pmConfig *config, const pmFPAview *view) { … … 13 38 14 39 // set the photcode for this image 15 if (!psphotAddPhotcode (recipe, config, view )) {40 if (!psphotAddPhotcode (recipe, config, view, "PPSIM.CHIP")) { 16 41 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 17 42 return false; … … 23 48 PS_ASSERT_PTR_NON_NULL (readout, false); 24 49 25 pmReadout *realSourceReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.REAL.SOURCES"); 26 PS_ASSERT_PTR_NON_NULL (realSourceReadout, false); 50 // the previously measured real sources are loaded into the PPSIM.REAL.SOURCES pmFPAfile 51 psArray *realSources = ppSimSelectSources (config, view, "PPSIM.REAL.SOURCES"); 52 PS_ASSERT_PTR_NON_NULL (realSources, false); 53 54 // the newly injected fake sources are saved on the PPSIM.OUTPUT pmFPAfile 55 psArray *injectedSources = ppSimSelectSources (config, view, "PPSIM.OUTPUT"); 56 PS_ASSERT_PTR_NON_NULL (injectedSources, false); 57 58 // XXX need to define the source pixels 59 ppSimDefinePixels (realSources, readout, recipe); 60 ppSimDefinePixels (injectedSources, readout, recipe); 61 62 // make a copy of the fake-source parameters so these can be saved independently from the 63 // measured fake-source parameters 64 psArray *fakeSources = psArrayAlloc (injectedSources->n); 65 for (int i = 0; i < injectedSources->n; i++) { 66 fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]); 67 } 68 69 // load the forced source lists 70 psArray *forceSources = ppSimLoadForceSources (config, view); 71 psAssert (forceSources, "failed to load force photometry sources"); 27 72 28 73 // Generate the mask and weight images, including the user-defined analysis region of interest … … 33 78 pmPSF *psf = psphotLoadPSF (config, view, recipe); 34 79 assert (psf); 35 36 // load the source lists37 // PPSIM.REAL.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)38 psArray *realSources = psMetadataLookupPtr (NULL, realSourceReadout->analysis, "PSPHOT.SOURCES");39 psArray *forceSources = ppSimLoadForceSources (config, view);40 41 // XXX make a copy of the fake-source parameters so these can be saved independently42 // from the measured fake-source parameters43 psArray *injectedSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");44 psArray *fakeSources = psArrayAlloc (injectedSources->n);45 for (int i = 0; i < injectedSources->n; i++) {46 fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]);47 }48 80 49 81 // remove all sources … … 97 129 // XXX for the fake sources, these must be identically zero 98 130 // XXX for the force sources, need the apresid to put the mags on the correct system 99 if (!psphotApResid (readout, forceSources, recipe, psf)) { 100 psLogMsg ("psphot", 3, "failed on psphotApResid"); 101 return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL); 131 if (0) { 132 if (!psphotApResid (readout, forceSources, recipe, psf)) { 133 psLogMsg ("psphot", 3, "failed on psphotApResid"); 134 return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL); 135 } 102 136 } 103 137 … … 119 153 // add forceSources to the readout (real and fake already there) 120 154 // these are outputs: we need to generate the fpa structure 121 // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FAKE.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources); 155 156 pmReadout *fakeReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.SOURCES"); 157 psMetadataAdd (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources); 158 122 159 // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FORCE.SOURCES", PS_DATA_ARRAY, "forced photometry ", forceSources); 123 160 psFree (forceSources);
Note:
See TracChangeset
for help on using the changeset viewer.
