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-1817: Check that utf-8 characters are supported #66

Merged
merged 3 commits into from
Nov 6, 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
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
Loading