- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotMagnitudes.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psphot merged eligible /branches/eam_branches/stackphot.20100406/psphot 27622-27655 /branches/pap_delete/psphot 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psphot/src
- Property svn:ignore
-
old new 18 18 psphotVersionDefinitions.h 19 19 psphotMomentsStudy 20 psphotPetrosianStudy 21 psphotForced 22 psphotMakePSF 23 psphotStack
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/psphot/src/psphotMagnitudes.c
r23349 r27840 1 1 # include "psphotInternal.h" 2 2 3 bool psphotMagnitudes(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf) { 3 bool psphotMagnitudes (pmConfig *config, const pmFPAview *view) 4 { 5 bool status = true; 6 7 // select the appropriate recipe information 8 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 9 psAssert (recipe, "missing recipe?"); 10 11 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 12 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 13 14 // skip the chisq image (optionally?) 15 int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM"); 16 if (!status) chisqNum = -1; 17 18 // loop over the available readouts 19 for (int i = 0; i < num; i++) { 20 if (i == chisqNum) continue; // skip chisq image 21 22 // find the currently selected readout 23 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest 24 psAssert (file, "missing file?"); 25 26 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 27 psAssert (readout, "missing readout?"); 28 29 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 30 psAssert (detections, "missing detections?"); 31 32 psArray *sources = detections->allSources; 33 psAssert (sources, "missing sources?"); 34 35 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 36 psAssert (psf, "missing psf?"); 37 38 if (!psphotMagnitudesReadout (config, recipe, view, readout, sources, psf)) { 39 psError (PSPHOT_ERR_CONFIG, false, "failed to measure magnitudes for PSPHOT.INPUT entry %d", i); 40 return false; 41 } 42 } 43 return true; 44 } 45 46 bool psphotMagnitudesReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, pmReadout *readout, psArray *sources, pmPSF *psf) { 4 47 5 48 bool status = false; 6 49 int Nap = 0; 7 50 51 if (!sources->n) { 52 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source magnitudes"); 53 return true; 54 } 55 8 56 psTimerStart ("psphot.mags"); 9 10 // select the appropriate recipe information11 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);12 assert (recipe);13 57 14 58 // determine the number of allowed threads … … 41 85 } 42 86 43 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");87 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH"); 44 88 bool INTERPOLATE_AP = psMetadataLookupBool (&status, recipe, "INTERPOLATE_AP"); 89 bool DIFF_STATS = psMetadataLookupBool (&status, recipe, "INTERPOLATE_AP"); 45 90 46 91 pmSourcePhotometryMode photMode = PM_SOURCE_PHOT_APCORR | PM_SOURCE_PHOT_WEIGHT; 47 92 if (!IGNORE_GROWTH) photMode |= PM_SOURCE_PHOT_GROWTH; 48 93 if (INTERPOLATE_AP) photMode |= PM_SOURCE_PHOT_INTERP; 94 if (DIFF_STATS) photMode |= PM_SOURCE_PHOT_DIFFSTATS; 49 95 50 96 // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts) … … 71 117 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 72 118 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 119 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 73 120 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp 74 121 … … 102 149 fprintf (stderr, "error with job\n"); 103 150 } else { 104 psScalar *scalar = job->args->data[ 7];151 psScalar *scalar = job->args->data[8]; 105 152 Nap += scalar->data.S32; 106 153 } … … 127 174 pmSourcePhotometryMode photMode = PS_SCALAR_VALUE(job->args->data[5],S32); 128 175 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 176 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[7],PS_TYPE_IMAGE_MASK_DATA); 129 177 130 178 for (int i = 0; i < sources->n; i++) { 131 179 pmSource *source = (pmSource *) sources->data[i]; 132 status = pmSourceMagnitudes (source, psf, photMode, maskVal); 180 181 // replace object in image 182 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 183 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 184 } 185 186 // clear the mask bit and set the circular mask pixels 187 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 188 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", markVal); 189 190 status = pmSourceMagnitudes (source, psf, photMode, maskVal); // maskVal includes markVal 133 191 if (status && isfinite(source->apMag)) Nap ++; 192 193 // clear the mask bit 194 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 195 196 // re-subtract the object, leave local sky 197 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 134 198 135 199 if (backModel) { … … 155 219 156 220 // change the value of a scalar on the array (wrap this and put it in psArray.h) 157 psScalar *scalar = job->args->data[ 7];221 psScalar *scalar = job->args->data[8]; 158 222 scalar->data.S32 = Nap; 159 223 160 224 return true; 161 225 } 162 163 # if (0)164 bool psphotMagnitudes_Unthreaded (int *nap, psArray *sources, pmPSF *psf, psImageBinning *binning, pmReadout *backModel, pmReadout *backStdev, pmSourcePhotometryMode photMode, psImageMaskType maskVal) {165 166 bool status;167 int Nap = 0;168 169 for (int i = 0; i < sources->n; i++) {170 pmSource *source = (pmSource *) sources->data[i];171 status = pmSourceMagnitudes (source, psf, photMode, maskVal);172 if (status && isfinite(source->apMag)) Nap ++;173 174 if (backModel) {175 psAssert (binning, "if backModel is defined, so should binning be");176 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);177 if (isnan(source->sky) && false) {178 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");179 }180 } else {181 source->sky = NAN;182 }183 184 if (backStdev) {185 psAssert (binning, "if backStdev is defined, so should binning be");186 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);187 if (isnan(source->skyErr) && false) {188 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");189 }190 } else {191 source->skyErr = NAN;192 }193 }194 195 // change the value of a scalar on the array (wrap this and put it in psArray.h)196 *nap = Nap;197 198 return true;199 }200 # endif201 226 202 227 bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources) {
Note:
See TracChangeset
for help on using the changeset viewer.
