Skip to content

Commit

Permalink
Merge pull request #167 from jonnymaserati/feature/survey_parameters
Browse files Browse the repository at this point in the history
Feature/survey parameters
  • Loading branch information
jonnymaserati committed Dec 16, 2023
2 parents 12f5e6d + b823ce9 commit 61dbd9a
Show file tree
Hide file tree
Showing 9 changed files with 2,573 additions and 2,272 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'numpy',
'scipy',
'pint',
'pyproj', # required for getting survey parameters
'PyYAML',
'setuptools',
'vtk'
Expand All @@ -43,7 +44,7 @@
'tabulate',
'trimesh',
'utm',
'vedo',
'vedo'
])

# this is the troublesome requirement that needs C dependencies
Expand Down
53 changes: 53 additions & 0 deletions tests/test_survey_parameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import inspect
import sys

import welleng as we

reference = {
'x': 588319.02, 'y': 5770571.03, 'northing': 5770571.03,
'easting': 588319.02, 'latitude': 52.077583926214494,
'longitude': 4.288694821453205, 'convergence': 1.0166440347220762,
'scale_factor': 0.9996957469340422, 'magnetic_field_intensity': 49381,
'declination': 2.213, 'dip': -67.199, 'date': '2023-12-16',
'srs': 'EPSG:23031'
}


def test_known_location():
calculator = we.survey.SurveyParameters(reference.get('srs'))
survey_parameters = calculator.get_factors_from_x_y(
x=reference.get('x'), y=reference.get('y'), date=reference.get('date')
)

for k, v in survey_parameters.items():
try:
assert round(v, 3) == round(reference.get(k), 3)
except TypeError:
assert v == reference.get(k)

pass


def one_function_to_run_them_all():
"""
Function to gather the test functions so that they can be tested by
running this module.
https://stackoverflow.com/questions/18907712/python-get-list-of-all-
functions-in-current-module-inspecting-current-module
"""
test_functions = [
obj for name, obj in inspect.getmembers(sys.modules[__name__])
if (inspect.isfunction(obj)
and name.startswith('test')
and name != 'all')
]

for f in test_functions:
f()

pass


if __name__ == '__main__':
one_function_to_run_them_all()
43 changes: 43 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import inspect
import sys

from welleng.units import ureg
from welleng.utils import annular_volume


def test_annular_volume():
av = annular_volume(
od=ureg('12.25 inch').to('meter'),
id=ureg(f'{9+5/8} inch').to('meter'),
length=ureg('1000 meter')
)

assert av.m == 3.491531223156194
assert str(av.u) == 'meter ** 3'

pass


def one_function_to_run_them_all():
"""
Function to gather the test functions so that they can be tested by
running this module.
https://stackoverflow.com/questions/18907712/python-get-list-of-all-
functions-in-current-module-inspecting-current-module
"""
test_functions = [
obj for name, obj in inspect.getmembers(sys.modules[__name__])
if (inspect.isfunction(obj)
and name.startswith('test')
and name != 'all')
]

for f in test_functions:
f()

pass


if __name__ == '__main__':
one_function_to_run_them_all()
Loading

0 comments on commit 61dbd9a

Please sign in to comment.