import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
import h5py
glitch_file_name = 'O3a_catalog_glitch_rate_data.hdf'
glitch_file = h5py.File(glitch_file_name, 'r')
print(glitch_file.keys())
print(glitch_file['H1'].keys())
H1_O2_median = glitch_file['H1/O2_median'][()]
H1_O3a_median = glitch_file['H1/O3a_median'][()]
H1_glitch_rate = glitch_file['H1/O3a_gltich_rate'][:]
H1_times = glitch_file['H1/O3a_times'][:]
plot = plt.figure(figsize=[10,4])
ax = plot.gca()
ax.scatter(H1_times,H1_glitch_rate,color='red',label='O3a glitch rate')
ax.axhline(H1_O2_median,label='O2 median rate',color='black',ls=':')
ax.axhline(H1_O3a_median,label='O3a median rate',color='black',ls='--')
ax.set_yscale('log')
ax.set_ylim(3e-2,5e1)
ax.set_xlabel('GPS time')
ax.set_ylabel('Glitch rate [per hour]')
ax.legend()
plot.show()
glitch_file.close()