Add interface to event portal filtered queries
This is to propose adding a new method in api.py
to request filtered queries like explained here: https://www.gw-openscience.org/apidocs/#event5.
And also a higher level method in datasets
to do basically the same, but just returning the names.
Proposed API:
api.fetch_filtered_events_json(select, host=DEFAULT_URL)
datasets.query_events(select)
Example:
-
api.fetch_filtered_events_json
>>> from gwosc import api >>> api.fetch_filtered_events_json(select=["mass-1-source < 5", "mass-2-source < 10", "luminosity-distance in (10, 100)"]) { "events": { "GW170817-v3": { "GPS": 1187008882.4, "catalog.shortName": "GWTC-1-confident", "chi_eff": 0.0, "chi_eff_lower": -0.01, "chi_eff_unit": "", ... "version": 3 } } }
This will internally call
/eventapi/json/query/show?max-mass-1-source=5&max-mass-2-source=10&min-luminosity-distance=10&max-luminosity-distance=100
-
datasets.query_events
>>> from gwosc import datasets >>> datasets.query_events.(select=["mass-1-source < 5", "mass-2-source < 10", "luminosity-distance in (10, 100)"]) ["GW170817-v3"]
This will internally call
/eventapi/json/query/show?max-mass-1-source=5&max-mass-2-source=10&min-luminosity-distance=10&max-luminosity-distance=100
This borrows the syntax used in GWpy.EventTable
for filtering, with the idea that eventually, the filtering that EventTable
does, can be done on gwosc.org's backend.