crosstalk_deprojection.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:atoolbox 作者: liweitianux 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号