From d1a6a53ead13959dc50fe0e2bf14f7ce84f5f108 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Wed, 3 Jul 2024 14:34:38 +0930 Subject: [PATCH] chore: added conversion utils functions --- LoopDataConverter/utils/__init__.py | 0 LoopDataConverter/utils/conversion.py | 75 +++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 LoopDataConverter/utils/__init__.py create mode 100644 LoopDataConverter/utils/conversion.py diff --git a/LoopDataConverter/utils/__init__.py b/LoopDataConverter/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/LoopDataConverter/utils/conversion.py b/LoopDataConverter/utils/conversion.py new file mode 100644 index 0000000..d019670 --- /dev/null +++ b/LoopDataConverter/utils/conversion.py @@ -0,0 +1,75 @@ +import numpy +import beartype + + +@beartype.beartype +def convert_dipdir_cardinals(cardinal: str): + """ + Convert cardinal directions to degrees. + """ + if cardinal == 'N': + return 0 + elif cardinal == 'NNE': + return 22.5 + elif cardinal == 'NE': + return 45 + elif cardinal == 'ENE': + return 67.5 + elif cardinal == 'E': + return 90 + elif cardinal == 'ESE': + return 112.5 + elif cardinal == 'SE': + return 135 + elif cardinal == 'SSE': + return 157.5 + elif cardinal == 'S': + return 180 + elif cardinal == 'SSW': + return 202.5 + elif cardinal == 'SW': + return 225 + elif cardinal == 'WSW': + return 247.5 + elif cardinal == 'W': + return 270 + elif cardinal == 'WNW': + return 292.5 + elif cardinal == 'NW': + return 315 + elif cardinal == 'NNW': + return 337.5 + else: + return numpy.nan + +def convert_dip_terms(dip_term: str): + """ + Convert dip terms to degrees. + """ + if dip_term == 'Vertical': + return 90 + elif dip_term == 'Horizontal': + return 0 + elif dip_term == 'Moderate': + return 45 + elif dip_term == 'Steep': + return 75 + else: + return numpy.nan + +def convert_tightness_terms(tightness_term: str): + """ + Convert tightness terms to degrees. + """ + if tightness_term == 'gentle': + return 150 + elif tightness_term == 'open': + return 95 + elif tightness_term == 'close': + return 50 + elif tightness_term == 'tight': + return 15 + elif tightness_term == 'isoclinal': + return 0 + else: + return numpy.nan \ No newline at end of file