Changeset 28029 for branches/czw_branch/20100427/psphot/src/psphotReadout.c
- Timestamp:
- May 19, 2010, 2:08:46 PM (16 years ago)
- Location:
- branches/czw_branch/20100427/psphot
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/psphotReadout.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100427/psphot
-
Property svn:mergeinfo
set to
/branches/eam_branches/psphot.20100506 merged eligible /branches/pap/psphot merged eligible /trunk/psphot merged eligible
-
Property svn:mergeinfo
set to
-
branches/czw_branch/20100427/psphot/src/psphotReadout.c
r27657 r28029 28 28 29 29 // set the photcode for this image 30 if (!psphotAddPhotcode (config, view )) {30 if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) { 31 31 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 32 32 return false; … … 34 34 35 35 // Generate the mask and weight images, including the user-defined analysis region of interest 36 if (!psphotSetMaskAndVariance (config, view )) {37 return psphotReadoutCleanup(config, view );36 if (!psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT")) { 37 return psphotReadoutCleanup(config, view, "PSPHOT.INPUT"); 38 38 } 39 39 if (!strcasecmp (breakPt, "NOTHING")) { 40 return psphotReadoutCleanup (config, view);40 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 41 41 } 42 42 43 43 // generate a background model (median, smoothed image) 44 if (!psphotModelBackground (config, view )) {45 return psphotReadoutCleanup (config, view );46 } 47 if (!psphotSubtractBackground (config, view )) {48 return psphotReadoutCleanup (config, view );44 if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) { 45 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 46 } 47 if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) { 48 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 49 49 } 50 50 if (!strcasecmp (breakPt, "BACKMDL")) { 51 return psphotReadoutCleanup (config, view );51 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 52 52 } 53 53 54 54 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are determined and saved on 55 55 // readout->analysis XXX this function currently only works with a single PSPHOT.INPUT 56 if (!psphotLoadPSF (config, view)) { 56 if (!psphotLoadPSF (config, view)) { // ??? need to supply 2 ? 57 57 psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model"); 58 return psphotReadoutCleanup (config, view );58 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 59 59 } 60 60 61 61 // find the detections (by peak and/or footprint) in the image. 62 if (!psphotFindDetections (config, view, true)) { // pass 162 if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1 63 63 // this only happens if we had an error in psphotFindDetections 64 64 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 65 return psphotReadoutCleanup (config, view );65 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 66 66 } 67 67 68 68 // construct sources and measure basic stats (saved on detections->newSources) 69 if (!psphotSourceStats (config, view, true)) { // pass 169 if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1 70 70 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources"); 71 return psphotReadoutCleanup (config, view );71 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 72 72 } 73 73 if (!strcasecmp (breakPt, "PEAKS")) { 74 return psphotReadoutCleanup (config, view);74 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 75 75 } 76 76 77 77 // find blended neighbors of very saturated stars (detections->newSources) 78 if (!psphotDeblendSatstars (config, view )) {78 if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) { 79 79 psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis"); 80 return psphotReadoutCleanup (config, view );80 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 81 81 } 82 82 83 83 // mark blended peaks PS_SOURCE_BLEND (detections->newSources) 84 if (!psphotBasicDeblend (config, view )) {84 if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) { 85 85 psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis"); 86 return psphotReadoutCleanup (config, view );86 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 87 87 } 88 88 89 89 // classify sources based on moments, brightness. if a PSF model has been loaded, the PSF 90 90 // clump defined for it is used not measured (detections->newSources) 91 if (!psphotRoughClass (config, view )) { // pass 191 if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) { // pass 1 92 92 psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications"); 93 return psphotReadoutCleanup (config, view );93 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 94 94 } 95 95 // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources) 96 if (!psphotImageQuality (config, view )) { // pass 196 if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1 97 97 psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality"); 98 return psphotReadoutCleanup (config, view);98 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 99 99 } 100 100 if (!strcasecmp (breakPt, "MOMENTS")) { 101 return psphotReadoutCleanup (config, view);101 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 102 102 } 103 103 104 104 // use bright stellar objects to measure PSF if we were supplied a PSF for any input file, 105 105 // this step is skipped 106 if (!psphotChoosePSF (config, view )) { // pass 1106 if (!psphotChoosePSF (config, view, "PSPHOT.INPUT")) { // pass 1 107 107 psLogMsg ("psphot", 3, "failure to construct a psf model"); 108 return psphotReadoutCleanup (config, view );108 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 109 109 } 110 110 if (!strcasecmp (breakPt, "PSFMODEL")) { 111 return psphotReadoutCleanup (config, view );111 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 112 112 } 113 113 114 114 // include externally-supplied sources 115 115 // XXX fix this in the new multi-input context 116 // psphotLoadExtSources (config, view ); // pass 1116 // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1 117 117 118 118 // construct an initial model for each object, set the radius to fitRadius, set circular 119 119 // fit mask (detections->newSources) 120 psphotGuessModels (config, view ); // pass 1120 psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1 121 121 122 122 // merge the newly selected sources into the existing list 123 123 // NOTE: merge OLD and NEW 124 psphotMergeSources (config, view );124 psphotMergeSources (config, view, "PSPHOT.INPUT"); 125 125 126 126 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 127 psphotFitSourcesLinear (config, view, false); // pass 1 (detections->allSources)127 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false); // pass 1 (detections->allSources) 128 128 129 129 // identify CRs and extended sources (only unmeasured sources are measured) 130 psphotSourceSize (config, view, true); // pass 1 (detections->allSources)130 psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources) 131 131 if (!strcasecmp (breakPt, "ENSEMBLE")) { 132 132 goto finish; … … 135 135 // non-linear PSF and EXT fit to brighter sources 136 136 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 137 psphotBlendFit (config, view ); // pass 1 (detections->allSources)137 psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 138 138 139 139 // replace all sources 140 psphotReplaceAllSources (config, view ); // pass 1 (detections->allSources)140 psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 141 141 142 142 // linear fit to include all sources (subtract again) 143 143 // NOTE : apply to ALL sources (extended + psf) 144 psphotFitSourcesLinear (config, view, true); // pass 2 (detections->allSources)144 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources) 145 145 146 146 // if we only do one pass, skip to extended source analysis … … 150 150 151 151 // add noise for subtracted objects 152 psphotAddNoise (config, view ); // pass 1 (detections->allSources)152 psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 153 153 154 154 // find fainter sources 155 155 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 156 psphotFindDetections (config, view, false); // pass 2 (detections->peaks, detections->footprints)156 psphotFindDetections (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->peaks, detections->footprints) 157 157 158 158 // remove noise for subtracted objects (ie, return to normal noise level) 159 159 // NOTE: this needs to operate only on the OLD sources 160 psphotSubNoise (config, view ); // pass 1 (detections->allSources)160 psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 161 161 162 162 // define new sources based on only the new peaks 163 163 // NOTE: new sources are saved on detections->newSources 164 psphotSourceStats (config, view, false); // pass 2 (detections->newSources)164 psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources) 165 165 166 166 // set source type 167 167 // NOTE: apply only to detections->newSources 168 if (!psphotRoughClass (config, view )) { // pass 2 (detections->newSources)168 if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) { // pass 2 (detections->newSources) 169 169 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 170 return psphotReadoutCleanup (config, view );170 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 171 171 } 172 172 173 173 // create full input models, set the radius to fitRadius, set circular fit mask 174 174 // NOTE: apply only to detections->newSources 175 psphotGuessModels (config, view ); // pass 2 (detections->newSources)175 psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources) 176 176 177 177 // replace all sources so fit below applies to all at once 178 178 // NOTE: apply only to OLD sources (which have been subtracted) 179 psphotReplaceAllSources (config, view ); // pass 2179 psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2 180 180 181 181 // merge the newly selected sources into the existing list 182 182 // NOTE: merge OLD and NEW 183 183 // XXX check on free of sources... 184 psphotMergeSources (config, view ); // (detections->newSources + detections->allSources -> detections->allSources)184 psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources) 185 185 186 186 // NOTE: apply to ALL sources 187 psphotFitSourcesLinear (config, view, true); // pass 3 (detections->allSources)187 psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources) 188 188 189 189 pass1finish: … … 191 191 // measure source size for the remaining sources 192 192 // NOTE: applies only to NEW (unmeasured) sources 193 psphotSourceSize (config, view, false); // pass 2 (detections->allSources)194 195 psphotExtendedSourceAnalysis (config, view ); // pass 1 (detections->allSources)196 psphotExtendedSourceFits (config, view ); // pass 1 (detections->allSources)193 psphotSourceSize (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->allSources) 194 195 psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 196 psphotExtendedSourceFits (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 197 197 198 198 finish: … … 202 202 203 203 // measure aperture photometry corrections 204 if (!psphotApResid (config, view )) { // pass 1 (detections->allSources)204 if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources) 205 205 psLogMsg ("psphot", 3, "failed on psphotApResid"); 206 return psphotReadoutCleanup (config, view );206 return psphotReadoutCleanup (config, view, "PSPHOT.INPUT"); 207 207 } 208 208 209 209 // calculate source magnitudes 210 psphotMagnitudes(config, view ); // pass 1 (detections->allSources)211 212 if (!psphotEfficiency(config, view )) { // pass 1210 psphotMagnitudes(config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources) 211 212 if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1 213 213 psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources"); 214 214 psErrorClear(); … … 219 219 220 220 // replace background in residual image 221 psphotSkyReplace (config, view ); // pass 1221 psphotSkyReplace (config, view, "PSPHOT.INPUT"); // pass 1 222 222 223 223 // drop the references to the image pixels held by each source 224 psphotSourceFreePixels (config, view ); // pass 1224 psphotSourceFreePixels (config, view, "PSPHOT.INPUT"); // pass 1 225 225 226 226 // create the exported-metadata and free local data 227 return psphotReadoutCleanup(config, view );227 return psphotReadoutCleanup(config, view, "PSPHOT.INPUT"); 228 228 }
Note:
See TracChangeset
for help on using the changeset viewer.
