diff --git a/tests/test_data/error_mwdrev5_iscwsa_validation_results.xlsx b/tests/test_data/error_mwdrev5_iscwsa_validation_results.xlsx index 4e13498..678c7ad 100644 Binary files a/tests/test_data/error_mwdrev5_iscwsa_validation_results.xlsx and b/tests/test_data/error_mwdrev5_iscwsa_validation_results.xlsx differ diff --git a/tests/test_utils.py b/tests/test_utils.py index 61d1e8e..24f981e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,3 @@ -import inspect -import sys import unittest import numpy as np @@ -78,6 +76,15 @@ def test_decimal2dms(self): np.array((np.array(LAT[:3]), np.array(LON[:3]))) )) + dms = decimal2dms(np.array([ + (LAT[0] + LAT[1] / 60 + LAT[2] / 3600), + (LON[0] + LON[1] / 60 + LON[2] / 3600) + ]), ndigits=4) + assert np.all(np.equal( + dms, + np.array((np.array(LAT[:3]), np.array(LON[:3]))) + )) + dms = decimal2dms(np.array([ (LAT[0] + LAT[1] / 60 + LAT[2] / 3600, LAT[3]), (LON[0] + LON[1] / 60 + LON[2] / 3600, LON[3]) diff --git a/welleng/utils.py b/welleng/utils.py index 3800faa..9f966ba 100644 --- a/welleng/utils.py +++ b/welleng/utils.py @@ -710,15 +710,20 @@ def decimal2dms(decimal: tuple | NDArray, ndigits: int = None) -> tuple | NDArra [[52 4 43.1868 'N'] [4 17 19.6368 'E']] """ + flag = False + _decimal = np.array(decimal) + if _decimal.dtype == np.float64: + _decimal = _decimal.reshape((-1, 1)) + flag = True try: - dms = np.apply_along_axis(_decimal2dms, -1, decimal, ndigits) + dms = np.apply_along_axis(_decimal2dms, -1, _decimal, ndigits) except np.exceptions.AxisError: - dms = _decimal2dms(decimal, ndigits) + dms = _decimal2dms(_decimal, ndigits) if dms.shape == (4,): return tuple(dms) else: - return dms + return dms.reshape((-1, 3)) if flag else dms def _dms2decimal(dms: NDArray, ndigits: int = None) -> NDArray: