From aa8530ab17ab58540d8777a175c21b2621d84c67 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 21 Sep 2022 23:13:04 +0200 Subject: Fixed temperature units to delta Celsius degrees --- szilagyi/__init__.py | 8 ++++---- szilagyi/tests.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/szilagyi/__init__.py b/szilagyi/__init__.py index 67da4a8..bfde154 100644 --- a/szilagyi/__init__.py +++ b/szilagyi/__init__.py @@ -7,9 +7,9 @@ There is only one function provided, so the use should be straight-forward. For >>> import pint >>> import szilagyi >>> u = pint.UnitRegistry() - >>> round(szilagyi.calculate_swi(10.5 * u.C, 24100 * u.ft), 3) + >>> round(szilagyi.calculate_swi(10.5 * u.delta_degC, 24100 * u.ft), 3) 0.811 - >>> round(szilagyi.calculate_swi(7 * u.C, 12500 * u.ft), 3) + >>> round(szilagyi.calculate_swi(7 * u.delta_degC, 12500 * u.ft), 3) -4.88 """ @@ -27,11 +27,11 @@ def calculate_swi(temperature_difference: Quantity, convective_cloud_depth: Quan of the original nomogram. The maximum values are available as MAX_TEMPERATURE_DIFFERENCE and MAX_CONVECTIVE_CLOUD_DEPTH constants. """ - if not temperature_difference.is_compatible_with("C"): + if not temperature_difference.is_compatible_with("delta_degC"): raise ValueError("temperature_difference must be convertible to Celsius degrees") if not convective_cloud_depth.is_compatible_with("ft"): raise ValueError("convective_cloud_depth must be convertible to Feet") - temperature_difference = temperature_difference.m_as("C") + temperature_difference = temperature_difference.m_as("delta_degC") convective_cloud_depth = convective_cloud_depth.m_as("ft") if temperature_difference < 0 or temperature_difference > MAX_TEMPERATURE_DIFFERENCE: raise ValueError(f"temperature_difference must be within <0, {MAX_TEMPERATURE_DIFFERENCE}> range") diff --git a/szilagyi/tests.py b/szilagyi/tests.py index 40d82f7..f0d0176 100644 --- a/szilagyi/tests.py +++ b/szilagyi/tests.py @@ -7,7 +7,7 @@ from . import calculate_swi class CalculateSwi(unittest.TestCase): def setUp(self): ureg = pint.UnitRegistry() - self.C = ureg.C + self.C = ureg.delta_degC self.ft = ureg.ft def test_out_of_range(self): -- cgit v1.1