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

heat_index encounters sqrt of negatives #596

Open
anissa111 opened this issue Apr 16, 2024 · 0 comments · May be fixed by #597
Open

heat_index encounters sqrt of negatives #596

anissa111 opened this issue Apr 16, 2024 · 0 comments · May be fixed by #597
Assignees
Labels
bug Something isn't working refactor Internal code refactoring testing Issue related to testing

Comments

@anissa111
Copy link
Member

anissa111 commented Apr 16, 2024

Pulling out of #582

Yeah, I agree we shouldn't do this because, at the least, our users will still see it. From some DMs, I actually think this is an unintended behavior "bug" and I'm looking into it currently.

In short, in heat_index, we apply some adjustments to the values depending on the value of a couple other variables. The adjustment itself should never attempt to square root a negative, but the function (xr.where), calculates all the adjustments and then applies them where the filter passes instead of finding where the filter passes and then calculating the adjustment. If that makes sense?

# adjustments
heatindex = xr.where(
np.logical_and(relative_humidity < 13,
np.logical_and(temperature > 80, temperature < 112)),
heatindex - ((13 - relative_humidity) / 4) * np.sqrt(
(17 - abs(temperature - 95)) / 17), heatindex)
heatindex = xr.where(
np.logical_and(relative_humidity > 85,
np.logical_and(temperature > 80, temperature < 87)),
heatindex + ((relative_humidity - 85.0) / 10.0) *
((87.0 - temperature) / 5.0), heatindex)
return heatindex

We're doing this partially because of dask compatibility and partially because it's the cleanest way to accept n-dimensional data of numpy/list/xarray types.

We could theoretically filter the warnings here, but it bothers me that we're doing a bunch of unnecessary calculations.

Originally posted by @anissa111 in #582 (comment)

@anissa111 anissa111 self-assigned this Apr 16, 2024
@anissa111 anissa111 added the bug Something isn't working label Apr 16, 2024
@anissa111 anissa111 linked a pull request Apr 16, 2024 that will close this issue
9 tasks
@anissa111 anissa111 added refactor Internal code refactoring testing Issue related to testing labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor Internal code refactoring testing Issue related to testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant