Plotting observing segments for O1#

The data from the full Observing Run 1 (O1) have been released by GWOSC.

This example demonstrates how to download segment information into a DataQualityFlag, and then plot them.

All we need to do is import the DataQualityFlag object, and then call the DataQualityFlag.fetch_open_data() method to query for, and download the segments for all of O1:

from gwpy.segments import DataQualityFlag
h1segs = DataQualityFlag.fetch_open_data(
    "H1_DATA",
    "Sep 12 2015",
    "Jan 19 2016",
)

We can then generate a plot of the times when LIGO-Hanford was operating:

plot = h1segs.plot(color="gwpy:ligo-hanford")
plot.show()
open data

That’s a lot of segments. We can pare-down the list a little to display only the segments from the first month of the run:

h1month1 = DataQualityFlag.fetch_open_data(
    "H1_DATA",
    "Sep 12 2015",
    "Oct 12 2015",
)
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/checkouts/latest/examples/segments/open-data.py", line 55, in <module>
    h1month1 = DataQualityFlag.fetch_open_data(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/checkouts/latest/gwpy/segments/flag.py", line 575, in fetch_open_data
    active = timeline.get_segments(flag, start, end, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/gwosc/timeline.py", line 59, in get_segments
    return list(
           ^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/gwosc/api/v2.py", line 386, in fetch_segments
    yield from produce_fetched_objects(segments_url, session=session)
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/gwosc/api/v2.py", line 188, in produce_fetched_objects
    current_page = fetch_json(next_page, session=sess)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/gwosc/api/v2.py", line 160, in fetch_json
    resp = _fetch_json(get_func, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/tenacity/__init__.py", line 331, in wrapped_f
    return copy(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/tenacity/__init__.py", line 470, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/tenacity/__init__.py", line 371, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/tenacity/__init__.py", line 393, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/tenacity/__init__.py", line 473, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/gwosc/api/v2.py", line 112, in _fetch_json
    return get_func(url, headers=CLIENT_HEADERS, timeout=TIMEOUT, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/requests/sessions.py", line 605, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/requests/sessions.py", line 592, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/requests/sessions.py", line 706, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/gwpy/conda/latest/lib/python3.12/site-packages/requests/adapters.py", line 660, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

We can also download the LIGO-Livingston segments from the same period and display them alongside, as well as those segments during which both interferometers were operating at the same time (see Intersection (&) for more details on this use of the & operator):

l1month1 = DataQualityFlag.fetch_open_data(
    "L1_DATA",
    "Sep 12 2015",
     "Oct 12 2015",
)
bothon = h1month1 & l1month1
plot = h1month1.plot()
ax = plot.gca()
ax.plot(l1month1)
ax.plot(bothon, label="Both")
plot.show()

Total running time of the script: (0 minutes 5.205 seconds)

Gallery generated by Sphinx-Gallery