Parsers for the NASA GCN notices.
Project description
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
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_parser import ParseError
from gcn_parser import parse
from gcn_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_parser import Topic
from gcn_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")
Parse Notices on Disk
Use a mission-specific parser when you already know the notice type and have the raw notice stored on disk.
from pathlib import Path
from gcn_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")
Parsed notices are Pydantic models. Access fields directly, or inspect the full parsed payload with:
notice.model_dump()
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
Swift is not operational at the moment, support will be added as soon as it gets back to operations (🤞). 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gcn_notice_parser-0.1.1.tar.gz.
File metadata
- Download URL: gcn_notice_parser-0.1.1.tar.gz
- Upload date:
- Size: 209.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"id":"bookworm","libc":{"lib":"glibc","version":"2.36"},"name":"Debian GNU/Linux","version":"12"},"implementation":{"name":"CPython","version":"3.11.2"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.20 7 Apr 2026","python":"3.11.2","system":{"name":"Linux","release":"6.1.0-49-amd64"}} HTTPX2/2.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
482f322107929bcb2ade76000538ddb1899513e354f3a0f639ccf73d2a4ea383
|
|
| MD5 |
b0e10c564ab9b8e6aba39c84cdcb00b8
|
|
| BLAKE2b-256 |
504dd650be1b9a5b3de5c8a0652bd2fd777a16ff86e1055f0be64498adf22e1e
|
File details
Details for the file gcn_notice_parser-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gcn_notice_parser-0.1.1-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"id":"bookworm","libc":{"lib":"glibc","version":"2.36"},"name":"Debian GNU/Linux","version":"12"},"implementation":{"name":"CPython","version":"3.11.2"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.20 7 Apr 2026","python":"3.11.2","system":{"name":"Linux","release":"6.1.0-49-amd64"}} HTTPX2/2.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f9121ea3c105d8fe9d72e1df78d4064ab869e1e807ee9d08ff291eeb76bd3cf
|
|
| MD5 |
bc2f1ccdf366204c81ead3b5034808f0
|
|
| BLAKE2b-256 |
9dc20f65623490f82d2cd7bba78e476ea4a08d6435896a6d05086e6cf968f922
|