Classify a Trigger With Gravity Spy

Introduction

Gravity Spy utilizes a trained convolutional nueral net (CNN) to classify excess noise events in gravitational wave (GW) detector data. Specifically, the CNN is trained on gwpy.timeseries.TimeSeries.q_transform of graviatational wave data which are a specialized form of spectrograms.

Below we will show what these spectrograms look like and how to use Classify a Trigger With Gravity Spy to classify a known instance of excess noise in GW data.

The excess noise event

In the following we demonstrate an example of the Scratchy excess noise event. From here on out, we will refer to these excess noise events as glitches.

In [1]: from gwpy.timeseries import TimeSeries

In [2]: from gravityspy.classify import classify

In [3]: timeseries = TimeSeries.read('data/timeseries/scratchy_timeseries_test.h5')

In [4]: event_time = 1127700030.877928972

In [5]: results = classify(event_time=event_time, channel_name='L1:GDS-CALIB_STRAIN',
   ...:                    path_to_cnn='../models/multi_view_classifier.h5',
   ...:                    timeseries=timeseries)
   ...: 

In [6]: print(results)
 1080Lines  1400Ripples Air_Compressor ... ml_label ml_confidence    q_value   
----------- ----------- -------------- ... -------- ------------- -------------
9.41278e-07 6.72757e-09      1.156e-08 ... Scratchy      0.999717 5.65685424949

Breaking down classify

It is best here to break down the steps in the above. The process goes as follows:

  • perform the q_transform around the provided event time
  • plot four different durations or views of the q_transform
  • utilize the four views of the image to create a single multiview image to be passed to the CNN
In [7]: from gravityspy.utils import utils

In [8]: config = utils.GravitySpyConfigFile()

In [9]: specsgrams, q_value = utils.make_q_scans(event_time=event_time, timeseries=timeseries, config=config)

In [10]: print(specsgrams[0], q_value)
(<Spectrogram([[ 0.62872391,  0.62872391,  0.33236706, ...,
                0.77925605,  0.77925605,  0.77925605],
              [ 0.58244376,  0.58244376,  0.29672182, ...,
                0.274742  ,  0.274742  ,  0.274742  ],
              [ 0.54079268,  0.54079268,  0.26722797, ...,
                1.29703917,  1.29703917,  1.29703917],
              ..., 
              [ 3.42043208,  3.42043208,  3.03072497, ...,
                0.03701189,  0.03701189,  0.03701189],
              [ 3.44803694,  3.44803694,  3.07957551, ...,
                1.00338999,  1.00338999,  1.00338999],
              [ 3.47218412,  3.47218412,  3.12661063, ...,
                3.8507399 ,  3.8507399 ,  3.8507399 ]]
             unit=Unit(dimensionless),
             name=None,
             epoch=<Time object: scale='utc' format='gps' value=1127700030.63>,
             channel=None,
             x0=<Quantity 1127700030.6279297 s>,
             dx=<Quantity 0.002 s>,
             xindex=<Index [  1.12770003e+09,  1.12770003e+09,  1.12770003e+09,...,
                              1.12770003e+09,  1.12770003e+09,  1.12770003e+09] s>,
             y0=<Quantity 10.0 Hz>,
             dy=<Quantity 0.5 Hz>,
             yindex=<Index [   10. ,   10.5,   11. ,...,  2046.5, 2047. , 2047.5] Hz>)>, 5.65685424949238)

Now we plot all 4 of the spectrograms as png

In [11]: from gravityspy.plot import plot_qtransform

In [12]: plot_time_ranges = config.plot_time_ranges

In [13]: plot_normalized_energy_range = config.plot_normalized_energy_range

In [14]: detector_name = 'L1'

In [15]: ind_fig_all, super_fig = plot_qtransform(specsgrams,
   ....:                                          plot_normalized_energy_range,
   ....:                                          plot_time_ranges,
   ....:                                          detector_name,
   ....:                                          event_time)
   ....: 

In [16]: super_fig
Out[16]: <gwpy.plot.plot.Plot at 0x11f2a8cd0>
classify/../_build/html/_static/plot-scratchy-all-durations.png