Changeset 28398
- Timestamp:
- Jun 17, 2010, 2:21:24 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotReadout.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotReadout.c
r28375 r28398 14 14 // by the multiple threads, not the total time used by all threads. 15 15 psTimerStart ("psphotReadout"); 16 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 16 17 17 pmModelClassSetLimits(PM_MODEL_LIMITS_LAX); 18 18 … … 26 26 char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT"); 27 27 psAssert (breakPt, "configuration error: set BREAK_POINT"); 28 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 28 29 29 // set the photcode for this image 30 30 if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) { … … 32 32 return false; 33 33 } 34 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 34 35 35 // Generate the mask and weight images, including the user-defined analysis region of interest 36 36 if (!psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT")) { … … 40 40 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 41 41 } 42 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 42 43 43 // generate a background model (median, smoothed image) 44 44 if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) { 45 45 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 46 46 } 47 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 47 48 48 if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) { 49 49 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); … … 52 52 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 53 53 } 54 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 54 55 55 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are determined and saved on 56 56 // readout->analysis XXX this function currently only works with a single PSPHOT.INPUT … … 59 59 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 60 60 } 61 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 61 62 62 // find the detections (by peak and/or footprint) in the image. 63 63 if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1 … … 66 66 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 67 67 } 68 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 68 69 69 // construct sources and measure basic stats (saved on detections->newSources) 70 70 if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1 … … 75 75 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 76 76 } 77 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 77 78 78 // find blended neighbors of very saturated stars (detections->newSources) 79 79 if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) { … … 81 81 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 82 82 } 83 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 83 84 84 // mark blended peaks PS_SOURCE_BLEND (detections->newSources) 85 85 if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) { … … 87 87 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 88 88 } 89 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 89 90 90 // classify sources based on moments, brightness. if a PSF model has been loaded, the PSF 91 91 // clump defined for it is used not measured (detections->newSources) … … 94 94 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 95 95 } 96 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 96 97 97 // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources) 98 98 if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1 … … 103 103 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 104 104 } 105 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 105 106 106 // use bright stellar objects to measure PSF if we were supplied a PSF for any input file, 107 107 // this step is skipped … … 117 117 // XXX fix this in the new multi-input context 118 118 // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1 119 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 119 120 120 // construct an initial model for each object, set the radius to fitRadius, set circular 121 121 // fit mask (detections->newSources) 122 122 psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1 123 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 123 124 124 // merge the newly selected sources into the existing list 125 125 // NOTE: merge OLD and NEW 126 126 psphotMergeSources (config, view, "PSPHOT.INPUT"); 127 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 127 128 128 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 129 129 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false); // pass 1 (detections->allSources) 130 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 130 131 131 // identify CRs and extended sources (only unmeasured sources are measured) 132 132 psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources) … … 134 134 goto finish; 135 135 } 136 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 136 137 137 // non-linear PSF and EXT fit to brighter sources 138 138 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 139 139 psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 140 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 140 141 141 // replace all sources 142 142 psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 143 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 143 144 144 // linear fit to include all sources (subtract again) 145 145 // NOTE : apply to ALL sources (extended + psf) 146 146 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources) 147 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 147 148 148 // if we only do one pass, skip to extended source analysis 149 149 if (!strcasecmp (breakPt, "PASS1")) goto pass1finish; 150 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 150 151 151 // NOTE: possibly re-measure background model here with objects subtracted / or masked 152 152 153 153 // add noise for subtracted objects 154 154 psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 155 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 155 156 156 // find fainter sources 157 157 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 158 158 psphotFindDetections (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->peaks, detections->footprints) 159 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 159 160 160 // remove noise for subtracted objects (ie, return to normal noise level) 161 161 // NOTE: this needs to operate only on the OLD sources 162 162 psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 163 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 163 164 164 // define new sources based on only the new peaks 165 165 // NOTE: new sources are saved on detections->newSources 166 166 psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources) 167 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 167 168 168 // set source type 169 169 // NOTE: apply only to detections->newSources … … 172 172 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 173 173 } 174 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 174 175 175 // create full input models, set the radius to fitRadius, set circular fit mask 176 176 // NOTE: apply only to detections->newSources 177 177 psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources) 178 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 178 179 179 // replace all sources so fit below applies to all at once 180 180 // NOTE: apply only to OLD sources (which have been subtracted) 181 181 psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2 182 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 182 183 183 // merge the newly selected sources into the existing list 184 184 // NOTE: merge OLD and NEW 185 185 // XXX check on free of sources... 186 186 psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources) 187 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 187 188 188 // NOTE: apply to ALL sources 189 189 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources) 190 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 190 191 191 pass1finish: 192 192 … … 194 194 // NOTE: applies only to NEW (unmeasured) sources 195 195 psphotSourceSize (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->allSources) 196 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 196 197 197 psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 198 198 psphotExtendedSourceFits (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 199 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 199 200 200 finish: 201 201 202 202 // plot positive sources 203 203 // psphotSourcePlots (readout, sources, recipe); 204 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 204 205 205 // measure aperture photometry corrections 206 206 if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources) … … 208 208 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 209 209 } 210 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 210 211 211 // calculate source magnitudes 212 212 if (!psphotMagnitudes(config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources) 213 213 psErrorStackPrint(stderr, "Unable to do magnitudes."); 214 214 psErrorClear(); 215 } 215 } 216 216 if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1 217 217 psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
Note:
See TracChangeset
for help on using the changeset viewer.
