Changeset 31154 for trunk/psphot/src/psphotReadout.c
- Timestamp:
- Apr 4, 2011, 1:12:39 PM (15 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 edited
-
. (modified) (2 props)
-
src/psphotReadout.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
- Property svn:ignore
-
old new 19 19 psphot-config 20 20 Doxyfile 21 a.out.dSYM
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
trunk/psphot/src/psphotReadout.c
r30624 r31154 9 9 } 10 10 11 // for now, let's store the detections on the readout->analysis for each readout 12 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 readouts 27 for (int i = 0; i < num; i++) { 28 29 // find the currently selected readout 30 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 31 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 11 62 bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) { 12 63 … … 52 103 } 53 104 105 # if (0) 106 // XXX test to mask outliers, not very helpful 107 // 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 # endif 117 54 118 if (!psphotSubtractBackground (config, view, filerule)) { 55 119 return psphotReadoutCleanup (config, view, filerule); … … 83 147 84 148 // find blended neighbors of very saturated stars (detections->newSources) 85 if (!psphotDeblendSatstars (config, view, filerule)) {86 psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis");87 return psphotReadoutCleanup (config, view, filerule);88 }149 // if (!psphotDeblendSatstars (config, view, filerule)) { 150 // psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis"); 151 // return psphotReadoutCleanup (config, view, filerule); 152 // } 89 153 90 154 // mark blended peaks PS_SOURCE_BLEND (detections->newSources) … … 134 198 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 135 199 psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources) 200 psphotDumpChisqs (config, view, filerule); 136 201 137 202 // identify CRs and extended sources (only unmeasured sources are measured) … … 144 209 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 145 210 psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources) 211 psphotDumpChisqs (config, view, filerule); 146 212 147 213 // replace all sources … … 151 217 // NOTE : apply to ALL sources (extended + psf) 152 218 psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources) 219 psphotDumpChisqs (config, view, filerule); 153 220 154 221 // if we only do one pass, skip to extended source analysis … … 157 224 // NOTE: possibly re-measure background model here with objects subtracted / or masked 158 225 159 // add noise for subtracted objects 160 psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources) 161 162 // find fainter sources 163 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 164 psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints) 165 166 // remove noise for subtracted objects (ie, return to normal noise level) 167 // NOTE: this needs to operate only on the OLD sources 168 psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources) 169 170 // define new sources based on only the new peaks 171 // NOTE: new sources are saved on detections->newSources 172 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) 173 174 // set source type 175 // NOTE: apply only to detections->newSources 176 if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources) 177 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 178 return psphotReadoutCleanup (config, view, filerule); 179 } 180 181 // create full input models, set the radius to fitRadius, set circular fit mask 182 // NOTE: apply only to detections->newSources 183 psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources) 184 185 // replace all sources so fit below applies to all at once 186 // NOTE: apply only to OLD sources (which have been subtracted) 187 psphotReplaceAllSources (config, view, filerule); // pass 2 188 189 // merge the newly selected sources into the existing list 190 // NOTE: merge OLD and NEW 191 // XXX check on free of sources... 192 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 193 194 // NOTE: apply to ALL sources 195 psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources) 226 // NOTE: this block performs the 2nd pass low-significance PSF detection stage 227 { 228 // add noise for subtracted objects 229 psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources) 230 231 // find fainter sources 232 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 233 psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints) 234 235 // remove noise for subtracted objects (ie, return to normal noise level) 236 // NOTE: this needs to operate only on the OLD sources 237 psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources) 238 239 // define new sources based on only the new peaks 240 // NOTE: new sources are saved on detections->newSources 241 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) 242 243 // set source type 244 // NOTE: apply only to detections->newSources 245 if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources) 246 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 247 return psphotReadoutCleanup (config, view, filerule); 248 } 249 250 // create full input models, set the radius to fitRadius, set circular fit mask 251 // NOTE: apply only to detections->newSources 252 psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources) 253 254 // replace all sources so fit below applies to all at once 255 // NOTE: apply only to OLD sources (which have been subtracted) 256 psphotReplaceAllSources (config, view, filerule); // pass 2 257 258 // merge the newly selected sources into the existing list 259 // NOTE: merge OLD and NEW 260 // XXX check on free of sources... 261 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 262 263 // NOTE: apply to ALL sources 264 psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources) 265 psphotDumpChisqs (config, view, filerule); 266 } 267 268 // NOTE: this block performs the 2nd pass low-significance EXT detection stage (smooth or rebin by NxN times PSF size) 269 if (0) { 270 // add noise for subtracted objects 271 psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources) 272 273 // find fainter sources 274 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 275 psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints) 276 277 // remove noise for subtracted objects (ie, return to normal noise level) 278 // NOTE: this needs to operate only on the OLD sources 279 psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources) 280 281 // define new sources based on only the new peaks 282 // NOTE: new sources are saved on detections->newSources 283 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) 284 285 // set source type 286 // NOTE: apply only to detections->newSources 287 if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources) 288 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 289 return psphotReadoutCleanup (config, view, filerule); 290 } 291 292 // create full input models, set the radius to fitRadius, set circular fit mask 293 // NOTE: apply only to detections->newSources 294 psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources) 295 296 // replace all sources so fit below applies to all at once 297 // NOTE: apply only to OLD sources (which have been subtracted) 298 psphotReplaceAllSources (config, view, filerule); // pass 2 299 300 // merge the newly selected sources into the existing list 301 // NOTE: merge OLD and NEW 302 // XXX check on free of sources... 303 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 304 305 // NOTE: apply to ALL sources 306 psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources) 307 } 196 308 197 309 pass1finish: … … 203 315 psphotExtendedSourceAnalysis (config, view, filerule); // pass 1 (detections->allSources) 204 316 psphotExtendedSourceFits (config, view, filerule); // pass 1 (detections->allSources) 317 psphotRadialApertures(config, view, filerule); 205 318 206 319 finish:
Note:
See TracChangeset
for help on using the changeset viewer.
