Comments (7)
The code from the PR, just in case that PRs on that repo won't be accessible in the future (we may close them completely if people keep sending PRs there instead of here):
def wavedec_coeff_len(data_len, filter_len, mode, level=None):
"""
Total number of coefficients in the output of `wavedec`, given data
length, filter length, mode and level.
Returns integer: len(cAn) + len(cDn) + len(cDn-1) + ... + len(cD1)
data_len - data length
filter_len - filter length or Wavelet instance
level - decomposition level. If level is None then it will be
calculated using `dwt_max_level` function.
"""
if level is None:
level = dwt_max_level(data_len, filter_len)
elif level < 0:
raise ValueError(
"Level value of %d is too low . Minimum level is 0." % level)
total_len = 0
for i in xrange(level):
data_len = dwt_coeff_len(data_len, filter_len, mode)
total_len += data_len
return total_len + data_len
from pywt.
PR author is @belevtsoff
from pywt.
Wow, thanks for resurrecting this, it's been 3 years :)
from pywt.
time flies:)
from pywt.
The motivation given on the original PR:
We used PyWavelets recently in our SpikeSort project. In particular, hstacked ouput from pywt.wavedec was used as a single feature vector. This approach is often used for spike sorting. The function I'm proposing, will be very handy when one wants to allocate a fixed-size numpy array to store wavelet coefficients (obtained from wavedec), before the input data is processed (for example, if one has a huge stack of equal-length independent signals to process and store).
@PyWavelets/core opinions on adding this function?
from pywt.
I think the implementation is correct and it would not be a burden to maintain. However, I'm not sure if there is still much of a use case for it (see below).
For batched 1D transforms, it should now be faster to run them all at once using the axis
feature of wavedec
(which was not present at the time the original PR was opened).
If wavedecn
was used to do the 1D transforms, one could also then use coeffs_to_array
to convert to a single array, which I think is the use case stated above?
e.g. to transform 1000 signals, each of length 256 and get the results in a single array:
coeffs = pywt.wavedecn(np.random.randn(256, 1000), 'db2', 'periodization', axes=(0, ))
coeff_array, slices = pywt.coeffs_to_array(coeffs, axes=(0, ))
from pywt.
Thanks @grlee77, good points. And if one really wanted to do preallocation for some reason, it wouldn't be much of an issue to run a single transform once and obtain the length from the output of that.
So closing.
from pywt.
Related Issues (20)
- Publish musllinux wheels again, and natively compile macOS arm64 wheels
- Inconsistent size returned from waverec2
- Ripples in output although low wavelet center frequency and high scale
- PyWavelet on EEG signals
- Unable to activated dump via ADB HOT 1
- import pywt error when pip-installed with -e flag HOT 2
- How is CWT cmor wavelet defined? HOT 5
- Hello,I have a question about the length of the image.
- Correct factors for complex Morlet wavelet
- Start building WASM wheels against newer Pyodide (version 0.26.0) HOT 4
- All the images illustrating wavelet families are broken on wavelets.pybytes.com HOT 2
- Plotting inconsistencies with CWT function
- Why are wavelet daubechies not supported in the CWT algorithm? HOT 1
- Algorithm for inverse continuous wavelet transform HOT 2
- PyWavelets==1.4.1 Error in linux image for Python 3.10.11 HOT 3
- Why does the DWT give values that should be 0 but are in fact around 1e-16? HOT 2
- `test_concurrent_cwt` failure on macOS arm64 with free-threaded CPython HOT 6
- Lower Power Spectral Density from `pywt.cwt` Compared to `scipy.signal.welch`
- pywt.swt yields unexpected results HOT 1
- Non-decimated wavelet packet transform
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pywt.