GCN Notice Parser
gcn-notice-parser is a Python 3.11+ package for parsing GCN Kafka messages or raw notice bytes into Pydantic models with named, typed fields.
Installation
The package is on PyPI. You can install it with:
pip install gcn-notice-parser
Live Kafka examples also need gcn-kafka:
pip install gcn-notice-parser gcn-kafka
Quickstart
Parse Live GCN Messages
from gcn_kafka import Consumer
from gcn_notice_parser import ParseError
from gcn_notice_parser import parse
from gcn_notice_parser import supported_topics
consumer = Consumer(
# fill blanks with your GCN credentials
client_id="...",
client_secret="...",
config={"auto.offset.reset": "earliest"},
)
consumer.subscribe(supported_topics())
while True:
for message in consumer.consume(timeout=1):
try:
notice = parse(message)
except ParseError as exc:
print(f"Failed to parse {message.topic()}: {exc}")
continue
print(f"{message.topic()}: {type(notice).__name__}")
print(notice)
Parse Selected Topics
Subscribe to selected topics when you know which notice family you want. This example listens for Fermi GBM final-position and ground-position notices and prints the burst position.
from gcn_kafka import Consumer
from gcn_notice_parser import Topic
from gcn_notice_parser import parse
consumer = Consumer(
# fill blanks with your GCN credentials
client_id="...",
client_secret="...",
config={"auto.offset.reset": "earliest"},
)
consumer.subscribe([Topic.FERMI_GBM_FIN_POS, Topic.FERMI_GBM_GND_POS])
while True:
for message in consumer.consume(timeout=1):
notice = parse(message)
print(f"RA: {notice.ra} deg")
print(f"Dec: {notice.dec} deg")
print(f"Error radius: {notice.error_radius} deg")
Mission-specific parsers
Use a mission-specific parser when you know the notice type in advance. This is useful when parsing a notice stored on disk.
from pathlib import Path
from gcn_notice_parser.fermi import parse_fermi_gbm_fin_pos
notice = parse_fermi_gbm_fin_pos(Path("fermi_gbm_fin_pos.xml").read_bytes())
print(f"RA: {notice.ra} deg")
print(f"Dec: {notice.dec} deg")
print(f"Error radius: {notice.error_radius} deg")
Supported Topics
Currently supported GCN topics are:
gcn.classic.voevent.FERMI_GBM_ALERT
gcn.classic.voevent.FERMI_GBM_FIN_POS
gcn.classic.voevent.FERMI_GBM_FLT_POS
gcn.classic.voevent.FERMI_GBM_GND_POS
gcn.classic.voevent.FERMI_LAT_OFFLINE
gcn.classic.voevent.FERMI_LAT_POS_DIAG
gcn.classic.voevent.FERMI_LAT_POS_INI
gcn.classic.voevent.FERMI_LAT_POS_UPD
gcn.notices.svom.voevent.grm
gcn.notices.svom.voevent.eclairs
gcn.notices.svom.voevent.mxt
gcn.notices.einstein_probe.wxt.alert
More will come. In need of a specific parser? Consider sending a PR, or asking in the discussion section.
Documentation
Looking for parse notices schema? For this and more, check out the documentation.
Metadata
Release files for gcn-notice-parser 0.2.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 |
|---|---|---|---|---|
| gcn_notice_parser-0.2.0.tar.gz | 207.9 kB | Without provenance | Details for gcn_notice_parser-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gcn_notice_parser-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for gcn_notice_parser-0.2.0-py3-none-any.whl |
Total release size: 245.2 kB
Release files / gcn_notice_parser-0.2.0.tar.gz
| Download URL | gcn_notice_parser-0.2.0.tar.gz |
|---|---|
| Size | 207.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8bc3b2059d35d6147e3a50ee7fb316dfd68f7c1becc522bd534f1b04adbd474
|
|
BLAKE2b-256 checksum How to use checksums |
8a945b2f6dd25ddc5e5e4ae3a83f78912ef7c650fb42e906e79b47e82e8a9e60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Release files / gcn_notice_parser-0.2.0-py3-none-any.whl
| Download URL | gcn_notice_parser-0.2.0-py3-none-any.whl |
|---|---|
| Size | 37.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fb50d5de432ede63641019c988cc67a98d01b0a2f412ed66436f930397a0a87
|
|
BLAKE2b-256 checksum How to use checksums |
2f506255872fa388ddf33a48e14c8e8e8089b478e4cd9daaae8b0724584b5c55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Security for gcn-notice-parser 0.2.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.