- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (2 props)
-
psphot/src/psphotReadout.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/psphot
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/psphot/src
- Property svn:ignore
-
old new 22 22 psphotMakePSF 23 23 psphotStack 24 psphotModelTest
-
- Property svn:mergeinfo set to
- Property svn:ignore
-
branches/meh_branches/ppstack_test/psphot/src/psphotReadout.c
r31452 r33415 9 9 } 10 10 11 // for now, let's store the detections on the readout->analysis for each readout12 bool psphotDumpChisqs (pmConfig *config, const pmFPAview *view, const char *filerule)13 {14 static int npass = 0;15 char filename[64];16 17 return true;18 19 bool status = true;20 21 int num = psphotFileruleCount(config, filerule);22 23 snprintf (filename, 64, "chisq.%02d.dat", npass);24 FILE *f = fopen (filename, "w");25 26 // loop over the available readouts27 for (int i = 0; i < num; i++) {28 29 // find the currently selected readout30 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest31 psAssert (file, "missing file?");32 33 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);34 psAssert (readout, "missing readout?");35 36 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");37 psAssert (detections, "missing detections?");38 39 psArray *sources = detections->allSources;40 psAssert (sources, "missing sources?");41 42 for (int i = 0; i < sources->n; i++) {43 pmSource *source = sources->data[i];44 if (!source) continue;45 46 pmModel *model = pmSourceGetModel (NULL, source);47 if (!model) continue;48 49 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) {50 fprintf (f, "%f %f %f %d %d %f 1 NONLINEAR\n", model->mag, model->params->data.F32[1], model->chisq, model->nDOF, model->nPix, model->chisqNorm);51 } else {52 fprintf (f, "%f %f %f %d %d %f 0 LINEAR\n", model->mag, model->params->data.F32[1], model->chisq, model->nDOF, model->nPix, model->chisqNorm);53 }54 }55 }56 fclose (f);57 npass ++;58 59 return true;60 }61 62 11 bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) { 63 12 … … 102 51 return psphotReadoutCleanup (config, view, filerule); 103 52 } 104 105 # if (0)106 // XXX test to mask outliers, not very helpful107 // mask the high values in the image (with MARK)108 if (!psphotMaskBackground (config, view, filerule)) {109 return psphotReadoutCleanup (config, view, filerule);110 }111 112 // generate a background model (median, smoothed image)113 if (!psphotModelBackground (config, view, filerule)) {114 return psphotReadoutCleanup (config, view, filerule);115 }116 # endif117 118 53 if (!psphotSubtractBackground (config, view, filerule)) { 119 54 return psphotReadoutCleanup (config, view, filerule); … … 137 72 } 138 73 139 // construct sources and measure basic stats (saved on detections->newSources) 74 // construct sources and measure moments and other basic stats (saved on detections->newSources) 75 // all sources use the auto-scaled window appropriate to a PSF, except for the saturated 76 // stars : these use a larger window (3x the basic window) 140 77 if (!psphotSourceStats (config, view, filerule, true)) { // pass 1 141 78 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources"); … … 153 90 154 91 // mark blended peaks PS_SOURCE_BLEND (detections->newSources) 155 if (!psphotBasicDeblend (config, view, filerule)) { 92 // XXX I've deactivated this because it was preventing galaxies close to stars from being 93 // XXX fitted as an extended source. 94 if (false && !psphotBasicDeblend (config, view, filerule)) { 156 95 psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis"); 157 96 return psphotReadoutCleanup (config, view, filerule); … … 188 127 // psphotLoadExtSources (config, view, filerule); // pass 1 189 128 190 // construct an initial model for each object, set the radius to fitRadius, set circular191 // fit mask (detections->newSources)192 psphotGuessModels (config, view, filerule); // pass 1193 194 129 // merge the newly selected sources into the existing list 195 130 // NOTE: merge OLD and NEW 196 131 psphotMergeSources (config, view, filerule); 197 132 133 // Construct an initial model for each object, set the radius to fitRadius, set circular 134 // fit mask. NOTE: only applied to sources without guess models 135 // pass 1 136 if (!psphotGuessModels (config, view, filerule)) { 137 psLogMsg ("psphot", 3, "failure to Guess Model - pass 1"); 138 return psphotReadoutCleanup (config, view, filerule); 139 } 140 198 141 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 199 142 psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources) 200 psphotDumpChisqs (config, view, filerule); 201 202 // XXX re-measure the kron mags with models subtracted 203 psphotKronMasked(config, view, filerule); 143 144 // measure the radial profiles to the sky 145 psphotRadialProfileWings (config, view, filerule); 146 147 // re-measure the kron mags with models subtracted. this pass uses a circular window of size PSF_MOMENTS_RADIUS (same window used to measure the psf-scale moments) 148 149 // but this is chosen above to be appropriate for the PSF objects (not galaxies) 150 // psphotKronMasked(config, view, filerule); 151 psphotKronIterate(config, view, filerule); 204 152 205 153 // identify CRs and extended sources (only unmeasured sources are measured) … … 211 159 // non-linear PSF and EXT fit to brighter sources 212 160 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 161 // XXX: can leave faulted job in done queue 213 162 psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources) 214 psphotDumpChisqs (config, view, filerule);215 163 216 164 // replace all sources 217 psphotReplaceAllSources (config, view, filerule ); // pass 1 (detections->allSources)165 psphotReplaceAllSources (config, view, filerule, false); // pass 1 (detections->allSources) 218 166 219 167 // linear fit to include all sources (subtract again) 220 168 // NOTE : apply to ALL sources (extended + psf) 221 169 psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources) 222 psphotDumpChisqs (config, view, filerule);223 170 224 171 // if we only do one pass, skip to extended source analysis … … 240 187 psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources) 241 188 242 // define new sources based on only the new peaks 189 // define new sources based on only the new peaks & measure moments 243 190 // NOTE: new sources are saved on detections->newSources 244 191 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) … … 251 198 } 252 199 253 // create full input models, set the radius to fitRadius, set circular fit mask254 // NOTE: apply only to detections->newSources255 psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)256 257 200 // replace all sources so fit below applies to all at once 258 201 // NOTE: apply only to OLD sources (which have been subtracted) 259 psphotReplaceAllSources (config, view, filerule ); // pass 2202 psphotReplaceAllSources (config, view, filerule, false); // pass 2 260 203 261 204 // merge the newly selected sources into the existing list … … 264 207 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 265 208 209 // Construct an initial model for each object, set the radius to fitRadius, set circular 210 // fit mask. NOTE: only applied to sources without guess models 211 psphotGuessModels (config, view, filerule); // pass 1 212 266 213 // NOTE: apply to ALL sources 267 214 psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources) 268 psphotDumpChisqs (config, view, filerule);269 215 } 270 216 … … 293 239 } 294 240 295 // create full input models, set the radius to fitRadius, set circular fit mask296 // NOTE: apply only to detections->newSources297 psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)298 299 241 // replace all sources so fit below applies to all at once 300 242 // NOTE: apply only to OLD sources (which have been subtracted) 301 psphotReplaceAllSources (config, view, filerule ); // pass 2243 psphotReplaceAllSources (config, view, filerule, false); // pass 2 302 244 303 245 // merge the newly selected sources into the existing list … … 306 248 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 307 249 250 // Construct an initial model for each object, set the radius to fitRadius, set circular 251 // fit mask. NOTE: only applied to sources without guess models 252 psphotGuessModels (config, view, filerule); // pass 1 253 308 254 // NOTE: apply to ALL sources 309 255 psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources) … … 312 258 pass1finish: 313 259 314 // XXX re-measure the kron mags with models subtracted 315 psphotKronMasked(config, view, filerule); 260 // measure the radial profiles to the sky (only measures new objects) 261 psphotRadialProfileWings (config, view, filerule); 262 263 // re-measure the kron mags with models subtracted 264 // psphotKronMasked(config, view, filerule); 265 psphotKronIterate(config, view, filerule); 316 266 317 267 // measure source size for the remaining sources … … 321 271 psphotExtendedSourceAnalysis (config, view, filerule); // pass 1 (detections->allSources) 322 272 psphotExtendedSourceFits (config, view, filerule); // pass 1 (detections->allSources) 323 psphotRadialApertures(config, view, filerule );273 psphotRadialApertures(config, view, filerule, 0); 324 274 325 275 finish: … … 359 309 } 360 310 311 psLogMsg ("psphot.readout", PS_LOG_WARN, "complete psphot readout : %f sec\n", psTimerMark ("psphotReadout")); 312 361 313 // create the exported-metadata and free local data 362 314 return psphotReadoutCleanup(config, view, filerule);
Note:
See TracChangeset
for help on using the changeset viewer.
