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

GetTDewPointFromHumRatio fails with NaN input #95

Open
gsalinas opened this issue Dec 20, 2022 · 2 comments
Open

GetTDewPointFromHumRatio fails with NaN input #95

gsalinas opened this issue Dec 20, 2022 · 2 comments

Comments

@gsalinas
Copy link

The GetTDewPoint methods (and, therefore, also any other methods that use dew points internally) have an iterative calculation inside them that fails to converge when called with NaN as input.

To Reproduce

psychrolib.GetTDewPointFromRelHum(25, np.nan)
psychrolib.GetTDewPointFromHumRatio(np.nan, 0.010, 101325)

Result:
ValueError: Convergence not reached in GetTDewPointFromVapPres. Stopping.

Expected behavior
Should return NaN, as happens with, e.g., psychrolib.GetHumRatioFromRelHum(25, np.nan, 101325). This also dovetails with supporting vectorised operations; it's helpful & efficient to be able to run the library methods on vectors that include missing data indicated with NaN.

@gsalinas
Copy link
Author

gsalinas commented Jan 5, 2023

Thanks to @C-H-Simpson I found out that I was missing the optional numba dependency, and this now mostly works. You get a runtime warning and dew point calculations involving NaN as an argument return 0 for me. I think NaN would be preferable but I'm already much happier with this situation.

@akiss-ic
Copy link

akiss-ic commented Mar 21, 2024

Adding to this, when using psychrolib.GetTWetBublFromRelHum with np.nan as an argument for relative humidity gives you a Runtime warning but also produces a viable result with RH ~1. E.g. psychro.GetTWetBulbFromRelHum(20,np.nan,101325) returns 19.99969482421875 whereas psychro.GetTWetBulbFromRelHum(np.nan, 0.5, 101325) returns nan as expected. This behavior extends to ndarrays with np.nan as values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants