jinwu-gecam
jinwu.gecam 是官方 GECAMTools 的接口包,沿用 JinWu 的
PipelineInput → InstrumentPipeline → StageResult 与阶段指纹/恢复机制。
不复制上游分析算法,也不把多探测器或高低增益直接叠加。
安装
当前为源码新增包,尚未发布:
python -m pip install -e packages/jinwu-gecam
# 从官方发布页下载并解压源码包,然后安装其中的 zip:
python -m pip install /path/to/gecamTools-v20240514.zip
GECAMTools 的 Python 导入名是 gecam,与 jinwu.gecam 分开。
官方后端不随本包自动安装;仅导入/发现插件不需要后端。
后续发行时核心 extra 为 jinwu[gecam],并纳入 jinwu[all]。
官方来源:任务网站、 源码与版本说明。 20240514 的发布记录取消了旧版依赖上限;本接口要求该版本或更新版本, 已验证范围见 VALIDATION.md。
使用
import astropy.units as u
from jinwu.gecam import GECAMInput, GECAMConfig, GECAMPipeline
# 官方公开样例 tn210511_112749_fb;MET 是绝对秒,不是相对触发的秒数。
config = GECAMConfig(
detectors=(17, 18), gain="high",
time_range=[74431550.6, 74431660.6] * u.s,
time_bin=0.5 * u.s, energy_edges=[40, 100, 300] * u.keV,
# 不需要谱时省略下列三项:
source_intervals=[[74431599.6, 74431609.6]] * u.s,
background_intervals=[[74431560.6, 74431580.6],
[74431625.6, 74431660.6]] * u.s,
channel_bin=4,
# responses={17: "/data/grd17_high.rsp", 18: "/data/grd18_high.rsp"},
)
job = GECAMPipeline(GECAMInput(
target_id="tn210511_112749_fb", root="/data/gecam",
event_file="gbg_evt_tn210511_112749_fb_v00.fits",
output_root="/data/gecam_analysis",
), config=config)
result = job.run(until="lightcurve")
result = job.run(resume=True)
也可用 jinwu.core.pipeline.pipeline(config, input_data) 自动发现插件。
这里 GECAMConfig 配置 GECAMTools 工作流;核心 instrument("GECAM", ...)
是已有的仪器/上限配置,不与该工作流配置互换。
- 阶段为
inspect → lightcurve → spectra → analysis → report。仅提取时可停在spectra。 不提供源/本底区间时,谱阶段记录enabled=False。 open_event(path)返回原生Evt,可继续使用官方低层接口。extract_lightcurve(...)返回原生LightCurve;extract_spectra(...)返回官方结果字典。- NPZ 保存 MET 分箱边界、原始/修正计数及其误差、死时间和实际能道/能量边界。
计数不是计数率;数组排列为
(energy_bin, time_bin)。能量边界由上游映射至通道, 时间边界沿用上游对齐策略,可能超出请求窗口;需检查实际边界。 - 所有时间参数要求带单位。EVT 按 FITS
MJDREF或MJDREFI/MJDREFF、TIMESYS=TT及TIMEZERO换算 UTC。输出 NPZ 同时保留换算后的 MET 零点和来源。 - 谱阶段直接调用官方多探测器谱接口,保留其分箱、死时间/背景处理、误差和
full/background/net type-II 格式。光变能段与
correct_dead_time不控制谱提取。 谱默认时间箱为 1 s,通道分组和背景多项式阶数可显式设置。 - 输入文件、响应、配置、上游 Python 源码和数值依赖版本纳入缓存指纹。 强制重跑创建新产物子目录;旧产物保留,当前报告更新。
成品能谱与光变
可用 source_spectra、background_spectra 和 lightcurve_products 从成品开始。
这一入口使用 JinWu 和 PyXspec,无需安装 GECAMTools。每个探测器使用对应增益的响应,
谱文件与光变文件路径可相对于输入 root。以下复用上例的配置和观测标识。
from dataclasses import replace
finished_config = replace(
config, source_intervals=None, background_intervals=None,
responses={17: "/data/bg17H.rsp", 18: "/data/bg18H.rsp"},
)
finished = GECAMPipeline(GECAMInput(
target_id="tn210511_112749_fb", root="/data/gecam_products",
output_root="/data/gecam_finished_fit",
source_spectra={17: "grd17_full.fits", 18: "grd18_full.fits"},
background_spectra={17: "grd17_background.fits", 18: "grd18_background.fits"},
), config=finished_config)
result = finished.run(resume=True)
- full type-II 谱按显式的 1-based 行号配对。
TIME是区间左边界,TIMEDEL为持续时间,EXPOSURE为有效曝光。无时钟的 GECAM-A/B 成品会记录采用2019-01-01T00:00:00 UTC的假设。GECAM-C/HEBS 成品若缺时钟,须在GECAMInput.met_reference_utc指定 MET 零点。 full 与 background 均含 FITS 时钟时,必须给出相同的 MET 零点;本底无时钟时,诊断信息 明确记录假设它与 full 共用零点。相同的TIME数组不能替代时钟核对。 - 原始计数与高斯模型本底在隔离目录写为明确的 Type-I PHA 及响应副本,保留
GROUPING、QUALITY和曝光。拟合用pgstat,默认cflux*powerlaw,取energy_edges首末值作为 观测者系能段,并链接同一时段的谱参数。通过GECAMConfig.analysis指定SourceAnalysisConfig可更换模型、共同通量能段或参数链接方式。启用拟合但缺少响应时,分析返回needs_review, 可用的光变仍会写出。补齐响应后可恢复运行。 gecam_lightcurve_products(...)把 NPZ 转为按实际箱宽计算的总计数率 ECSV, 保留能段、死时间校正选择和相对 UTC 参考的实际箱边界。可把其返回值传给lightcurve_products。可用prepare_gecam_spectra(...)独立准备谱,并与其他仪器的 同一源产品一起交给jinwu.core.source_analysis.SourceAnalysisPipeline。
边界
首版针对 A/B/C GRD EVT;真实数据验收限 GECAM-B 官方样例。
下载、姿态选探头、CALDB 响应生成、T90、CPD 及并道数据由独立的原生工具处理。
science_status="requires_review" 与 fit_performed 分别记录科学状态和拟合执行状态。
使用响应前需检查校准版本、生成警告及响应关联。样例响应编码问题、显式副本和验证记录。
Metadata
Release files for jinwu-gecam 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jinwu_gecam-0.3.0.tar.gz | 34.4 kB | Without provenance | Details for jinwu_gecam-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jinwu_gecam-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for jinwu_gecam-0.3.0-py3-none-any.whl |
Total release size: 52.1 kB
Release files / jinwu_gecam-0.3.0.tar.gz
| Download URL | jinwu_gecam-0.3.0.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5097b2984617d305e88cef1ba5ad144f3fc7f3a657e5d24270c0f155ee700caa
|
|
BLAKE2b-256 checksum How to use checksums |
58c2f1092c950c84ca0bb27b490267174a1b4177fd4a45f1ea7d09604f2d116c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / jinwu_gecam-0.3.0-py3-none-any.whl
| Download URL | jinwu_gecam-0.3.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1fc2637c14246d94ea95cc01c8a49e2f0f711b63b48159da39c86313f754e82
|
|
BLAKE2b-256 checksum How to use checksums |
82248d78d31026073b0873a594e3bdc30e20be20312ca50bbfefe205957a2ab5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for jinwu-gecam 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.