curve-apps 0.1.0a1__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.
- curve_apps-0.1.0a1/PKG-INFO +200 -0
- curve_apps-0.1.0a1/README.rst +163 -0
- curve_apps-0.1.0a1/curve_apps/__init__.py +23 -0
- curve_apps-0.1.0a1/curve_apps/driver.py +103 -0
- curve_apps-0.1.0a1/curve_apps/edge_detection/__init__.py +5 -0
- curve_apps-0.1.0a1/curve_apps/edge_detection/driver.py +211 -0
- curve_apps-0.1.0a1/curve_apps/edge_detection/params.py +84 -0
- curve_apps-0.1.0a1/curve_apps/params.py +29 -0
- curve_apps-0.1.0a1/curve_apps/trend_lines/__init__.py +5 -0
- curve_apps-0.1.0a1/curve_apps/trend_lines/driver.py +186 -0
- curve_apps-0.1.0a1/curve_apps/trend_lines/params.py +69 -0
- curve_apps-0.1.0a1/curve_apps-assets/__init__.py +5 -0
- curve_apps-0.1.0a1/curve_apps-assets/curve_apps_demo.geoh5 +0 -0
- curve_apps-0.1.0a1/curve_apps-assets/uijson/edge_detection.ui.json +107 -0
- curve_apps-0.1.0a1/curve_apps-assets/uijson/trend_lines.ui.json +120 -0
- curve_apps-0.1.0a1/pyproject.toml +116 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: curve_apps
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Find edges on 2D grids or vertices.
|
|
5
|
+
Home-page: https://mirageoscience.com
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: Mira Geoscience
|
|
8
|
+
Author-email: support@mirageoscience.com
|
|
9
|
+
Requires-Python: >=3.9,<3.11
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX
|
|
17
|
+
Classifier: Operating System :: Unix
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
25
|
+
Requires-Dist: Pillow
|
|
26
|
+
Requires-Dist: geoapps-utils (>=0.3.0a2,<0.4.0)
|
|
27
|
+
Requires-Dist: geoh5py (>=0.9.0-alpha.3,<0.10.0)
|
|
28
|
+
Requires-Dist: h5py
|
|
29
|
+
Requires-Dist: numpy (>=1.23.5,<1.24.0)
|
|
30
|
+
Requires-Dist: pydantic (>=2.5,<2.6)
|
|
31
|
+
Requires-Dist: scikit-image (>=0.19.0,<0.20.0)
|
|
32
|
+
Requires-Dist: scipy (>=1.10.1,<1.11.0)
|
|
33
|
+
Requires-Dist: tqdm (>=4.66.0,<4.67.0)
|
|
34
|
+
Project-URL: Repository, https://github.com/MiraGeoscience/curve_apps
|
|
35
|
+
Description-Content-Type: text/x-rst
|
|
36
|
+
|
|
37
|
+
|coverage| |maintainability| |precommit_ci| |docs| |style| |version| |status| |pyversions|
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
.. |docs| image:: https://readthedocs.org/projects/curve-apps/badge/
|
|
41
|
+
:alt: Documentation Status
|
|
42
|
+
:target: https://curve-apps.readthedocs.io/en/latest/?badge=latest
|
|
43
|
+
|
|
44
|
+
.. |coverage| image:: https://codecov.io/gh/MiraGeoscience/curve-apps/branch/develop/graph/badge.svg
|
|
45
|
+
:alt: Code coverage
|
|
46
|
+
:target: https://codecov.io/gh/MiraGeoscience/curve-apps
|
|
47
|
+
|
|
48
|
+
.. |style| image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
|
49
|
+
:alt: Coding style
|
|
50
|
+
:target: https://github.com/pf/black
|
|
51
|
+
|
|
52
|
+
.. |version| image:: https://img.shields.io/pypi/v/edge-detection.svg
|
|
53
|
+
:alt: version on PyPI
|
|
54
|
+
:target: https://pypi.python.org/pypi/edge-detection/
|
|
55
|
+
|
|
56
|
+
.. |status| image:: https://img.shields.io/pypi/status/edge-detection.svg
|
|
57
|
+
:alt: version status on PyPI
|
|
58
|
+
:target: https://pypi.python.org/pypi/edge-detection/
|
|
59
|
+
|
|
60
|
+
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/edge-detection.svg
|
|
61
|
+
:alt: Python versions
|
|
62
|
+
:target: https://pypi.python.org/pypi/edge-detection/
|
|
63
|
+
|
|
64
|
+
.. |precommit_ci| image:: https://results.pre-commit.ci/badge/github/MiraGeoscience/edge-detection/develop.svg
|
|
65
|
+
:alt: pre-commit.ci status
|
|
66
|
+
:target: https://results.pre-commit.ci/latest/github/MiraGeoscience/edge-detection/develop
|
|
67
|
+
|
|
68
|
+
.. |maintainability| image:: https://api.codeclimate.com/v1/badges/_token_/maintainability
|
|
69
|
+
:target: https://codeclimate.com/github/MiraGeoscience/edge-detection/maintainability
|
|
70
|
+
:alt: Maintainability
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
curve-apps
|
|
74
|
+
==========
|
|
75
|
+
|
|
76
|
+
Auto-detection of trends and edges in geoscientific data.
|
|
77
|
+
|
|
78
|
+
.. contents:: Table of Contents
|
|
79
|
+
:local:
|
|
80
|
+
:depth: 3
|
|
81
|
+
|
|
82
|
+
Documentation
|
|
83
|
+
^^^^^^^^^^^^^
|
|
84
|
+
`Online documentation <https://edge-detection.readthedocs.io/en/latest/>`_
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
Installation
|
|
88
|
+
^^^^^^^^^^^^
|
|
89
|
+
**curve-apps** is currently written and tested for Python 3.10.
|
|
90
|
+
|
|
91
|
+
Install Conda
|
|
92
|
+
-------------
|
|
93
|
+
|
|
94
|
+
To install **curve-apps**, you need to install **Conda** first.
|
|
95
|
+
|
|
96
|
+
We recommend to install **Conda** using `miniforge`_.
|
|
97
|
+
|
|
98
|
+
.. _miniforge: https://github.com/conda-forge/miniforge
|
|
99
|
+
|
|
100
|
+
Within a conda environment
|
|
101
|
+
--------------------------
|
|
102
|
+
|
|
103
|
+
You can install (or update) a conda environment with all the requires packages to run **curve-apps**.
|
|
104
|
+
To do so you can directly run the **Install_or_Update.bat** file by double left clicking on it.
|
|
105
|
+
|
|
106
|
+
Install with conda
|
|
107
|
+
------------------
|
|
108
|
+
|
|
109
|
+
You can install the package using ``conda`` and the ``.lock`` files from a conda prompt:
|
|
110
|
+
|
|
111
|
+
.. code-block:: bash
|
|
112
|
+
|
|
113
|
+
conda env create -n my-env -f environments/[the_desired_env].lock.yml
|
|
114
|
+
|
|
115
|
+
Install with PyPI
|
|
116
|
+
-----------------
|
|
117
|
+
|
|
118
|
+
You should not install the package from PyPI, as the app requires conda packages to run.
|
|
119
|
+
Still, you can install it in a conda environment without its dependencies (``--no-deps``).
|
|
120
|
+
|
|
121
|
+
From PyPI
|
|
122
|
+
~~~~~~~~~
|
|
123
|
+
|
|
124
|
+
To install the **curve-apps** package published on PyPI:
|
|
125
|
+
|
|
126
|
+
.. code-block:: bash
|
|
127
|
+
|
|
128
|
+
pip install -U --no-deps curve-apps
|
|
129
|
+
|
|
130
|
+
From a Git tag or branch
|
|
131
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
132
|
+
If the package is not on PiPY yet, you can install it from a Git tag:
|
|
133
|
+
|
|
134
|
+
.. code-block:: bash
|
|
135
|
+
|
|
136
|
+
pip install -U --no-deps --force-reinstall https://github.com/MiraGeoscience/curve-apps/archive/refs/tags/TAG.zip
|
|
137
|
+
|
|
138
|
+
Or to install the latest changes available on a given Git branch:
|
|
139
|
+
|
|
140
|
+
.. code-block:: bash
|
|
141
|
+
|
|
142
|
+
pip install -U --no-deps --force-reinstall https://github.com/MiraGeoscience/curve-apps/archive/refs/heads/BRANCH.zip
|
|
143
|
+
|
|
144
|
+
.. note::
|
|
145
|
+
The ``--force-reinstall`` option is used to make sure the updated version
|
|
146
|
+
of the sources is installed, and not the cached version, even if the version number
|
|
147
|
+
did not change. The ``-U`` or ``--upgrade`` option is used to make sure to get the latest version,
|
|
148
|
+
on not merely reinstall the same version. As the package is aimed to be in a **Conda environment**, the option ``--no-deps`` is used to avoid installing the dependencies with pip, as they will be installed with conda.
|
|
149
|
+
|
|
150
|
+
From a local copy of the sources
|
|
151
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
152
|
+
If you have a git clone of the package sources locally,
|
|
153
|
+
you can install **curve-apps** from the local copy of the sources with:
|
|
154
|
+
|
|
155
|
+
.. code-block:: bash
|
|
156
|
+
|
|
157
|
+
pip install -U --force-reinstall path/to/project_folder_with_pyproject_toml
|
|
158
|
+
|
|
159
|
+
Or in **editable mode**, so that you can edit the sources and see the effect immediately at runtime:
|
|
160
|
+
|
|
161
|
+
.. code-block:: bash
|
|
162
|
+
|
|
163
|
+
pip install -e -U --force-reinstall path/to/project_folder_with_pyproject_toml
|
|
164
|
+
|
|
165
|
+
Setup for development
|
|
166
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
167
|
+
To configure the development environment and tools, please see `README-dev.rst`_.
|
|
168
|
+
|
|
169
|
+
.. _README-dev.rst: README-dev.rst
|
|
170
|
+
|
|
171
|
+
License
|
|
172
|
+
^^^^^^^
|
|
173
|
+
curve-apps is free software: you can redistribute it and/or modify
|
|
174
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
175
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
176
|
+
(at your option) any later version.
|
|
177
|
+
|
|
178
|
+
curve-apps is distributed in the hope that it will be useful,
|
|
179
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
180
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
181
|
+
GNU Lesser General Public License for more details.
|
|
182
|
+
|
|
183
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
184
|
+
along with curve-apps. If not, see <https://www.gnu.org/licenses/>.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
Third Party Software
|
|
188
|
+
^^^^^^^^^^^^^^^^^^^^
|
|
189
|
+
The curve-apps Software may provide links to third party libraries or code (collectively “Third Party Software”)
|
|
190
|
+
to implement various functions. Third Party Software does not comprise part of the Software.
|
|
191
|
+
The use of Third Party Software is governed by the terms of such software license(s).
|
|
192
|
+
Third Party Software notices and/or additional terms and conditions are located in the
|
|
193
|
+
`THIRD_PARTY_SOFTWARE.rst`_ file.
|
|
194
|
+
|
|
195
|
+
.. _THIRD_PARTY_SOFTWARE.rst: ./docs/THIRD_PARTY_SOFTWARE.rst
|
|
196
|
+
|
|
197
|
+
Copyright
|
|
198
|
+
^^^^^^^^^
|
|
199
|
+
Copyright (c) 2024 Mira Geoscience Ltd.
|
|
200
|
+
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
|coverage| |maintainability| |precommit_ci| |docs| |style| |version| |status| |pyversions|
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
.. |docs| image:: https://readthedocs.org/projects/curve-apps/badge/
|
|
5
|
+
:alt: Documentation Status
|
|
6
|
+
:target: https://curve-apps.readthedocs.io/en/latest/?badge=latest
|
|
7
|
+
|
|
8
|
+
.. |coverage| image:: https://codecov.io/gh/MiraGeoscience/curve-apps/branch/develop/graph/badge.svg
|
|
9
|
+
:alt: Code coverage
|
|
10
|
+
:target: https://codecov.io/gh/MiraGeoscience/curve-apps
|
|
11
|
+
|
|
12
|
+
.. |style| image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
|
13
|
+
:alt: Coding style
|
|
14
|
+
:target: https://github.com/pf/black
|
|
15
|
+
|
|
16
|
+
.. |version| image:: https://img.shields.io/pypi/v/edge-detection.svg
|
|
17
|
+
:alt: version on PyPI
|
|
18
|
+
:target: https://pypi.python.org/pypi/edge-detection/
|
|
19
|
+
|
|
20
|
+
.. |status| image:: https://img.shields.io/pypi/status/edge-detection.svg
|
|
21
|
+
:alt: version status on PyPI
|
|
22
|
+
:target: https://pypi.python.org/pypi/edge-detection/
|
|
23
|
+
|
|
24
|
+
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/edge-detection.svg
|
|
25
|
+
:alt: Python versions
|
|
26
|
+
:target: https://pypi.python.org/pypi/edge-detection/
|
|
27
|
+
|
|
28
|
+
.. |precommit_ci| image:: https://results.pre-commit.ci/badge/github/MiraGeoscience/edge-detection/develop.svg
|
|
29
|
+
:alt: pre-commit.ci status
|
|
30
|
+
:target: https://results.pre-commit.ci/latest/github/MiraGeoscience/edge-detection/develop
|
|
31
|
+
|
|
32
|
+
.. |maintainability| image:: https://api.codeclimate.com/v1/badges/_token_/maintainability
|
|
33
|
+
:target: https://codeclimate.com/github/MiraGeoscience/edge-detection/maintainability
|
|
34
|
+
:alt: Maintainability
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
curve-apps
|
|
38
|
+
==========
|
|
39
|
+
|
|
40
|
+
Auto-detection of trends and edges in geoscientific data.
|
|
41
|
+
|
|
42
|
+
.. contents:: Table of Contents
|
|
43
|
+
:local:
|
|
44
|
+
:depth: 3
|
|
45
|
+
|
|
46
|
+
Documentation
|
|
47
|
+
^^^^^^^^^^^^^
|
|
48
|
+
`Online documentation <https://edge-detection.readthedocs.io/en/latest/>`_
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Installation
|
|
52
|
+
^^^^^^^^^^^^
|
|
53
|
+
**curve-apps** is currently written and tested for Python 3.10.
|
|
54
|
+
|
|
55
|
+
Install Conda
|
|
56
|
+
-------------
|
|
57
|
+
|
|
58
|
+
To install **curve-apps**, you need to install **Conda** first.
|
|
59
|
+
|
|
60
|
+
We recommend to install **Conda** using `miniforge`_.
|
|
61
|
+
|
|
62
|
+
.. _miniforge: https://github.com/conda-forge/miniforge
|
|
63
|
+
|
|
64
|
+
Within a conda environment
|
|
65
|
+
--------------------------
|
|
66
|
+
|
|
67
|
+
You can install (or update) a conda environment with all the requires packages to run **curve-apps**.
|
|
68
|
+
To do so you can directly run the **Install_or_Update.bat** file by double left clicking on it.
|
|
69
|
+
|
|
70
|
+
Install with conda
|
|
71
|
+
------------------
|
|
72
|
+
|
|
73
|
+
You can install the package using ``conda`` and the ``.lock`` files from a conda prompt:
|
|
74
|
+
|
|
75
|
+
.. code-block:: bash
|
|
76
|
+
|
|
77
|
+
conda env create -n my-env -f environments/[the_desired_env].lock.yml
|
|
78
|
+
|
|
79
|
+
Install with PyPI
|
|
80
|
+
-----------------
|
|
81
|
+
|
|
82
|
+
You should not install the package from PyPI, as the app requires conda packages to run.
|
|
83
|
+
Still, you can install it in a conda environment without its dependencies (``--no-deps``).
|
|
84
|
+
|
|
85
|
+
From PyPI
|
|
86
|
+
~~~~~~~~~
|
|
87
|
+
|
|
88
|
+
To install the **curve-apps** package published on PyPI:
|
|
89
|
+
|
|
90
|
+
.. code-block:: bash
|
|
91
|
+
|
|
92
|
+
pip install -U --no-deps curve-apps
|
|
93
|
+
|
|
94
|
+
From a Git tag or branch
|
|
95
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
96
|
+
If the package is not on PiPY yet, you can install it from a Git tag:
|
|
97
|
+
|
|
98
|
+
.. code-block:: bash
|
|
99
|
+
|
|
100
|
+
pip install -U --no-deps --force-reinstall https://github.com/MiraGeoscience/curve-apps/archive/refs/tags/TAG.zip
|
|
101
|
+
|
|
102
|
+
Or to install the latest changes available on a given Git branch:
|
|
103
|
+
|
|
104
|
+
.. code-block:: bash
|
|
105
|
+
|
|
106
|
+
pip install -U --no-deps --force-reinstall https://github.com/MiraGeoscience/curve-apps/archive/refs/heads/BRANCH.zip
|
|
107
|
+
|
|
108
|
+
.. note::
|
|
109
|
+
The ``--force-reinstall`` option is used to make sure the updated version
|
|
110
|
+
of the sources is installed, and not the cached version, even if the version number
|
|
111
|
+
did not change. The ``-U`` or ``--upgrade`` option is used to make sure to get the latest version,
|
|
112
|
+
on not merely reinstall the same version. As the package is aimed to be in a **Conda environment**, the option ``--no-deps`` is used to avoid installing the dependencies with pip, as they will be installed with conda.
|
|
113
|
+
|
|
114
|
+
From a local copy of the sources
|
|
115
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
116
|
+
If you have a git clone of the package sources locally,
|
|
117
|
+
you can install **curve-apps** from the local copy of the sources with:
|
|
118
|
+
|
|
119
|
+
.. code-block:: bash
|
|
120
|
+
|
|
121
|
+
pip install -U --force-reinstall path/to/project_folder_with_pyproject_toml
|
|
122
|
+
|
|
123
|
+
Or in **editable mode**, so that you can edit the sources and see the effect immediately at runtime:
|
|
124
|
+
|
|
125
|
+
.. code-block:: bash
|
|
126
|
+
|
|
127
|
+
pip install -e -U --force-reinstall path/to/project_folder_with_pyproject_toml
|
|
128
|
+
|
|
129
|
+
Setup for development
|
|
130
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
131
|
+
To configure the development environment and tools, please see `README-dev.rst`_.
|
|
132
|
+
|
|
133
|
+
.. _README-dev.rst: README-dev.rst
|
|
134
|
+
|
|
135
|
+
License
|
|
136
|
+
^^^^^^^
|
|
137
|
+
curve-apps is free software: you can redistribute it and/or modify
|
|
138
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
139
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
140
|
+
(at your option) any later version.
|
|
141
|
+
|
|
142
|
+
curve-apps is distributed in the hope that it will be useful,
|
|
143
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
144
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
145
|
+
GNU Lesser General Public License for more details.
|
|
146
|
+
|
|
147
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
148
|
+
along with curve-apps. If not, see <https://www.gnu.org/licenses/>.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Third Party Software
|
|
152
|
+
^^^^^^^^^^^^^^^^^^^^
|
|
153
|
+
The curve-apps Software may provide links to third party libraries or code (collectively “Third Party Software”)
|
|
154
|
+
to implement various functions. Third Party Software does not comprise part of the Software.
|
|
155
|
+
The use of Third Party Software is governed by the terms of such software license(s).
|
|
156
|
+
Third Party Software notices and/or additional terms and conditions are located in the
|
|
157
|
+
`THIRD_PARTY_SOFTWARE.rst`_ file.
|
|
158
|
+
|
|
159
|
+
.. _THIRD_PARTY_SOFTWARE.rst: ./docs/THIRD_PARTY_SOFTWARE.rst
|
|
160
|
+
|
|
161
|
+
Copyright
|
|
162
|
+
^^^^^^^^^
|
|
163
|
+
Copyright (c) 2024 Mira Geoscience Ltd.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright (c) 2024 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of curve-apps package.
|
|
4
|
+
#
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0-alpha.1"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def assets_path() -> Path:
|
|
15
|
+
"""Return the path to the assets folder."""
|
|
16
|
+
|
|
17
|
+
parent = Path(__file__).parent
|
|
18
|
+
folder_name = f"{parent.name}-assets"
|
|
19
|
+
assets_folder = parent.parent / folder_name
|
|
20
|
+
if not assets_folder.is_dir():
|
|
21
|
+
raise RuntimeError(f"Assets folder not found: {assets_folder}")
|
|
22
|
+
|
|
23
|
+
return assets_folder
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Copyright (c) 2024 Mira Geoscience Ltd.
|
|
2
|
+
#
|
|
3
|
+
# This file is part of edge-detection package.
|
|
4
|
+
#
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
#
|
|
7
|
+
#
|
|
8
|
+
# This file is part of curve-apps.
|
|
9
|
+
#
|
|
10
|
+
# curve-apps is distributed under the terms and conditions of the MIT License
|
|
11
|
+
# (see LICENSE file at the root of this source code package).
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import logging
|
|
17
|
+
import tempfile
|
|
18
|
+
from abc import abstractmethod
|
|
19
|
+
|
|
20
|
+
from geoapps_utils.driver.data import BaseData
|
|
21
|
+
from geoapps_utils.driver.driver import BaseDriver
|
|
22
|
+
from geoh5py.groups import ContainerGroup
|
|
23
|
+
from geoh5py.objects import ObjectBase
|
|
24
|
+
from geoh5py.ui_json import InputFile
|
|
25
|
+
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class BaseCurveDriver(BaseDriver):
|
|
30
|
+
"""
|
|
31
|
+
Driver for the edge detection application.
|
|
32
|
+
|
|
33
|
+
:param parameters: Application parameters.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
_parameter_class: type[BaseData]
|
|
37
|
+
_default_name: str
|
|
38
|
+
|
|
39
|
+
def __init__(self, parameters: BaseData | InputFile):
|
|
40
|
+
if isinstance(parameters, InputFile):
|
|
41
|
+
parameters = self._parameter_class.build(parameters)
|
|
42
|
+
|
|
43
|
+
# TODO need to re-type params in base class
|
|
44
|
+
super().__init__(parameters)
|
|
45
|
+
|
|
46
|
+
def run(self):
|
|
47
|
+
"""
|
|
48
|
+
Run method of the driver.
|
|
49
|
+
"""
|
|
50
|
+
with self.workspace.open(mode="r+") as workspace:
|
|
51
|
+
parent = None
|
|
52
|
+
if self.params.output.out_group is not None:
|
|
53
|
+
parent = ContainerGroup.create(
|
|
54
|
+
workspace=workspace,
|
|
55
|
+
name=self.params.output.out_group,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
name = self.params.output.export_as
|
|
59
|
+
if name is None:
|
|
60
|
+
name = self._default_name
|
|
61
|
+
|
|
62
|
+
logger.info("Begin process.")
|
|
63
|
+
output = self.create_output(name, parent=parent)
|
|
64
|
+
logger.info("Process completed.")
|
|
65
|
+
|
|
66
|
+
if output is not None:
|
|
67
|
+
self.update_monitoring_directory(
|
|
68
|
+
parent if parent is not None else output
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
logger.info("Curve object '%s' saved to '%s'.", name, str(workspace.h5file))
|
|
72
|
+
|
|
73
|
+
@abstractmethod
|
|
74
|
+
def create_output(self, name: str, parent: ContainerGroup | None = None):
|
|
75
|
+
"""
|
|
76
|
+
Create output.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def params(self) -> BaseData:
|
|
81
|
+
"""Application parameters."""
|
|
82
|
+
return self._params
|
|
83
|
+
|
|
84
|
+
@params.setter
|
|
85
|
+
def params(self, val: BaseData):
|
|
86
|
+
if not isinstance(val, BaseData):
|
|
87
|
+
raise TypeError("Parameters must be of type Parameters.")
|
|
88
|
+
self._params = val
|
|
89
|
+
|
|
90
|
+
def add_ui_json(self, entity: ObjectBase | ContainerGroup):
|
|
91
|
+
"""
|
|
92
|
+
Add ui.json file to entity.
|
|
93
|
+
|
|
94
|
+
:param entity: Object to add ui.json file to.
|
|
95
|
+
"""
|
|
96
|
+
param_dict = self.params.flatten()
|
|
97
|
+
self.params.input_file.update_ui_values(param_dict)
|
|
98
|
+
|
|
99
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
100
|
+
file_path = self.params.input_file.write_ui_json(
|
|
101
|
+
path=temp_dir, name=self.params.name + ".ui.json"
|
|
102
|
+
)
|
|
103
|
+
entity.add_file(str(file_path))
|