gwexpy.timeseries.TimeSeries

class gwexpy.timeseries.TimeSeries(data: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], *args: Any, **kwargs: Any)[source]

Bases: PlotMixin, TimeSeriesInteropMixin, TimeSeriesAnalysisMixin, TimeSeriesResamplingMixin, TimeSeriesSignalMixin, SignalAnalysisMixin, TimeSeriesSpectralMixin, StatisticsMixin, FittingMixin, PhaseMethodsMixin, TimeSeriesCore

Extended TimeSeries with all gwexpy functionality.

This class combines functionality from multiple modules: - Core operations: is_regular, _check_regular, tail, crop, append, find_peaks - Spectral transforms: fft, psd, cwt, laplace, etc. - Signal processing: hilbert, mix_down, xcorr, etc. - Analysis: impute, standardize, rolling_*, etc. - Interoperability: to_pandas, to_torch, to_xarray, etc.

Inherits from gwpy.timeseries.TimeSeries for full compatibility.

__init__()

Methods

__init__()

abs(**kwargs)

Return the absolute value of the data in this Array.

all([axis, out])

angle([unwrap, deg])

Alias for phase(unwrap=unwrap, deg=deg).

any([axis, out])

append(other, *[, inplace, pad, gap, resize])

Append another TimeSeries (GWpy-compatible), returning gwexpy TimeSeries.

ar([p])

Fit an AutoRegressive AR(p) model.

argmax([axis, out, keepdims])

argmin([axis, out, keepdims])

argpartition(kth[, axis, kind, order])

Returns the indices that would partition this array.

argsort([axis, kind, order])

arima([order, seasonal_order, auto])

Fit an ARIMA or SARIMAX model to this TimeSeries.

arma([p, q])

Fit an ARMA(p, q) model.

asd(*args, **kwargs)

asfreq(rule[, method, fill_value, origin, ...])

Reindex the TimeSeries to a new fixed-interval grid associated with the given rule.

astype(dtype[, order, casting, subok, copy])

Copy of the array, cast to a specified type.

auto_coherence(dt[, fftlength, overlap, window])

Calculate the coherence between this series and a shifted copy of itself.

average_fft([fftlength, overlap, window])

Compute the averaged one-dimensional DFT of this TimeSeries.

bandpass(flow, fhigh[, gpass, gstop, fstop, ...])

Filter this TimeSeries with a band-pass filter.

baseband(*[, phase, f0, fdot, fddot, ...])

Demodulate the TimeSeries to baseband with optional lowpass and resampling.

byteswap([inplace])

Swap the bytes of the array elements

cepstrum([kind, window, detrend, eps, fft_mode])

Compute the cepstrum of the time series.

check_compatible(other[, casting, ...])

Check whether this Series and other are compatible.

choose(choices[, out, mode])

clip([min, max, out])

Return an array whose values are limited to [min, max].

coherence(*args, **kwargs)

coherence_spectrogram(other, stride[, ...])

Calculate the coherence spectrogram between this TimeSeries and other.

compress(condition[, axis, out])

Return selected slices of this array along given axis.

conj()

Complex-conjugate all elements.

conjugate()

Return the complex conjugate, element-wise.

convolve(fir[, window])

Convolve this TimeSeries with an FIR filter using the overlap-save method.

copy([order])

Return a copy of the array.

correlate(mfilter[, window, detrend, ...])

Cross-correlate this TimeSeries with another signal.

correlation(other[, method])

Calculate correlation coefficient with another TimeSeries.

crop([start, end, copy])

Crop this series to the given GPS start and end times.

csd(other, *args, **kwargs)

csd_spectrogram(other, stride[, fftlength, ...])

Calculate the cross spectral density spectrogram with other.

cumprod([axis, dtype, out])

Return the cumulative product of the elements along the given axis.

cumsum([axis, dtype, out])

Return the cumulative sum of the elements along the given axis.

cwt([wavelet, widths, frequencies, window, ...])

Compute the Continuous Wavelet Transform (CWT).

dct([type, norm, window, detrend])

Compute the Discrete Cosine Transform (DCT).

decompose([bases])

Generates a new Quantity with the units decomposed.

degree([unwrap])

Calculate the phase angle of the TimeSeries in degrees.

demodulate(f[, stride, phase, deg, exp])

Compute the average magnitude and phase of the TimeSeries at a given frequency (GWpy-compatible).

detrend([detrend])

Remove the trend from this TimeSeries.

diagonal([offset, axis1, axis2])

Return specified diagonals.

diff([n, axis])

Calculate the n-th order discrete difference along given axis.

distance_correlation(other)

Calculate Distance Correlation (dCor).

dot(b[, out])

dump(file)

Not implemented, use .value.dump() instead.

dumps()

Not implemented, use .value.dumps() instead.

ediff1d([to_end, to_begin])

emd(*[, method, max_imf, sift_max_iter, ...])

Decompose the TimeSeries using Empirical Mode Decomposition (EMD).

envelope(*args, **kwargs)

Compute the envelope (amplitude) of the TimeSeries via Hilbert transform.

fastmi(other, **kwargs)

Estimate mutual information using a fast copula/probit + FFT-based estimator.

fetch(channel, start, end, *[, host, port, ...])

Fetch data from NDS.

fetch_open_data(ifo, start, end[, ...])

Fetch open-access data from GWOSC.

fft([nfft, mode, pad_mode, pad_left, ...])

Compute the Discrete Fourier Transform (DFT).

fftgram(fftlength[, overlap, window])

Calculate the Fourier-gram of this TimeSeries.

fill(value)

filter(filt, *[, analog, unit, ...])

Filter this TimeSeries with an IIR or FIR filter.

find(channel, start, end, *[, observatory, ...])

Find and return data for multiple channels using GWDataFind.

find_gates([tzero, whiten, threshold, ...])

Identify points that should be gates using a provided threshold.

find_peaks([height, threshold, distance, ...])

Find peaks in the series.

fit(model[, x_range, sigma, p0, limits, fixed])

Fit the data to a model using iminuit.

fit_arima([order])

Fit ARIMA model to the series.

flatten([order])

Return a copy of the array collapsed into one dimension.

from_arrakis(series, *[, copy])

Construct a new series from an arrakis.Series object.

from_astropy_timeseries(ap_ts[, column, unit])

Create from astropy.timeseries.TimeSeries.

from_control(response, **kwargs)

Create TimeSeries from python-control TimeResponseData.

from_cupy(array, *[, t0, dt, unit])

Create from cupy array.

from_dask(array, *[, t0, dt, unit, compute])

Create from dask.array.

from_dict(data_dict)

Create TimeSeries from a dictionary.

from_hdf5_dataset(group, path)

Read from HDF5 group/dataset.

from_jax(array, *[, t0, dt, unit])

Create from jax array.

from_json(json_str)

Create TimeSeries from a JSON string.

from_lal(lalts, *[, copy])

Generate a new TimeSeries from a LAL TimeSeries of any type.

from_mne(raw, channel, *[, unit])

Create TimeSeries from mne.io.Raw.

from_nds2_buffer(buffer, *[, scaled, copy])

Construct a new series from an nds2.buffer object.

from_netcdf4(ds, var_name)

Read from netCDF4 Dataset.

from_obspy(tr, *[, unit, name_policy])

Create TimeSeries from obspy.Trace.

from_obspy_trace(tr, *[, unit, name_policy])

Alias for from_obspy().

from_pandas(series, *[, unit, t0, dt])

Create TimeSeries from pandas.Series.

from_polars(data[, times, unit])

Create TimeSeries from polars.DataFrame or polars.Series.

from_pycbc(pycbcseries, *[, copy])

Convert a pycbc.types.timeseries.TimeSeries into a TimeSeries.

from_pydub(seg, *[, unit])

Create from pydub.AudioSegment.

from_pyroomacoustics_mic_signals(room, *[, ...])

Create from pyroomacoustics simulated microphone signals.

from_pyroomacoustics_rir(room, *[, source, ...])

