When is a timeseries a time series?

Working on Challenge 2:
Variable “hdata” is timeseries, but not!?

Here is code:

# Challenge 2 (2 points) -- Rookie
# Signal in colored, Gaussian noise.

# Use the data file "challenge2.gwf", with channel name "H1:CHALLENGE2"
# The data contain a BBH signal with m1=m2=30 solar masses, spin = 0.

import gwpy
from gwpy.timeseries import TimeSeries
import numpy
import pylab
%matplotlib inline

hdata = TimeSeries.read("challenge2.gwf", "H1:CHALLENGE2")
print(f"time series = {hdata}")     
print( "\n***************************")
print(f"datatype for variable hdata = {type(hdata)}")
print( "***************************")

print(f"          delta_t = {hdata.dt}")
print(f"number of samples = {len(hdata)}")
print(f"     elapsed time = {hdata.dt*(len(hdata)-2)}")
print(f"    sampling rate = {1/hdata.dt}")
hdata.plot()
import pylab
from pycbc.catalog import Merger
from pycbc.filter import resample_to_delta_t, highpass
##################################################
# Preconditioning the Data
###################################################
strain = highpass(hdata, 15.0)

Here is stuff that worked:

time series = [ 1.16850460e-22 -6.44996982e-22 -3.20366127e-22 ...
 -1.91886478e-23 -2.10989354e-22  2.30287965e-22] ct

***************************
datatype for variable hdata = <class 'gwpy.timeseries.timeseries.TimeSeries'>
***************************
          delta_t = 0.000244140625 s
number of samples = 262144
     elapsed time = 63.99951171875 s
    sampling rate = 4096.0 1 / s

Here is failure info:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [5], in <cell line: 30>()
     26 from pycbc.filter import resample_to_delta_t, highpass
     27 ##################################################
     28 # Preconditioning the Data
     29 ###################################################
---> 30 strain = highpass(hdata, 15.0)

File ~/.local/lib/python3.9/site-packages/pycbc/filter/resample.py:302, in highpass(timeseries, frequency, filter_order, attenuation)
    272 """Return a new timeseries that is highpassed.
    273 
    274 Return a new time series that is highpassed above the `frequency`.
   (...)
    298 
    299 """
    301 if not isinstance(timeseries, TimeSeries):
--> 302     raise TypeError("Can only resample time series")
    304 if timeseries.kind is not 'real':
    305     raise TypeError("Time series must be real")

TypeError: Can only resample time series

Any help is appreciated.

forgot “Timeseries.” wish I could delete this post

@buyukcam Hi! It looks like you read in the data using gwpy, but then tried to use a high pass filter from pycbc.

gwpy and pycbc both have an object they call timeseries, but they are not the same object! In general, you’ll want to pick one package at a time to use. Or, to say it a different way, if you read in the data with gwpy, then you should also use gwpy to process and plot the data.

Good luck!

Thanks, Jonah! I’m going through the tutorials again in a more organized manner.
Thanks again!! (great relief)