New in version 0.2.
Version 0.2 of PyWavelets includes many new features and improvements. One of such new feature is a two-dimensional wavelet packet transform structure that is almost completely sharing programming interface with the one-dimensional tree structure.
In order to achieve this simplification, a new inheritance scheme was used in which a BaseNode base node class is a superclass for both Node and Node2D node classes.
The node classes are used as data wrappers and can be organized in trees (binary trees for 1D transform case and quad-trees for the 2D one). They are also superclasses to the WaveletPacket class and WaveletPacket2D class that are used as the decomposition tree roots and contain a couple additional methods.
The below diagram illustrates the inheritance tree:
- BaseNode - common interface for 1D and 2D nodes:
- Node - data carrier node in a 1D decomposition tree
- WaveletPacket - 1D decomposition tree root node
- Node2D - data carrier node in a 2D decomposition tree
- WaveletPacket2D - 2D decomposition tree root node
Note
The BaseNode is a base class for Node and Node2D. It should not be used directly unless creating a new transformation type. It is included here to document the common interface of 1D and 2D node an wavelet packet transform classes.
Parameters: |
|
---|
Data associated with the node. 1D or 2D numeric array (depends on the transform type).
Parent node. Used in tree navigation. None for root node.
Signal extension mode for the dwt() (dwt2()) and idwt() (idwt2()) decomposition and reconstruction functions. Inherited from parent node.
Decomposition level of the current node. 0 for root (original data), 1 for the first decomposition level, etc.
Path string defining position of the node in the decomposition tree.
Node name describing data coefficients type of the current subnode.
See Node.node_name and Node2D.node_name.
Maximum allowed level of decomposition. Evaluated from parent or child nodes.
Checks if node has any subnodes (is not a leaf node).
Performs Inverse Discrete Wavelet Transform on subnodes coefficients and returns reconstructed data for the current level.
Parameters: | update – If set, the data attribute will be updated with the reconstructed value. |
---|
Note
Descends to subnodes and recursively calls reconstruct() on them.
Returns subnode or None (see decomposition flag description).
Parameters: |
|
---|
Used to access nodes in the decomposition tree by string path.
Parameters: | path – Path string composed from valid node names. See Node.node_name and Node2D.node_name for node naming convention. |
---|
Similar to get_subnode() method with decompose=True, but can access nodes on any level in the decomposition tree.
If node does not exist yet, it will be created by decomposition of its parent node.
Used to set node or node’s data in the decomposition tree. Nodes are identified by string path.
Parameters: |
|
---|
Used to delete node from the decomposition tree.
Parameters: | path – Path string composed from valid node names. See Node.node_name and Node2D.node_name for node naming convention. |
---|
Traverses through the decomposition tree and collects leaf nodes (nodes without any subnodes).
Parameters: | decompose – If decompose is True, the method will try to decompose the tree up to the maximum level. |
---|
Traverses the decomposition tree and calls func(node, *args, **kwargs) on every node. If func returns True, descending to subnodes will continue.
Parameters: |
|
---|---|
Args : | arguments to pass to the func |
Kwargs : | keyword arguments to pass to the func |
Similar to walk() but traverses the tree in depth-first order.
Parameters: |
|
---|---|
Args : | arguments to pass to the func |
Kwargs : | keyword arguments to pass to the func |
Node name describing data coefficients type of the current subnode.
Parameters: |
|
---|
Collects nodes from the given level of decomposition.
Parameters: |
|
---|
If nodes at the given level are missing (i.e. the tree is partially decomposed) and the decompose is set to False, only existing nodes will be returned.
Parameters: |
|
---|
Collects nodes from the given level of decomposition.
Parameters: |
|
---|
If nodes at the given level are missing (i.e. the tree is partially decomposed) and the decompose is set to False, only existing nodes will be returned.