Create from pyroomacoustics room impulse responses.

from_pyroomacoustics_source(room, *[, ...])

Create from a pyroomacoustics sound source signal.

from_pyspice_transient(analysis, *[, node, ...])

Create from a PySpice TransientAnalysis.

from_root(obj[, return_error])

Create TimeSeries from ROOT TGraph or TH1.

from_simpeg(data_obj, **kwargs)

Create TimeSeries from SimPEG Data object.

from_skrf_impulse_response(ntwk, *[, ...])

Create from a scikit-rf Network impulse response.

from_skrf_step_response(ntwk, *[, ...])

Create from a scikit-rf Network step response.

from_sqlite(conn, series_id)

Load from sqlite3 database.

from_tensorflow(tensor, *[, t0, dt, unit])

Create from tensorflow.Tensor.

from_torch(tensor, *[, t0, dt, unit])

Create from torch.Tensor.

from_xarray(da, *[, unit])

Create TimeSeries from xarray.DataArray.

from_zarr(store, path)

Read from Zarr array.

gate([tzero, tpad, whiten, threshold, ...])

Remove high amplitude peaks from data using inverse Tukey window.

gauch(fftlength[, window, stride, overlap])

Compute GauCh (Modified KS test) for non-Gaussianity detection.

getfield(dtype[, offset])

Returns a field of the given array as a certain type.

granger_causality(other[, maxlag, test, verbose])

Check if 'other' Granger-causes 'self'.

heterodyne(phase[, stride, singlesided])

Compute the average magnitude and phase of the TimeSeries after heterodyning with a given phase series.

hht(*[, emd_method, emd_kwargs, ...])

Perform Hilbert-Huang Transform (HHT) on the TimeSeries.

highpass(frequency[, gpass, gstop, fstop, ...])

Filter this TimeSeries with a high-pass filter.

hilbert([pad, pad_mode, pad_value, ...])

Compute the analytic signal via Hilbert transform.

hilbert_analysis(*[, unwrap_phase, ...])

Perform Hilbert analysis to extract instantaneous amplitude, phase, and frequency.

histogram([bins, range, weights, density])

Compute a histogram of the values in this TimeSeries.

hurst(**kwargs)

Compute Hurst exponent.

impute(*[, method, limit, axis, max_gap])

Impute missing values.

inject(other, *[, inplace])

Add two compatible Series along their shared x-axis values.

insert(obj, values[, axis])

Insert values along the given axis before the given indices and return a new ~astropy.units.Quantity object.

instantaneous_frequency([unwrap, smooth])

Compute the instantaneous frequency of the TimeSeries.

instantaneous_phase([deg, unwrap])

Compute the instantaneous phase of the TimeSeries via Hilbert transform.

is_compatible(other)

Check whether this series and other have compatible metadata.

is_contiguous(other[, tol])

Check whether other is contiguous with self.

item(*args)

Copy an element of an array to a scalar Quantity and return it.

itemset(*args)

ktau(other)

Calculate Kendall's Rank Correlation Coefficient.

kurtosis([axis, fisher, nan_policy])

Compute the kurtosis (Fisher or Pearson) of the data.

laplace(*[, sigma, frequencies, t_start, ...])

Compute the Laplace Transform.

local_hurst(window, **kwargs)

Compute local Hurst exponent over a sliding window.

lock_in([f0, phase, fdot, fddot, ...])

Perform lock-in amplification (demodulation + filtering/averaging).

lowpass(frequency[, gpass, gstop, fstop, ...])

Filter this TimeSeries with a Butterworth low-pass filter.

ma([q])

Fit a Moving Average MA(q) model.

mask([deadtime, flag, query_open_data, ...])

Mask portions of this TimeSeries that fall within a given list of segments.

max([axis, out, keepdims, initial, where])

mean([axis, dtype, out, keepdims, where])

median([axis, out, overwrite_input, keepdims])

Compute the median.

mic(other[, alpha, c, est])

Calculate Maximal Information Coefficient (MIC) using minepy.

