-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve generate.py with spatial on generate_template() #2098
Improve generate.py with spatial on generate_template() #2098
Conversation
Cool, awesome, I'll test that asap in between two grant proposals :-) Thanks a lot. The propagation is isotropic for now, am I right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring comments
Co-authored-by: Zach McKenzie <[email protected]>
Co-authored-by: Zach McKenzie <[email protected]>
for more information, see https://pre-commit.ci
dist = distances[u, :].copy() | ||
dist -= np.min(dist) | ||
delay_s = dist / propagation_speed / 1000.0 | ||
sample_shifts = delay_s * fs | ||
|
||
# apply the delay with fft transform to get sub sample shift | ||
n = wfs.shape[0] | ||
wfs_f = np.fft.rfft(wfs, axis=0) | ||
if n % 2 == 0: | ||
# n is even sig_f[-1] is nyquist and so pi | ||
omega = np.linspace(0, np.pi, wfs_f.shape[0]) | ||
else: | ||
# n is odd sig_f[-1] is exactly nyquist!! we need (n-1) / n factor!! | ||
omega = np.linspace(0, np.pi * (n - 1) / n, wfs_f.shape[0]) | ||
# broadcast omega and sample_shifts depend the axis | ||
shifts = omega[:, np.newaxis] * sample_shifts[np.newaxis, :] | ||
wfs = np.fft.irfft(wfs_f * np.exp(-1j * shifts), n=n, axis=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
This add:
@yger