From 0144994796664786e45ca5c651d52020444dea47 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Wed, 3 Jul 2024 16:03:36 +0930 Subject: [PATCH] chore: added displacement conversion function --- LoopDataConverter/utils/__init__.py | 4 + LoopDataConverter/utils/conversion.py | 133 ++++++++++++++++---------- 2 files changed, 88 insertions(+), 49 deletions(-) diff --git a/LoopDataConverter/utils/__init__.py b/LoopDataConverter/utils/__init__.py index e69de29..f17630d 100644 --- a/LoopDataConverter/utils/__init__.py +++ b/LoopDataConverter/utils/__init__.py @@ -0,0 +1,4 @@ +from .conversion import (convert_dip_terms, + convert_dipdir_terms, + convert_tightness_terms, + convert_displacement_terms) \ No newline at end of file diff --git a/LoopDataConverter/utils/conversion.py b/LoopDataConverter/utils/conversion.py index 3cf43c8..e19132b 100644 --- a/LoopDataConverter/utils/conversion.py +++ b/LoopDataConverter/utils/conversion.py @@ -1,4 +1,4 @@ -import numpy +import numpy import beartype @@ -7,47 +7,48 @@ def convert_dipdir_cardinals(cardinal: str): """ Convert cardinal directions to degrees. - Parameters: + Parameters: cardinal (str): The cardinal direction to convert. return (float): The cardinal direction in degrees. """ - if cardinal == 'N': - return 0. - elif cardinal == 'NNE': + if cardinal == "N": + return 0.0 + elif cardinal == "NNE": return 22.5 - elif cardinal == 'NE': - return 45. - elif cardinal == 'ENE': + elif cardinal == "NE": + return 45.0 + elif cardinal == "ENE": return 67.5 - elif cardinal == 'E': - return 90. - elif cardinal == 'ESE': + elif cardinal == "E": + return 90.0 + elif cardinal == "ESE": return 112.5 - elif cardinal == 'SE': - return 135. - elif cardinal == 'SSE': + elif cardinal == "SE": + return 135.0 + elif cardinal == "SSE": return 157.5 - elif cardinal == 'S': - return 180. - elif cardinal == 'SSW': + elif cardinal == "S": + return 180.0 + elif cardinal == "SSW": return 202.5 - elif cardinal == 'SW': - return 225. - elif cardinal == 'WSW': + elif cardinal == "SW": + return 225.0 + elif cardinal == "WSW": return 247.5 - elif cardinal == 'W': - return 270. - elif cardinal == 'WNW': + elif cardinal == "W": + return 270.0 + elif cardinal == "WNW": return 292.5 - elif cardinal == 'NW': - return 315. - elif cardinal == 'NNW': + elif cardinal == "NW": + return 315.0 + elif cardinal == "NNW": return 337.5 else: return numpy.nan -def convert_dip_terms(dip_term: str): + +def convert_dip_terms(dip_term: str, type: str): """ Convert dip terms to degrees. @@ -56,16 +57,30 @@ def convert_dip_terms(dip_term: str): return (float): The dip term in 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 + if type == "fault": + if dip_term == "Vertical": + return 90.0 + elif dip_term == "Horizontal": + return 0.0 + elif dip_term == "Moderate": + return 45.0 + elif dip_term == "Steep": + return 75.0 + else: + return numpy.nan + + elif type == "fold": + if dip_term == "Upright": + return 90.0 + elif dip_term == "Recumbent": + return 0.0 + elif dip_term == "Inclined": + return 45.0 + elif dip_term == "Reclined": + return 75.0 + else: + return numpy.nan + def convert_tightness_terms(tightness_term: str): """ @@ -74,18 +89,38 @@ def convert_tightness_terms(tightness_term: str): Parameters: tightness_term (str): The tightness term to convert. - return (float): The tightness term in degrees, + return (float): The tightness term in degrees, which is the average of the interlimb angle range. """ - 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. + if tightness_term == "gentle": + return 150.0 + elif tightness_term == "open": + return 95.0 + elif tightness_term == "close": + return 50.0 + elif tightness_term == "tight": + return 15.0 + elif tightness_term == "isoclinal": + return 0.0 + else: + return numpy.nan + +def convert_displacement_terms(displacement_term: str): + """ + Convert displacement terms to meters. + + Parameters: + displacement_term (str): The displacement term to convert. + + return (float): The displacement term in meters. + """ + if displacement_term == "1m-100m": + return 50.5 + elif displacement_term == "100m-1km": + return 550.0 + elif displacement_term == "1km-5km": + return 3000.0 + elif displacement_term == ">5km": + return 5000.0 else: - return numpy.nan \ No newline at end of file + return numpy.nan