min([axis, out, keepdims, initial, where])

mix_down(*[, phase, f0, fdot, fddot, ...])

Mix the TimeSeries with a complex oscillator.

newbyteorder([new_order])

Return the array with the same data viewed with a different byte order.

nonzero()

Return the indices of the elements that are non-zero.

notch(frequency[, type, filtfilt])

Notch out a frequency in this TimeSeries.

override_unit(unit[, parse_strict])

Reset the unit of these data.

pad(pad_width, **kwargs)

Pad this series to a new size.

partial_correlation(other, *[, controls, method])

Calculate partial correlation between self and other, controlling for controls.

partition(kth[, axis, kind, order])

Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array.

pcc(other)

Calculate Pearson Correlation Coefficient.

phase([unwrap, deg])

Calculate the phase of the data.

plot(**kwargs)

Plot this object using gwexpy.plot.Plot.

prepend(other, *[, inplace, gap, pad, resize])

Connect another series onto the start of the current one.

prod([axis, dtype, out, keepdims, initial, ...])

Return the product of the array elements over the given axis

psd(*args, **kwargs)

ptp([axis, out, keepdims])

Peak to peak (maximum - minimum) value along a given axis.

put(indices, values[, mode])

q_gram([qrange, frange, mismatch, snrthresh])

Scan a TimeSeries using the multi-Q transform.

q_transform([qrange, frange, gps, search, ...])

Compute the multi-Q transform and return an interpolated spectrogram.

radian([unwrap])

Calculate the phase angle of the TimeSeries in radians.

ravel([order])

Return a flattened array.

rayleigh_spectrogram(*args, **kwargs)

Compute the Rayleigh statistic spectrogram.

rayleigh_spectrum([fftlength, overlap, window])

Calculate the Rayleigh FrequencySeries for this TimeSeries.

rayleigh_test(fftlength, stride[, n_samples])

Compute Rayleigh statistic p-value spectrogram.

repeat(repeats[, axis])

Repeat elements of an array.

resample(rate, *args[, ignore_nan])

Resample the TimeSeries.

reshape(shape[, order])

Returns an array containing the same data with a new shape.

resize(new_shape[, refcheck])

Change shape and size of array in-place.

rfft(*args, **kwargs)

Real-valued Fast Fourier Transform.

rms([axis, keepdims, ignore_nan])

Compute the Root Mean Square (RMS) value.

rolling_max(window, *[, center, min_count, ...])

Rolling maximum over time.

rolling_mean(window, *[, center, min_count, ...])

Rolling mean over time.

rolling_median(window, *[, center, ...])

Rolling median over time.

rolling_min(window, *[, center, min_count, ...])

Rolling minimum over time.

rolling_std(window, *[, center, min_count, ...])

Rolling standard deviation over time.

round([decimals, out])

searchsorted(v, *args, **kwargs)

setfield(val, dtype[, offset])

Put a value into a specified place in a field defined by a data-type.

setflags([write, align, uic])

Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.

shift(delta)

Shift this Series forward on the X-axis by delta.

skewness([axis, nan_policy])

Compute the skewness of the data.

smooth(width[, method, ignore_nan])

Smooth the series.

sort([axis, kind, order])

Sort an array in-place.

spectral_variance(stride[, fftlength, ...])

Calculate the SpectralVariance of this TimeSeries.

spectrogram(*args, **kwargs)

Compute the average power spectrogram.

spectrogram2(*args, **kwargs)

Compute an alternative spectrogram (spectrogram2).

squeeze([axis])

Remove axes of length one from a.

standardize(*[, method, ddof, robust])

Standardize the series.

std([axis, dtype, out, ddof, keepdims, where])

step(**kwargs)

Create a step plot of this series.

stlt([stride, window, fftlength, overlap, ...])

Compute Short-Time Laplace Transform (STLT).

student_t_spectrogram(fftlength[, stride, ...])

Compute Student-t degree of freedom (nu) spectrogram.

sum([axis, dtype, out, keepdims, initial, where])

Return the sum of the array elements over the given axis.

swapaxes(axis1, axis2)

Return a view of the array with axis1 and axis2 interchanged.

tail([n])

Return the last n samples of this series.

take(indices[, axis, out, mode])

taper([side, duration, nsamples])

Taper the ends of this TimeSeries smoothly to zero.

to(unit[, equivalencies, copy])

Return a new ~astropy.units.Quantity object with the specified unit.

to_astropy_timeseries([column, time_format])

Convert to astropy.timeseries.TimeSeries.

to_cupy([dtype])

Convert to CuPy Array.

to_dask([chunks])

Convert to Dask Array.

to_dict()

Convert TimeSeries to a dictionary.

to_hdf5_dataset(group, path, *[, overwrite, ...])

Write to HDF5 group/dataset.

to_jax()

Convert to JAX Array.

to_json()

Convert TimeSeries to a JSON string.

to_lal()

Convert this TimeSeries into a LAL TimeSeries.

to_librosa([y_dtype])

Export to librosa-compatible numpy array.

to_mne([info])

Convert to mne.io.RawArray (single-channel).

to_neo([units])

Convert to neo.AnalogSignal.

to_netcdf4(ds, var_name, **kwargs)

Write to netCDF4 Dataset.

to_obspy(*[, stats_extra, dtype])

Convert to obspy.Trace.

to_obspy_trace(*[, stats_extra, dtype])

Alias for to_obspy().

to_pandas([index, name, copy])

Convert TimeSeries to pandas.Series.

to_polars([name, as_dataframe, times, time_unit])

Convert TimeSeries to polars object.

to_pycbc(*[, copy])

Convert this TimeSeries into a PyCBC ~pycbc.types.timeseries.TimeSeries.

to_pydub([sample_width, channels])

Export to pydub.AudioSegment.

to_pyroomacoustics_source()

Export as a signal and sample rate tuple for pyroomacoustics.

to_simpeg([location, rx_type, orientation])

Convert to SimPEG Data object.

to_sqlite(conn[, series_id, overwrite])

Save to sqlite3 database.

to_string([unit, precision, format, subfmt, ...])

Generate a string representation of the quantity and its unit.

to_tensorflow([dtype])

Convert to tensorflow.Tensor.

to_tgraph([error])

Convert to ROOT TGraph or TGraphErrors.

to_th1d([error])

Convert to ROOT TH1D.

to_torch([device, dtype, requires_grad, copy])

Convert to torch.Tensor.

to_value([unit, equivalencies])

The numerical value, possibly in a different unit.

to_xarray([time_coord])

Convert to xarray.DataArray.

to_zarr(store[, path])

Save to Zarr storage.

tobytes([order])

Not implemented, use .value.tobytes() instead.

tofile(fid[, sep, format])

Not implemented, use .value.tofile() instead.

tolist()

tostring([order])

Not implemented, use .value.tostring() instead.

trace([offset, axis1, axis2, dtype, out])

transfer_function(other[, fftlength, ...])

Compute the transfer function between this TimeSeries and another.

transpose(*axes)

Returns a view of the array with axes transposed.

unwrap_phase([deg])

Alias for instantaneous_phase(unwrap=True).

update(other, *[, inplace, gap, pad])

Update this series by appending new data like a buffer.

value_at(x)

Return the value of this Series at the given xindex value.

var([axis, dtype, out, ddof, keepdims, where])

view([dtype][, type])

New view of array with the same data.

whiten([fftlength, overlap, method, window, ...])

Whiten this TimeSeries using inverse spectrum truncation.

xcorr(other, *[, maxlag, normalize, mode, ...])

Compute time-domain cross-correlation between two TimeSeries.

zip()

Zip the xindex and value arrays of this Series.

zpk(zeros, poles, gain, *[, analog, unit, ...])

Filter this TimeSeries by applying a digital zero-pole-gain filter.

Attributes

T

View of the transposed array.

base

Base object if memory is from some other object.

cgs

Returns a copy of the current Quantity instance with CGS units.

channel

Instrumental channel associated with these data.

ctypes

