Reusable TOMToolkit app to support gravitational wave superevent and other nonlocalized event EM follow-up observations.
Project description
tom_nonlocalizedevents
This reusable TOM Toolkit app supports electromagnetic (EM) follow-up observations of non-localized events: gravitational-wave (GW) superevents, gamma-ray bursts, neutrino events, and X-ray transients. GW events currently have the most support and are ingested from the IGWN alert stream or manually from GraceDB, their skymaps are processed into healpix credible regions, and candidate targets can be matched against those regions.
Requirements
-
PostgreSQLis required to support the healpix MOC volume-map lookups via healpix-alchemy. -
tom-alertstreamsis required to listen to the IGWN alert stream.
Installation
-
Install the package into your TOM environment:
pip install tom-nonlocalizedevents
-
In your project's
settings.py, addtom_nonlocalizedeventstoINSTALLED_APPS. With TOM Toolkit 3's scaffold that looks like:INSTALLED_APPS = TOMTOOKIT_INSTALLED_APPS + [ 'tom_nonlocalizedevents', ]
(
TOMTOOKIT_INSTALLED_APPSis the (misspelled) literal variable name in the TOM Toolkit scaffold — don't "correct" the spelling.) -
Also in
settings.py, add the settings this app reads:# required: the model layer builds Hermes links from this URL HERMES_API_URL = 'https://hermes.lco.global' # optional, shown with their defaults: GRACEDB_API_URL = 'https://gracedb.ligo.org/api/' # for manual GraceDB ingestion SAVE_TEST_ALERTS = True # ingest test events (event ids beginning with 'M')?
-
Run
python manage.py migrateto create the tom_nonlocalizedevents models. -
Optionally, set environment variables to tune the SQLAlchemy engine used for the healpix lookups:
Env variable Description Default SA_DB_CONNECTION_URLPostgres connection URL for SQLAlchemy built from the Django defaultdatabasePOOL_SIZEConnections kept open in the pool (docs) 5 MAX_OVERFLOWConnections allowed in pool "overflow" (docs) 10 CREDIBLE_REGION_PROBABILITIESJSON list of credible-region probabilities checked for each candidate '[0.25, 0.5, 0.75, 0.9, 0.95]'
Features
-
The event list page (
/nonlocalizedevents/): lazy-loading tabs — All, Gravitational Wave (the landing tab), Gamma-ray Burst, Neutrino, X-ray Transient, Unknown — each with its own sortable, filterable htmx table. The GW tab carries the science columns and filters (1/FAR, most-likely classification, distance, HasNS, HasRemnant); the other event types currently show a generic table awaiting type-specific columns. -
Event detail pages, resolved per event type (type-specific templates with a generic fallback), showing the event's sequences, localization areas and distances, and external links (Hermes, GraceDB, Treasure Map).
-
Manual GraceDB ingestion: the Ingest event from GraceDB button on the list page (login required), or the equivalent management command:
python manage.py ingest_LVK_event S230518h
-
REST API endpoints under
/api/:nonlocalizedevents/,eventlocalizations/, andeventcandidates/(with bulk-create and PATCH support for candidates).
Configuration to ingest GW events from the IGWN alert stream
To ingest GW events automatically, install and configure
tom_alertstreams in your TOM
(tom_alertstreams is intentionally not a dependency of this app — it is only
needed for stream listening). Point the igwn.gwalert topic at this app's handler:
ALERT_STREAMS = [
{
'ACTIVE': True,
'NAME': 'tom_alertstreams.alertstreams.hopskotch.HopskotchAlertStream',
'OPTIONS': {
'URL': 'kafka://kafka.scimma.org/',
'USERNAME': os.getenv('SCIMMA_AUTH_USERNAME'),
'PASSWORD': os.getenv('SCIMMA_AUTH_PASSWORD'),
'TOPIC_HANDLERS': {
'igwn.gwalert':
'tom_nonlocalizedevents.alertstream_handlers.igwn_event_handler.handle_igwn_message',
},
},
},
]
Then run the stream listener: python manage.py readstreams.
Development
Extending for an event type
The per-event-type tabs and detail pages are extension points. To implement an event type (e.g. gamma-ray bursts), add its type-specific columns, filters, and detail content to its stub classes and template:
tables.py—GammaRayBurstEventTable: add type-specific columns.filters.py—GammaRayBurstEventFilterSet: add type-specific filters.templates/tom_nonlocalizedevents/detail/grb_detail.html— extend the generic detail page with type-specific content.
Running the tests
The test suite needs a reachable PostgreSQL. The repository's docker-compose.yml provides one whose credentials match the test harness defaults:
docker compose up -d
python tom_nonlocalizedevents/tests/run_tests.py # from the repository root
Pointing a TOM at the docker-compose database
When developing a TOM (or developing tom_nonlocalizedevents in the context
of a TOM), this Django DATABASES configuration dictionary matches the
PostgreSQL database configured by the docker-compose.yml in this repo. Put it in settings.py or local_settings.py.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'tom_nonlocalizedevents', # POSTGRES_DB in docker-compose.yml
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
},
}
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 tom_nonlocalizedevents-1.0.0.tar.gz.
File metadata
- Download URL: tom_nonlocalizedevents-1.0.0.tar.gz
- Upload date:
- Size: 60.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ccdd0883e5cf078905de9f929c05f166904a521649850d47443954f404a6822
|
|
| MD5 |
62b7df1b94493ab623dee0856a9cf15d
|
|
| BLAKE2b-256 |
4b0ce1022999dc7d7fcf84b17c7ee77a60b7b463827dd288752ae34cbef50c9b
|
Provenance
The following attestation bundles were made for tom_nonlocalizedevents-1.0.0.tar.gz:
Publisher:
pypi-release.yml on TOMToolkit/tom_nonlocalizedevents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tom_nonlocalizedevents-1.0.0.tar.gz -
Subject digest:
9ccdd0883e5cf078905de9f929c05f166904a521649850d47443954f404a6822 - Sigstore transparency entry: 2219973415
- Sigstore integration time:
-
Permalink:
TOMToolkit/tom_nonlocalizedevents@209e993030df36a84aad262e2cf77e078d85a050 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/TOMToolkit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@209e993030df36a84aad262e2cf77e078d85a050 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tom_nonlocalizedevents-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tom_nonlocalizedevents-1.0.0-py3-none-any.whl
- Upload date:
- Size: 84.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48beef287a41e8071fea04883fdbf892cfdc6b0538433d0156a29ac0aa0f8223
|
|
| MD5 |
d0ab53a79bd1725f5e44a98d66c21bfa
|
|
| BLAKE2b-256 |
c18f0a847f3b091d1ea38dd5c3f8f4e4a9b14905841dea45c17b37fb6b217881
|
Provenance
The following attestation bundles were made for tom_nonlocalizedevents-1.0.0-py3-none-any.whl:
Publisher:
pypi-release.yml on TOMToolkit/tom_nonlocalizedevents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tom_nonlocalizedevents-1.0.0-py3-none-any.whl -
Subject digest:
48beef287a41e8071fea04883fdbf892cfdc6b0538433d0156a29ac0aa0f8223 - Sigstore transparency entry: 2219973443
- Sigstore integration time:
-
Permalink:
TOMToolkit/tom_nonlocalizedevents@209e993030df36a84aad262e2cf77e078d85a050 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/TOMToolkit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@209e993030df36a84aad262e2cf77e078d85a050 -
Trigger Event:
release
-
Statement type: