import os
import numpy as np
import pytest
import las_rs
test_dir = os.path.dirname(__file__)
def fixture(*parts):
return os.path.join(test_dir, "fixtures", *parts)
def _las_meters():
return las_rs.read("""\
~VERSION INFORMATION
VERS. 2.0 : LAS VERSION 2.0
WRAP. NO : ONE LINE PER DEPTH STEP
~WELL INFORMATION
STRT.M 500.0 : START DEPTH
STOP.M 502.0 : STOP DEPTH
STEP.M 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. NORDIC PETROLEUM : COMPANY
WELL. FJORD-3 #1 : WELL NAME
~CURVE INFORMATION
DEPT.M : MEASURED DEPTH
GR .GAPI : GAMMA RAY
~ASCII LOG DATA
500.0 33.11
501.0 41.55
502.0 38.72
""")
def _las_feet():
return las_rs.read("""\
~VERSION INFORMATION
VERS. 2.0 : LAS VERSION 2.0
WRAP. NO : ONE LINE PER DEPTH STEP
~WELL INFORMATION
STRT.FT 1640.0 : START DEPTH
STOP.FT 1643.0 : STOP DEPTH
STEP.FT 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. GULF COAST ENERGY : COMPANY
WELL. LONGHORN-9 #2 : WELL NAME
~CURVE INFORMATION
DEPT.FT : MEASURED DEPTH
GR .GAPI : GAMMA RAY
~ASCII LOG DATA
1640.0 55.21
1641.0 62.88
1642.0 49.77
1643.0 57.30
""")
def _las_unknown_unit():
return las_rs.read("""\
~VERSION INFORMATION
VERS. 2.0 : LAS VERSION 2.0
WRAP. NO : ONE LINE PER DEPTH STEP
~WELL INFORMATION
STRT.FATH 100.0 : START DEPTH
STOP.FATH 102.0 : STOP DEPTH
STEP.FATH 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. ABYSSAL SURVEYS : COMPANY
WELL. SEAMOUNT-1 #3 : WELL NAME
~CURVE INFORMATION
DEPT.FATH : MEASURED DEPTH
GR .GAPI : GAMMA RAY
~ASCII LOG DATA
100.0 27.44
101.0 31.19
102.0 29.88
""")
_FT_PER_M = 1.0 / 0.3048 _M_PER_FT = 0.3048
@pytest.mark.xfail(reason="not yet implemented")
def test_index_unit_meters():
las = _las_meters()
assert las.index_unit == "M"
@pytest.mark.xfail(reason="not yet implemented")
def test_index_unit_feet():
las = _las_feet()
assert las.index_unit == "FT"
@pytest.mark.xfail(reason="not yet implemented")
def test_index_unit_none():
las = _las_unknown_unit()
assert las.index_unit is None
@pytest.mark.xfail(reason="not yet implemented")
def test_depth_m_from_meters():
las = _las_meters()
expected = las.curves["DEPT"].data
np.testing.assert_array_almost_equal(las.depth_m, expected)
@pytest.mark.xfail(reason="not yet implemented")
def test_depth_m_from_feet():
las = _las_feet()
depth_ft = las.curves["DEPT"].data
expected_m = depth_ft * _M_PER_FT
np.testing.assert_array_almost_equal(las.depth_m, expected_m, decimal=4)
@pytest.mark.xfail(reason="not yet implemented")
def test_depth_ft_from_feet():
las = _las_feet()
expected = las.curves["DEPT"].data
np.testing.assert_array_almost_equal(las.depth_ft, expected)
@pytest.mark.xfail(reason="not yet implemented")
def test_depth_ft_from_meters():
las = _las_meters()
depth_m = las.curves["DEPT"].data
expected_ft = depth_m * _FT_PER_M
np.testing.assert_array_almost_equal(las.depth_ft, expected_ft, decimal=4)
@pytest.mark.xfail(reason="not yet implemented")
def test_depth_unknown_raises():
las = _las_unknown_unit()
with pytest.raises((las_rs.LASUnknownUnitError, Exception)):
_ = las.depth_m
@pytest.mark.xfail(reason="not yet implemented")
def test_force_index_unit():
las = las_rs.read("""\
~VERSION INFORMATION
VERS. 2.0 : LAS VERSION 2.0
WRAP. NO : ONE LINE PER DEPTH STEP
~WELL INFORMATION
STRT.FT 5000.0 : START DEPTH
STOP.FT 5002.0 : STOP DEPTH
STEP.FT 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. SUMMIT DRILLING : COMPANY
WELL. HIGHPEAK-2 #1 : WELL NAME
~CURVE INFORMATION
DEPT.FT : MEASURED DEPTH
GR .GAPI : GAMMA RAY
~ASCII LOG DATA
5000.0 44.10
5001.0 52.37
5002.0 48.95
""", index_unit="m")
assert las.index_unit is not None
assert las.index_unit.lower() == "m"