Skip to main content

Extract structured astrophysical information from NASA GCN circulars using an LLM via OpenRouter.

Project description

GCN Circular Parser

Python 3.10+ License: MIT

This is a light-weight package for extracting structured astrophysical information from NASA GCN circulars using an LLM via OpenRouter.

Features

  • Fetch all circulars for a given event from the GCN archive
  • Extract structured fields with an LLM: coordinates, redshift, host galaxy, classification, flux/magnitude measurements, observations, references, and a one-sentence summary
  • Export magnitude/flux measurements across all circulars into a single time-sorted CSV light-curve table

Installation

git clone git@github.com:LAujust/gcn_parser.git
cd gcn_parser
pip install -e .

Or install directly without cloning:

pip install git+https://github.com/LAujust/gcn_parser.git

Configuration

Set your OpenRouter API key:

export OPENROUTER_API_KEY=sk-or-v1-...

Or create a .env file (see .env.example).

Usage

Run the CLI for an event identifier:

# JSON to stdout
gcn-parser GRB250101A

# Save JSON and CSV light-curve
gcn-parser GRB250101A -o output.json --csv lightcurve.csv

# Use a different model
gcn-parser GRB250101A -m openai/gpt-4o

You can also run it as a module:

python -m gcn_parser GRB250101A

Output

JSON

Each circular is an object containing the GCN number and the extracted fields.

[
  {
    "gcn": "GCN 12345",
    "extraction": {
      "event_type": "GRB",
      "coordinates": {
        "ra": "12:34:56.78",
        "dec": "+12:34:56.7",
        "system": "J2000",
        "error_arcsec": 1.2
      },
      "redshift": 0.5,
      "host_galaxy": "Host Galaxy Name",
      "classification": "Long GRB",
      "flux_magnitude": [
        {
          "value": 18.5,
          "band": "r",
          "instrument": "ZTF",
          "utc": "2025-01-01T12:00:00Z",
          "mjd": null,
          "unit": "AB mag",
          "upper_limit": false
        }
      ],
      "observations": ["Swift/XRT follow-up"],
      "references": ["GCN 12344"],
      "confidence": "high",
      "summary": "..."
    }
  }
]

CSV Light-Curve

The --csv option aggregates all flux_magnitude measurements across circulars into a single table:

Column Description
gcn_number Source circular
utc Observation time in ISO-8601 UTC
mjd Modified Julian Date (optional)
value Numeric measurement
unit e.g. mag, AB mag, erg cm^-2 s^-1
band Photometric band
instrument Telescope or instrument
upper_limit true if upper limit

Rows are sorted by date.

Project Structure

gcn_parser/
├── archive.py       # Fetch circulars from GCN archive
├── models.py        # Pydantic schema for structured extraction
├── extractor.py     # OpenRouter LLM client and prompt
├── csv_export.py    # Flatten measurements to CSV
├── cli.py           # argparse CLI entry point
└── __main__.py      # Enables `python -m gcn_parser`

Default Model

minimax/minimax-m2.5:free via OpenRouter.

License

This project is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcn_circular_llm-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcn_circular_llm-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file gcn_circular_llm-0.1.0.tar.gz.

File metadata

  • Download URL: gcn_circular_llm-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for gcn_circular_llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4300dd49651771c86b10839b4896096ee16ad7f3dba4a51b3069e9fa15c6bd12
MD5 f9e5b516d66a21b2975b13875adc2776
BLAKE2b-256 381ce14050230300630f13a832cafc650382828b7567c0a3c3686b09bfdd1c66

See more details on using hashes here.

File details

Details for the file gcn_circular_llm-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gcn_circular_llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4547f47f5c47d7918b8b5321c831c3de7a5cdfc81abdad361c76bdf4c5e6a374
MD5 1f4f2714cfe7df5e4fe40ad5ca2c8ca8
BLAKE2b-256 17451b44341a04dd2fabd4cab14093834efc400b3815d6294dc2de754fa8d7b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page