Changeset 27650
- Timestamp:
- Apr 11, 2010, 2:48:58 PM (16 years ago)
- Location:
- branches/eam_branches/stackphot.20100406/psphot/src
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphotMergeSources.c (modified) (3 diffs)
-
psphotSourceMatch.c (modified) (3 diffs)
-
psphotSourceStats.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/stackphot.20100406/psphot/src
- Property svn:ignore
-
old new 21 21 psphotForced 22 22 psphotMakePSF 23 psphotStack
-
- Property svn:ignore
-
branches/eam_branches/stackphot.20100406/psphot/src/psphotMergeSources.c
r27314 r27650 76 76 pmDetections *extCMF = NULL; 77 77 psArray *extSourcesTXT = NULL; 78 79 // find the currently selected readout 80 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", 0); // File of interest 78 int index = 0; 79 80 // find the currently selected readout 81 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", index); // File of interest 81 82 psAssert (file, "missing file?"); 82 83 … … 118 119 psFree (source->modelPSF); 119 120 source->modelPSF = NULL; 121 source->imageID = index; 120 122 121 123 psArrayAdd (detections->newSources, 100, source); … … 140 142 psFree (source->modelPSF); 141 143 source->modelPSF = NULL; 144 source->imageID = index; 142 145 143 146 psArrayAdd (detections->newSources, 100, source); -
branches/eam_branches/stackphot.20100406/psphot/src/psphotSourceMatch.c
r27649 r27650 1 1 # include "psphotInternal.h" 2 3 bool psphotMatchSourcesGenerate (pmConfig *config, const pmFPAview *view, psArray *objects); 2 4 3 5 psArray *psphotMatchSources (pmConfig *config, const pmFPAview *view) … … 19 21 } 20 22 21 // psphotMatchSourcesGenerate (objects, config, view, "PSPHOT.INPUT", i);23 psphotMatchSourcesGenerate (config, view, objects); 22 24 23 25 return objects; … … 135 137 pmPhotObjAddSource(obj, src); 136 138 psArrayAdd (objects, 100, obj); 139 psFree (obj); 137 140 } 138 141 psLogMsg ("psphot", PS_LOG_DETAIL, "matched sources (%ld vs %ld)", sources->n, objects->n); 139 142 143 psFree (found); 140 144 return true; 141 145 } 146 147 bool psphotMatchSourcesGenerate (pmConfig *config, const pmFPAview *view, psArray *objects) { 148 149 bool status = false; 150 151 // select the appropriate recipe information 152 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 153 psAssert (recipe, "missing recipe?"); 154 155 // determine properties (sky, moments) of initial sources 156 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 157 psAssert (status, "missing SKY_OUTER_RADIUS in recipe?"); 158 159 int nImages = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 160 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 161 162 // generate look-up arrays for detections and readouts 163 psArray *detArrays = psArrayAlloc(nImages); 164 psArray *readouts = psArrayAlloc(nImages); 165 166 for (int i = 0; i < nImages; i++) { 167 168 // find the currently selected readout 169 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest 170 psAssert (file, "missing file?"); 171 172 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 173 psAssert (readout, "missing readout?"); 174 175 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 176 psAssert (detections, "missing detections?"); 177 178 detArrays->data[i] = psMemIncrRefCounter(detections); 179 readouts->data[i] = psMemIncrRefCounter(readout); 180 } 181 182 // vector to track if source for an image is found 183 psVector *found = psVectorAlloc(nImages, PS_TYPE_U8); 184 185 for (int i = 0; i < objects->n; i++) { 186 pmPhotObj *obj = objects->data[i]; 187 188 // mark the images for which sources have been found 189 psVectorInit (found, 0); 190 for (int j = 0; j < obj->sources->n; j++) { 191 192 pmSource *src = obj->sources->data[j]; 193 int index = src->imageID; 194 psAssert (index >= 0, "invalid index"); 195 psAssert (index < found->n, "invalid index"); 196 197 found->data.U8[index] = 1; 198 } 199 200 // generate new sources for the image that are missing 201 for (int index = 0; index < found->n; index++) { 202 if (found->data.U8[index]) continue; 203 204 pmDetections *detections = detArrays->data[index]; 205 pmReadout *readout = readouts->data[index]; 206 int row0 = readout->image->row0; 207 int col0 = readout->image->col0; 208 209 // XXX the peak type is not really used in psphot 210 // PM_PEAK_LONE is certainly not true, but irrelevant 211 float peakFlux = readout->image->data.F32[(int)(obj->y-row0-0.5)][(int)(obj->x-col0-0.5)]; 212 pmPeak *peak = pmPeakAlloc(obj->x, obj->y, peakFlux, PM_PEAK_LONE); 213 peak->flux = peakFlux; 214 peak->SN = 1.0; 215 peak->xf = obj->x; 216 peak->yf = obj->y; 217 peak->dx = NAN; 218 peak->dy = NAN; 219 220 // XXX assign to a footprint? 221 222 // create a new source 223 pmSource *source = pmSourceAlloc(); 224 source->imageID = index; 225 226 // add the peak 227 source->peak = psMemIncrRefCounter(peak); 228 229 // allocate space for moments 230 source->moments = pmMomentsAlloc(); 231 232 // allocate image, weight, mask arrays for each peak (square of radius OUTER) 233 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 234 235 peak->assigned = true; 236 pmPhotObjAddSource(obj, source); 237 psArrayAdd (detections->newSources, 100, source); 238 psFree (source); 239 psFree (peak); 240 } 241 } 242 243 // how many sources do we have now? 244 int nSources = 0; 245 for (int i = 0; i < objects->n; i++) { 246 pmPhotObj *obj = objects->data[i]; 247 nSources += obj->sources->n; 248 } 249 psLogMsg ("psphot", PS_LOG_DETAIL, "total of %d sources for %d images", nSources, nImages); 250 251 252 psFree (found); 253 psFree (detArrays); 254 psFree (readouts); 255 return true; 256 } -
branches/eam_branches/stackphot.20100406/psphot/src/psphotSourceStats.c
r27571 r27650 2 2 3 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) 4 // variance) Note: this function only generates sources for the new peaks (peak->assigned). 5 // The new sources are added to any existing sources on detections->newSources. The sources 6 // on detections->allSources are ignored. 5 7 bool psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow) 6 8 { … … 40 42 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 41 43 psAssert (detections, "missing detections?"); 42 psAssert (!detections->newSources, "new sources already defined?");43 44 44 45 // XXX TEST: … … 84 85 85 86 // generate the array of sources, define the associated pixel 86 sources = psArrayAllocEmpty (peaks->n); 87 if (!detections->newSources) { 88 detections->newSources = psArrayAllocEmpty (peaks->n); 89 } 90 sources = detections->newSources; 87 91 88 92 // if there are no peaks, we save the empty source array and return 89 93 if (!peaks->n) { 90 // save the new sources on the detection structure:91 detections->newSources = sources;92 94 return true; 93 95 } … … 100 102 // create a new source 101 103 pmSource *source = pmSourceAlloc(); 104 source->imageID = index; 102 105 103 106 // add the peak … … 119 122 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n"); 120 123 psphotVisualShowMoments (sources); 121 detections->newSources = sources;122 124 return true; 123 125 } … … 126 128 if (!psphotSetMomentsWindow(recipe, readout->analysis, sources)) { 127 129 psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to determine Moments Window!"); 128 psFree( sources);130 psFree(detections->newSources); 129 131 return false; 130 132 } … … 178 180 psError(PS_ERR_UNKNOWN, false, "Unable to launch thread job PSPHOT_SOURCE_STATS"); 179 181 psFree (job); 180 psFree( sources);182 psFree(detections->newSources); 181 183 return false; 182 184 } … … 187 189 if (!psThreadPoolWait (false)) { 188 190 psError(PS_ERR_UNKNOWN, false, "Failure in thread job PSPHOT_SOURCE_STATS"); 189 psFree(sources);191 psFree(detections->newSources); 190 192 return false; 191 193 } … … 215 217 psphotVisualShowMoments (sources); 216 218 217 // save the new sources on the detection structure:218 detections->newSources = sources;219 220 221 219 if (detections->allSources) { 222 220 psphotMaskCosmicRayFootprintCheck(detections->allSources); … … 377 375 pmSource *source = sources->data[i]; 378 376 377 if (source->tmpFlags & PM_SOURCE_TMPF_MOMENTS_MEASURED) continue; 378 source->tmpFlags |= PM_SOURCE_TMPF_MOMENTS_MEASURED; 379 379 380 // skip faint sources for moments measurement 380 381 if (source->peak->SN < MIN_SN) {
Note:
See TracChangeset
for help on using the changeset viewer.
