Skip to content
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

Wave.resample changes the dtype! #31

Open
j9ac9k opened this issue Dec 10, 2019 · 1 comment
Open

Wave.resample changes the dtype! #31

j9ac9k opened this issue Dec 10, 2019 · 1 comment
Labels
good first issue Good for newcomers

Comments

@j9ac9k
Copy link
Collaborator

j9ac9k commented Dec 10, 2019

  • signalworks version: 0.3.1
  • Python version: 3.7.5
  • Operating System: macOS

Description

When calling tracking.wave.resample(some_freq), I get a new track back, but the dtype of the new_track was floating point (when the original track dtype was int16). This of course causes all sorts of havok with wave.min and wave.max, and thus plotting

Here is the code for resampling:

https://github.com/TimeViewers/signalworks/blob/master/signalworks/tracking/wave.py#L189-L202

In the end, it calls the Wave constructor, with the new values from resample_poly.

The thing to do here would be to convert the returned values into the dtype of the original array, something along the lines of

return type(self)(resample_poly(self._value, 1, int(self._fs / fs).astype(self._value.dtype), fs)
@j9ac9k j9ac9k added the good first issue Good for newcomers label Dec 10, 2019
@lxkain
Copy link
Collaborator

lxkain commented Dec 11, 2019

The assumption is that folks are ok with loosing the additional precision that would be necessary to capture the details of the resampling. I'm ok with making this assumption. Maybe we should have explicit bit-depth converters between 16 (int16), 32 (float32), and 64 (float64) bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants