-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add fft frequency transformation #62
base: master
Are you sure you want to change the base?
Conversation
…t be at least twice the signal bandwidth
…t at least twice the signal bandwidth
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.
thanks @SaraPido!
For our reference, which formula did you implement for this solution here? It would be good to reference why we changed the implementation.
@@ -16,6 +16,7 @@ def fft_freq(amplitude_values, sampling_frequency): | |||
* `amplitude_values (numpy.ndarray)` | |||
* `frequency_values (numpy.ndarray)` | |||
""" | |||
frequency_values = np.fft.fftfreq(len(amplitude_values), 1 / sampling_frequency) | |||
# frequency_values = np.fft.fftfreq(len(amplitude_values), 1 / sampling_frequency) | |||
frequency_values = np.arange(0, len(amplitude_values)) * sampling_frequency |
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.
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.
Theoretically the end time is:
End Time = Timestamp + (Length of Values * sampling frequency )
So the frequencies values are
np.arange(0, N)* sampling frequency
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.
LGTM! Thanks @SaraPido!
Maximum frequency value = sampling_frequency * len(amplitude_values)
Fft frequency transformation when data sampling rate is not at least twice the signal's bandwidth.
Previous solution:
- Designed for cases where amplitude values include both positive and negative frequency components.
- Designed for data where sampling rate is at least twice the signal's bandwidth.
- Not suitable for our use case, which assumes amplitude values represent only the positive side of the FFT result.
- The formula was using the Numpy fftfreq function: frequency_values = np.fft.fftfreq(len(amplitude_values), 1 / sampling_frequency)
Current solution:
- Addresses the limitations of
numpy.fft.fftfreq
andnumpy.fft.rfftfreq
, which do not directly align with our assumptions about positive-only FFT amplitudes.- Assumes a uniformly spaced frequency axis starting at zero and progressing in increments based on the sampling frequency, ensuring compatibility with our assumptions.
- Now, the function is: frequency_values = np.arange(0, len(amplitude_values)) * sampling_frequency