demean

function of dascore.proc.basic source

demean(
    patch ,
    dim: str = time,
)

Remove the mean along a given dimension of a DASCore patch.

Parameters

Parameter Description
patch : The patch to remove the mean from.
dim : str Dimension name (e.g., “time”, “distance”).

import matplotlib.pyplot as plt import dascore as dc import numpy as np

patch = dc.get_example_patch(‘example_event_2’) nx,nt = patch.data.shape

Add some periodic common-mode noise

x = np.linspace(0, 6 * np.pi, nt) y = np.sin(x) * patch.data.max() / 30 Y = y[np.newaxis, :] * np.ones((nx,nt), dtype=float) patch0 = patch + Y

Prepare figure

fig, axs = plt.subplots(1, 3, figsize=(20,8), layout=‘constrained’)

Show patch with common-mode noise

ax0 = patch0.viz.waterfall(ax = axs[0], show=False) _ = ax0.set_title(‘Original with common-mode noise’);

Show demean applied patch

patch1 = patch0.demean(dim=‘distance’) ax1 = patch1.viz.waterfall(ax = axs[1], show=False) _ = ax1.set_title(‘Removed common-mode noise’);

Show difference

ax2 = (patch0-patch1).viz.waterfall(ax = axs[2], show=False) _ = ax2.set_title(‘Difference’);

plt.show()