Skip to content

Commit

Permalink
rename effTime variables; remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kadrlica committed Jan 31, 2024
1 parent 92839df commit a9363a1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
49 changes: 28 additions & 21 deletions python/lsst/pipe/tasks/computeExposureSummaryStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,22 @@ class ComputeExposureSummaryStatsConfig(pexConfig.Config):
fiducialSkyBackground = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Fiducial sky background level (cts/s) assumed when calculating effective exposure time.",
doc="Fiducial sky background level (ADU/s) assumed when calculating effective exposure time. "
"Keyed by band.",
default={'u': 1.0, 'g': 1.0, 'r': 1.0, 'i': 1.0, 'z': 1.0, 'y': 1.0},
)
fiducialPsfSigma = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Fiducial PSF sigma (pixels) assumed when calculating effective exposure time.",
doc="Fiducial PSF sigma (pixels) assumed when calculating effective exposure time. "
"Keyed by band.",
default={'u': 1.0, 'g': 1.0, 'r': 1.0, 'i': 1.0, 'z': 1.0, 'y': 1.0},
)
fiducialZeroPoint = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Fiducial zero point assumed when calculating effective exposure time.",
doc="Fiducial zero point assumed when calculating effective exposure time. "
"Keyed by band.",
default={'u': 25.0, 'g': 25.0, 'r': 25.0, 'i': 25.0, 'z': 25.0, 'y': 25.0},
)
maxEffectiveTransparency = pexConfig.Field(
Expand Down Expand Up @@ -177,9 +180,9 @@ class ComputeExposureSummaryStatsTask(pipeBase.Task):
These quantities are computed to assess depth:
- effTime
- effTimeScalePsfSigma
- effTimeScaleSkyBg
- effTimeScaleZeroPoint
- effTimePsfSigmaScale
- effTimeSkyBgScale
- effTimeZeroPointScale
"""
ConfigClass = ComputeExposureSummaryStatsConfig
_DefaultName = "computeExposureSummaryStats"
Expand Down Expand Up @@ -536,9 +539,9 @@ def update_effective_time_stats(self, summary, exposure):

nan = float("nan")
summary.effTime = nan
summary.effTimeScalePsfSigma = nan
summary.effTimeScaleSkyBg = nan
summary.effTimeScaleZeroPoint = nan
summary.effTimePsfSigmaScale = nan
summary.effTimeSkyBgScale = nan
summary.effTimeZeroPointScale = nan

exposureTime = exposure.getInfo().getVisitInfo().getExposureTime()
filterLabel = exposure.getFilter()
Expand All @@ -547,36 +550,40 @@ def update_effective_time_stats(self, summary, exposure):
else:
band = filterLabel.bandLabel

if band is None:
self.log.warn("No band associated with exposure; effTime not calculated.")
return

# PSF component
if np.isnan(summary.psfSigma):
self.log.warn("PSF sigma is NaN")
self.log.debug("PSF sigma is NaN")
f_eff = nan
elif band not in self.config.fiducialPsfSigma:
self.log.warn(f"Fiducial PSF value not found for {band}")
f_eff = 1.0
self.log.debug(f"Fiducial PSF value not found for {band}")
f_eff = nan
else:
fiducialPsfSigma = self.config.fiducialPsfSigma[band]
f_eff = (summary.psfSigma / fiducialPsfSigma)**-2

# Transparency component (note that exposure time may be removed from zeropoint)
if np.isnan(summary.zeroPoint):
self.log.warn("Zero point is NaN")
self.log.debug("Zero point is NaN")
c_eff = nan
elif band not in self.config.fiducialZeroPoint:
self.log.warn(f"Fiducial zero point value not found for {band}")
c_eff = 1.0
self.log.debug(f"Fiducial zero point value not found for {band}")
c_eff = nan
else:
fiducialZeroPoint = self.config.fiducialZeroPoint[band]
zeroPointDiff = fiducialZeroPoint - (summary.zeroPoint - 2.5*np.log10(exposureTime))
c_eff = min(10**(-2.0*(zeroPointDiff)/2.5), self.config.maxEffectiveTransparency)

# Sky brightness component (convert to cts/s)
if np.isnan(summary.skyBg):
self.log.warn("Sky background is NaN")
self.log.debug("Sky background is NaN")
b_eff = nan
elif band not in self.config.fiducialSkyBackground:
self.log.warn(f"Fiducial sky background value not found for {band}")
b_eff = 1.0
self.log.debug(f"Fiducial sky background value not found for {band}")
b_eff = nan
else:
fiducialSkyBackground = self.config.fiducialSkyBackground[band]
b_eff = fiducialSkyBackground/(summary.skyBg/exposureTime)
Expand All @@ -589,9 +596,9 @@ def update_effective_time_stats(self, summary, exposure):

# Output quantities
summary.effTime = float(effectiveTime)
summary.effTimeScalePsfSigma = float(f_eff)
summary.effTimeScaleSkyBg = float(b_eff)
summary.effTimeScaleZeroPoint = float(c_eff)
summary.effTimePsfSigmaScale = float(f_eff)
summary.effTimeSkyBgScale = float(b_eff)
summary.effTimeZeroPointScale = float(c_eff)


def maximum_nearest_psf_distance(
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/pipe/tasks/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,8 +1571,8 @@ def run(self, visitSummaryRefs):
'psfStarDeltaSizeMedian', 'psfStarDeltaSizeScatter',
'psfStarScaledDeltaSizeScatter',
'psfTraceRadiusDelta', 'maxDistToNearestPsf',
'effTime', 'effTimeScalePsfSigma',
'effTimeScaleSkyBg', 'effTimeScaleZeroPoint']
'effTime', 'effTimePsfSigmaScale',
'effTimeSkyBgScale', 'effTimeZeroPointScale']
ccdEntry = summaryTable[selectColumns].to_pandas().set_index('id')
# 'visit' is the human readable visit number.
# 'visitId' is the key to the visitId table. They are the same.
Expand Down

0 comments on commit a9363a1

Please sign in to comment.