las-geoh5 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- las_geoh5-0.1.0/LICENSE.txt +21 -0
- las_geoh5-0.1.0/PKG-INFO +89 -0
- las_geoh5-0.1.0/README.rst +58 -0
- las_geoh5-0.1.0/las_geoh5/__init__.py +11 -0
- las_geoh5-0.1.0/las_geoh5/export_directories/__init__.py +7 -0
- las_geoh5-0.1.0/las_geoh5/export_directories/driver.py +58 -0
- las_geoh5-0.1.0/las_geoh5/export_directories/uijson.py +37 -0
- las_geoh5-0.1.0/las_geoh5/export_las.py +222 -0
- las_geoh5-0.1.0/las_geoh5/import_directories/__init__.py +7 -0
- las_geoh5-0.1.0/las_geoh5/import_directories/driver.py +72 -0
- las_geoh5-0.1.0/las_geoh5/import_directories/uijson.py +19 -0
- las_geoh5-0.1.0/las_geoh5/import_files/__init__.py +7 -0
- las_geoh5-0.1.0/las_geoh5/import_files/driver.py +129 -0
- las_geoh5-0.1.0/las_geoh5/import_files/uijson.py +70 -0
- las_geoh5-0.1.0/las_geoh5/import_las.py +378 -0
- las_geoh5-0.1.0/las_geoh5/uijson/__init__.py +6 -0
- las_geoh5-0.1.0/las_geoh5/uijson/export_las_directories.ui.json +30 -0
- las_geoh5-0.1.0/las_geoh5/uijson/import_las_directories.ui.json +30 -0
- las_geoh5-0.1.0/las_geoh5/uijson/import_las_files.ui.json +73 -0
- las_geoh5-0.1.0/las_geoh5/uijson/write_uijson.py +75 -0
- las_geoh5-0.1.0/pyproject.toml +88 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Mira Geoscience
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
las_geoh5-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: las-geoh5
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Las/Geoh5 conversion
|
|
5
|
+
Home-page: https://mirageoscience.com
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: geology,geophysics,earth sciences,io,data,interoperability
|
|
8
|
+
Author: Mira Geoscience
|
|
9
|
+
Author-email: support@mirageoscience.com
|
|
10
|
+
Requires-Python: >=3.9,<3.11
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX
|
|
18
|
+
Classifier: Operating System :: Unix
|
|
19
|
+
Classifier: Programming Language :: Python
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
26
|
+
Requires-Dist: geoh5py (>=0.8.0rc3,<0.9.0)
|
|
27
|
+
Requires-Dist: lasio (>=0.31,<0.32)
|
|
28
|
+
Requires-Dist: tqdm (>=4.64.0,<5.0.0)
|
|
29
|
+
Description-Content-Type: text/x-rst
|
|
30
|
+
|
|
31
|
+
las-geoh5
|
|
32
|
+
=========
|
|
33
|
+
|
|
34
|
+
Import/Export LAS files to/from geoh5 format.
|
|
35
|
+
|
|
36
|
+
This package contains three modules for import/export of LAS files in
|
|
37
|
+
and out of a geoh5 file. the import/export directories modules allow
|
|
38
|
+
export and subsequent re-import of LAS files from a drillhole group
|
|
39
|
+
saved in a geoh5 file to a structured set of directories on disk. The
|
|
40
|
+
import files module is intended for the more general case of LAS file
|
|
41
|
+
import to an existing drillhole group.
|
|
42
|
+
|
|
43
|
+
Basic Usage
|
|
44
|
+
-----------
|
|
45
|
+
.. _Geoscience ANALYST Pro: https://mirageoscience.com/mining-industry-software/geoscience-analyst-pro/
|
|
46
|
+
|
|
47
|
+
The most convenient way to use this package is through `Geoscience ANALYST Pro`_
|
|
48
|
+
where the import files driver may be run from the **file -> import**
|
|
49
|
+
menu.
|
|
50
|
+
|
|
51
|
+
All drivers may also be run from a ui.json file in `Geoscience ANALYST Pro`_
|
|
52
|
+
by either adding to the Python Scripts directory or drag and drop into
|
|
53
|
+
the viewport. Defaulted ui.json files can be found in the uijson folder
|
|
54
|
+
of the las-geoh5 project.
|
|
55
|
+
|
|
56
|
+
Finally, the drivers can be run from CLI using the following
|
|
57
|
+
|
|
58
|
+
.. code:: bash
|
|
59
|
+
|
|
60
|
+
python -m las_geoh5.module.driver some_file.ui.json
|
|
61
|
+
|
|
62
|
+
Where module is one of ``import_files``, ``export_files``, or ``import_las``.
|
|
63
|
+
|
|
64
|
+
License
|
|
65
|
+
-------
|
|
66
|
+
|
|
67
|
+
MIT License
|
|
68
|
+
|
|
69
|
+
Copyright (c) 2023 Mira Geoscience
|
|
70
|
+
|
|
71
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
72
|
+
copy of this software and associated documentation files (the
|
|
73
|
+
“Software”), to deal in the Software without restriction, including
|
|
74
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
75
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
76
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
77
|
+
the following conditions:
|
|
78
|
+
|
|
79
|
+
The above copyright notice and this permission notice shall be included
|
|
80
|
+
in all copies or substantial portions of the Software.
|
|
81
|
+
|
|
82
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
83
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
84
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
85
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
86
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
87
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
88
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
89
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
las-geoh5
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Import/Export LAS files to/from geoh5 format.
|
|
5
|
+
|
|
6
|
+
This package contains three modules for import/export of LAS files in
|
|
7
|
+
and out of a geoh5 file. the import/export directories modules allow
|
|
8
|
+
export and subsequent re-import of LAS files from a drillhole group
|
|
9
|
+
saved in a geoh5 file to a structured set of directories on disk. The
|
|
10
|
+
import files module is intended for the more general case of LAS file
|
|
11
|
+
import to an existing drillhole group.
|
|
12
|
+
|
|
13
|
+
Basic Usage
|
|
14
|
+
-----------
|
|
15
|
+
.. _Geoscience ANALYST Pro: https://mirageoscience.com/mining-industry-software/geoscience-analyst-pro/
|
|
16
|
+
|
|
17
|
+
The most convenient way to use this package is through `Geoscience ANALYST Pro`_
|
|
18
|
+
where the import files driver may be run from the **file -> import**
|
|
19
|
+
menu.
|
|
20
|
+
|
|
21
|
+
All drivers may also be run from a ui.json file in `Geoscience ANALYST Pro`_
|
|
22
|
+
by either adding to the Python Scripts directory or drag and drop into
|
|
23
|
+
the viewport. Defaulted ui.json files can be found in the uijson folder
|
|
24
|
+
of the las-geoh5 project.
|
|
25
|
+
|
|
26
|
+
Finally, the drivers can be run from CLI using the following
|
|
27
|
+
|
|
28
|
+
.. code:: bash
|
|
29
|
+
|
|
30
|
+
python -m las_geoh5.module.driver some_file.ui.json
|
|
31
|
+
|
|
32
|
+
Where module is one of ``import_files``, ``export_files``, or ``import_las``.
|
|
33
|
+
|
|
34
|
+
License
|
|
35
|
+
-------
|
|
36
|
+
|
|
37
|
+
MIT License
|
|
38
|
+
|
|
39
|
+
Copyright (c) 2023 Mira Geoscience
|
|
40
|
+
|
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
42
|
+
copy of this software and associated documentation files (the
|
|
43
|
+
“Software”), to deal in the Software without restriction, including
|
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
47
|
+
the following conditions:
|
|
48
|
+
|
|
49
|
+
The above copyright notice and this permission notice shall be included
|
|
50
|
+
in all copies or substantial portions of the Software.
|
|
51
|
+
|
|
52
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
53
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright (c) 2023 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of las_geoh5 project.
|
|
4
|
+
#
|
|
5
|
+
# las-geoh5 is distributed under the terms and conditions of the MIT License
|
|
6
|
+
# (see LICENSE file at the root of this source code package).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
# flake8: noqa
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (c) 2023 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of las-geoh5 project.
|
|
4
|
+
#
|
|
5
|
+
# las-geoh5 is distributed under the terms and conditions of the MIT License
|
|
6
|
+
# (see LICENSE file at the root of this source code package).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from geoh5py.groups import DrillholeGroup
|
|
15
|
+
from geoh5py.objects import Drillhole
|
|
16
|
+
from geoh5py.shared.utils import fetch_active_workspace
|
|
17
|
+
from geoh5py.ui_json import InputFile
|
|
18
|
+
from tqdm import tqdm
|
|
19
|
+
|
|
20
|
+
from las_geoh5.export_las import drillhole_to_las
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def run(file: str | Path):
|
|
24
|
+
ifile = InputFile.read_ui_json(file)
|
|
25
|
+
dh_group = ifile.data["drillhole_group"]
|
|
26
|
+
name = ifile.data["name"]
|
|
27
|
+
with fetch_active_workspace(ifile.data["geoh5"]):
|
|
28
|
+
export_las_directory(dh_group, Path(ifile.path), name)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def export_las_directory(
|
|
32
|
+
group: DrillholeGroup, basepath: str | Path, name: str | None = None
|
|
33
|
+
):
|
|
34
|
+
"""
|
|
35
|
+
Export contents of drillhole group to las files organized by directories.
|
|
36
|
+
|
|
37
|
+
:param group: Drillhole group container.
|
|
38
|
+
:param basepath: Base path where directories/files will be created.
|
|
39
|
+
:param name: Alternate name of root directory to be created.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
if isinstance(basepath, str):
|
|
43
|
+
basepath = Path(basepath)
|
|
44
|
+
|
|
45
|
+
drillholes = [k for k in group.children if isinstance(k, Drillhole)]
|
|
46
|
+
|
|
47
|
+
name = name if name is not None else group.name
|
|
48
|
+
subpath = basepath / name
|
|
49
|
+
if not subpath.exists():
|
|
50
|
+
subpath.mkdir()
|
|
51
|
+
|
|
52
|
+
print(f"Exporting drillhole surveys and property group data to {str(subpath)}")
|
|
53
|
+
for drillhole in tqdm(drillholes):
|
|
54
|
+
drillhole_to_las(drillhole, subpath)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
run(sys.argv[1])
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Copyright (c) 2023 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of las-geoh5 project.
|
|
4
|
+
#
|
|
5
|
+
# las-geoh5 is distributed under the terms and conditions of the MIT License
|
|
6
|
+
# (see LICENSE file at the root of this source code package).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
ui_json = {
|
|
11
|
+
"title": "Drillhole group to LAS file directories",
|
|
12
|
+
"geoh5": None,
|
|
13
|
+
"run_command": "las_geoh5.export_directories.driver",
|
|
14
|
+
"run_command_boolean": {
|
|
15
|
+
"value": False,
|
|
16
|
+
"label": "Run python module",
|
|
17
|
+
"main": True,
|
|
18
|
+
"tooltip": "Warning: launches process to run python model on save",
|
|
19
|
+
},
|
|
20
|
+
"monitoring_directory": None,
|
|
21
|
+
"conda_environment": "las-geoh5",
|
|
22
|
+
"conda_environment_boolean": False,
|
|
23
|
+
"workspace": None,
|
|
24
|
+
"drillhole_group": {
|
|
25
|
+
"main": True,
|
|
26
|
+
"label": "Drillhole group",
|
|
27
|
+
"value": None,
|
|
28
|
+
"groupType": ["{825424fb-c2c6-4fea-9f2b-6cd00023d393}"],
|
|
29
|
+
},
|
|
30
|
+
"name": {
|
|
31
|
+
"main": True,
|
|
32
|
+
"label": "Property group name",
|
|
33
|
+
"value": None,
|
|
34
|
+
"optional": True,
|
|
35
|
+
"enabled": False,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Copyright (c) 2023 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of las-geoh5 project.
|
|
4
|
+
#
|
|
5
|
+
# las-geoh5 is distributed under the terms and conditions of the MIT License
|
|
6
|
+
# (see LICENSE file at the root of this source code package).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from geoh5py.data import ReferencedData
|
|
14
|
+
from geoh5py.objects import Drillhole
|
|
15
|
+
from geoh5py.shared.concatenation import ConcatenatedPropertyGroup
|
|
16
|
+
from lasio import HeaderItem, LASFile
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def add_well_data(
|
|
20
|
+
file: LASFile,
|
|
21
|
+
drillhole: Drillhole,
|
|
22
|
+
) -> LASFile:
|
|
23
|
+
"""
|
|
24
|
+
Populate las file well data from drillhole.
|
|
25
|
+
|
|
26
|
+
:param file: lasio file object.
|
|
27
|
+
:param drillhole: geoh5py drillhole object.
|
|
28
|
+
|
|
29
|
+
:returns: Updated lasio file object.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
# Add well name
|
|
33
|
+
file.well["WELL"] = drillhole.name
|
|
34
|
+
|
|
35
|
+
# Add epsg code
|
|
36
|
+
if drillhole.coordinate_reference_system is not None:
|
|
37
|
+
file.well.append(
|
|
38
|
+
HeaderItem(
|
|
39
|
+
mnemonic="GDAT",
|
|
40
|
+
value=drillhole.coordinate_reference_system["Code"],
|
|
41
|
+
descr=drillhole.coordinate_reference_system["Name"],
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Add collar data
|
|
46
|
+
file.well.append(HeaderItem(mnemonic="X", value=float(drillhole.collar["x"])))
|
|
47
|
+
file.well.append(HeaderItem(mnemonic="Y", value=float(drillhole.collar["y"])))
|
|
48
|
+
file.well.append(HeaderItem(mnemonic="ELEV", value=float(drillhole.collar["z"])))
|
|
49
|
+
|
|
50
|
+
return file
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def add_curve_data(file: LASFile, drillhole: Drillhole, group):
|
|
54
|
+
"""
|
|
55
|
+
Populate las file with curve data from each property in group.
|
|
56
|
+
|
|
57
|
+
:param file: lasio file object.
|
|
58
|
+
:param drillhole: geoh5py.drillhole object containing property
|
|
59
|
+
groups for collocated data.
|
|
60
|
+
:param group: Property group containing collocated float data
|
|
61
|
+
objects of 'drillhole'.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
if not isinstance(group, ConcatenatedPropertyGroup):
|
|
65
|
+
raise TypeError("Property group must be of type ConcatenatedPropertyGroup.")
|
|
66
|
+
|
|
67
|
+
if group.depth_:
|
|
68
|
+
file.append_curve("DEPTH", group.depth_.values, unit="m")
|
|
69
|
+
else:
|
|
70
|
+
file.append_curve("DEPTH", group.from_.values, unit="m", descr="FROM")
|
|
71
|
+
file.append_curve("TO", group.to_.values, unit="m", descr="TO")
|
|
72
|
+
|
|
73
|
+
properties = [] if group.properties is None else group.properties
|
|
74
|
+
data = [drillhole.get_data(k)[0] for k in properties]
|
|
75
|
+
filtered_data = [k for k in data if len(k.values) != 0]
|
|
76
|
+
for datum in filtered_data:
|
|
77
|
+
if any(k in datum.name for k in ["FROM", "TO", "DEPT"]):
|
|
78
|
+
continue
|
|
79
|
+
|
|
80
|
+
file.append_curve(datum.name, datum.values)
|
|
81
|
+
|
|
82
|
+
if isinstance(datum, ReferencedData):
|
|
83
|
+
for k, v in datum.value_map.map.items(): # pylint: disable=invalid-name
|
|
84
|
+
file.params.append(
|
|
85
|
+
HeaderItem(
|
|
86
|
+
mnemonic=f"{datum.name} ({k})", value=v, descr="REFERENCE"
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return file
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def add_survey_data(file: LASFile, drillhole: Drillhole) -> LASFile:
|
|
94
|
+
"""
|
|
95
|
+
Add drillhole survey data to LASFile object.
|
|
96
|
+
|
|
97
|
+
:param file: las file object.
|
|
98
|
+
:param drillhole: drillhole containing survey data.
|
|
99
|
+
|
|
100
|
+
:return: Updated las file object.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
# Add survey data
|
|
104
|
+
file.append_curve("DEPTH", drillhole.surveys[:, 0], unit="m")
|
|
105
|
+
file.append_curve(
|
|
106
|
+
"DIP",
|
|
107
|
+
drillhole.surveys[:, 1],
|
|
108
|
+
unit="degrees",
|
|
109
|
+
descr="from horizontal",
|
|
110
|
+
)
|
|
111
|
+
file.append_curve(
|
|
112
|
+
"AZIM",
|
|
113
|
+
drillhole.surveys[:, 2],
|
|
114
|
+
unit="degrees",
|
|
115
|
+
descr="from north (clockwise)",
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
return file
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def write_curves(
|
|
122
|
+
drillhole: Drillhole,
|
|
123
|
+
basepath: str | Path,
|
|
124
|
+
directory: bool = True,
|
|
125
|
+
):
|
|
126
|
+
"""
|
|
127
|
+
Write a formatted .las file for each property group in 'drillhole'.
|
|
128
|
+
|
|
129
|
+
:param drillhole: geoh5py drillhole object containing property
|
|
130
|
+
groups for collocated data.
|
|
131
|
+
:param basepath: Path to working directory.
|
|
132
|
+
:param directory: True if data is stored in sub-directories
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
if isinstance(basepath, str):
|
|
136
|
+
basepath = Path(basepath)
|
|
137
|
+
|
|
138
|
+
if not drillhole.property_groups:
|
|
139
|
+
raise AttributeError("Drillhole doesn't have any associated property groups.")
|
|
140
|
+
|
|
141
|
+
for group in drillhole.property_groups:
|
|
142
|
+
if group.property_group_type not in ["Interval table", "Depth table"]:
|
|
143
|
+
continue # bypasses strike and dip groups
|
|
144
|
+
|
|
145
|
+
if group.name == "Static-Survey":
|
|
146
|
+
continue # bypasses survey data handled elsewhere
|
|
147
|
+
|
|
148
|
+
file = LASFile()
|
|
149
|
+
file = add_well_data(file, drillhole)
|
|
150
|
+
file = add_curve_data(file, drillhole, group)
|
|
151
|
+
|
|
152
|
+
if not [
|
|
153
|
+
k for k in file.curves if k.mnemonic not in ["FROM", "TO", "DEPTH", "DEPT"]
|
|
154
|
+
]:
|
|
155
|
+
continue
|
|
156
|
+
|
|
157
|
+
if directory:
|
|
158
|
+
subpath = basepath / group.name
|
|
159
|
+
if not subpath.exists():
|
|
160
|
+
subpath.mkdir()
|
|
161
|
+
filename = f"{drillhole.name}.las"
|
|
162
|
+
else:
|
|
163
|
+
subpath = basepath
|
|
164
|
+
filename = f"{drillhole.name}_{group.name}.las"
|
|
165
|
+
|
|
166
|
+
with open(
|
|
167
|
+
subpath / filename, "a", encoding="utf8"
|
|
168
|
+
) as io: # pylint: disable=invalid-name
|
|
169
|
+
file.write(io)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def write_survey(
|
|
173
|
+
drillhole: Drillhole,
|
|
174
|
+
basepath: str | Path,
|
|
175
|
+
directory: bool = True,
|
|
176
|
+
):
|
|
177
|
+
"""
|
|
178
|
+
Write a formatted .las file with survey data from 'drillhole'.
|
|
179
|
+
|
|
180
|
+
:param drillhole: geoh5py drillhole object containing property
|
|
181
|
+
groups for collocated data.
|
|
182
|
+
:param basepath: Path to working directory.
|
|
183
|
+
:param directory: True if data is stored in sub-directories
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
if isinstance(basepath, str):
|
|
187
|
+
basepath = Path(basepath)
|
|
188
|
+
|
|
189
|
+
file = LASFile()
|
|
190
|
+
file = add_well_data(file, drillhole)
|
|
191
|
+
file = add_survey_data(file, drillhole)
|
|
192
|
+
|
|
193
|
+
if directory:
|
|
194
|
+
basepath = basepath / "Surveys"
|
|
195
|
+
if not basepath.exists():
|
|
196
|
+
basepath.mkdir()
|
|
197
|
+
filename = f"{drillhole.name}.las"
|
|
198
|
+
else:
|
|
199
|
+
filename = f"{drillhole.name}_survey.las"
|
|
200
|
+
|
|
201
|
+
with open(
|
|
202
|
+
basepath / filename, "a", encoding="utf8"
|
|
203
|
+
) as io: # pylint: disable=invalid-name
|
|
204
|
+
file.write(io)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def drillhole_to_las(
|
|
208
|
+
drillhole: Drillhole,
|
|
209
|
+
basepath: str | Path,
|
|
210
|
+
directory: bool = True,
|
|
211
|
+
):
|
|
212
|
+
"""
|
|
213
|
+
Write a formatted .las file with data from 'drillhole'.
|
|
214
|
+
|
|
215
|
+
:param drillhole: geoh5py drillhole object containing property
|
|
216
|
+
groups for collocated data.
|
|
217
|
+
:param basepath: Path to working directory.
|
|
218
|
+
:param directory: True if data is stored in sub-directories
|
|
219
|
+
"""
|
|
220
|
+
|
|
221
|
+
write_survey(drillhole, basepath, directory)
|
|
222
|
+
write_curves(drillhole, basepath, directory)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Copyright (c) 2023 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of las-geoh5 project.
|
|
4
|
+
#
|
|
5
|
+
# las-geoh5 is distributed under the terms and conditions of the MIT License
|
|
6
|
+
# (see LICENSE file at the root of this source code package).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
import lasio
|
|
15
|
+
from geoh5py import Workspace
|
|
16
|
+
from geoh5py.groups import DrillholeGroup
|
|
17
|
+
from geoh5py.shared.utils import fetch_active_workspace
|
|
18
|
+
from geoh5py.ui_json import InputFile
|
|
19
|
+
|
|
20
|
+
from las_geoh5.import_las import las_to_drillhole
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def run(file: str):
|
|
24
|
+
ifile = InputFile.read_ui_json(file)
|
|
25
|
+
dh_group = ifile.data["drillhole_group"]
|
|
26
|
+
name = ifile.data["name"]
|
|
27
|
+
with fetch_active_workspace(ifile.data["geoh5"], mode="a") as workspace:
|
|
28
|
+
basepath = Path(ifile.path) / dh_group
|
|
29
|
+
import_las_directory(workspace, basepath, name)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def import_las_directory(
|
|
33
|
+
workspace: Workspace, basepath: str | Path, name: str | None = None
|
|
34
|
+
):
|
|
35
|
+
"""
|
|
36
|
+
Import directory/files from previous export.
|
|
37
|
+
|
|
38
|
+
:param workspace: Project workspace.
|
|
39
|
+
:param basepath: Root directory for las data.
|
|
40
|
+
:param name: Alternate name for property group to create.
|
|
41
|
+
|
|
42
|
+
:return: New drillhole group containing imported items.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
if isinstance(basepath, str):
|
|
46
|
+
basepath = Path(basepath)
|
|
47
|
+
|
|
48
|
+
if not basepath.exists():
|
|
49
|
+
raise OSError(f"Path {str(basepath)} does not exist.")
|
|
50
|
+
|
|
51
|
+
name = name if name is not None else basepath.name
|
|
52
|
+
dh_group = DrillholeGroup.create(workspace, name=name)
|
|
53
|
+
|
|
54
|
+
surveys_path = basepath / "Surveys"
|
|
55
|
+
surveys = list(surveys_path.iterdir()) if surveys_path.exists() else None
|
|
56
|
+
|
|
57
|
+
property_group_folders = [
|
|
58
|
+
p for p in basepath.iterdir() if p.is_dir() and p.name != "Surveys"
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
for prop in property_group_folders:
|
|
62
|
+
lasfiles = []
|
|
63
|
+
for file in [k for k in prop.iterdir() if k.suffix == ".las"]:
|
|
64
|
+
lasfiles.append(lasio.read(file, mnemonic_case="preserve"))
|
|
65
|
+
print(f"Importing property group data from to {prop.name}")
|
|
66
|
+
las_to_drillhole(workspace, lasfiles, dh_group, prop.name, surveys)
|
|
67
|
+
|
|
68
|
+
return dh_group
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
run(sys.argv[1])
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright (c) 2023 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of las-geoh5 project.
|
|
4
|
+
#
|
|
5
|
+
# las-geoh5 is distributed under the terms and conditions of the MIT License
|
|
6
|
+
# (see LICENSE file at the root of this source code package).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
from copy import deepcopy
|
|
10
|
+
|
|
11
|
+
from las_geoh5.export_directories.uijson import ui_json
|
|
12
|
+
|
|
13
|
+
ui_json = dict(
|
|
14
|
+
deepcopy(ui_json),
|
|
15
|
+
**{
|
|
16
|
+
"title": "LAS file directories to Drillhole group",
|
|
17
|
+
"run_command": "las_geoh5.import_directories.driver",
|
|
18
|
+
}
|
|
19
|
+
)
|