from gwpy.timeseries import TimeSeriesDict
import matplotlib
%matplotlib inline
# channel and file information for event S190924h
channels = ['L1:DCS-CALIB_STRAIN_CLEAN_C01',
'L1:DCS-CALIB_STRAIN_CLEAN_C01_glitch',
'L1:DCS-CALIB_STRAIN_CLEAN_C01_T1700406_v4']
data_dict = TimeSeriesDict.read('L-L1_HOFT_C01_T1700406_v4-1253322752-4096.gwf',channels)
print(data_dict['L1:DCS-CALIB_STRAIN_CLEAN_C01'])
gps_glitch = 1253326740.85
data_dict_cropped = data_dict.copy().crop(gps_glitch-0.2,gps_glitch+0.2)
# plot all data in the frame file
plot = data_dict_cropped.plot()
ax = plot.gca()
ax.legend()
ax.set_ylabel('[strain]')
plot.show()
# plot only the glitch model
plot = data_dict_cropped['L1:DCS-CALIB_STRAIN_CLEAN_C01_glitch'].plot(label='L1:DCS-CALIB_STRAIN_CLEAN_C01_glitch')
ax = plot.gca()
ax.legend()
ax.set_ylabel('[strain]')
plot.show()
# plot a spectrogram the original data using the q-transorm
qscan = data_dict['L1:DCS-CALIB_STRAIN_CLEAN_C01']\
.crop(gps_glitch-32,gps_glitch+32)\
.q_transform(outseg=(gps_glitch-4, gps_glitch+4))
plot = qscan.plot(figsize=(12,4))
ax = plot.gca()
ax.set_xscale('seconds')
ax.set_yscale('log')
ax.set_ylim(10, 500)
ax.set_ylabel('Frequency [Hz]')
ax.grid(True, axis='y', which='both')
ax.colorbar(cmap='viridis', label='Normalized energy',vmin=0,vmax=25)
plot.show()
# plot a spectrogram of the data with the glitch subtracted using the q-transorm
qscan = data_dict['L1:DCS-CALIB_STRAIN_CLEAN_C01_T1700406_v4']\
.crop(gps_glitch-32,gps_glitch+32)\
.q_transform(outseg=(gps_glitch-4, gps_glitch+4))
plot = qscan.plot(figsize=(12,4))
ax = plot.gca()
ax.set_xscale('seconds')
ax.set_yscale('log')
ax.set_ylim(10, 500)
ax.set_ylabel('Frequency [Hz]')
ax.grid(True, axis='y', which='both')
ax.colorbar(cmap='viridis', label='Normalized energy',vmin=0,vmax=25)
plot.show()