- 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/psphotExtendedSourceAnalysis.c (modified) (8 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/psphotExtendedSourceAnalysis.c
r21519 r27840 1 1 # include "psphotInternal.h" 2 2 3 // for now, let's store the detections on the readout->analysis for each readout 4 bool psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view) 5 { 6 bool status = true; 7 8 // select the appropriate recipe information 9 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 10 psAssert (recipe, "missing recipe?"); 11 12 // perform full non-linear fits / extended source analysis? 13 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANALYSIS")) { 14 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n"); 15 return true; 16 } 17 18 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 19 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 20 21 // loop over the available readouts 22 for (int i = 0; i < num; i++) { 23 if (!psphotExtendedSourceAnalysisReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 24 psError (PSPHOT_ERR_CONFIG, false, "failed on measure extended source aperture-like parameters for PSPHOT.INPUT entry %d", i); 25 return false; 26 } 27 } 28 return true; 29 } 30 3 31 // aperture-like measurements for extended sources 4 bool psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe) {32 bool psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 5 33 6 34 bool status; … … 11 39 int Nkron = 0; 12 40 41 psTimerStart ("psphot.extended"); 42 43 // find the currently selected readout 44 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 45 psAssert (file, "missing file?"); 46 47 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 48 psAssert (readout, "missing readout?"); 49 50 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 51 psAssert (detections, "missing detections?"); 52 53 psArray *sources = detections->allSources; 54 psAssert (sources, "missing sources?"); 55 56 if (!sources->n) { 57 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size"); 58 return true; 59 } 60 13 61 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 14 62 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 15 63 assert (maskVal); 16 64 17 // perform full non-linear fits / extended source analysis? 18 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANALYSIS")) { 19 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n"); 20 return true; 21 } 65 // XXX require petrosian analysis for non-linear fits? 22 66 23 // option to limit analysis to a specific region 24 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 25 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region)); 26 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined"); 67 // XXX temporary user-supplied systematic sky noise measurement (derive from background model) 68 float skynoise = psMetadataLookupF32 (&status, recipe, "SKY.NOISE"); 27 69 28 70 // S/N limit to perform full non-linear fits … … 35 77 bool doKron = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_KRON"); 36 78 79 # if (0) 80 // if backModel or backStdev are missing, the values of sky and/or skyErr will be set to NAN 81 // XXX use this to set skynoise 82 pmReadout *backModel = psphotSelectBackground (config, view); 83 pmReadout *backStdev = psphotSelectBackgroundStdev (config, view); 84 # endif 85 37 86 // source analysis is done in S/N order (brightest first) 38 87 sources = psArraySort (sources, pmSourceSortBySN); 39 88 40 // XXX some init functions for the extended source recipe options? 89 // option to limit analysis to a specific region 90 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 91 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region)); 92 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined"); 41 93 42 94 // choose the sources of interest … … 49 101 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 50 102 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 103 if (source->mode & PM_SOURCE_MODE_DEFECT) continue; 104 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue; 105 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue; 51 106 52 107 // limit selection to some SN limit … … 66 121 Next ++; 67 122 123 // force source image to be a bit larger... 124 float radius = source->peak->xf - source->pixels->col0; 125 radius = PS_MAX (radius, source->peak->yf - source->pixels->row0); 126 radius = PS_MAX (radius, source->pixels->numRows - source->peak->yf + source->pixels->row0); 127 radius = PS_MAX (radius, source->pixels->numCols - source->peak->xf + source->pixels->col0); 128 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, 1.5*radius); 129 68 130 // if we request any of these measurements, we require the radial profile 69 131 if (doPetrosian || doIsophotal || doAnnuli || doKron) { 70 if (!psphotRadialProfile (source, recipe, maskVal)) {132 if (!psphotRadialProfile (source, recipe, skynoise, maskVal)) { 71 133 // all measurements below require the radial profile; skip them all 72 134 // re-subtract the object, leave local sky 73 135 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 74 136 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 75 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;76 137 continue; 77 138 } … … 79 140 } 80 141 142 // Petrosian Mags 143 if (doPetrosian) { 144 if (!psphotPetrosian (source, recipe, skynoise, maskVal)) { 145 psTrace ("psphot", 5, "FAILED petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 146 } else { 147 psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 148 Npetro ++; 149 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 150 } 151 } 152 153 # if (0) 81 154 // Isophotal Mags 82 155 if (doIsophotal) { … … 89 162 } 90 163 } 91 92 // Petrosian Mags93 if (doPetrosian) {94 if (!psphotPetrosian (source, recipe, maskVal)) {95 psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My);96 } else {97 psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My);98 Npetro ++;99 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS;100 }101 }102 103 164 // Kron Mags 104 165 if (doKron) { … … 111 172 } 112 173 } 113 114 // Radial Annuli 115 if (doAnnuli) { 116 if (!psphotAnnuli (source, recipe, maskVal)) { 117 psError(PSPHOT_ERR_UNKNOWN, false, "failure in Annuli analysis"); 118 return false; 119 } 120 psTrace ("psphot", 5, "measured annuli for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 121 Nannuli ++; 122 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 123 } 174 # endif 124 175 125 176 // re-subtract the object, leave local sky 126 177 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 127 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 178 179 if (source->extpars) { 180 psFree(source->extpars->radFlux); 181 psFree(source->extpars->ellipticalFlux); 182 } 128 183 } 129 184 130 psLogMsg ("psphot", PS_LOG_INFO, "extended source analysis: %f sec for %d objects\n", psTimerMark ("psphot "), Next);185 psLogMsg ("psphot", PS_LOG_INFO, "extended source analysis: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next); 131 186 psLogMsg ("psphot", PS_LOG_INFO, " %d petrosian\n", Npetro); 132 187 psLogMsg ("psphot", PS_LOG_INFO, " %d isophotal\n", Nisophot); 133 188 psLogMsg ("psphot", PS_LOG_INFO, " %d annuli\n", Nannuli); 134 189 psLogMsg ("psphot", PS_LOG_INFO, " %d kron\n", Nkron); 190 191 psphotVisualShowResidualImage (readout); 192 193 if (doPetrosian) { 194 psphotVisualShowPetrosians (sources); 195 } 196 135 197 return true; 136 198 }
Note:
See TracChangeset
for help on using the changeset viewer.
