Debian Codegraph @

doc/source/pyplots/plot_boundary_modes.py

raw symbols SCIP
1 """A visual illustration of the various signal extension modes supported in
2 PyWavelets. For efficiency, in the C routines the array is not actually
3 extended as is done here. This is just a demo for easier visual explanation of
4 the behavior of the various boundary modes.
5
6 In practice, which signal extension mode is beneficial will depend on the
7 signal characteristics. For this particular signal, some modes such as
8 "periodic", "antisymmetric" and "zero" result in large discontinuities that
9 would lead to large amplitude boundary coefficients in the detail coefficients
10 of a discrete wavelet transform.
11 """
12 import numpy as np
13 from matplotlib import pyplot as plt
14 from pywt._doc_utils import boundary_mode_subplot
15
16 # synthetic test signal
17 x = 5 - np.linspace(-1.9, 1.1, 9)**2
18
19 # Create a figure with one subplots per boundary mode
20 fig, axes = plt.subplots(3, 3, figsize=(10, 6))
21 plt.subplots_adjust(hspace=0.5)
22 axes = axes.ravel()
23 boundary_mode_subplot(x, 'symmetric', axes[0], symw=False)
24 boundary_mode_subplot(x, 'reflect', axes[1], symw=True)
25 boundary_mode_subplot(x, 'periodic', axes[2], symw=False)
26 boundary_mode_subplot(x, 'antisymmetric', axes[3], symw=False)
27 boundary_mode_subplot(x, 'antireflect', axes[4], symw=True)
28 boundary_mode_subplot(x, 'periodization', axes[5], symw=False)
29 boundary_mode_subplot(x, 'smooth', axes[6], symw=False)
30 boundary_mode_subplot(x, 'constant', axes[7], symw=False)
31 boundary_mode_subplot(x, 'zero', axes[8], symw=False)
32 plt.show()