diff options
author | Aki <please@ignore.pl> | 2022-09-07 10:42:26 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-09-07 10:42:26 +0200 |
commit | a09b2bbf82b74e155b99eae3aaa10acfd4269c92 (patch) | |
tree | 5967b9935d2f16ddb0da3d851d50a4402d839b66 | |
parent | 27dd532241efbe38f640c923533d8ea91ebabe2e (diff) | |
download | szilagyi-a09b2bbf82b74e155b99eae3aaa10acfd4269c92.zip szilagyi-a09b2bbf82b74e155b99eae3aaa10acfd4269c92.tar.gz szilagyi-a09b2bbf82b74e155b99eae3aaa10acfd4269c92.tar.bz2 |
Added error checking to public interface of the package
-rw-r--r-- | szilagyi/__init__.py | 15 | ||||
-rw-r--r-- | szilagyi/plots.py | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/szilagyi/__init__.py b/szilagyi/__init__.py index 99ba9fc..ce6e840 100644 --- a/szilagyi/__init__.py +++ b/szilagyi/__init__.py @@ -1 +1,14 @@ -from .nomogram import calculate_swi +from .nomogram import calculate_swi as _calculate_swi + + +def calculate_swi(temperature_difference, convective_cloud_depth): + """ + Calculates the Szilagyi Waterspout Index for *temperature_difference* and *convective_cloud_depth*. + + May raise :exc:`ValueError` if the values are not in range of the original nomogram. + """ + if temperature_difference < 0 or temperature_difference > 40: + raise ValueError("temperature_difference must be within <0, 40> range") + if convective_cloud_depth < 0 or convective_cloud_depth > 50000: + raise ValueError("convective_cloud_depth must be within <0, 50000> range") + return _calculate_swi(temperature_difference, convective_cloud_depth) diff --git a/szilagyi/plots.py b/szilagyi/plots.py index 516efd1..31b8af2 100644 --- a/szilagyi/plots.py +++ b/szilagyi/plots.py @@ -3,7 +3,7 @@ import math import matplotlib.pyplot as plot from . import _dataset -from . import calculate_swi +from .nomogram import calculate_swi MAX_X = 40 |