Metadata-Version: 2.5
Name: tgcn
Version: 0.0.2
Summary: Parse NASA GCN Circulars into typed Python models.
Project-URL: Documentation, https://peppedilillo.github.io/tgcn/
Project-URL: Source, https://github.com/peppedilillo/tgcn/
Project-URL: Issues, https://github.com/peppedilillo/tgcn/issues
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.13
Requires-Dist: astropy>=8.0.1
Requires-Dist: click>=8.5.0
Requires-Dist: linkify-it-py>=2.0
Requires-Dist: openai>=2.0
Requires-Dist: pydantic>=2.13.4
Requires-Dist: pysbd>=0.3.4
Requires-Dist: rich>=13.9
Provides-Extra: benchmark
Requires-Dist: jupyterlab>=4.6.3; extra == 'benchmark'
Requires-Dist: jupytext>=1.19.5; extra == 'benchmark'
Requires-Dist: matplotlib>=3.11.1; extra == 'benchmark'
Requires-Dist: pandas>=3.0.5; extra == 'benchmark'
Requires-Dist: scikit-learn>=1.9.0; extra == 'benchmark'
Description-Content-Type: text/markdown

# tgcn

This is a package for 
parsing [NASA GCN Circulars](https://gcn.nasa.gov/circulars/) into 
structured output.

For example, `tgcn` turns this circular:

```text
TITLE:   GCN CIRCULAR
NUMBER:  44104
SUBJECT: GRB 260310A: LBT optical observations
DATE:    26/03/24 14:51:33 GMT
FROM:    N. Passaleva at Sapienza University of Rome <niccolo.passaleva@uniroma1.it>

Niccolo’ Passaleva, Yu-Han Yang, Narges Shahamt, Eleonora Troja (U Rome) report 
on behalf of the ERC BHianca team:

Following the detection of GRB 260310A by Fermi/GBM and AstroSat CZTI (Fermi 
GBM team, GCN 43951,43975; AstroSat CZTI collaboration, GCN 43958), we observed 
the likely counterpart AT2026fgk (discovered by GOTO; O’Neill et al. 2026, TNS 
Discovery Report 294132) in r and z filters with the Large Binocular Camera 
(LBC) mounted on the Large Binocular Telescope (LBT). Observations started at 
2026-03-18T09:25:06 (~ 8.2 d after the GBM trigger) with an average airmass of 
1.3. 
We detect the source with a preliminary magnitude of r~18.7 AB mag, calibrated 
using nearby stars from the Legacy Survey DR10 (Dey et al. 2019) catalogue, 
uncorrected for Galactic extinction. 
Our measurement in consistent with those at the same observing time reported by 
Perley et al. (GCN 44096), Volnova et al. (GCN 44060).
We acknowledge excellent support from the LBTO and LBT-INAF staff.
```

Into this:

```python
Output(
    claims=(
        Claim[Quantity](
            subject=Subject(
                id='s.grb',
                aliases=('GRB 260310A',),
                citations=(43951, 43975, 43958)
            ),
            propositions=(
                Proposition(
                    statement=Classification(kind='class', name=SciClass.GRB),
                    qualifier=Qualifier.ASSERTED
                ),
            ),
            quantities=()
        ),
        Claim[Quantity](
            subject=Subject(
                id='s.optical_counterpart',
                aliases=('AT2026fgk',),
                citations=(44096, 44060)
            ),
            propositions=(
                Proposition(
                    statement=Relation(
                        kind=RelationKind.COUNTERPART,
                        to='s.grb'
                    ),
                    qualifier=Qualifier.UNCERTAIN
                ),
            ),
            quantities=(
                Magnitude(
                    value=Decimal('18.7'),
                    unit=UnitDimensionless.MAGNITUDE,
                    band='r',
                    system='ab',
                    time=TimePoint(
                        year=2026,
                        month=3,
                        day=18,
                        hour=9,
                        minute=25,
                        second=Decimal('6')
                    ),
                    time_role='start',
                    instruments=(Instrument.TELESCOPE_LBT,),
                    references=((482, 589), (592, 783))
                ),
            )
        )
    )
)
```

## Setup

Clone the repository and run one of these commands from its root.

```sh
# Include development dependencies to run the tests.
uv sync
# Install the package and its five CLI tools.
uv sync --no-dev
# Include development dependencies and the benchmark notebooks' dependencies.
uv sync --extra benchmark

# Equivalent pip install
# python -m pip install -e ".[benchmark]" --group dev
```

Or get it from [PyPI](https://pypi.org/project/tgcn/) with:

```sh
pip install tgcn
```

## Quick start

The following command should be enough to check everything is working:

```sh
LLM_API_KEY=your-openrouter-api-key-here \
uv run python -c "from tgcn import *; print(Parser().parse(Circular.from_web(44430)).to_json())" | \
jq '.' -
```

For real use, avoid typing the key directly into a command saved in shell history.


## Documentation

For everything else, refer to our [documentation](https://peppedilillo.github.io/tgcn/).
