MCPcopy Create free account
hub / github.com/PyWavelets/pywt / WaveletPacketND

Class WaveletPacketND

pywt/_wavelet_packets.py:940–1051  ·  view source on GitHub ↗

Data structure representing ND Wavelet Packet decomposition of signal. Parameters ---------- data : ND ndarray Data associated with the node. wavelet : Wavelet object or name string Wavelet used in DWT decomposition and reconstruction mode : str, optional

Source from the content-addressed store, hash-verified

938
939
940class WaveletPacketND(NodeND):
941 """
942 Data structure representing ND Wavelet Packet decomposition of signal.
943
944 Parameters
945 ----------
946 data : ND ndarray
947 Data associated with the node.
948 wavelet : Wavelet object or name string
949 Wavelet used in DWT decomposition and reconstruction
950 mode : str, optional
951 Signal extension mode for the `dwt` and `idwt` decomposition and
952 reconstruction functions.
953 maxlevel : int, optional
954 Maximum level of decomposition.
955 If None, it will be calculated based on the `wavelet` and `data`
956 length using `pywt.dwt_max_level`.
957 axes : tuple of int, optional
958 The axes to transform. The default value of `None` corresponds to all
959 axes.
960 """
961 def __init__(self, data, wavelet, mode='smooth', maxlevel=None,
962 axes=None):
963 if (data is None) and (axes is None):
964 # ndim is required to create a NodeND object
965 raise ValueError("If data is None, axes must be specified")
966
967 # axes determines the number of transform dimensions
968 if axes is None:
969 axes = range(data.ndim)
970 elif np.isscalar(axes):
971 axes = (axes, )
972 axes = tuple(axes)
973 if len(np.unique(axes)) != len(axes):
974 raise ValueError("Expected a set of unique axes.")
975 ndim_transform = len(axes)
976
977 if data is not None:
978 data = np.asarray(data)
979 if data.ndim == 0:
980 raise ValueError("data must be at least 1D")
981 ndim = data.ndim
982 else:
983 ndim = len(axes)
984
985 super().__init__(None, data, "", ndim,
986 ndim_transform)
987 if not isinstance(wavelet, Wavelet):
988 wavelet = Wavelet(wavelet)
989 self.wavelet = wavelet
990 self.mode = mode
991 self.axes = axes
992 self.ndim_transform = ndim_transform
993 if data is not None:
994 if data.ndim < len(axes):
995 raise ValueError("The number of axes exceeds the number of "
996 "data dimensions.")
997 self.data_size = data.shape

Callers 1

wp_nd.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected