BackgroundSpectralPrior#

class jinwu.background.BackgroundSpectralPrior(a0: ndarray, b0: float, area_ratio: float, channels: ndarray)[source]#

Bases: object

考虑能谱的背景先验:对所选能道逐道建立 Gamma 先验 λ_k ~ Gamma(a0_k, b0), 其中 b0=t_ref(FITS 中的总参考曝光),a0_k 是把“计/厘米^2”乘以 OFF 区域有效面积后、 在 t_ref 内的 OFF 区域先验计数(可理解为先验的等效观测计数)。

该类可使用 OFF 区域的观测谱做共轭更新,并聚合为 BackgroundCountsPosterior, 用于对 ON/OFF 的总计数进行后验预测采样或期望计算。

字段#

a0np.ndarray (n_chan,)

每个选择能道的先验 shape。

b0float

先验 rate(秒),通常为背景文件中的 EXPOSURE(如 1e6 s)。

area_ratiofloat

A_on / A_off。

channelsnp.ndarray (n_chan,)

参与先验的 CHANNEL 索引集合(用于与观测谱对齐/筛选)。

Methods Summary

as_counts_posterior()

from_epwxt_background(fits_path, *[, ...])

读取单个 EP/WXT 背景 FITS(SPECTRUM: COUNTS 为“计/厘米^2”)并按能团形成逐道先验。

update_with_off_spectrum(pha_path, *[, ...])

用 OFF 区域的观测谱(PHA,COUNTS 为整数计数)进行共轭更新,聚合为总计数后验。

update_with_on_bg_spectrum(pha_path, *[, ...])

使用 ON 区域“背景-only”时段的观测谱进行更新: - shape 增加 sum(n_on_obs) - rate 增加 area_ratio * t_on_obs 返回聚合后的 BackgroundCountsPosterior。

Methods Documentation

as_counts_posterior() BackgroundCountsPosterior[source]#
classmethod from_epwxt_background(fits_path: str, *, chan_lo: int = 53, chan_hi: int = 506, arf_path: str | None = None, arf_bin_lo: int = 81, arf_bin_hi: int = 780, pixel_size_mm: float = 0.015, pixel_fov_deg: float = 0.00229, src_radius_arcmin: float = 9.0, bkg_rin_arcmin: float = 18.0, bkg_rout_arcmin: float = 36.0, verbose: bool = True) BackgroundSpectralPrior[source]#

读取单个 EP/WXT 背景 FITS(SPECTRUM: COUNTS 为“计/厘米^2”)并按能团形成逐道先验。

若提供 ARF,则用 SPECRESP 的第 [arf_bin_lo, arf_bin_hi](1-based)能道推断能段, 并用 EBOUNDS 做能段重合筛选;否则回退到 CHANNEL 区间 [chan_lo, chan_hi]。 OFF/ON 区域面积由像元尺寸及 FoV 计算得到,area_ratio=A_on/A_off。

update_with_off_spectrum(pha_path: str, *, chan_lo: int | None = None, chan_hi: int | None = None, use_ebounds: bool = True, verbose: bool = True) BackgroundCountsPosterior[source]#

用 OFF 区域的观测谱(PHA,COUNTS 为整数计数)进行共轭更新,聚合为总计数后验。

  • 若 use_ebounds=True,优先用 EBOUNDS 与 self.channels 对齐;否则按 CHANNEL 匹配。

  • 曝光时间从 PHA 的 SPECTRUM header[‘EXPOSURE’] 读取。

返回 BackgroundCountsPosterior,参数 a_total=sum(a0)+sum(n_off_obs),b=b0+t_off_obs。

update_with_on_bg_spectrum(pha_path: str, *, chan_lo: int | None = None, chan_hi: int | None = None, use_ebounds: bool = True, verbose: bool = True) BackgroundCountsPosterior[source]#

使用 ON 区域“背景-only”时段的观测谱进行更新: - shape 增加 sum(n_on_obs) - rate 增加 area_ratio * t_on_obs 返回聚合后的 BackgroundCountsPosterior。