Skip to content

`Spectrogram` slicing produces incorrect `FrequencySeries` metadata

Created by: pmeyers279

When I try to slice a Spectrogram to pull out a single FrequencySeries the metadata of the resulting FrequencySeries is incorrect. Slicing along the other axis works as expected. Test example from a notebook is below:

In[116]: from gwpy.spectrogram import Spectrogram
In[117]: import numpy as np
In[118]: test = Spectrogram(np.zeros((2,2)), times=np.arange(2)*10, frequencies=np.arange(2))
In[119]: test
Out[119]: 
<Spectrogram([[0.,0.],
              [0.,0.]]
             unit=Unit(dimensionless),
             name=None,
             epoch=<Time object: scale='utc' format='gps' value=0.0>,
             channel=None,
             x0=<Quantity 0. s>,
             dx=<Quantity 10. s>,
             xindex=<Index [ 0., 10.] s>,
             y0=<Quantity 0. Hz>,
             dy=<Quantity 1. Hz>,
             yindex=<Index [0., 1.] Hz>)>
In[120]:  test[0,:]
Out[120]: 
<FrequencySeries([0.,0.]
                 unit=Unit(dimensionless),
                 f0=<Quantity 0. s>,
                 df=<Quantity 10. s>,
                 epoch=None,
                 name=None,
                 channel=None,
                 frequencies=None)>
In[121]: test[:,0]
Out[121]: 
<TimeSeries([0.,0.]
            unit=Unit(dimensionless),
            t0=<Quantity 0. s>,
            dt=<Quantity 10. s>,
            name=None,
            channel=None)>