summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-09-21 23:13:04 +0200
committerAki <please@ignore.pl>2022-09-21 23:13:04 +0200
commitaa8530ab17ab58540d8777a175c21b2621d84c67 (patch)
tree5161b2fb7f153bc34cac1eb91465385ef8271268
parent7082cbb1d05f684e674949edd87fef10e655f49a (diff)
downloadszilagyi-aa8530ab17ab58540d8777a175c21b2621d84c67.zip
szilagyi-aa8530ab17ab58540d8777a175c21b2621d84c67.tar.gz
szilagyi-aa8530ab17ab58540d8777a175c21b2621d84c67.tar.bz2
Fixed temperature units to delta Celsius degrees
-rw-r--r--szilagyi/__init__.py8
-rw-r--r--szilagyi/tests.py2
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):