Changeset 28013 for trunk/psphot/src/psphotStackReadout.c
- Timestamp:
- May 18, 2010, 4:11:53 PM (16 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/psphotStackReadout.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
-
Property svn:mergeinfo
set to
/branches/eam_branches/psphot.20100506 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/psphot/src/psphotStackReadout.c
r27657 r28013 1 1 # include "psphotInternal.h" 2 3 # define STACK_RAW "PSPHOT.STACK.INPUT.RAW" 4 # define STACK_OUT "PSPHOT.STACK.OUTPUT.IMAGE" 2 5 3 6 bool psphotStackReadout (pmConfig *config, const pmFPAview *view) { … … 17 20 PS_ASSERT_PTR_NON_NULL (breakPt, false); 18 21 22 // we have 3 relevant files: RAW, CNV, OUT 23 19 24 // set the photcode for each image 20 if (!psphotAddPhotcode (config, view )) {25 if (!psphotAddPhotcode (config, view, STACK_OUT)) { 21 26 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 22 27 return false; … … 24 29 25 30 // Generate the mask and weight images 26 if (!psphotSetMaskAndVariance (config, view)) { 27 return psphotReadoutCleanup (config, view); 31 // XXX this should be done before we perform the convolutions 32 if (!psphotSetMaskAndVariance (config, view, STACK_RAW)) { 33 return psphotReadoutCleanup (config, view, STACK_OUT); 28 34 } 29 35 if (!strcasecmp (breakPt, "NOTHING")) { 30 return psphotReadoutCleanup (config, view );36 return psphotReadoutCleanup (config, view, STACK_OUT); 31 37 } 32 38 33 39 // generate a background model (median, smoothed image) 34 40 // XXX I think this is not defined correctly for an array of images. 35 if (!psphotModelBackground (config, view)) { 36 return psphotReadoutCleanup (config, view); 41 // XXX probably need to subtract the model (same model?) for both RAW and OUT 42 if (!psphotModelBackground (config, view, STACK_RAW)) { 43 return psphotReadoutCleanup (config, view, STACK_OUT); 37 44 } 38 if (!psphotSubtractBackground (config, view )) {39 return psphotReadoutCleanup (config, view );45 if (!psphotSubtractBackground (config, view, STACK_RAW)) { 46 return psphotReadoutCleanup (config, view, STACK_OUT); 40 47 } 41 48 if (!strcasecmp (breakPt, "BACKMDL")) { 42 return psphotReadoutCleanup (config, view );49 return psphotReadoutCleanup (config, view, STACK_OUT); 43 50 } 44 51 … … 47 54 if (!psphotLoadPSF (config, view)) { 48 55 psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model"); 49 return psphotReadoutCleanup (config, view );56 return psphotReadoutCleanup (config, view, STACK_OUT); 50 57 } 51 58 52 if (!psphotStackChisqImage(config, view )) {59 if (!psphotStackChisqImage(config, view, STACK_RAW, STACK_OUT)) { 53 60 psError (PSPHOT_ERR_UNKNOWN, false, "failure to generate chisq image"); 54 return psphotReadoutCleanup (config, view );61 return psphotReadoutCleanup (config, view, STACK_OUT); 55 62 } 56 63 if (!strcasecmp (breakPt, "CHISQ")) { 57 return psphotReadoutCleanup (config, view );64 return psphotReadoutCleanup (config, view, STACK_OUT); 58 65 } 59 66 60 67 // find the detections (by peak and/or footprint) in the image. 61 68 // This finds the detections on Chisq image as well as the individuals 62 if (!psphotFindDetections (config, view, true)) { // pass 169 if (!psphotFindDetections (config, view, STACK_RAW, true)) { // pass 1 63 70 // this only happens if we had an error in psphotFindDetections 64 71 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 65 return psphotReadoutCleanup (config, view); 72 return psphotReadoutCleanup (config, view, STACK_OUT); 73 } 74 75 // copy the detections from RAW to OUT 76 if (!psphotCopySources (config, view, STACK_OUT, STACK_RAW)) { 77 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 78 return psphotReadoutCleanup (config, view, STACK_OUT); 66 79 } 67 80 68 81 // construct sources and measure basic stats (saved on detections->newSources) 69 82 // only run this on detections from the input images, not chisq image 70 if (!psphotSourceStats (config, view, true)) { // pass 183 if (!psphotSourceStats (config, view, STACK_OUT, true)) { // pass 1 71 84 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources"); 72 return psphotReadoutCleanup (config, view );85 return psphotReadoutCleanup (config, view, STACK_OUT); 73 86 } 74 87 75 // *** generate the objects (whichunify the sources from the different images)76 psArray *objects = psphotMatchSources (config, view );88 // generate the objects (object unify the sources from the different images) 89 psArray *objects = psphotMatchSources (config, view, STACK_OUT); 77 90 78 91 // construct sources for the newly-generated sources (from other images) 79 if (!psphotSourceStats (config, view, false)) { // pass 192 if (!psphotSourceStats (config, view, STACK_OUT, false)) { // pass 1 80 93 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources"); 81 return psphotReadoutCleanup (config, view );94 return psphotReadoutCleanup (config, view, STACK_OUT); 82 95 } 83 96 … … 85 98 // if (!psphotDeblendSatstars (config, view)) { 86 99 // psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis"); 87 // return psphotReadoutCleanup (config, view );100 // return psphotReadoutCleanup (config, view, STACK_OUT); 88 101 // } 89 102 … … 91 104 // if (!psphotBasicDeblend (config, view)) { 92 105 // psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis"); 93 // return psphotReadoutCleanup (config, view );106 // return psphotReadoutCleanup (config, view, STACK_OUT); 94 107 // } 95 108 96 109 // classify sources based on moments, brightness 97 110 // only run this on detections from the input images, not chisq image 98 if (!psphotRoughClass (config, view )) {111 if (!psphotRoughClass (config, view, STACK_OUT)) { 99 112 psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications"); 100 return psphotReadoutCleanup (config, view );113 return psphotReadoutCleanup (config, view, STACK_OUT); 101 114 } 102 115 // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources) 103 116 // only run this on detections from the input images, not chisq image 104 if (!psphotImageQuality (config, view )) { // pass 1117 if (!psphotImageQuality (config, view, STACK_OUT)) { // pass 1 105 118 psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality"); 106 return psphotReadoutCleanup (config, view);119 return psphotReadoutCleanup (config, view, STACK_OUT); 107 120 } 108 121 if (!strcasecmp (breakPt, "MOMENTS")) { 109 return psphotReadoutCleanup (config, view );122 return psphotReadoutCleanup (config, view, STACK_OUT); 110 123 } 111 124 112 125 // use bright stellar objects to measure PSF if we were supplied a PSF for any input file, 113 126 // this step is skipped 114 if (!psphotChoosePSF (config, view )) { // pass 1127 if (!psphotChoosePSF (config, view, STACK_OUT)) { // pass 1 115 128 psLogMsg ("psphot", 3, "failure to construct a psf model"); 116 return psphotReadoutCleanup (config, view );129 return psphotReadoutCleanup (config, view, STACK_OUT); 117 130 } 118 131 if (!strcasecmp (breakPt, "PSFMODEL")) { 119 return psphotReadoutCleanup (config, view );132 return psphotReadoutCleanup (config, view, STACK_OUT); 120 133 } 121 134 122 // include externally-supplied sources123 // XXX fix this in the new multi-input context124 // psphotLoadExtSources (config, view); // pass 1125 126 135 // construct an initial model for each object, set the radius to fitRadius, set circular fit mask 127 psphotGuessModels (config, view );136 psphotGuessModels (config, view, STACK_OUT); 128 137 129 138 // merge the newly selected sources into the existing list 130 139 // NOTE: merge OLD and NEW 131 psphotMergeSources (config, view );140 psphotMergeSources (config, view, STACK_OUT); 132 141 133 142 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 134 143 psphotFitSourcesLinearStack (config, objects, FALSE); 135 psFree (objects);136 144 137 145 // identify CRs and extended sources 138 psphotSourceSize (config, view, TRUE);146 psphotSourceSize (config, view, STACK_OUT, TRUE); 139 147 140 148 // measure aperture photometry corrections 141 if (!psphotApResid (config, view)) { 149 if (!psphotApResid (config, view, STACK_OUT)) { 150 psFree (objects); 142 151 psLogMsg ("psphot", 3, "failed on psphotApResid"); 143 return psphotReadoutCleanup (config, view );152 return psphotReadoutCleanup (config, view, STACK_OUT); 144 153 } 145 154 155 psphotStackObjectsUnifyPosition (objects); 156 psphotRadialAperturesByObject (config, objects, view, STACK_OUT); 157 158 psphotExtendedSourceAnalysisByObject (config, objects, view, STACK_OUT); // pass 1 (detections->allSources) 159 psphotExtendedSourceFits (config, view, STACK_OUT); // pass 1 (detections->allSources) 160 146 161 // calculate source magnitudes 147 psphotMagnitudes(config, view );162 psphotMagnitudes(config, view, STACK_OUT); 148 163 149 if (!psphotEfficiency(config, view )) {164 if (!psphotEfficiency(config, view, STACK_OUT)) { 150 165 psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources"); 151 166 psErrorClear(); … … 156 171 157 172 // replace background in residual image 158 psphotSkyReplace (config, view );173 psphotSkyReplace (config, view, STACK_RAW); 159 174 160 175 // drop the references to the image pixels held by each source 161 psphotSourceFreePixels (config, view );176 psphotSourceFreePixels (config, view, STACK_OUT); 162 177 163 178 // remove chisq image from config->file:PSPHOT.INPUT (why?) 164 psphotStackRemoveChisqFromInputs(config); 179 psphotStackRemoveChisqFromInputs(config, STACK_RAW); 180 181 psFree (objects); 165 182 166 183 // create the exported-metadata and free local data 167 return psphotReadoutCleanup (config, view );184 return psphotReadoutCleanup (config, view, STACK_OUT); 168 185 } 169 186
Note:
See TracChangeset
for help on using the changeset viewer.
