Skip to content

Commit

Permalink
Merge pull request #66 from MiraGeoscience/GEOPY-1817
Browse files Browse the repository at this point in the history
GEOPY-1817: Check that utf-8 characters are supported
  • Loading branch information
domfournier authored Nov 6, 2024
2 parents 8fcbea6 + eaeada1 commit c1f9e00
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 3 additions & 1 deletion las_geoh5/import_directories/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def import_las_directory(dh_group: DrillholeGroup, basepath: str | Path):
for prop in property_group_folders:
lasfiles = []
for file in [k for k in prop.iterdir() if k.suffix == ".las"]:
lasfiles.append(lasio.read(file, mnemonic_case="preserve"))
lasfiles.append(
lasio.read(file, mnemonic_case="preserve", encoding="utf-8")
)
print(f"Importing property group data from to '{prop.name}'")
las_to_drillhole(
lasfiles,
Expand Down
2 changes: 1 addition & 1 deletion las_geoh5/import_las.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,4 @@ def lasio_read(file):
"""

_patch_lasio_reader()
return lasio.read(file, mnemonic_case="preserve")
return lasio.read(file, mnemonic_case="preserve", encoding="utf-8")
30 changes: 30 additions & 0 deletions tests/import_las_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@
]


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

lasfile = generate_lasfile(
well="dh1é",
collar={"UTMX": 0.0, "UTMY": 0.0, "ELEV": 10.0},
depths=np.arange(0, 11, 1),
properties={"my_property": np.zeros(11)},
)
lasfiles = [write_lasfile(tmp_path, lasfile)]
filepath = write_import_params_file(
tmp_path / "import_las_files.ui.json",
dh_group,
"my_property_group",
lasfiles,
(
"UTMX",
"UTMY",
"ELEV",
),
)

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

with workspace.open(mode="r"):
assert workspace.get_entity("dh1é")[0] is not None


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

0 comments on commit c1f9e00

Please sign in to comment.