An object to simplify the interaction of the array with the ctypes module.

data

Python buffer object pointing to the start of the array's data.

dt

Time (seconds) between successive samples.

dtype

Data-type of the array's elements.

duration

Duration of this series in seconds.

dx

X-axis sample separation.

epoch

GPS epoch for these data.

equivalencies

A list of equivalencies that will be applied by default during unit conversions.

flags

Information about the memory layout of the array.

flat

A 1-D iterator over the Quantity array.

get

imag

The imaginary part of the array.

info

Container for meta information like name, description, format.

is_regular

Return True if this series has a regular grid (constant spacing).

isscalar

True if the value of this quantity is a scalar, or False if it is an array-like object.

itemsize

Length of one array element in bytes.

name

Name for this data set.

nbytes

Total bytes consumed by the elements of the array.

ndim

Number of array dimensions.

read

real

The real part of the array.

sample_rate

Data rate for this TimeSeries in samples per second (Hertz).

shape

Tuple of array dimensions.

si

Returns a copy of the current Quantity instance with SI units.

size

Number of elements in the array.

span

Time (seconds) spanned by this series.

strides

Tuple of bytes to step in each dimension when traversing an array.

t0

GPS start time of this series.

times

Array of GPS times for each sample.

unit

The physical unit of these data.

value

The numerical value of this instance.

write

x0

X-axis coordinate of the first data point.

xindex

Positions of the data on the x-axis.

xspan

X-axis [low, high) segment encompassed by these data.

xunit

Unit of x-axis index.

df

to_simpeg(location: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None, rx_type: str = 'PointElectricField', orientation: str = 'x', **kwargs: Any) Any[source]

Convert to SimPEG Data object.

Parameters:
  • location (array_like, optional) – Rx location (x, y, z). Default is [0, 0, 0].

  • rx_type (str, optional) – Receiver class name. Default “PointElectricField”.

  • orientation (str, optional) – Receiver orientation (‘x’, ‘y’, ‘z’). Default ‘x’.

Return type:

simpeg.data.Data

classmethod from_simpeg(data_obj: Any, **kwargs: Any) TimeSeries[source]

Create TimeSeries from SimPEG Data object.

Parameters:

data_obj (simpeg.data.Data) – Input SimPEG Data.

Return type:

TimeSeries

classmethod from_control(response: Any, **kwargs: Any) TimeSeries | TimeSeriesDict[source]

Create TimeSeries from python-control TimeResponseData.

Parameters:
  • response (control.TimeResponseData) – The simulation result from python-control.

  • **kwargs (dict) – Additional arguments passed to the constructor.

Returns:

The converted time-domain data.

Return type:

TimeSeries or TimeSeriesDict

arima(order: tuple[int, int, int] = (1, 0, 0), *, seasonal_order: tuple[int, int, int, int] | None = None, auto: bool = False, **kwargs: Any) Any[source]

Fit an ARIMA or SARIMAX model to this TimeSeries.

This method wraps statsmodels.tsa.arima.model.ARIMA (or SARIMAX). If auto=True, it uses pmdarima to automatically find the best parameters.

Parameters:
  • order (tuple, default=(1, 0, 0)) – The (p,d,q) order of the model.

  • seasonal_order (tuple, optional) – The (P,D,Q,s) seasonal order.

  • auto (bool, default=False) – If True, perform Auto-ARIMA search (requires pmdarima).

  • **kwargs – Additional arguments passed to fit_arima.

Returns:

Object containing the fitted model, with methods .predict(), .forecast(), .plot().

Return type:

ArimaResult

ar(p: int = 1, **kwargs: Any) Any[source]

Fit an AutoRegressive AR(p) model. Shortcut for .arima(order=(p, 0, 0)).

ma(q: int = 1, **kwargs: Any) Any[source]

Fit a Moving Average MA(q) model. Shortcut for .arima(order=(0, 0, q)).

arma(p: int = 1, q: int = 1, **kwargs: Any) Any[source]

Fit an ARMA(p, q) model. Shortcut for .arima(order=(p, 0, q)).