Last active
June 18, 2020 12:18
-
-
Save syaffers/b7026f1f160056e05bf30bd798b24791 to your computer and use it in GitHub Desktop.
Downsampled sliding window extractor
This file contains hidden or 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 extract_windows_downsampling(array, clearing_time_index, max_time_steps, | |
sub_window_size, downsampling_ratio): | |
start = clearing_time_index + 1 - (sub_window_size - 1) * downsampling_ratio | |
K_indices = np.arange(0, sub_window_size * downsampling_ratio, | |
step=downsampling_ratio) | |
T_indices = np.arange(0, (max_time_steps + 1) * downsampling_ratio, | |
step=downsampling_ratio) | |
sub_windows = np.round( | |
start + | |
np.expand_dims(K_indices, 0) + | |
np.expand_dims(T_indices, 0).T | |
).astype(np.int) | |
return array[sub_windows] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment