Closed mjwillson closed 3 years ago
Tanks a lot for pointing this out!
Fourier transform does return both positive and negative frequencies due to symmetry, but the subsequent application of rapsd should only return positive frequencies. It seems that the range above is too wide and "overflew" into the negative frequencies.
I will check the code to see what happens. My first feeling is that it can be solved by stopping the range for even sizes at int(L/2)-1, but I should check where is the DC term to ensure there is the correct correspondence.
https://github.com/pySTEPS/pysteps/blob/76324d8f315f63c6723887f4c99d155749a31e83/pysteps/utils/spectral.py#L149
I believe there is a typo. It should be if L % 2 == 1:
Ok. In that case the docstring return section should be changed to: The length of the array is int(L/2) (if L is even) or int(L/2)+1 (if L is odd), where L=max(M,N). Correct?
Was this intentional? Note this doesn't happen for odd sizes:
It looks like this code is responsible -- was there a reason for the +1 here with even sizes?
Note that plot_spectrum1d is I think ignoring this negative frequency as it'll be mapped to NaN after taking logs.