Skip to content

Commit

Permalink
chore: added displacement conversion function
Browse files Browse the repository at this point in the history
  • Loading branch information
rabii-chaarani committed Jul 3, 2024
1 parent 05212db commit 0144994
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 49 deletions.
4 changes: 4 additions & 0 deletions LoopDataConverter/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .conversion import (convert_dip_terms,
convert_dipdir_terms,
convert_tightness_terms,
convert_displacement_terms)
133 changes: 84 additions & 49 deletions LoopDataConverter/utils/conversion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy
import numpy
import beartype


Expand All @@ -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.
Expand All @@ -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):
"""
Expand All @@ -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
return numpy.nan

0 comments on commit 0144994

Please sign in to comment.