def estimate_errors(self, gehrels=True):
"""
Estimate the statistical errors of each spectral group (after
applying grouping) for the source spectrum (and background spectrum).
If `gehrels=True', the statistical error for a spectral group with
N photons is given by `1 + sqrt(N + 0.75)'; otherwise, the error
is given by `sqrt(N)'.
Attributes
----------
spec_err : `~numpy.ndarray`
Estimated errors for the spectral data.
NOTE: If the spectral data (in counts) have negative groups, the
errors of those groups are set to 0.0!
"""
with np.errstate(invalid="ignore"):
if gehrels:
self.spec_err = 1.0 + np.sqrt(self.spec_data + 0.75)
else:
self.spec_err = np.sqrt(self.spec_data)
# Warn about and fix the invalid error values
invalid = ~np.isfinite(self.spec_err)
if np.sum(invalid) > 0:
print("WARNING: invalid spectral errors are set to 0.0! " +
"(due to negative spectral group counts)")
self.spec_err[invalid] = 0.0
评论列表
文章目录