-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Foundation for inversion module (#339)
- Loading branch information
Showing
19 changed files
with
230 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. _inversionapi: | ||
|
||
Inversion | ||
######### | ||
|
||
.. automodapi:: emg3d.inversion | ||
:no-inheritance-diagram: | ||
:no-heading: | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
|
||
simpeg | ||
pygimli | ||
|
||
.. grid:: 1 | ||
:gutter: 2 | ||
|
||
.. grid-item-card:: | ||
|
||
SimPEG(emg3d): :mod:`emg3d.inversion.simpeg` | ||
|
||
.. grid-item-card:: | ||
|
||
pyGIMLi(emg3d): :mod:`emg3d.inversion.pygimli` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pyGIMLi(emg3d) | ||
============== | ||
|
||
.. automodapi:: emg3d.inversion.pygimli | ||
:no-inheritance-diagram: | ||
:no-heading: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SimPEG(emg3d) | ||
============= | ||
|
||
.. automodapi:: emg3d.inversion.simpeg | ||
:no-inheritance-diagram: | ||
:no-heading: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
""" | ||
The inversion submodule of emg3d provides wrapper functionalities to use emg3d | ||
as a forward modelling kernel within third-party inversion frameworks. These | ||
third-party libraries are not included in emg3d, you have to install them | ||
separately. | ||
.. note:: | ||
This development is work in progress. Until an official *«inversion»* | ||
release, everything can change or disappear without warning. | ||
Currently planned wrappers and their corresponding requirements: | ||
- SimPEG(emg3d): Requires `SimPEG <https://simpeg.xyz>`_ (*Simulation and | ||
Parameter Estimation in Geophysics*). | ||
- pyGIMLi(emg3d): Requires `pyGIMLi <https://pygimli.org>`_ (*Geophysical | ||
Inversion & Modelling Library*). | ||
""" | ||
# Copyright 2024 The emsig community. | ||
# | ||
# This file is part of emg3d. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy | ||
# of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
import importlib as _importlib | ||
|
||
|
||
submodules = [ | ||
'pygimli', | ||
'simpeg', | ||
] | ||
|
||
__all__ = submodules | ||
|
||
|
||
def __dir__(): | ||
return __all__ | ||
|
||
|
||
def __getattr__(name): | ||
if name in submodules: | ||
return _importlib.import_module(f"emg3d.inversion.{name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Thin wrappers to use emg3d as a forward modelling kernel within the | ||
*Geophysical Inversion & Modelling Library* `pyGIMLi <https://pygimli.org>`_. | ||
It deals mainly with converting the data and model from the emg3d format to the | ||
pyGIMLi format and back, and creating the correct classes and functions as | ||
expected by a pyGIMLi inversion. | ||
""" | ||
# Copyright 2024 The emsig community. | ||
# | ||
# This file is part of emg3d. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy | ||
# of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# import numpy as np | ||
|
||
from emg3d import utils # io, _multiprocessing | ||
|
||
try: | ||
import pygimli | ||
# Add pygimli and pgcore to the emg3d.Report(). | ||
utils.OPTIONAL.extend(['pygimli', 'pgcore']) | ||
except ImportError: | ||
pygimli = None | ||
|
||
__all__ = [] | ||
|
||
|
||
def __dir__(): | ||
return __all__ | ||
|
||
|
||
if pygimli is not None: | ||
print("NOTE: pyGIMLi(emg3d) is in development.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Thin wrappers to use emg3d as a forward modelling kernel within the package | ||
*Simulation and Parameter Estimation in Geophysics* `SimPEG | ||
<https://simpeg.xyz>`_. | ||
It deals mainly with converting the data and model from the emg3d format to the | ||
SimPEG format and back, and creating the correct classes and functions as | ||
expected by a SimPEG inversion. | ||
""" | ||
# Copyright 2024 The emsig community. | ||
# | ||
# This file is part of emg3d. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy | ||
# of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# import numpy as np | ||
|
||
from emg3d import utils # electrodes, meshes, models, simulations, surveys | ||
|
||
try: | ||
import simpeg | ||
# import discretize | ||
# from simpeg.electromagnetics import frequency_domain as simpeg_fd | ||
# Add simpeg to the emg3d.Report(). | ||
utils.OPTIONAL.extend(['simpeg',]) | ||
except ImportError: | ||
simpeg = None | ||
|
||
|
||
__all__ = [] | ||
|
||
|
||
def __dir__(): | ||
return __all__ | ||
|
||
|
||
if simpeg is not None: | ||
print("NOTE: SimPEG(emg3d) is in development.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ xarray | |
discretize | ||
matplotlib | ||
ipympl | ||
pygimli>=1.5.2 | ||
simpeg>=0.22.1 | ||
|
||
# SETUP RELATED | ||
setuptools_scm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
author_email="[email protected]", | ||
url="https://emsig.xyz", | ||
license="Apache-2.0", | ||
packages=["emg3d", "emg3d.cli"], | ||
packages=["emg3d", "emg3d.inversion", "emg3d.cli"], | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"License :: OSI Approved :: Apache Software License", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from emg3d import inversion | ||
from emg3d.inversion import pygimli as ipygimli | ||
|
||
|
||
def test_all_dir(): | ||
assert set(inversion.__all__) == set(dir(inversion)) | ||
assert set(ipygimli.__all__) == set(dir(ipygimli)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from emg3d import inversion | ||
from emg3d.inversion import simpeg as isimpeg | ||
|
||
|
||
def test_all_dir(): | ||
assert set(inversion.__all__) == set(dir(inversion)) | ||
assert set(isimpeg.__all__) == set(dir(isimpeg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters