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

Class WaveletPacket2D

pywt/_wavelet_packets.py:809–937  ·  view source on GitHub ↗

Data structure representing 2D Wavelet Packet decomposition of signal. Parameters ---------- data : 2D 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

807
808
809class WaveletPacket2D(Node2D):
810 """
811 Data structure representing 2D Wavelet Packet decomposition of signal.
812
813 Parameters
814 ----------
815 data : 2D ndarray
816 Data associated with the node.
817 wavelet : Wavelet object or name string
818 Wavelet used in DWT decomposition and reconstruction
819 mode : str, optional
820 Signal extension mode for the `dwt` and `idwt` decomposition and
821 reconstruction functions.
822 maxlevel : int
823 Maximum level of decomposition.
824 If None, it will be calculated based on the `wavelet` and `data`
825 length using `pywt.dwt_max_level`.
826 axes : 2-tuple of ints, optional
827 The axes that will be transformed.
828 """
829 def __init__(self, data, wavelet, mode='smooth', maxlevel=None,
830 axes=(-2, -1)):
831 super().__init__(None, data, "")
832
833 if not isinstance(wavelet, Wavelet):
834 wavelet = Wavelet(wavelet)
835 self.wavelet = wavelet
836 self.mode = mode
837 self.axes = tuple(axes)
838 if len(np.unique(self.axes)) != 2:
839 raise ValueError("Expected two unique axes.")
840 if data is not None:
841 data = np.asarray(data)
842 if data.ndim < 2:
843 raise ValueError(
844 "WaveletPacket2D requires data with 2 or more dimensions.")
845 self.data_size = data.shape
846 transform_size = [data.shape[ax] for ax in self.axes]
847 if maxlevel is None:
848 maxlevel = dwt_max_level(min(transform_size), self.wavelet)
849 else:
850 self.data_size = None
851 self._maxlevel = maxlevel
852
853 def __reduce__(self):
854 return (WaveletPacket2D,
855 (self.data, self.wavelet, self.mode, self.maxlevel))
856
857 def reconstruct(self, update=True):
858 """
859 Reconstruct data using coefficients from subnodes.
860
861 Parameters
862 ----------
863 update : bool, optional
864 If True (default) then the coefficients of the current node
865 and its subnodes will be replaced with values from reconstruction.
866 """

Callers 1

wp_2d.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected