Bug with irregular sampling rate
Created by: artem-basalaev
Hello! I found what looks like a bug in GWpy v2.1.3. Here's how to reproduce. This code works:
import gwpy
import math
import numpy
a=numpy.zeros(500)
t=numpy.zeros(500)
for k in range(500):
t[k]=k/100.
a[k] = math.cos(50*float(k))+ 0.1*math.cos(float(k))
from gwpy.timeseries import TimeSeries
ts = TimeSeries(a, t0 = 1337089517.154, sample_rate = 100)
#ts.plot()
downsampled_ts = ts.resample(10)
downsampled_ts.plot()
downsampled_ts.psd()
And this code results in error AttributeError("This series has an irregular x-axis " "index, so 'dx' is not well defined")
import gwpy
import math
import numpy
a=numpy.zeros(500)
t=numpy.zeros(500)
for k in range(500):
t[k]=k/100.
a[k] = math.cos(50*float(k))+ 0.1*math.cos(float(k))
from gwpy.timeseries import TimeSeries
ts = TimeSeries(a, t0 = 1337089517.154, sample_rate = 100)
#Note this line below is UNCOMMENTED
ts.plot()
downsampled_ts = ts.resample(10)
downsampled_ts.plot()
downsampled_ts.psd()
Note just one line uncommented - to plot the time series, which supposedly should not change anything further on, even if AttributeError is expected in some cases.
P.S.: Sorry if I formatting of this report is wrong (and please let me know why), this is the first time I'm opening an Issue.