Created
January 22, 2015 16:50
-
-
Save bmcfee/3ee8c1820a0cb246a803 to your computer and use it in GitHub Desktop.
wrap window functions to handle fractional length
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def window_wrapper(window_function): | |
def _wrap(n, *args, **kwargs): | |
n_min, n_max = int(np.floor(n)), int(np.ceil(n)) | |
window = window_function(n, *args, **kwargs) | |
if len(window) < n_max: | |
window = np.pad(window, [(0, n_max - len(window))], mode='constant') | |
window[n_min:] = 0.0 | |
return window | |
return _wrap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's how it behaves on (most of) the
scipy.signal.windows
suite:Output: