- Timestamp:
- Jul 31, 2012, 11:50:18 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120627/psphot
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120627/psphot
- Property svn:mergeinfo changed
/trunk/psphot merged: 34135-34136,34200-34202,34215,34218,34226
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120627/psphot/src
- Property svn:mergeinfo changed
/trunk/psphot/src merged: 34135-34136,34200-34202,34215,34218,34226
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120627/psphot/src/psphotStackReadout.c
r33958 r34247 1 1 # include "psphotInternal.h" 2 3 static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule); 2 4 3 5 // we have 3 possible real filesets: … … 67 69 char *STACK_SRC = useRaw ? STACK_RAW : STACK_CNV; 68 70 char *STACK_DET = STACK_RAW; 71 72 // load WCS 73 if (!psphotStackLoadWCS(config, view, STACK_SRC)) { 74 psError (PSPHOT_ERR_CONFIG, false, "trouble loading WCS for %s", STACK_SRC); 75 return false; 76 } 69 77 70 78 // set the photcode for each image … … 179 187 180 188 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 181 psphotFitSourcesLinear (config, view, STACK_SRC, false );189 psphotFitSourcesLinear (config, view, STACK_SRC, false, false); 182 190 psphotStackVisualFilerule(config, view, STACK_SRC); 183 191 … … 207 215 // NOTE : apply to ALL sources (extended + psf) 208 216 // NOTE 2 : this function subtracts the models from the given filerule (SRC), not DET 209 psphotFitSourcesLinear (config, view, STACK_SRC, true ); // pass 2 (detections->allSources)217 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 2 (detections->allSources) 210 218 211 219 // NOTE: possibly re-measure background model here with objects subtracted / or masked … … 278 286 } 279 287 288 // gcc doesn't like the label to refer to a declaration so we declare this here 289 bool splitLinearFit; 290 280 291 pass1finish: 292 293 splitLinearFit = psMetadataLookupBool(NULL, recipe, "PSPHOT.STACK.SPLIT.LINEAR.FIT"); 294 if (splitLinearFit) { 295 psLogMsg ("psphot", 3, "splitting fit of detected and matched soures\n"); 296 // Fit the detected sources separately from matched that wea are about to create. 297 // NOTE: apply to ALL sources but only include sources with postitive flux in the fit 298 psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources) 299 } 281 300 282 301 // generate the objects (objects unify the sources from the different images) NOTE: could … … 286 305 psMemDump("matchsources"); 287 306 307 // check the source density. If it too high change the number of radial bins 308 // in the recipe. 309 psphotLimitRadialApertures(recipe, objects->n); 310 288 311 // Construct an initial model for each object, set the radius to fitRadius, set circular 289 312 // fit mask. NOTE: only applied to sources without guess models … … 294 317 psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects); 295 318 296 // NOTE: apply to ALL sources 297 psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 3 (detections->allSources) 319 if (splitLinearFit) { 320 // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will 321 // not be included in this fit. 322 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources) 323 } else { 324 // Fit all sources together 325 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources) 326 } 298 327 299 328 // measure the radial profiles to the sky (only measures new objects) … … 344 373 } 345 374 } 346 psphotRadialApertures (config, view, STACK_CNV, 0); // XXX entry 0 == unmatched?375 psphotRadialApertures (config, view, STACK_CNV, 0); // entry 0 == unmatched 347 376 psMemDump("extmeas"); 348 377 378 // mark any inputs that we want to skip the matched apertures for 379 psphotStackSetInputsToSkip(config, view, STACK_OUT, true); 380 349 381 int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT); 350 351 382 for (int entry = 1; entry < nRadialEntries; entry++) { 352 383 // NOTE: entry 0 is the unmatched image set … … 359 390 360 391 // this is necessary to get the right normalization for the new models 361 psphotFitSourcesLinear (config, view, STACK_OUT, false );392 psphotFitSourcesLinear (config, view, STACK_OUT, false, false); 362 393 363 394 // measure circular, radial apertures (objects sorted by S/N) 364 // entry 0 == unmatched? pass entry + 1?365 395 psphotRadialApertures (config, view, STACK_OUT, entry); 366 396 … … 373 403 } 374 404 } 405 psphotStackSetInputsToSkip(config, view, STACK_OUT, false); 375 406 376 407 // measure aperture photometry corrections … … 413 444 // create the exported-metadata and free local data 414 445 return psphotReadoutCleanup (config, view, STACK_SRC); 446 } 447 448 static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule) { 449 450 int num = psphotFileruleCount(config, filerule); 451 452 for (int i=0; i<num; i++) { 453 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 454 psAssert (file, "missing file?"); 455 456 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 457 psAssert (readout, "missing readout?"); 458 459 pmHDU *hdu = pmHDUFromReadout(readout); 460 psAssert (hdu, "input missing hdu?"); 461 462 if (!pmAstromReadWCS(file->fpa, readout->parent->parent, hdu->header, 1.0)) { 463 psError (PSPHOT_ERR_UNKNOWN, false, "failed to read WCS from header for input %d", i); 464 return false; 465 } 466 } 467 return true; 415 468 } 416 469
Note:
See TracChangeset
for help on using the changeset viewer.
