From 47fe8e4f56fc4b330b235823c510a61658aa6aa8 Mon Sep 17 00:00:00 2001 From: sebhmg Date: Wed, 23 Oct 2024 21:42:15 -0400 Subject: [PATCH 1/2] Revert "version is 0.3": bump to 0.4.0 on develop This reverts commit ed923bae81bb878ca5999336bf45afc3ec921621. --- docs/source/conf.py | 4 ++-- las_geoh5/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7554469..04d46ec 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,6 +27,6 @@ html_static_path = ["_static"] # The short X.Y version. -version = "0.3.0" +version = "0.4.0" # The full version, including alpha/beta/rc tags. -release = "0.3.0-alpha.1" +release = "0.4.0-alpha.1" diff --git a/las_geoh5/__init__.py b/las_geoh5/__init__.py index a16f005..1401e90 100644 --- a/las_geoh5/__init__.py +++ b/las_geoh5/__init__.py @@ -11,7 +11,7 @@ from pathlib import Path -__version__ = "0.3.0-alpha.1" +__version__ = "0.4.0-alpha.1" def assets_path() -> Path: diff --git a/pyproject.toml b/pyproject.toml index 327ec76..c9c6cca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "las-geoh5" -version = "0.3.0-alpha.1" +version = "0.4.0-alpha.1" description = "Las/Geoh5 conversion" license = "MIT" readme = "README.rst" From 0ba5985bce764ddc1a8f870cad752369da2bda71 Mon Sep 17 00:00:00 2001 From: benjamink Date: Tue, 5 Nov 2024 13:35:00 -0800 Subject: [PATCH 2/2] fix read encoding to utf-8 --- las_geoh5/import_directories/driver.py | 4 +++- las_geoh5/import_las.py | 2 +- tests/import_las_test.py | 30 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/las_geoh5/import_directories/driver.py b/las_geoh5/import_directories/driver.py index 7553319..f508b9c 100644 --- a/las_geoh5/import_directories/driver.py +++ b/las_geoh5/import_directories/driver.py @@ -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, diff --git a/las_geoh5/import_las.py b/las_geoh5/import_las.py index 722e060..bbd5ab1 100644 --- a/las_geoh5/import_las.py +++ b/las_geoh5/import_las.py @@ -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") diff --git a/tests/import_las_test.py b/tests/import_las_test.py index 335fec3..b4912a4 100644 --- a/tests/import_las_test.py +++ b/tests/import_las_test.py @@ -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")