<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/opt/local/bin/python

"""Plot the all-O2 range
"""

import numpy as np
import h5py
import scipy


import matplotlib as mpl
from matplotlib import use
use('agg')  # nopep8


from gwpy.plot import Plot
from gwpy.timeseries import TimeSeries

rc_params = {'backend': 'pdf',
             'axes.labelsize': 20,
             'axes.titlesize': 20,
             'font.size': 20,
             'legend.fontsize': 20,
             'xtick.labelsize': 20,
             'ytick.labelsize': 20,
             'font.family': 'serif',
             'font.sans-serif': ['Bitstream Vera Sans'],
             'font.serif': ['Times New Roman'],
             'text.usetex':True
            }

mpl.rcParams.update(rc_params)

###__author__ = "Duncan Macleod &lt;duncan.macleod@ligo.org&gt;"
### heavily and inelegantly modified by brian.oreilly@ligo.org due to persistent 
### issues running original script.

#mpl.rc('axes', labelsize=20, edgecolor='k')
mpl.rc('axes', edgecolor='k')
#mpl.rc('xtick', labelsize=20)
#mpl.rc('ytick', labelsize=20)
#mpl.rc('font', family='Times New Roman')

#datafile = (
#    '/Users/irish/IFO/cbc-catalog/rangeplot/data/full.h5')
datafile='./full.h5'

data5 = h5py.File(datafile,'r')

h1 = data5.get('/H1:DCH-CLEAN_STRAIN_C02_RANGE_1_4_1_4')
l1 = data5.get('/L1:DCH-CLEAN_STRAIN_C02_RANGE_1_4_1_4')
v1 = data5.get('/V1:Hrec_hoft_V1O2Repro2A_16384Hz_RANGE_1_4_1_4')

h1.values = np.array(h1)
h1t = (
      range(int(h1.attrs['x0']),int(h1.attrs['x0']+h1.attrs['dx']*len(h1.values)),int(h1.attrs['dx'])))
h1.times = np.array(h1t)

h1.values = h1.values[0::30]
h1.times =  h1.times[0::30]

l1.values = np.array(l1)
l1t = (
      range(int(l1.attrs['x0']),int(l1.attrs['x0']+l1.attrs['dx']*(len(l1.values))),int(l1.attrs['dx'])))
l1.times = np.array(l1t)

l1.values = l1.values[0::30]
l1.times =  l1.times[0::30]

v1.values = np.array(v1)
v1t = (
      range(int(v1.attrs['x0']),int(v1.attrs['x0']+v1.attrs['dx']*(len(v1.values))),int(v1.attrs['dx'])))
v1.times = np.array(v1t)

v1.values = v1.values[0::30]
v1.times =  v1.times[0::30]

plot = Plot(figsize=(10, 6.18))
###plot = Plot()
ax = plot.gca()
ax.set_autoscalex_on(False)

kw = {'marker': '.', 'markersize': 2, 'linestyle': ''}

for i, (data, label) in enumerate([
        (h1, 'LIGO-Hanford'),
        (l1, 'LIGO-Livingston'),
        (v1, 'Virgo'),
]):

    color = 'gwpy:{}'.format(label.lower())
    ax.plot([0], label=label, color=color)  # dummy for labelling
    ax.plot(data.times, np.ma.masked_where(data.values == 0., data.values),
            color=color, zorder=-i, **kw)

ax.set_xlim(1164556817, 1187733618)
ax.set_xscale('weeks', epoch=1164556817)
#ax.set_xlabel('Time [weeks] from 2016-11-30 16:00 UTC')
ax.set_xlabel('Weeks from Start of O2')

ax.set_ybound(lower=0)
ax.set_ylabel('BNS Range [Mpc]')
ax.grid(color='darkgrey', linewidth=1, linestyle='--')
ax.legend(loc='lower right', bbox_to_anchor=(1., 1.), borderaxespad=0,
          frameon=False, ncol=3, fontsize=18, linewidth=18)

plot.save('o2-range.png',dpi=250)
plot.save('o2-range.pdf',dpi=250)
</pre></body></html>