tgcn 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tgcn-0.0.1/.github/workflows/docs.yml +29 -0
- tgcn-0.0.1/.gitignore +36 -0
- tgcn-0.0.1/.python-version +1 -0
- tgcn-0.0.1/.secrets.sample +1 -0
- tgcn-0.0.1/AGENTS.md +30 -0
- tgcn-0.0.1/LICENSE +21 -0
- tgcn-0.0.1/PKG-INFO +151 -0
- tgcn-0.0.1/README.md +129 -0
- tgcn-0.0.1/docs/circulars.md +11 -0
- tgcn-0.0.1/docs/claims.md +27 -0
- tgcn-0.0.1/docs/develop.md +36 -0
- tgcn-0.0.1/docs/index.md +1 -0
- tgcn-0.0.1/docs/output.md +76 -0
- tgcn-0.0.1/docs/parsing.md +124 -0
- tgcn-0.0.1/docs/proposition.md +69 -0
- tgcn-0.0.1/docs/quantities.md +242 -0
- tgcn-0.0.1/docs/tools.md +67 -0
- tgcn-0.0.1/pyproject.toml +64 -0
- tgcn-0.0.1/src/tgcn/__init__.py +21 -0
- tgcn-0.0.1/src/tgcn/_repr.py +42 -0
- tgcn-0.0.1/src/tgcn/_version.py +4 -0
- tgcn-0.0.1/src/tgcn/circulars.py +294 -0
- tgcn-0.0.1/src/tgcn/citations.py +68 -0
- tgcn-0.0.1/src/tgcn/claims.py +248 -0
- tgcn-0.0.1/src/tgcn/classifications.py +69 -0
- tgcn-0.0.1/src/tgcn/config.py +117 -0
- tgcn-0.0.1/src/tgcn/config_default.json +60 -0
- tgcn-0.0.1/src/tgcn/instruments.py +67 -0
- tgcn-0.0.1/src/tgcn/link.py +47 -0
- tgcn-0.0.1/src/tgcn/llm.py +1006 -0
- tgcn-0.0.1/src/tgcn/normalized.py +1410 -0
- tgcn-0.0.1/src/tgcn/parser.py +659 -0
- tgcn-0.0.1/src/tgcn/prompts.py +1452 -0
- tgcn-0.0.1/src/tgcn/py.typed +0 -0
- tgcn-0.0.1/src/tgcn/reported.py +927 -0
- tgcn-0.0.1/src/tgcn/segmenter.py +167 -0
- tgcn-0.0.1/src/tgcn/units.py +167 -0
- tgcn-0.0.1/src/tgcn_tools/__init__.py +1 -0
- tgcn-0.0.1/src/tgcn_tools/_jsonl.py +43 -0
- tgcn-0.0.1/src/tgcn_tools/brun/__init__.py +170 -0
- tgcn-0.0.1/src/tgcn_tools/brun/__main__.py +5 -0
- tgcn-0.0.1/src/tgcn_tools/brun/claims.py +98 -0
- tgcn-0.0.1/src/tgcn_tools/brun/cli.py +494 -0
- tgcn-0.0.1/src/tgcn_tools/brun/lines.py +73 -0
- tgcn-0.0.1/src/tgcn_tools/brun/quantities.py +115 -0
- tgcn-0.0.1/src/tgcn_tools/collect.py +127 -0
- tgcn-0.0.1/src/tgcn_tools/filter.py +126 -0
- tgcn-0.0.1/src/tgcn_tools/manifest.py +71 -0
- tgcn-0.0.1/src/tgcn_tools/reference.py +153 -0
- tgcn-0.0.1/tests/_collect_samples.py +36 -0
- tgcn-0.0.1/tests/_llm_samples.py +27 -0
- tgcn-0.0.1/tests/_reported_samples.py +151 -0
- tgcn-0.0.1/tests/conftest.py +37 -0
- tgcn-0.0.1/tests/fixtures/circulars.jsonl +193 -0
- tgcn-0.0.1/tests/fixtures/configs.jsonl +2 -0
- tgcn-0.0.1/tests/fixtures/minibench1.jsonl +3 -0
- tgcn-0.0.1/tests/fixtures/minibench2.jsonl +2 -0
- tgcn-0.0.1/tests/fixtures/minimanifest.jsonl +5 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/claims/responses/prompt.txt +1172 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/claims/responses/schema.json +332 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/lines/decisions/questions.json +29 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/lines/decisions/state.json +100 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/lines/responses/prompt.txt +11 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/lines/responses/schema.json +44 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/quantities/responses/prompt.txt +169 -0
- tgcn-0.0.1/tests/parser_reference/0.0.1-accordion/quantities/responses/schema.json +2688 -0
- tgcn-0.0.1/tests/test_circulars.py +593 -0
- tgcn-0.0.1/tests/test_citations.py +44 -0
- tgcn-0.0.1/tests/test_claims.py +255 -0
- tgcn-0.0.1/tests/test_config.py +280 -0
- tgcn-0.0.1/tests/test_error_message.py +46 -0
- tgcn-0.0.1/tests/test_line_decisions.py +246 -0
- tgcn-0.0.1/tests/test_link.py +61 -0
- tgcn-0.0.1/tests/test_llm.py +1491 -0
- tgcn-0.0.1/tests/test_meta.py +96 -0
- tgcn-0.0.1/tests/test_normalized.py +1651 -0
- tgcn-0.0.1/tests/test_normalized_claims.py +70 -0
- tgcn-0.0.1/tests/test_normalized_units.py +427 -0
- tgcn-0.0.1/tests/test_parse_call_summaries.py +253 -0
- tgcn-0.0.1/tests/test_parsed.py +905 -0
- tgcn-0.0.1/tests/test_parsed_json.py +488 -0
- tgcn-0.0.1/tests/test_parser.py +1004 -0
- tgcn-0.0.1/tests/test_radio_flux.py +179 -0
- tgcn-0.0.1/tests/test_relative_reference.py +187 -0
- tgcn-0.0.1/tests/test_reported.py +163 -0
- tgcn-0.0.1/tests/test_reported_fluxes.py +203 -0
- tgcn-0.0.1/tests/test_reported_localizations.py +204 -0
- tgcn-0.0.1/tests/test_reported_values.py +507 -0
- tgcn-0.0.1/tests/test_repr.py +202 -0
- tgcn-0.0.1/tests/test_retry.py +256 -0
- tgcn-0.0.1/tests/test_rich_repr.py +67 -0
- tgcn-0.0.1/tests/test_segmenter.py +186 -0
- tgcn-0.0.1/tests/test_tool_dependencies.py +28 -0
- tgcn-0.0.1/tests/test_units.py +82 -0
- tgcn-0.0.1/tests/tools/test_brun.py +1707 -0
- tgcn-0.0.1/tests/tools/test_collect.py +186 -0
- tgcn-0.0.1/tests/tools/test_filter.py +154 -0
- tgcn-0.0.1/tests/tools/test_manifest.py +104 -0
- tgcn-0.0.1/tests/tools/test_notebooks.py +16 -0
- tgcn-0.0.1/tests/tools/test_predictions.py +24 -0
- tgcn-0.0.1/tests/tools/test_quantity_matching.py +104 -0
- tgcn-0.0.1/tests/tools/test_reference.py +173 -0
- tgcn-0.0.1/uv.lock +3359 -0
- tgcn-0.0.1/zensical.toml +52 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
- main
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
pages: write
|
|
10
|
+
id-token: write
|
|
11
|
+
jobs:
|
|
12
|
+
deploy:
|
|
13
|
+
environment:
|
|
14
|
+
name: github-pages
|
|
15
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/configure-pages@v6
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
- uses: actions/setup-python@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version-file: .python-version
|
|
23
|
+
- run: pip install uv
|
|
24
|
+
- run: uv run --locked --no-dev --group docs zensical build --clean
|
|
25
|
+
- uses: actions/upload-pages-artifact@v5
|
|
26
|
+
with:
|
|
27
|
+
path: site
|
|
28
|
+
- uses: actions/deploy-pages@v5
|
|
29
|
+
id: deployment
|
tgcn-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# OS files
|
|
13
|
+
.DS_Store
|
|
14
|
+
|
|
15
|
+
# docs
|
|
16
|
+
site/
|
|
17
|
+
|
|
18
|
+
# jupyter
|
|
19
|
+
*.ipynb
|
|
20
|
+
.ipynb_checkpoints
|
|
21
|
+
*/.ipynb_checkpoints/*
|
|
22
|
+
|
|
23
|
+
# IDE & LLM
|
|
24
|
+
.idea
|
|
25
|
+
prompt.md
|
|
26
|
+
|
|
27
|
+
# Secrets and env vars
|
|
28
|
+
.secrets
|
|
29
|
+
.secrets.openai
|
|
30
|
+
.secrets.openrouter
|
|
31
|
+
.env
|
|
32
|
+
|
|
33
|
+
# other artifacts
|
|
34
|
+
_notes_*
|
|
35
|
+
.eval-artifacts/
|
|
36
|
+
*.jsonl.lock
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
LLM_API_KEY=
|
tgcn-0.0.1/AGENTS.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Guidelines:
|
|
2
|
+
* We value elegance, mantainability and simplicity greatly.
|
|
3
|
+
* Strive for self-documenting code but when a code block is not
|
|
4
|
+
self-explainatory, use a short comment to explain it's purpose.
|
|
5
|
+
* Working on documentation and comments, use a simple and clear language. If
|
|
6
|
+
you can't explain your solution in simple terms, it's likely that it can be
|
|
7
|
+
improved. Avoid jargon unless truly needed.
|
|
8
|
+
* It's ok to use an informal tone in comments.
|
|
9
|
+
* Use inline attribute docstrings for Pydantic model fields. Use
|
|
10
|
+
Google-style docstrings for regular classes and callables, including
|
|
11
|
+
methods on Pydantic models. Private models and helpers may use a one-line
|
|
12
|
+
docstring when the signature makes the parameters clear.
|
|
13
|
+
* Keep tests focused. Each test should ideally stress one system behaviour.
|
|
14
|
+
* Test serves the double purpose of documentation. Good tests show what a
|
|
15
|
+
function does.
|
|
16
|
+
* Do not test against prompts content unless asked.
|
|
17
|
+
* Target 80 columns width for docstrings and long strings, 120 columns for code.
|
|
18
|
+
* Do not waste token on linter formatting. I will run these myself.
|
|
19
|
+
* Ask before writing any prose in README or other docs files.
|
|
20
|
+
* Commit only when asked to, with meaningful subject-body messages.
|
|
21
|
+
Commit messages should stay small (up to one short paragraph).
|
|
22
|
+
* When you commit yourself, commit as codex.
|
|
23
|
+
* Documents in the `benchmarks/references` directory are references and
|
|
24
|
+
implementation details are out of their scope.
|
|
25
|
+
* Do not waste tokens on .ipynb notebooks. We are working with paired .py
|
|
26
|
+
jupytext notebook to avoid this.
|
|
27
|
+
* The main subpackage is `tgcn`. It should not import from any
|
|
28
|
+
other subpackage.
|
|
29
|
+
* Instructions for a LLM belong to the prompt. Schema descriptions are docs:
|
|
30
|
+
they should not be used for instructions.
|
tgcn-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Giuseppe Dilillo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tgcn-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tgcn
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Parse NASA GCN Circulars into typed Python models.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Requires-Dist: astropy>=8.0.1
|
|
9
|
+
Requires-Dist: click>=8.5.0
|
|
10
|
+
Requires-Dist: linkify-it-py>=2.0
|
|
11
|
+
Requires-Dist: openai>=2.0
|
|
12
|
+
Requires-Dist: pydantic>=2.13.4
|
|
13
|
+
Requires-Dist: pysbd>=0.3.4
|
|
14
|
+
Requires-Dist: rich>=13.9
|
|
15
|
+
Provides-Extra: benchmark
|
|
16
|
+
Requires-Dist: jupyterlab>=4.6.3; extra == 'benchmark'
|
|
17
|
+
Requires-Dist: jupytext>=1.19.5; extra == 'benchmark'
|
|
18
|
+
Requires-Dist: matplotlib>=3.11.1; extra == 'benchmark'
|
|
19
|
+
Requires-Dist: pandas>=3.0.5; extra == 'benchmark'
|
|
20
|
+
Requires-Dist: scikit-learn>=1.9.0; extra == 'benchmark'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# tgcn
|
|
24
|
+
|
|
25
|
+
This is a package for
|
|
26
|
+
parsing [NASA GCN Circulars](https://gcn.nasa.gov/circulars/) into
|
|
27
|
+
structured output.
|
|
28
|
+
|
|
29
|
+
For example, `tgcn` turns this circular:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
TITLE: GCN CIRCULAR
|
|
33
|
+
NUMBER: 44104
|
|
34
|
+
SUBJECT: GRB 260310A: LBT optical observations
|
|
35
|
+
DATE: 26/03/24 14:51:33 GMT
|
|
36
|
+
FROM: N. Passaleva at Sapienza University of Rome <niccolo.passaleva@uniroma1.it>
|
|
37
|
+
|
|
38
|
+
Niccolo’ Passaleva, Yu-Han Yang, Narges Shahamt, Eleonora Troja (U Rome) report
|
|
39
|
+
on behalf of the ERC BHianca team:
|
|
40
|
+
|
|
41
|
+
Following the detection of GRB 260310A by Fermi/GBM and AstroSat CZTI (Fermi
|
|
42
|
+
GBM team, GCN 43951,43975; AstroSat CZTI collaboration, GCN 43958), we observed
|
|
43
|
+
the likely counterpart AT2026fgk (discovered by GOTO; O’Neill et al. 2026, TNS
|
|
44
|
+
Discovery Report 294132) in r and z filters with the Large Binocular Camera
|
|
45
|
+
(LBC) mounted on the Large Binocular Telescope (LBT). Observations started at
|
|
46
|
+
2026-03-18T09:25:06 (~ 8.2 d after the GBM trigger) with an average airmass of
|
|
47
|
+
1.3.
|
|
48
|
+
We detect the source with a preliminary magnitude of r~18.7 AB mag, calibrated
|
|
49
|
+
using nearby stars from the Legacy Survey DR10 (Dey et al. 2019) catalogue,
|
|
50
|
+
uncorrected for Galactic extinction.
|
|
51
|
+
Our measurement in consistent with those at the same observing time reported by
|
|
52
|
+
Perley et al. (GCN 44096), Volnova et al. (GCN 44060).
|
|
53
|
+
We acknowledge excellent support from the LBTO and LBT-INAF staff.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Into this:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
Output(
|
|
60
|
+
claims=(
|
|
61
|
+
Claim[Quantity](
|
|
62
|
+
subject=Subject(
|
|
63
|
+
id='s.grb',
|
|
64
|
+
aliases=('GRB 260310A',),
|
|
65
|
+
citations=(43951, 43975, 43958)
|
|
66
|
+
),
|
|
67
|
+
propositions=(
|
|
68
|
+
Proposition(
|
|
69
|
+
statement=Classification(kind='class', name=SciClass.GRB),
|
|
70
|
+
qualifier=Qualifier.ASSERTED
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
quantities=()
|
|
74
|
+
),
|
|
75
|
+
Claim[Quantity](
|
|
76
|
+
subject=Subject(
|
|
77
|
+
id='s.optical_counterpart',
|
|
78
|
+
aliases=('AT2026fgk',),
|
|
79
|
+
citations=(44096, 44060)
|
|
80
|
+
),
|
|
81
|
+
propositions=(
|
|
82
|
+
Proposition(
|
|
83
|
+
statement=Relation(
|
|
84
|
+
kind=RelationKind.COUNTERPART,
|
|
85
|
+
to='s.grb'
|
|
86
|
+
),
|
|
87
|
+
qualifier=Qualifier.UNCERTAIN
|
|
88
|
+
),
|
|
89
|
+
),
|
|
90
|
+
quantities=(
|
|
91
|
+
Magnitude(
|
|
92
|
+
value=Decimal('18.7'),
|
|
93
|
+
unit=UnitDimensionless.MAGNITUDE,
|
|
94
|
+
band='r',
|
|
95
|
+
system='ab',
|
|
96
|
+
time=TimePoint(
|
|
97
|
+
year=2026,
|
|
98
|
+
month=3,
|
|
99
|
+
day=18,
|
|
100
|
+
hour=9,
|
|
101
|
+
minute=25,
|
|
102
|
+
second=Decimal('6')
|
|
103
|
+
),
|
|
104
|
+
time_role='start',
|
|
105
|
+
instruments=(Instrument.TELESCOPE_LBT,),
|
|
106
|
+
references=((482, 589), (592, 783))
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Setup
|
|
115
|
+
|
|
116
|
+
Clone the repository and run one of these commands from its root.
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
# Include development dependencies to run the tests.
|
|
120
|
+
uv sync
|
|
121
|
+
# Install the package and its five CLI tools.
|
|
122
|
+
uv sync --no-dev
|
|
123
|
+
# Include development dependencies and the benchmark notebooks' dependencies.
|
|
124
|
+
uv sync --extra benchmark
|
|
125
|
+
|
|
126
|
+
# Equivalent pip install
|
|
127
|
+
# python -m pip install -e ".[benchmark]" --group dev
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Or get it from PyPI with:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
pip install tgcn
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Quick start
|
|
137
|
+
|
|
138
|
+
The following command should be enough to check everything is working:
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
LLM_API_KEY=your-openrouter-api-key-here \
|
|
142
|
+
uv run python -c "from tgcn import *; print(Parser().parse(Circular.from_web(44430)).to_json())" | \
|
|
143
|
+
jq '.' -
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For real use, avoid typing the key directly into a command saved in shell history.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
For everything else, refer to our [documentation](https://peppedilillo.github.io/tgcn/).
|
tgcn-0.0.1/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# tgcn
|
|
2
|
+
|
|
3
|
+
This is a package for
|
|
4
|
+
parsing [NASA GCN Circulars](https://gcn.nasa.gov/circulars/) into
|
|
5
|
+
structured output.
|
|
6
|
+
|
|
7
|
+
For example, `tgcn` turns this circular:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
TITLE: GCN CIRCULAR
|
|
11
|
+
NUMBER: 44104
|
|
12
|
+
SUBJECT: GRB 260310A: LBT optical observations
|
|
13
|
+
DATE: 26/03/24 14:51:33 GMT
|
|
14
|
+
FROM: N. Passaleva at Sapienza University of Rome <niccolo.passaleva@uniroma1.it>
|
|
15
|
+
|
|
16
|
+
Niccolo’ Passaleva, Yu-Han Yang, Narges Shahamt, Eleonora Troja (U Rome) report
|
|
17
|
+
on behalf of the ERC BHianca team:
|
|
18
|
+
|
|
19
|
+
Following the detection of GRB 260310A by Fermi/GBM and AstroSat CZTI (Fermi
|
|
20
|
+
GBM team, GCN 43951,43975; AstroSat CZTI collaboration, GCN 43958), we observed
|
|
21
|
+
the likely counterpart AT2026fgk (discovered by GOTO; O’Neill et al. 2026, TNS
|
|
22
|
+
Discovery Report 294132) in r and z filters with the Large Binocular Camera
|
|
23
|
+
(LBC) mounted on the Large Binocular Telescope (LBT). Observations started at
|
|
24
|
+
2026-03-18T09:25:06 (~ 8.2 d after the GBM trigger) with an average airmass of
|
|
25
|
+
1.3.
|
|
26
|
+
We detect the source with a preliminary magnitude of r~18.7 AB mag, calibrated
|
|
27
|
+
using nearby stars from the Legacy Survey DR10 (Dey et al. 2019) catalogue,
|
|
28
|
+
uncorrected for Galactic extinction.
|
|
29
|
+
Our measurement in consistent with those at the same observing time reported by
|
|
30
|
+
Perley et al. (GCN 44096), Volnova et al. (GCN 44060).
|
|
31
|
+
We acknowledge excellent support from the LBTO and LBT-INAF staff.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Into this:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
Output(
|
|
38
|
+
claims=(
|
|
39
|
+
Claim[Quantity](
|
|
40
|
+
subject=Subject(
|
|
41
|
+
id='s.grb',
|
|
42
|
+
aliases=('GRB 260310A',),
|
|
43
|
+
citations=(43951, 43975, 43958)
|
|
44
|
+
),
|
|
45
|
+
propositions=(
|
|
46
|
+
Proposition(
|
|
47
|
+
statement=Classification(kind='class', name=SciClass.GRB),
|
|
48
|
+
qualifier=Qualifier.ASSERTED
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
quantities=()
|
|
52
|
+
),
|
|
53
|
+
Claim[Quantity](
|
|
54
|
+
subject=Subject(
|
|
55
|
+
id='s.optical_counterpart',
|
|
56
|
+
aliases=('AT2026fgk',),
|
|
57
|
+
citations=(44096, 44060)
|
|
58
|
+
),
|
|
59
|
+
propositions=(
|
|
60
|
+
Proposition(
|
|
61
|
+
statement=Relation(
|
|
62
|
+
kind=RelationKind.COUNTERPART,
|
|
63
|
+
to='s.grb'
|
|
64
|
+
),
|
|
65
|
+
qualifier=Qualifier.UNCERTAIN
|
|
66
|
+
),
|
|
67
|
+
),
|
|
68
|
+
quantities=(
|
|
69
|
+
Magnitude(
|
|
70
|
+
value=Decimal('18.7'),
|
|
71
|
+
unit=UnitDimensionless.MAGNITUDE,
|
|
72
|
+
band='r',
|
|
73
|
+
system='ab',
|
|
74
|
+
time=TimePoint(
|
|
75
|
+
year=2026,
|
|
76
|
+
month=3,
|
|
77
|
+
day=18,
|
|
78
|
+
hour=9,
|
|
79
|
+
minute=25,
|
|
80
|
+
second=Decimal('6')
|
|
81
|
+
),
|
|
82
|
+
time_role='start',
|
|
83
|
+
instruments=(Instrument.TELESCOPE_LBT,),
|
|
84
|
+
references=((482, 589), (592, 783))
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Setup
|
|
93
|
+
|
|
94
|
+
Clone the repository and run one of these commands from its root.
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
# Include development dependencies to run the tests.
|
|
98
|
+
uv sync
|
|
99
|
+
# Install the package and its five CLI tools.
|
|
100
|
+
uv sync --no-dev
|
|
101
|
+
# Include development dependencies and the benchmark notebooks' dependencies.
|
|
102
|
+
uv sync --extra benchmark
|
|
103
|
+
|
|
104
|
+
# Equivalent pip install
|
|
105
|
+
# python -m pip install -e ".[benchmark]" --group dev
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Or get it from PyPI with:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
pip install tgcn
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Quick start
|
|
115
|
+
|
|
116
|
+
The following command should be enough to check everything is working:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
LLM_API_KEY=your-openrouter-api-key-here \
|
|
120
|
+
uv run python -c "from tgcn import *; print(Parser().parse(Circular.from_web(44430)).to_json())" | \
|
|
121
|
+
jq '.' -
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
For real use, avoid typing the key directly into a command saved in shell history.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
## Documentation
|
|
128
|
+
|
|
129
|
+
For everything else, refer to our [documentation](https://peppedilillo.github.io/tgcn/).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Circulars
|
|
2
|
+
|
|
3
|
+
A `Circular` holds a NASA GCN circular's text, publication details and
|
|
4
|
+
metadata. You can load a circular from JSON or download it from the web,
|
|
5
|
+
then find the other circulars it cites, the links it contains, and any email
|
|
6
|
+
addresses or URL reported in its body.
|
|
7
|
+
|
|
8
|
+
::: tgcn.Circular
|
|
9
|
+
options:
|
|
10
|
+
show_root_heading: true
|
|
11
|
+
heading_level: 2
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Claims
|
|
2
|
+
|
|
3
|
+
In the final stage of the parser, [quantities](quantities.md) and
|
|
4
|
+
[propositions](proposition.md) are assigned to `Subject` models representing
|
|
5
|
+
astrophysical events or sources, and grouped into one `Claim` model or more.
|
|
6
|
+
Each claim has a single subject.
|
|
7
|
+
|
|
8
|
+
Every subject has a unique identifier used to link it to other subjects via
|
|
9
|
+
[relations](proposition.md#tgcn.claims.Relation), along with a
|
|
10
|
+
list of `aliases` recording the names used for it in the text. When discussing
|
|
11
|
+
a subject, authors frequently cite earlier circulars where it was mentioned;
|
|
12
|
+
those circular IDs are collected in the subject's `citations` field.
|
|
13
|
+
|
|
14
|
+
::: tgcn.claims.Claim
|
|
15
|
+
options:
|
|
16
|
+
show_root_heading: true
|
|
17
|
+
heading_level: 2
|
|
18
|
+
unwrap_annotated: true
|
|
19
|
+
members: [subject, propositions, quantities]
|
|
20
|
+
|
|
21
|
+
::: tgcn.claims.Subject
|
|
22
|
+
options:
|
|
23
|
+
show_root_heading: true
|
|
24
|
+
heading_level: 2
|
|
25
|
+
unwrap_annotated: true
|
|
26
|
+
show_attribute_values: false
|
|
27
|
+
members: [id, aliases, citations]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# For developers
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Install the full dependency tree:
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
uv sync --all-extras --all-groups
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Tests
|
|
12
|
+
|
|
13
|
+
Assuming you synced the whole dependency tree:
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
uv run pytest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Versioning
|
|
20
|
+
|
|
21
|
+
The parser and package versions are decoupled. A dedicated test checks if
|
|
22
|
+
the current prompts and schemas match a reference for the installed package
|
|
23
|
+
and parser versions.
|
|
24
|
+
|
|
25
|
+
When shipping remember to:
|
|
26
|
+
|
|
27
|
+
1. bump the software version in `pyproject.toml`
|
|
28
|
+
2. if a change in the parser requires migrating or reprocessing existing data,
|
|
29
|
+
bump the parser version in `_version.py`.
|
|
30
|
+
3. generate and review a new parser reference in the dedicated directory with
|
|
31
|
+
`uv run reference tests/parser_reference`
|
|
32
|
+
4. commit and tag with the new package version.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
tgcn-0.0.1/docs/index.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include-markdown "../README.md" %}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Output
|
|
2
|
+
|
|
3
|
+
[`Parser`](parsing.md) turns a circular into `Output`, an object containing
|
|
4
|
+
extracted [claims](claims.md) along with metadata about the circular and the
|
|
5
|
+
parser run. You can serialize `Output` with `to_json()` and restore it later
|
|
6
|
+
with `Output.from_json()`. `Output.info.calls` records every model call in
|
|
7
|
+
execution order—including any failed attempts—along with details such as the
|
|
8
|
+
parsing stage, model, and timestamps.
|
|
9
|
+
|
|
10
|
+
Starting from `Output`, you can obtain a `View`, an object useful for
|
|
11
|
+
exploring a parsed circular's content:
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from tgcn.parser import Output
|
|
15
|
+
|
|
16
|
+
output = Output.from_json(...)
|
|
17
|
+
view = output.view()
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Each `View` holds two collections: `context`, which contains every claim
|
|
21
|
+
extracted from the circular, and `selected`, which contains the currently
|
|
22
|
+
selected claims. Filtering and navigation return a new view with the same
|
|
23
|
+
context.
|
|
24
|
+
|
|
25
|
+
For example, consider a circular with a subject for a transient classified as
|
|
26
|
+
`SciClass.GRB` and another subject for its optical counterpart. This snippet
|
|
27
|
+
selects the claim about the GRB subject:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from tgcn import SciClass
|
|
31
|
+
|
|
32
|
+
grbs = view.classified(SciClass.GRB)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The next snippet moves from the GRB to its optical counterpart:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
counterparts = view.classified(SciClass.GRB).counterparts()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
!!! warning
|
|
42
|
+
Order matters: `.classified(SciClass.GRB).counterparts()` does not produce
|
|
43
|
+
the same view as `.counterparts().classified(SciClass.GRB)`. The first
|
|
44
|
+
selects claims about counterparts of subjects classified as a GRB. The
|
|
45
|
+
second selects claims about subjects that are counterparts of any subject
|
|
46
|
+
and are themselves classified as a GRB.
|
|
47
|
+
|
|
48
|
+
The `View` interface makes it easy to explore a parsed circular with a fluent,
|
|
49
|
+
readable syntax. The next snippet extracts localization quantities, if any,
|
|
50
|
+
for all of the GRB's counterparts:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from tgcn import SciClass
|
|
54
|
+
|
|
55
|
+
locs = view.classified(SciClass.GRB).counterparts().localizations
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
::: tgcn.Output
|
|
59
|
+
options:
|
|
60
|
+
show_root_heading: true
|
|
61
|
+
heading_level: 2
|
|
62
|
+
|
|
63
|
+
::: tgcn.View
|
|
64
|
+
options:
|
|
65
|
+
show_root_heading: true
|
|
66
|
+
heading_level: 2
|
|
67
|
+
|
|
68
|
+
::: tgcn.parser.Info
|
|
69
|
+
options:
|
|
70
|
+
show_root_heading: true
|
|
71
|
+
heading_level: 2
|
|
72
|
+
|
|
73
|
+
::: tgcn.parser.InfoCall
|
|
74
|
+
options:
|
|
75
|
+
show_root_heading: true
|
|
76
|
+
heading_level: 2
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Parsing from scratch
|
|
2
|
+
|
|
3
|
+
[`Parser`](parsing.md#tgcn.Parser) turns a
|
|
4
|
+
[`Circular`](circulars.md#tgcn.Circular) into structured data
|
|
5
|
+
according to an optional `Configuration`. Its `parse` method returns an
|
|
6
|
+
[`Output`](output.md#tgcn.Output) object wrapping the extracted
|
|
7
|
+
[claims](claims.md) and providing methods to import and export parsed data.
|
|
8
|
+
|
|
9
|
+
Running the parser requires either setting the `LLM_API_KEY` environment
|
|
10
|
+
variable to your provider API key or passing the API key directly to `Parser`.
|
|
11
|
+
In this example, we assume `LLM_API_KEY` is already set and run the parsing
|
|
12
|
+
pipeline:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from tgcn import Circular, Configuration, Parser
|
|
16
|
+
|
|
17
|
+
debug = []
|
|
18
|
+
configuration = Configuration.load("config.json")
|
|
19
|
+
circular = Circular.from_web(44430)
|
|
20
|
+
parser = Parser(configuration=configuration)
|
|
21
|
+
output = parser.parse(circular, on_call=debug.append)
|
|
22
|
+
output
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
::: tgcn.Parser
|
|
26
|
+
options:
|
|
27
|
+
show_root_heading: true
|
|
28
|
+
heading_level: 2
|
|
29
|
+
|
|
30
|
+
::: tgcn.llm.Meta
|
|
31
|
+
options:
|
|
32
|
+
show_root_heading: true
|
|
33
|
+
heading_level: 3
|
|
34
|
+
|
|
35
|
+
## Writing a configuration file
|
|
36
|
+
|
|
37
|
+
A `Configuration` controls the provider connections, models, and request
|
|
38
|
+
parameters used by the parser. Each stage—`lines`, `quantities`, and
|
|
39
|
+
`claims`—has an ordered list of attempts. If an attempt fails, the parser
|
|
40
|
+
tries the next until one succeeds or none remain. You can load a
|
|
41
|
+
configuration from a JSON file or use the bundled default.
|
|
42
|
+
|
|
43
|
+
This is an example configuration JSON file:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"api_urls": {
|
|
48
|
+
"responses": "https://openrouter.ai/api/v1",
|
|
49
|
+
"decisions": "https://openrouter.ai/api/alpha/decisions"
|
|
50
|
+
},
|
|
51
|
+
"lines": [
|
|
52
|
+
{
|
|
53
|
+
"api": "decisions",
|
|
54
|
+
"model": "typesafe/jev-1.13",
|
|
55
|
+
"parameters": {}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"quantities": [
|
|
59
|
+
{
|
|
60
|
+
"api": "responses",
|
|
61
|
+
"model": "openai/gpt-6-luna",
|
|
62
|
+
"parameters": {
|
|
63
|
+
"max_output_tokens": 16384,
|
|
64
|
+
"reasoning": {
|
|
65
|
+
"effort": "medium"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"api": "responses",
|
|
71
|
+
"model": "openai/gpt-6.1-sol",
|
|
72
|
+
"parameters": {
|
|
73
|
+
"max_output_tokens": 16384,
|
|
74
|
+
"reasoning": {
|
|
75
|
+
"effort": "high"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"claims": [
|
|
81
|
+
{
|
|
82
|
+
"api": "responses",
|
|
83
|
+
"model": "openai/gpt-6-luna",
|
|
84
|
+
"parameters": {
|
|
85
|
+
"max_output_tokens": 16384,
|
|
86
|
+
"reasoning": {
|
|
87
|
+
"effort": "medium"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This configuration sends all requests through OpenRouter. Each attempt's
|
|
96
|
+
`api` selects a URL from `api_urls`: an API root for Responses, or a full
|
|
97
|
+
endpoint for Decisions. There are three stages:
|
|
98
|
+
|
|
99
|
+
- `lines` labels the circular's lines, such as text and tables. It calls
|
|
100
|
+
`typesafe/jev-1.13` through the Decisions API.
|
|
101
|
+
- `quantities` extracts measurements, such as times and fluxes. It first tries
|
|
102
|
+
`openai/gpt-6-luna` with medium reasoning effort. If that fails, it tries
|
|
103
|
+
`openai/gpt-6.1-sol` with high reasoning effort.
|
|
104
|
+
- `claims` identifies what the circular says about its subjects, using
|
|
105
|
+
`openai/gpt-6-luna` with medium reasoning effort with no retry fallback.
|
|
106
|
+
|
|
107
|
+
The Decisions API is supported only for `lines`. All stages can use a
|
|
108
|
+
Responses API.
|
|
109
|
+
|
|
110
|
+
The `parameters` field holds extra options sent to the provider. An empty
|
|
111
|
+
`{}` adds no options. In this example, `max_output_tokens` limits the
|
|
112
|
+
model's output and `reasoning.effort` sets its reasoning effort. Supported
|
|
113
|
+
options depend on the provider and model.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
::: tgcn.Configuration
|
|
117
|
+
options:
|
|
118
|
+
show_root_heading: true
|
|
119
|
+
heading_level: 2
|
|
120
|
+
|
|
121
|
+
::: tgcn.config.Api
|
|
122
|
+
options:
|
|
123
|
+
show_root_heading: true
|
|
124
|
+
heading_level: 2
|