Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEOPY-1693: las-geoh5 import files driver doesn't support numeric well names #52

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions las_geoh5/import_las.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def create_or_append_drillhole(
translator = LASTranslator(NameOptions())

name = translator.retrieve("well_name", lasfile)
if not isinstance(name, str):
name = str(name)
if not name and logger is not None:
logger.warning(
"No well name provided for LAS file. "
Expand Down
32 changes: 32 additions & 0 deletions tests/import_las_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,35 @@ def test_warning_no_well_name(tmp_path: Path, caplog):
)

assert match in caplog.text


def test_handle_numeric_well_name(tmp_path: Path):
with Workspace.create(tmp_path / "test.geoh5") as workspace:
dh_group = DrillholeGroup.create(workspace, name="dh_group")

lasfile = generate_lasfile(
"123",
{"UTMX": 0.0, "UTMY": 0.0, "ELEV": 10.0},
np.arange(0, 11, 1),
{"my_property": np.zeros(11)},
)
lasfile = write_lasfile(tmp_path, lasfile)

filepath = write_import_params_file(
tmp_path / "import_las_files.ui.json",
dh_group,
"my_property_group",
[lasfile],
(
"UTMX",
"UTMY",
"ELEV",
),
)

module = importlib.import_module("las_geoh5.import_files.driver")
module.run(filepath)

with workspace.open():
dh_group = workspace.get_entity("dh_group")[0]
assert "123" in [k.name for k in dh_group.children]
5 changes: 5 additions & 0 deletions tests/script_las_to_geoh5_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .helpers import generate_lasfile, write_import_params_file, write_lasfile


# pylint: disable=duplicate-code
@pytest.fixture(scope="module", name="lasfile")
def lasfile_fixture(tmp_path_factory) -> Path:
input_dir = tmp_path_factory.mktemp("input")
Expand Down Expand Up @@ -75,6 +76,7 @@ def test_las_to_geoh5_without_output_name(
"""Test the las_to_geoh5 script."""

workspace_file = input_workspace.h5file
assert isinstance(workspace_file, Path)
modified_date = workspace_file.stat().st_mtime

with patch("sys.argv", ["las_to_geoh5", str(params_filepath)]):
Expand All @@ -93,6 +95,7 @@ def test_las_to_geoh5_with_monitoring_folder(
"""Test the las_to_geoh5 script."""

workspace_file = input_workspace.h5file
assert isinstance(workspace_file, Path)
modified_date = workspace_file.stat().st_mtime

monitoring_folder = tmp_path / "monitored here"
Expand Down Expand Up @@ -124,6 +127,7 @@ def test_las_to_geoh5_with_output_name(
"""Test the las_to_geoh5 script."""

workspace_file = input_workspace.h5file
assert isinstance(workspace_file, Path)
modified_date = workspace_file.stat().st_mtime

working_dir = tmp_path / "working"
Expand All @@ -150,6 +154,7 @@ def test_las_to_geoh5_with_absolute_output_path(
"""Test the las_to_geoh5 script."""

workspace_file = input_workspace.h5file
assert isinstance(workspace_file, Path)
modified_date = workspace_file.stat().st_mtime

output_dir = tmp_path / "output"
Expand Down
Loading