Skip to content
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

Preserve dtype for wrap_lons #4119

Open
stephenworsley opened this issue May 6, 2021 · 0 comments · Fixed by Rohansjamadagni/iris#1
Open

Preserve dtype for wrap_lons #4119

stephenworsley opened this issue May 6, 2021 · 0 comments · Fixed by Rohansjamadagni/iris#1
Labels
Good First Issue A good issue to take on if you're just getting started with Iris development

Comments

@stephenworsley
Copy link
Contributor

📰 Custom Issue

Currently, iris.analysis.cartography.wrap_lons promotes dtype to np.float64. This is causing some users to have to manually change the dtype back to its original version.

# It is important to use 64bit floating precision when changing a floats
# numbers range.
lons = lons.astype(np.float64)
return ((lons - base + period * 2) % period) + base

I believe this is done to avoid rounding errors within the calculation. If this is the case, It may be worth converting back to the original dtype after the calculation with something like the following code:

orig_dtype = lons.dtype
lons = lons.astype(np.float64)
return (((lons – base + period * 2) % period) + base).astype(orig_dtype)
@trexfeathers trexfeathers added the Good First Issue A good issue to take on if you're just getting started with Iris development label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue A good issue to take on if you're just getting started with Iris development
Projects
Status: No status
2 participants