change isotropize to satisfy Parseval's thereom#222
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Hi @roxyboy, following your suggestions, I've reformatted the modified codes using Lines 953 to 959 in 9ac46f9 cannot be passed. The slopes of the two arrays are the same but differ by a constant that may depend on the number of points within each radial band, as |
Apologies for my slow reply, I was away for the past week. Thanks for the Black formatting! I understand that the assertion isn't passing because the radial wavenumber is taken using a |
|
I've changed the assertion to I also changed Line 1012 in 9ac46f9 Not sure if it is fine. It cannot get passed when |
xrft/tests/test_xrft.py
Outdated
| npt.assert_almost_equal(np.ma.masked_invalid(iso_ps).mask.sum(), 0.0) | ||
| y_fit, a, b = xrft.fit_loglog(iso_ps.freq_r.values[4:], iso_ps.values[4:]) | ||
| npt.assert_allclose(a, s, atol=0.1) | ||
| npt.assert_allclose(a, s, atol=1) |
There was a problem hiding this comment.
Does this mean that this PR results in the slopes differing by a factor of one...? If so, this is not good.
Yes, this is what I was personally worried that could happen when switching the isotropization from |
|
Hi @roxyboy, I just looked into the test, and found that the frequency range to be fitted is crucial. Line 1011 in 9ac46f9 Previously, indices from 4 to end are used, which include the highest frequencies that are steeper than expected. Now I switch the indices from 0 to -35, which overlap with the expected range, and this test passed even with a smaller `atol=0.06. The red curve is the fitted line over indices from 0 to -35. You may want to check if this is OK. |
|
@miniufo Ok, this is great! Can you run the Black formatting once more and I can merge this :) |
|
Oops, I forgot to do this after any changes. Can you check it again? |
|
@miniufo Sorry, it seems that some files are still missing the Black formatting... |
|
That's strange. I format all .py files. Possibly missing the .ipynb files. Please try again and see if it is fine now. |
|
@miniufo I agree that this is kind of unexpected behavior but the GitHub log is saying that |
|
Thanks for your work @miniufo ! The checks are all passing now so I will merge this. |
|
That's great~ |

This PR tries to solve #219.
Also, we add 3D detrending codes, which may be useful when calculating 3D (2D space and 1D time) frequency-wavenumber spectrum.