Changeset 28375 for trunk/psphot/src/psphotReadout.c
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/czw_branch/20100519 (added) merged: 28044-28045,28164,28245,28304,28334,28338
- Property svn:mergeinfo changed
-
trunk/psphot
- Property svn:mergeinfo changed
/branches/czw_branch/20100519/psphot (added) merged: 28164,28304
- Property svn:mergeinfo changed
-
trunk/psphot/src/psphotReadout.c
r28013 r28375 14 14 // by the multiple threads, not the total time used by all threads. 15 15 psTimerStart ("psphotReadout"); 16 16 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 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 28 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 29 29 // set the photcode for this image 30 30 if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) { … … 32 32 return false; 33 33 } 34 34 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 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 42 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 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 if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) { 48 49 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); … … 51 52 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 52 53 } 53 54 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 54 55 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are determined and saved on 55 56 // readout->analysis XXX this function currently only works with a single PSPHOT.INPUT … … 58 59 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 59 60 } 60 61 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 61 62 // find the detections (by peak and/or footprint) in the image. 62 63 if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1 … … 65 66 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 66 67 } 67 68 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 68 69 // construct sources and measure basic stats (saved on detections->newSources) 69 70 if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1 … … 74 75 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 75 76 } 76 77 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 77 78 // find blended neighbors of very saturated stars (detections->newSources) 78 79 if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) { … … 80 81 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 81 82 } 82 83 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 83 84 // mark blended peaks PS_SOURCE_BLEND (detections->newSources) 84 85 if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) { … … 86 87 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 87 88 } 88 89 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 89 90 // classify sources based on moments, brightness. if a PSF model has been loaded, the PSF 90 91 // clump defined for it is used not measured (detections->newSources) … … 93 94 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 94 95 } 96 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 95 97 // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources) 96 98 if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1 … … 101 103 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 102 104 } 103 105 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 104 106 // use bright stellar objects to measure PSF if we were supplied a PSF for any input file, 105 107 // this step is skipped … … 115 117 // XXX fix this in the new multi-input context 116 118 // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1 117 119 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 118 120 // construct an initial model for each object, set the radius to fitRadius, set circular 119 121 // fit mask (detections->newSources) 120 122 psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1 121 123 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 122 124 // merge the newly selected sources into the existing list 123 125 // NOTE: merge OLD and NEW 124 126 psphotMergeSources (config, view, "PSPHOT.INPUT"); 125 127 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 126 128 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 127 129 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false); // pass 1 (detections->allSources) 128 130 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 129 131 // identify CRs and extended sources (only unmeasured sources are measured) 130 132 psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources) … … 132 134 goto finish; 133 135 } 134 136 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 135 137 // non-linear PSF and EXT fit to brighter sources 136 138 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 137 139 psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 138 140 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 139 141 // replace all sources 140 142 psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 141 143 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 142 144 // linear fit to include all sources (subtract again) 143 145 // NOTE : apply to ALL sources (extended + psf) 144 146 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources) 145 147 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 146 148 // if we only do one pass, skip to extended source analysis 147 149 if (!strcasecmp (breakPt, "PASS1")) goto pass1finish; 148 150 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 149 151 // NOTE: possibly re-measure background model here with objects subtracted / or masked 150 152 151 153 // add noise for subtracted objects 152 154 psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 153 155 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 154 156 // find fainter sources 155 157 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 156 158 psphotFindDetections (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->peaks, detections->footprints) 157 159 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 158 160 // remove noise for subtracted objects (ie, return to normal noise level) 159 161 // NOTE: this needs to operate only on the OLD sources 160 162 psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 161 163 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 162 164 // define new sources based on only the new peaks 163 165 // NOTE: new sources are saved on detections->newSources 164 166 psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources) 165 167 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 166 168 // set source type 167 169 // NOTE: apply only to detections->newSources … … 170 172 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 171 173 } 172 174 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 173 175 // create full input models, set the radius to fitRadius, set circular fit mask 174 176 // NOTE: apply only to detections->newSources 175 177 psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources) 176 178 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 177 179 // replace all sources so fit below applies to all at once 178 180 // NOTE: apply only to OLD sources (which have been subtracted) 179 181 psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2 180 182 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 181 183 // merge the newly selected sources into the existing list 182 184 // NOTE: merge OLD and NEW 183 185 // XXX check on free of sources... 184 186 psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources) 185 187 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 186 188 // NOTE: apply to ALL sources 187 189 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources) 188 190 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 189 191 pass1finish: 190 192 … … 192 194 // NOTE: applies only to NEW (unmeasured) sources 193 195 psphotSourceSize (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->allSources) 194 196 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 195 197 psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 196 198 psphotExtendedSourceFits (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 197 199 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 198 200 finish: 199 201 200 202 // plot positive sources 201 203 // psphotSourcePlots (readout, sources, recipe); 202 204 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 203 205 // measure aperture photometry corrections 204 206 if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources) … … 206 208 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 207 209 } 208 210 printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast())); 209 211 // calculate source magnitudes 210 psphotMagnitudes(config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 211 212 if (!psphotMagnitudes(config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources) 213 psErrorStackPrint(stderr, "Unable to do magnitudes."); 214 psErrorClear(); 215 } 212 216 if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1 213 217 psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources"); … … 219 223 220 224 // replace background in residual image 221 psphotSkyReplace (config, view, "PSPHOT.INPUT"); // pass 1 222 225 if (!psphotSkyReplace (config, view, "PSPHOT.INPUT")) { // pass 1 226 psErrorStackPrint(stderr, "Unable to replace sky"); 227 psErrorClear(); 228 229 /* psLogMsg("psphot", 3, "failed on psphotSkyReplace"); */ 230 /* return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */ 231 } 223 232 // drop the references to the image pixels held by each source 224 psphotSourceFreePixels (config, view, "PSPHOT.INPUT"); // pass 1 225 233 if (!psphotSourceFreePixels (config, view, "PSPHOT.INPUT")) { // pass 1 234 psErrorStackPrint(stderr, "Unable to free source pixels"); 235 psErrorClear(); 236 237 /* psLogMsg ("psphot", 3, "failed on psphotSourceFreePixels"); */ 238 /* return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */ 239 } 226 240 // create the exported-metadata and free local data 227 241 return psphotReadoutCleanup(config, view, "PSPHOT.INPUT");
Note:
See TracChangeset
for help on using the changeset viewer.
