-
Notifications
You must be signed in to change notification settings - Fork 54
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
Floating point error in feature detection breaks interpn #433
Comments
Hi @travis-j-hahn , thanks for raising this issue. Do you have a minimal example that can recreate this error? (e.g. a subset of the data you were using). I'll have a look into this |
wrf_tb_tobac_test.zip
Then I used the snippet:
|
Anecdotally, I have also seen this issue, and I agree with the proposed solution. Thanks much @travis-j-hahn |
Thanks for sending the test data, I've successfully recreated the error. One thing to watch out for with the fix is that with periodic boundary conditions there are expected situations where the feature point lies outside the range of the coordinate axis (e.g. a feature a 359.5 longitude when the coord ranges 0-359), which we should ensure is handled correctly |
@freemansw1 we will also have to update the new |
Yes those need fixing anyway. Good note. |
Yes, I believe our expected out would be 359.5 there, but I'm not sure how |
Add coordinates doesn't currently handle PBCs at all 😬 I have no idea how we've avoided these errors before now... |
Fixed with #434 |
It looks like there is a chance during the feature detection step for the identification of cells on boundary edges which result in hdim1 or hdim2 values slightly outside of the maximum boundary. I.e. the feature detection can create a cell with ix value of 218.00000003 when the maximum index is 218, and this throws an error in tobac/general.py:107 with
coordinate_points = interpn(points, values, xi)
raisingValueError: One of the requested xi is out of bounds in dimension 0
Full Error:
This can be fixed by using np.clip to ensure there is no overflow:
The text was updated successfully, but these errors were encountered: