-
Notifications
You must be signed in to change notification settings - Fork 145
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
Incorrectly reconstructed Fourier frequency array #856
Comments
Hi @matteolucchini1, good catch! Between the two methods, I would absolutely vote for using the machinery in |
@matteobachetti yea I agree. I think the easiest implementation to make this a bit more bulletproof would be to replace the calls with np.rint() to just int() - there's a few in other classes (e.g. |
@matteolucchini1 I don't agree with this though. The current implementation in |
I'm confused - the implementation in We could pass |
|
Description of the Bug
We typically have two ways to construct arrays of Fourier frequency. One is to take the size of a segment to calculate the number of bins (e.g. flux.size), another is to calculate the number of bins in a segment of given size with numpy.rint by hand. The bug is these two methods round non-integers differently, and as a result the two arrays are not necessarily the same.
Steps/Code to Replicate the Bug
seg_size = 5
time_res = 0.03
freq_int = fftfreq(int(seg_size/time_res),time_res)
freq_rint = ftfreq(int(np.rint(seg_size/time_res))),time_res)
Expected Results
These two should be the same the parts of the code that use either method to be consistent.
Actual Results
int(5/0.03) = 166 and np.rint(5/0.03) = 167.
The result is that parts of the code that call the two methods, one can get an error due to the array masking not working correctly. For example, VarEnergyspectrum uses the first method in the initialization when calling avg_pds_from_timeseries, and the second in _get_good_frequency_bins().
The text was updated successfully, but these errors were encountered: