TimeSeriesMatrixο
Stability: Stable
What it isο
Use TimeSeriesMatrix when channels share one time axis and you want matrix-wide FFT, PSD, coherence, or preprocessing methods.
Representative Signaturesο
TimeSeriesMatrix(data, times=None, dt=None, t0=None, sample_rate=None, ...)
TimeSeriesMatrix.psd(fftlength=None, overlap=0, ...)
Minimal Exampleο
from gwexpy.timeseries import TimeSeriesMatrix
import numpy as np
mat = TimeSeriesMatrix(np.random.randn(2, 2, 256), sample_rate=256)
coh = mat.coherence(mat)
API Referenceο
The detailed generated API continues below on this page.
Inherits from: PhaseMethodsMixin, TimeSeriesMatrixCoreMixin, TimeSeriesMatrixAnalysisMixin, TimeSeriesMatrixSpectralMixin, TimeSeriesMatrixInteropMixin, SeriesMatrix
2D Matrix container for multiple TimeSeries objects sharing a common time axis.
This class represents a 2-dimensional array (rows x columns) where each element corresponds to a TimeSeries data stream. Crucially, all elements in the matrix share the same time array (same t0, dt, and number of samples). It behaves like a multivariate time series organized in a grid structure.
Provides dt, t0, times aliases and constructs FrequencySeriesMatrix via FFT.
Methodsο
MetaDataMatrixο
Metadata matrix containing per-element metadata.
N_samplesο
Number of samples along the x-axis.
Tο
Transpose of the matrix (rows and columns swapped).
angleο
angle(self, unwrap: bool = False, deg: bool = False, **kwargs: Any) -> Any
Alias for phase(unwrap=unwrap, deg=deg).
appendο
append(self, other, inplace=True, pad=None, gap=None, resize=True)
Append another matrix along the sample axis.
append_exactο
append_exact(self, other, inplace=False, pad=None, gap=None, tol=3.814697265625e-06)
Append another matrix with strict contiguity checking.
asdο
asd(self, **kwargs: 'Any') -> 'Any'
Compute ASD of each element. Returns FrequencySeriesMatrix.
astypeο
astype(self, dtype, copy=True)
Cast matrix data to a specified type.
auto_coherenceο
auto_coherence(self, *args, **kwargs)
Element-wise delegate to TimeSeries.auto_coherence.
bandpassο
bandpass(self, *args, **kwargs)
Element-wise delegate to TimeSeries.bandpass.
channel_namesο
Flattened list of all element names.
channelsο
2D array of channel identifiers for each matrix element.
coherenceο
coherence(self, other, *args, **kwargs)
Element-wise delegate to TimeSeries.coherence with another TimeSeries.
col_indexο
col_index(self, key: 'Any') -> 'int'
Get the integer index for a column key.
col_keysο
col_keys(self) -> 'tuple[Any, ...]'
Get the keys (labels) for all columns.
conjο
conj(self)
Complex conjugate of the matrix.
copyο
copy(self, order='C')
Create a deep copy of this matrix.
correlation_vectorο
correlation_vector(self, target_timeseries, method='mic', nproc=None)
Calculate correlation between a target TimeSeries and all channels in this Matrix.
Notesο
method="pearson"uses a vectorized path (fast for many channels).For small matrices,
nprocmay be throttled to avoid process overhead.
partial_correlation_matrixο
partial_correlation_matrix(self, *, estimator: str = 'empirical', shrinkage: float | str | None = None, eps: float = 1e-08, return_precision: bool = False) -> Any
Compute the partial-correlation matrix across all channels (flattened).
cropο
crop(self, start: 'Any' = None, end: 'Any' = None, copy: 'bool' = False) -> 'Any'
Crop this matrix to the given GPS start and end times. Accepts any time format supported by gwexpy.time.to_gps (str, datetime, pandas, obspy, etc).
csdο
csd(self, other, *args, **kwargs)
Element-wise delegate to TimeSeries.csd with another TimeSeries.
degreeο
degree(self, unwrap: 'bool' = False, **kwargs: 'Any') -> 'Any'
Calculate the instantaneous phase of the matrix in degrees.
Parametersο
unwrap : bool, optional If True, unwrap the phase. **kwargs Passed to analytic_signal.
Returnsο
TimeSeriesMatrix The phase of the matrix elements, in degrees.
detο
det(self)
Compute the determinant of the matrix at each sample point.
detrendο
detrend(self, *args, **kwargs)
Element-wise delegate to TimeSeries.detrend.
diagonalο
diagonal(self, output: 'str' = 'list')
Extract diagonal elements from the matrix.
dict_classο
dict_class(...)
Dictionary of TimeSeries objects.
diffο
diff(self, n=1, axis=None)
Calculate the n-th discrete difference along the sample axis.
dtο
Time spacing (dx).
durationο
Duration covered by the samples.
dxο
Step size between samples on the x-axis.
fftο
fft(self, **kwargs: 'Any') -> 'Any'
Compute FFT of each element. Returns FrequencySeriesMatrix.
filterο
filter(self, *args, **kwargs)
Element-wise delegate to TimeSeries.filter.
find_peaksο
find_peaks(self, threshold: 'Optional[float]' = None, method: 'str' = 'amplitude', **kwargs: 'Any') -> 'Any'
Find peaks in each element of the matrix. Element-wise delegate to TimeSeries.find_peaks.
from_neoο
from_neo(sig: 'Any') -> 'Any'
Create TimeSeriesMatrix from neo.AnalogSignal.
Parametersο
sig : neo.core.AnalogSignal Input signal.
Returnsο
TimeSeriesMatrix
get_indexο
get_index(self, key_row: 'Any', key_col: 'Any') -> 'tuple[int, int]'
Get the (row, col) integer indices for given keys.
highpassο
highpass(self, *args, **kwargs)
Element-wise delegate to TimeSeries.highpass.
icaο
ica(self, return_model: 'bool' = False, **kwargs: 'Any') -> 'Any'
Fit and transform ICA.
ica_fitο
ica_fit(self, **kwargs: 'Any') -> 'Any'
Fit ICA.
ica_inverse_transformο
ica_inverse_transform(self, ica_res: 'Any', sources: 'Any') -> 'Any'
Inverse transform ICA sources.
ica_transformο
ica_transform(self, ica_res: 'Any') -> 'Any'
Transform using ICA.
imagο
imag(self)
Imaginary part of the matrix.
imputeο
impute(self, *, method: 'str' = 'linear', limit: 'Optional[int]' = None, axis: 'str' = 'time', max_gap: 'Optional[float]' = None, **kwargs: 'Any') -> 'Any'
Impute missing values in the matrix.
interpolateο
interpolate(self, xindex, **kwargs)
Interpolate the matrix to a new sample axis.
invο
inv(self, swap_rowcol: 'bool' = True)
Compute the matrix inverse at each sample point.
is_compatibleο
is_compatible(self, other: 'Any') -> 'bool'
Compatibility check.
is_compatible_exactο
is_compatible_exact(self, other: 'Any') -> 'bool'
Check strict compatibility with another matrix.
is_contiguousο
is_contiguous(self, other: 'Any', tol: 'float' = 3.814697265625e-06) -> 'int'
Check if this matrix is contiguous with another.
is_contiguous_exactο
is_contiguous_exact(self, other: 'Any', tol: 'float' = 3.814697265625e-06) -> 'int'
Check contiguity with strict shape matching.
is_regularο
Return True if this series has a regular grid (constant spacing).
keysο
keys(self) -> 'tuple[tuple[Any, ...], tuple[Any, ...]]'
Get both row and column keys.
list_classο
list_class(*items)
List of TimeSeries objects.
locο
Label-based indexer for direct value access.
lock_inο
lock_in(self, **kwargs: 'Any') -> 'Any'
Apply lock-in amplification element-wise.
Returnsο
TimeSeriesMatrix or tuple of TimeSeriesMatrix If output=βamp_phaseβ (default) or βiqβ, returns (matrix1, matrix2). If output=βcomplexβ, returns a single complex TimeSeriesMatrix.
lowpassο
lowpass(self, *args, **kwargs)
Element-wise delegate to TimeSeries.lowpass.
maxο
max(self, axis=None, out=None, keepdims=False, initial=None, where=True, ignore_nan=True)
a.max(axis=None, out=None, keepdims=False, initial=
Return the maximum along a given axis.
Refer to numpy.amax for full documentation.
See Alsoο
numpy.amax : equivalent function
(Inherited from ndarray)
meanο
mean(self, axis=None, dtype=None, out=None, keepdims=False, *, where=True, ignore_nan=True)
a.mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)
Returns the average of the array elements along given axis.
Refer to numpy.mean for full documentation.
See Alsoο
numpy.mean : equivalent function
(Inherited from ndarray)
medianο
median(self, axis=None, out=None, overwrite_input=False, keepdims=False, ignore_nan=True)
No documentation available.
minο
min(self, axis=None, out=None, keepdims=False, initial=None, where=True, ignore_nan=True)
a.min(axis=None, out=None, keepdims=False, initial=
Return the minimum along a given axis.
Refer to numpy.amin for full documentation.
See Alsoο
numpy.amin : equivalent function
(Inherited from ndarray)
namesο
2D array of names for each matrix element. Alias for channel_names if 1D.
notchο
notch(self, *args, **kwargs)
Element-wise delegate to TimeSeries.notch.
padο
pad(self, pad_width, **kwargs)
Pad the matrix along the sample axis.
pcaο
pca(self, return_model: 'bool' = False, **kwargs: 'Any') -> 'Any'
Fit and transform PCA.
pca_fitο
pca_fit(self, **kwargs: 'Any') -> 'Any'
Fit PCA.
pca_inverse_transformο
pca_inverse_transform(self, pca_res: 'Any', scores: 'Any') -> 'Any'
Inverse transform PCA scores.
pca_transformο
pca_transform(self, pca_res: 'Any', **kwargs: 'Any') -> 'Any'
Transform using PCA.
phaseο
phase(self, unwrap: bool = False, deg: bool = False, **kwargs: Any) -> Any
Calculate the phase of the data.
Parametersο
unwrap : bool, optional
If True, unwrap the phase to remove discontinuities.
Default is False.
deg : bool, optional
If True, return the phase in degrees.
Default is False (radians).
**kwargs
Additional arguments passed to the underlying calculation.
Returnsο
Series or Matrix or Collection
The phase of the data.
plotο
plot(self, **kwargs: 'Any') -> 'Any'
Plot the matrix data.
prependο
prepend(self, other, inplace=True, pad=None, gap=None, resize=True)
Prepend another matrix at the beginning along the sample axis.
prepend_exactο
prepend_exact(self, other, inplace=False, pad=None, gap=None, tol=3.814697265625e-06)
Prepend another matrix with strict contiguity checking.
psdο
psd(self, **kwargs: 'Any') -> 'Any'
Compute PSD of each element. Returns FrequencySeriesMatrix.
q_transformο
q_transform(self, *args: 'Any', **kwargs: 'Any') -> 'Any'
Compute Q-transform of each element. Returns SpectrogramMatrix.
radianο
radian(self, unwrap: 'bool' = False, **kwargs: 'Any') -> 'Any'
Calculate the instantaneous phase of the matrix in radians.
Parametersο
unwrap : bool, optional If True, unwrap the phase. **kwargs Passed to analytic_signal.
Returnsο
TimeSeriesMatrix The phase of the matrix elements, in radians.
readο
read(source, format=None, **kwargs)
Read a SeriesMatrix from file.
Parametersο
source : str or path-like Path to file to read. format : str, optional File format. If None, inferred from extension. **kwargs Additional arguments passed to the reader.
Returnsο
SeriesMatrix The loaded matrix.
The available built-in formats are:
======== ==== ===== ============= Format Read Write Auto-identify ======== ==== ===== ============= ats Yes No No gbd Yes No No gse2 Yes No No knet Yes No No li Yes No No lsf Yes No No mem Yes No No miniseed Yes No No orf Yes No No sac Yes No No sdb Yes No No sqlite Yes No No sqlite3 Yes No No taffmat Yes No No tdms Yes No No wav Yes No No wdf Yes No No win Yes No No win32 Yes No No wvf Yes No No ======== ==== ===== =============
Public direct-I/O note:
TimeSeriesMatrix supports generic HDF5 through read(..., format="hdf5"),
write(..., format="hdf5"), and to_hdf5(), but collection-first formats such
as hdf.ndscope and xml.diaggui are not part of the public matrix direct-I/O
contract.
realο
real(self)
Real part of the matrix.
resampleο
resample(self, *args, **kwargs)
Element-wise delegate to TimeSeries.resample.
reshapeο
reshape(self, shape, order='C')
Reshape the matrix dimensions.
rmsο
rms(self, axis=None, keepdims=False, ignore_nan=True)
No documentation available.
rolling_maxο
rolling_max(self, window: 'Any', *, center: 'bool' = False, min_count: 'int' = 1, nan_policy: 'str' = 'omit', backend: 'str' = 'auto', ignore_nan: 'Optional[bool]' = None) -> 'Any'
Rolling maximum along the time axis.
rolling_meanο
rolling_mean(self, window: 'Any', *, center: 'bool' = False, min_count: 'int' = 1, nan_policy: 'str' = 'omit', backend: 'str' = 'auto', ignore_nan: 'Optional[bool]' = None) -> 'Any'
Rolling mean along the time axis.
rolling_medianο
rolling_median(self, window: 'Any', *, center: 'bool' = False, min_count: 'int' = 1, nan_policy: 'str' = 'omit', backend: 'str' = 'auto', ignore_nan: 'Optional[bool]' = None) -> 'Any'
Rolling median along the time axis.
rolling_minο
rolling_min(self, window: 'Any', *, center: 'bool' = False, min_count: 'int' = 1, nan_policy: 'str' = 'omit', backend: 'str' = 'auto', ignore_nan: 'Optional[bool]' = None) -> 'Any'
Rolling minimum along the time axis.
rolling_stdο
rolling_std(self, window: 'Any', *, center: 'bool' = False, min_count: 'int' = 1, nan_policy: 'str' = 'omit', backend: 'str' = 'auto', ddof: 'int' = 0, ignore_nan: 'Optional[bool]' = None) -> 'Any'
Rolling standard deviation along the time axis.
row_indexο
row_index(self, key: 'Any') -> 'int'
Get the integer index for a row key.
row_keysο
row_keys(self) -> 'tuple[Any, ...]'
Get the keys (labels) for all rows.
sample_rateο
Sampling rate (1/dt).
schurο
schur(self, keep_rows, keep_cols=None, eliminate_rows=None, eliminate_cols=None)
Compute the Schur complement of a block matrix.
series_classο
series_class(data, *args, **kwargs)
Extended TimeSeries with all gwexpy functionality.
smoothο
smooth(self, width: 'Any', method: 'str' = 'amplitude', ignore_nan: 'bool' = True) -> 'Any'
Smooth the data. Element-wise delegate to TimeSeries.smooth.
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: analytic_signal, 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.
shape3Dο
Shape of the matrix as a 3-tuple (n_rows, n_cols, n_samples). For 4D matrices (spectrograms), the last dimension is likely frequency, so n_samples is determined by _x_axis_index.
shiftο
shift(self, delta)
Shift the sample axis by a constant offset.
spanο
Time span (xspan).
spectrogramο
spectrogram(self, *args: 'Any', **kwargs: 'Any') -> 'Any'
Compute spectrogram of each element. Returns SpectrogramMatrix.
spectrogram2ο
spectrogram2(self, *args: 'Any', **kwargs: 'Any') -> 'Any'
Compute spectrogram2 of each element. Returns SpectrogramMatrix.
standardizeο
standardize(self, *, axis: 'str' = 'time', method: 'str' = 'zscore', ddof: 'int' = 0, **kwargs: 'Any') -> 'Any'
Standardize the matrix. See gwexpy.timeseries.preprocess.standardize_matrix.
stdο
std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True, ignore_nan=True)
a.std(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)
Returns the standard deviation of the array elements along given axis.
Refer to numpy.std for full documentation.
See Alsoο
numpy.std : equivalent function
(Inherited from ndarray)
stepο
step(self, where: 'str' = 'post', **kwargs: 'Any') -> 'Any'
Plot the matrix as a step function.
submatrixο
submatrix(self, row_keys, col_keys)
Extract a submatrix by selecting specific rows and columns.
t0ο
Start time (x0).
taperο
taper(self, *args, **kwargs)
Element-wise delegate to TimeSeries.taper.
timesο
Time array (xindex).
to_cupyο
to_cupy(self, dtype=None) -> Any
Convert to CuPy Array.
to_daskο
to_dask(self, chunks='auto') -> Any
Convert to Dask Array.
to_dictο
to_dict(self) -> 'Any'
Convert matrix to an appropriate collection dict (e.g. TimeSeriesDict). Follows the matrix structure (row, col) unless itβs a 1-column matrix.
to_dict_flatο
to_dict_flat(self) -> 'dict[str, Series]'
Convert matrix to a flat dictionary mapping name to Series.
to_hdf5ο
to_hdf5(self, filepath, **kwargs)
Write matrix to HDF5 file.
to_jaxο
to_jax(self) -> Any
Convert to JAX Array.
to_listο
to_list(self) -> 'Any'
Convert matrix to an appropriate collection list (e.g. TimeSeriesList).
to_mneο
to_mne(self, info: 'Any' = None) -> 'Any'
Convert to mne.io.RawArray.
to_neoο
to_neo(self, units: 'Any' = None) -> 'Any'
Convert to neo.AnalogSignal.
Returnsο
neo.core.AnalogSignal
to_pandasο
to_pandas(self, format='wide')
Convert matrix to a pandas DataFrame.
to_series_1Dlistο
to_series_1Dlist(self) -> 'list[Series]'
Convert matrix to a flat 1D list of Series objects.
to_series_2Dlistο
to_series_2Dlist(self) -> 'list[list[Series]]'
Convert matrix to a 2D nested list of Series objects.
to_tensorflowο
to_tensorflow(self, dtype: Any = None) -> Any
Convert to tensorflow.Tensor.
to_torchο
to_torch(self, device: Optional[str] = None, dtype: Any = None, requires_grad: bool = False, copy: bool = False) -> Any
Convert to torch.Tensor.
to_zarrο
to_zarr(self, store, path=None, **kwargs) -> Any
Save to Zarr storage.
traceο
trace(self)
Compute the trace of the matrix (sum of diagonal elements).
transfer_functionο
transfer_function(self, other, *args, **kwargs)
Element-wise delegate to TimeSeries.transfer_function with another TimeSeries.
transposeο
transpose(self, *axes)
Transpose rows and columns, preserving sample axis as 2.
unitsο
2D array of units for each matrix element.
updateο
update(self, other, inplace=True, pad=None, gap=None)
Update matrix by appending without resizing (rolling buffer style).
valueο
Underlying numpy array of data values.
value_atο
value_at(self, x)
Get the matrix values at a specific x-axis location.
varο
var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True, ignore_nan=True)
a.var(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)
Returns the variance of the array elements, along given axis.
Refer to numpy.var for full documentation.
See Alsoο
numpy.var : equivalent function
(Inherited from ndarray)
whitenο
whiten(self, *args, **kwargs)
Element-wise delegate to TimeSeries.whiten.
whiten_channelsο
whiten_channels(self, *, method: 'str' = 'pca', eps: 'float' = 1e-12, n_components: 'Optional[int]' = None, return_model: 'bool' = True) -> 'Any'
Whiten the matrix (channels/components). Returns (whitened_matrix, WhiteningModel) by default. Set return_model=False to return only the whitened matrix. See gwexpy.timeseries.preprocess.whiten_matrix.
writeο
write(self, target, format=None, **kwargs)
Write matrix to file.
x0ο
Starting value of the sample axis.
xarrayο
Return the sample axis values.
xindexο
Sample axis index array.
xspanο
Full extent of the sample axis as a tuple (start, end).
xunitο
No documentation available.