xrsignal package

Submodules

xrsignal.convolution module

xrsignal.convolution.correlate(in1, in2, **kwargs)

correlate two xarray objects (in1, in2) - unlike the scipy.signal.correlate, in1 can be ndimensional, but in2 must be 1d - the dimension of in2 must be contained in in1 and this is the dimension that the correlation is computed along

Parameters:
  • in1 (xr.DataArray) – data to be correlated. This can be ndimensional data

  • in2 (xr.DataArray) – data to correlate with in1. This must be a 1D xarray.DataArray.

  • **kwargs (dict) – keyword arguments to pass to scipy.signal.correlate

Returns:

correlated data. type will be determined by type of in1

Return type:

Union[xr.DataArray, xr.Dataset]

xrsignal.convolution.correlate_chunk(in1, in2, **kwargs)

correlate_chunk_dask, cross-correlate single block of dask arrays in1 and in2

Parameters:
  • in1 (dask.array.core.Array) – data to be correlated. in1 mush have shape (N, … ) where N is correlation dimension

  • in2 (dask.array.core.Array) – data to correlate with in1. in2 must have shape (M, ) where M is correlation dimension

  • **kwargs (dict) – keyword arguments to pass to scipy.signal.correlate

xrsignal.convolution.correlate_da(in1, in2, **kwargs)

correlate two xarray objects (in1, in2) - unlike the scipy.signal.correlate, in1 can be ndimensional, but in2 must be 1d - correlation dimension is specified by the dimension of in2, and this dimension must also be contained in in1

Parameters:
  • in1 (xr.DataArray) – data to be correlated. This can be ndimensional data

  • in2 (xr.DataArray) – data to correlate with in1. This must be a 1D xarray.DataArray.

  • **kwargs (dict) – keyword arguments to pass to scipy.signal.correlate

Returns:

correlated data. type will be determined by type of in1

Return type:

xr.DataArray

xrsignal.filtering module

xrsignal.filtering.filtfilt(da, dim, b, a, **kwargs)

distributed version for filtfilt

For know, I’m going to just build this up for a dataarray and see where we get. filter only considers a single chunk, therfore causing errors at chunk boundaries

TODO make this work for dataset or dataarray

Parameters:
  • da (xr.DataArray) – dataset or dataarray containing data to be filtered.

  • dim (str) – dimension to filter accross

  • b (array like) – numerator design coefficients for filter

  • a (array like) – denominator design coefficients for filter

  • kwargs (hashable) – passed to filtfitl

Returns:

ds_filt – dask future array that lays out task graph for filtering data

Return type:

{xr.Dataset, xr.DataArray}

xrsignal.filtering.hilbert(da, dim, **kwargs)

calculate the hilbert magnitude of da

Parameters:
  • da (xr.DataArray, or xr.Dataset)

  • dim (str) – dimension over which to calculate hilbert transform

xrsignal.filtering.hilbert_mag(da, dim, **kwargs)

calculate the hilbert magnitude of da

Parameters:
  • da (xr.DataArray, or xr.Dataset)

  • dim (str) – dimension over which to calculate hilbert transform

xrsignal.spectral_analysis module

xrsignal.spectral_analysis.csd(data, dim, dB=False, **kwargs)

Estimate the cross power spectral density, Pxy, using Welch’s method.

Parameters:
  • data (xr.Dataset) – dataset containing data to estimate cross power spectral density. must only contain two data variables

  • dim (str) – dimension to calculate PSD over

  • dB (bool) – if True, return PSD in dB

  • kwargs (hashable) – passed to scipy.signal.csd

Returns:

csd – cross power spectral density

Return type:

xr.DataArray

xrsignal.spectral_analysis.welch(data, dim, dB=False, **kwargs)

Estimate power spectral density using welch method For now, an integer number of chunks in PSD dimension is required

Parameters:
  • data (xr.DataArray or xr.Dataset) – data array to estimate power spectral density

  • dim (str) – dimension to calculate PSD over

  • dB (bool) – if True, return PSD in dB