anemone-core 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.
Files changed (34) hide show
  1. anemone_core-0.1.0/LICENSE +8 -0
  2. anemone_core-0.1.0/PKG-INFO +65 -0
  3. anemone_core-0.1.0/README.md +38 -0
  4. anemone_core-0.1.0/pyproject.toml +42 -0
  5. anemone_core-0.1.0/setup.cfg +4 -0
  6. anemone_core-0.1.0/setup.py +4 -0
  7. anemone_core-0.1.0/src/anemone/__init__.py +26 -0
  8. anemone_core-0.1.0/src/anemone/experiment/__init__.py +1 -0
  9. anemone_core-0.1.0/src/anemone/experiment/experiment.py +53 -0
  10. anemone_core-0.1.0/src/anemone/forwards/__init__.py +1 -0
  11. anemone_core-0.1.0/src/anemone/forwards/forwards.py +755 -0
  12. anemone_core-0.1.0/src/anemone/inversion/__init__.py +3 -0
  13. anemone_core-0.1.0/src/anemone/inversion/inversion.py +785 -0
  14. anemone_core-0.1.0/src/anemone/inversion/models.py +266 -0
  15. anemone_core-0.1.0/src/anemone/physics/__init__.py +1 -0
  16. anemone_core-0.1.0/src/anemone/physics/physics.py +859 -0
  17. anemone_core-0.1.0/src/anemone/system/__init__.py +1 -0
  18. anemone_core-0.1.0/src/anemone/system/system.py +595 -0
  19. anemone_core-0.1.0/src/anemone/transforms/__init__.py +1 -0
  20. anemone_core-0.1.0/src/anemone/transforms/hankel_coefficients.py +212 -0
  21. anemone_core-0.1.0/src/anemone/transforms/transforms.py +449 -0
  22. anemone_core-0.1.0/src/anemone_core.egg-info/PKG-INFO +65 -0
  23. anemone_core-0.1.0/src/anemone_core.egg-info/SOURCES.txt +32 -0
  24. anemone_core-0.1.0/src/anemone_core.egg-info/dependency_links.txt +1 -0
  25. anemone_core-0.1.0/src/anemone_core.egg-info/requires.txt +17 -0
  26. anemone_core-0.1.0/src/anemone_core.egg-info/top_level.txt +1 -0
  27. anemone_core-0.1.0/tests/test_bugs.py +201 -0
  28. anemone_core-0.1.0/tests/test_examples.py +118 -0
  29. anemone_core-0.1.0/tests/test_forwards.py +809 -0
  30. anemone_core-0.1.0/tests/test_inversion.py +696 -0
  31. anemone_core-0.1.0/tests/test_physics.py +130 -0
  32. anemone_core-0.1.0/tests/test_saving.py +103 -0
  33. anemone_core-0.1.0/tests/test_system.py +92 -0
  34. anemone_core-0.1.0/tests/test_transforms.py +401 -0
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright © 2025 anemone developers
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: anemone-core
3
+ Version: 0.1.0
4
+ Summary: A PyTorch based 1D electromagnetic modelling and inversion code
5
+ Author-email: Matt Griffiths <mpg@geo.au.dk>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/hydrogeophysicsgroup/anemone
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: scipy
14
+ Requires-Dist: torch
15
+ Requires-Dist: nosj
16
+ Requires-Dist: biotsavartlaw
17
+ Requires-Dist: libaarhusxyz
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest; extra == "dev"
20
+ Requires-Dist: jupyter>=1.1.1; extra == "dev"
21
+ Provides-Extra: docs
22
+ Requires-Dist: mkdocs; extra == "docs"
23
+ Requires-Dist: mkdocs-jupyter; extra == "docs"
24
+ Requires-Dist: pymdown-extensions; extra == "docs"
25
+ Requires-Dist: pytest; extra == "docs"
26
+ Dynamic: license-file
27
+
28
+ # anEMone
29
+ a pytorch based 1D electromagnetic modelling and inversion code.
30
+
31
+ ## Installation
32
+
33
+ ```console
34
+ pip install anemone-core
35
+ ```
36
+
37
+ The package is published on PyPI as `anemone-core`, but is imported as `anemone`:
38
+
39
+ ```python
40
+ import anemone
41
+ ```
42
+
43
+ ## Documentation
44
+
45
+ The documentation site is built from markdown files in `docs/` using MkDocs.
46
+
47
+ Install the documentation tools:
48
+
49
+ ```console
50
+ pip install -e ".[docs]"
51
+ ```
52
+
53
+ Preview the site locally:
54
+
55
+ ```console
56
+ mkdocs serve
57
+ ```
58
+
59
+ Build the static site:
60
+
61
+ ```console
62
+ mkdocs build
63
+ ```
64
+
65
+ Jupyter notebooks can be rendered as documentation pages through `mkdocs-jupyter` when curated notebooks are placed under `docs/` and added to `mkdocs.yml`.
@@ -0,0 +1,38 @@
1
+ # anEMone
2
+ a pytorch based 1D electromagnetic modelling and inversion code.
3
+
4
+ ## Installation
5
+
6
+ ```console
7
+ pip install anemone-core
8
+ ```
9
+
10
+ The package is published on PyPI as `anemone-core`, but is imported as `anemone`:
11
+
12
+ ```python
13
+ import anemone
14
+ ```
15
+
16
+ ## Documentation
17
+
18
+ The documentation site is built from markdown files in `docs/` using MkDocs.
19
+
20
+ Install the documentation tools:
21
+
22
+ ```console
23
+ pip install -e ".[docs]"
24
+ ```
25
+
26
+ Preview the site locally:
27
+
28
+ ```console
29
+ mkdocs serve
30
+ ```
31
+
32
+ Build the static site:
33
+
34
+ ```console
35
+ mkdocs build
36
+ ```
37
+
38
+ Jupyter notebooks can be rendered as documentation pages through `mkdocs-jupyter` when curated notebooks are placed under `docs/` and added to `mkdocs.yml`.
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "anemone-core"
7
+ version = "0.1.0"
8
+ description = "A PyTorch based 1D electromagnetic modelling and inversion code"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Matt Griffiths", email = "mpg@geo.au.dk" },
14
+ ]
15
+ dependencies = [
16
+ "numpy",
17
+ "matplotlib",
18
+ "scipy",
19
+ "torch",
20
+ "nosj",
21
+ "biotsavartlaw",
22
+ "libaarhusxyz",
23
+ ]
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/hydrogeophysicsgroup/anemone"
27
+
28
+ [project.optional-dependencies]
29
+ dev = [
30
+ "pytest",
31
+ "jupyter>=1.1.1",
32
+ ]
33
+ docs = [
34
+ "mkdocs",
35
+ "mkdocs-jupyter",
36
+ "pymdown-extensions",
37
+ "pytest",
38
+ ]
39
+
40
+ [tool.setuptools.packages.find]
41
+ where = ["src"]
42
+ include = ["anemone*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from setuptools import setup
2
+
3
+
4
+ setup()
@@ -0,0 +1,26 @@
1
+ import torch
2
+
3
+ class constants:
4
+ pi = torch.pi
5
+ twopi = 2*torch.pi
6
+ fourpi = 4*torch.pi
7
+ sqrt_twopi = (2*torch.pi)**(1./2.)
8
+ sqrt_pi = torch.pi**(1./2.)
9
+ mu0 = 4*torch.pi*1e-7
10
+ epsilon0 = 8.854187817e-12
11
+ log2 = 0.6931471805599453
12
+
13
+ default_dtype = 'double'
14
+ if default_dtype=='float':
15
+ torch.set_default_dtype(torch.float32)
16
+ elif default_dtype=='double':
17
+ torch.set_default_dtype(torch.float64)
18
+
19
+ def rdtype():
20
+ return torch.get_default_dtype()
21
+
22
+ def cdtype():
23
+ cfloat = rdtype()
24
+ if cfloat==torch.float32: return torch.complex64
25
+ elif cfloat==torch.float64: return torch.complex128
26
+ raise NotImplementedError(f"no complex type associated with current default float {cfloat}")
@@ -0,0 +1 @@
1
+ from .experiment import *
@@ -0,0 +1,53 @@
1
+ import numpy as np
2
+ import torch
3
+ from .. import constants as c
4
+ from ..system import *
5
+
6
+
7
+ def compute_relstd(t_gates, data_val, noise_slope_exponent=-0.5, noise_level_at_1ms=1e-8, current=1, relative_noise=0.03):
8
+ b = noise_level_at_1ms/(1e-3**noise_slope_exponent)
9
+ abs_noise = b*(t_gates**noise_slope_exponent)
10
+ y = data_val*current
11
+ std_rel = abs_noise/y.T
12
+ relstd_tot = torch.sqrt(std_rel**2 + relative_noise**2)
13
+ return relstd_tot.to(data_val.device).T
14
+
15
+ def plot_error_statistics(times, dbdt, dbdt_ref, ax=None, log_relerr=True, abs_color="C0", rel_color="C3", min_percentile=5., max_percentile=95., ok_relerr_lines=3.):
16
+ if ax is None:
17
+ from matplotlib.pyplot import subplots
18
+ fig,ax = subplots()
19
+
20
+ abserr = np.abs(dbdt - dbdt_ref)
21
+ relerr = 100*(dbdt - dbdt_ref) / np.abs(dbdt_ref)
22
+
23
+ ax2 = ax.twinx()
24
+
25
+ if log_relerr:
26
+ relerr = np.abs(relerr)
27
+
28
+ ax.plot(times, relerr.mean(0), '--', color=rel_color)
29
+ ax.plot(times, np.median(relerr, axis=0), '-', color=rel_color)
30
+ lb = np.percentile(relerr, min_percentile, axis=0)
31
+ ub = np.percentile(relerr, max_percentile, axis=0)
32
+ ax.fill_between(times, lb, ub, color=rel_color, alpha=0.2)
33
+
34
+
35
+ ax2.loglog(times, abserr.mean(0), '--', color=abs_color)
36
+ ax2.loglog(times, np.median(abserr, axis=0), '-', color=abs_color)
37
+ lb = np.percentile(abserr, min_percentile, axis=0)
38
+ ub = np.percentile(abserr, max_percentile, axis=0)
39
+ ax2.fill_between(times, lb, ub, color=abs_color, alpha=0.2)
40
+
41
+ ax2.set_ylabel('Absolute Error [V/m$^2$]', color=abs_color)
42
+ ax.set_ylabel('Relative Error [%]', color=rel_color)
43
+
44
+ if log_relerr:
45
+ ax.set_yscale('log')
46
+
47
+ ax.grid(lw=0.5, which='both')
48
+ if ok_relerr_lines is not None:
49
+ ax.axhline( ok_relerr_lines, color='k', lw=2)
50
+ ax.axhline(-ok_relerr_lines, color='k', lw=2)
51
+ ax.set_xlabel('time [s]')
52
+
53
+ return ax,ax2
@@ -0,0 +1 @@
1
+ from .forwards import *