Skip to content

Commit 98c43ef

Browse files
handle acre unit in HIP-RA-X
1 parent 05c827a commit 98c43ef

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/geophires_x/Parameter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from abc import ABC
1616

17+
from pint import UndefinedUnitError
1718
from pint.facets.plain import PlainQuantity
1819

1920
from geophires_x.OptionList import GeophiresInputEnum
@@ -947,8 +948,13 @@ def LookupUnits(sUnitText: str):
947948
return item, uType
948949

949950
# No match was found with the unit text string, so try with the canonical symbol (if different).
950-
symbol = _ureg.get_symbol(sUnitText)
951-
if symbol != sUnitText: return LookupUnits(symbol)
951+
try:
952+
symbol = _ureg.get_symbol(sUnitText)
953+
if symbol != sUnitText:
954+
return LookupUnits(symbol)
955+
except UndefinedUnitError as _uue:
956+
return sUnitText, uType
957+
952958
return None, None
953959

954960

src/geophires_x/Units.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class AreaUnit(str, Enum):
135135
FEET2 = "ft**2"
136136
INCHES2 = "in**2"
137137
MILES2 = "mi**2"
138+
ACRES = 'acre'
138139

139140

140141
class VolumeUnit(str, Enum):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Reservoir Temperature, 212.5
2+
Rejection Temperature, 60.0
3+
Reservoir Porosity, 10.0
4+
Reservoir Area, 109930 acre
5+
Reservoir Thickness, 0.25
6+
Reservoir Life Cycle, 25

tests/hip_ra_x_tests/test_hip_ra_x.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,16 @@ def test_hip_ra_input_parameters_init(self):
474474
with self.assertRaises(ValueError):
475475
HipRaInputParameters(1)
476476

477-
def _new_hip_ra_test_instance(self, enable_hip_ra_logging_config=False, pre_re_stash_runner=None) -> HIP_RA_X:
477+
def test_area_acre(self):
478+
result: HipRaResult = HipRaXClient().get_hip_ra_x_result(
479+
HipRaInputParameters(self._get_test_file_path('hip-ra-x-area-acres.txt'))
480+
)
481+
482+
self.assertEqual('km**2', result.result['SUMMARY OF INPUTS']['Reservoir Area']['unit'])
483+
self.assertAlmostEqual(444.9, result.result['SUMMARY OF INPUTS']['Reservoir Area']['value'], places=1)
484+
485+
@staticmethod
486+
def _new_hip_ra_test_instance(enable_hip_ra_logging_config=False, pre_re_stash_runner=None) -> HIP_RA_X:
478487
stash_cwd = Path.cwd()
479488
stash_sys_argv = sys.argv
480489

0 commit comments

Comments
 (0)