integrate-module 0.99.9.1__tar.gz → 1.0.3__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.
- {integrate_module-0.99.9.1/integrate_module.egg-info → integrate_module-1.0.3}/PKG-INFO +20 -16
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/README.md +13 -8
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/prior.py +1 -1
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/__init__.py +12 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/anemone_forward.py +259 -14
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/gaaem_forward.py +5 -2
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate.py +396 -312
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_borehole.py +57 -201
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_io.py +746 -219
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_plot.py +703 -55
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_query.py +133 -9
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_rejection.py +909 -188
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_rejection_cli.py +59 -13
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_rejection_jax.py +184 -70
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/simpeg_forward.py +80 -39
- integrate_module-1.0.3/integrate/sr2_gex.py +273 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3/integrate_module.egg-info}/PKG-INFO +20 -16
- integrate_module-1.0.3/integrate_module.egg-info/SOURCES.txt +74 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate_module.egg-info/requires.txt +7 -9
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/pyproject.toml +27 -13
- integrate_module-1.0.3/tests/test_anemone_core.py +428 -0
- integrate_module-1.0.3/tests/test_coherent_area.py +43 -0
- integrate_module-1.0.3/tests/test_likelihood_gaussian.py +168 -0
- integrate_module-1.0.3/tests/test_likelihood_kernels.py +100 -0
- integrate_module-1.0.3/tests/test_prior_timing.py +82 -0
- integrate_module-1.0.3/tests/test_rejection_backends.py +254 -0
- integrate_module-1.0.3/tests/test_rejection_cli.py +63 -0
- integrate_module-1.0.3/tests/test_rejection_em_height.py +264 -0
- integrate_module-1.0.3/tests/test_rejection_per_type_T.py +224 -0
- integrate_module-1.0.3/tests/test_voronoi_grid.py +139 -0
- integrate_module-0.99.9.1/frontend/static/figures/006b874a67148744.json +0 -1
- integrate_module-0.99.9.1/frontend/static/figures/01c54329eb934b92.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/0454af65d7dea5f1.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/061d5cecc1a2f677.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/066bb5c9da4d0c0b.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/0baffb84416e0aa5.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/0bddf00c6308d581.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/0d0c87a2b0317423.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/0e020d8b85920d7e.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/105023459d1a8567.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/12846323d657202c.json +0 -1
- integrate_module-0.99.9.1/frontend/static/figures/12846323d657202c.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/1a9964bb2736785c.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/1acd3021d782ccc2.json +0 -1
- integrate_module-0.99.9.1/frontend/static/figures/1acd3021d782ccc2.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/1c84cb9595fbcb9b.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/1ec73b329d1e30c1-0.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/29dc879298fdfa8a.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/2b167d8b53dd646f.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/2b764aca24a6fd44.json +0 -1
- integrate_module-0.99.9.1/frontend/static/figures/2d78ec085ac2bbef.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/3bf8957c95d8dc58.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/3f50930542de8196.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/41ef6a32da0ec924.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/426adc78c42b1a27.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/427dd675638f594d.json +0 -1
- integrate_module-0.99.9.1/frontend/static/figures/427dd675638f594d.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/487ff0ef8da5a2ec.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/4dc6542b7b0f149f.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/4ec72f25a8ec038c.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/4feb7f1a8281a0bd.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/525d39d8ea618a41.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/53da1cb8aa8a6cb1.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/55d5162d81b64a36.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/588f962e19adecff.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/5a5b4b0457603714.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/5d84b1ae75e96c16.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/5fdc8164998fe564.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/64cdac3bedd0cecd.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/65cf5a549f2f1b33.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/689bb914194a8d64.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/68bdea6008a16e42.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/6a7883226a8a477d.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/6c85602ebffb533e.json +0 -1
- integrate_module-0.99.9.1/frontend/static/figures/6c85602ebffb533e.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/75c488b1f85e3369.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/78a160053c2cac33.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/79d91b91323697cd.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/7a64c69b35eaf912.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/7bb22ced65184b59.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/7e7213e8f8247031.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/7fd95f0d2c9595c9.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/994f10f602985978.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/9a6b1d1f0a7ffd11.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/9a8729c07d09bd5a.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/9ddc30d24404a155-0.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/a6f07ace7e42da09.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/ab655c40d7fffc4f.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b12e125404b2aea1.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b2f3a4ce9f535f45.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b605415c314c6cef.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b7d8d18a140c0073.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b829df1a78718dd6.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b8dbb12675172fda.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/b99e09ec69df4967.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/be438f0ac7f59a5c.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/c9030d3cf5e7b94c.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/d20e6de716ab4454.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/d2295c0eaa723af8.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/d5925defec62f763.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/d7daade6e2618161.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/e029eb6cb62868dd.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/e4000e24e61bcefc.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/e58009ee8354d189.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/e5b501e77c7db114.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/e8b65132706e5437.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/f015d3f025e93a71.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/f3cf99660141b008.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/f4a3311840de58e2-0.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/f5a08d8db05edb9c.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/f8907379e981be33-0.png +0 -0
- integrate_module-0.99.9.1/frontend/static/figures/fb3b9efeef379e15.png +0 -0
- integrate_module-0.99.9.1/integrate_module.egg-info/SOURCES.txt +0 -150
- integrate_module-0.99.9.1/tests/test_anemone_sr2.py +0 -164
- integrate_module-0.99.9.1/tests/test_likelihood_nan.py +0 -126
- integrate_module-0.99.9.1/tests/test_noise_model_per_type.py +0 -67
- integrate_module-0.99.9.1/tests/test_rx_z_sign.py +0 -100
- integrate_module-0.99.9.1/tests/test_simpeg_forward.py +0 -362
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/LICENSE +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/__init__.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/__main__.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/app.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/components.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/config.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/__init__.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/_forms.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/_jobs_ui.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/borehole.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/files.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/forward.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/geoprior.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/inversion.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/plotting.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/profile.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/query.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/results.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/stubs.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/workflow.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/pages/workspace_ui.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/__init__.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/figures.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/files.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/integrate_api.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/jobs.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/session.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/worker.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/workspace.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/services/xlsx.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/app.css +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/fonts/archivo-latin-ext.woff2 +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/fonts/archivo-latin.woff2 +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/fonts/archivo-vietnamese.woff2 +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/htmx.min.js +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/modernist.css +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/frontend/static/picker.js +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/em_system.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/gex.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_hdf5_info_cli.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/integrate_timing_cli.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate/mlmapping.py +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate_module.egg-info/dependency_links.txt +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate_module.egg-info/entry_points.txt +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/integrate_module.egg-info/top_level.txt +0 -0
- {integrate_module-0.99.9.1 → integrate_module-1.0.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: integrate_module
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Localized probabilistic data integration
|
|
5
5
|
Author-email: Thomas Mejer Hansen <tmeha@geo.au.dk>
|
|
6
6
|
License: MIT
|
|
@@ -20,11 +20,12 @@ Requires-Dist: scipy
|
|
|
20
20
|
Requires-Dist: psutil
|
|
21
21
|
Requires-Dist: tqdm
|
|
22
22
|
Requires-Dist: requests
|
|
23
|
-
Requires-Dist: geoprior1d>=0.
|
|
23
|
+
Requires-Dist: geoprior1d>=1.0.1
|
|
24
24
|
Requires-Dist: shapely
|
|
25
25
|
Requires-Dist: ga-aem-forward-win; platform_system == "Windows"
|
|
26
26
|
Requires-Dist: simpeg>=0.25
|
|
27
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: anemone-core>=0.1.1
|
|
28
|
+
Requires-Dist: jupyter>=1.0.1
|
|
28
29
|
Requires-Dist: jupytext
|
|
29
30
|
Requires-Dist: ipykernel
|
|
30
31
|
Requires-Dist: pandas
|
|
@@ -40,8 +41,10 @@ Requires-Dist: threadpoolctl
|
|
|
40
41
|
Provides-Extra: dev
|
|
41
42
|
Requires-Dist: pytest; extra == "dev"
|
|
42
43
|
Requires-Dist: black; extra == "dev"
|
|
44
|
+
Provides-Extra: ui
|
|
45
|
+
Requires-Dist: integrate_ui; extra == "ui"
|
|
43
46
|
Provides-Extra: ml
|
|
44
|
-
Requires-Dist: tensorflow; extra == "ml"
|
|
47
|
+
Requires-Dist: tensorflow[and-cuda]; extra == "ml"
|
|
45
48
|
Requires-Dist: scikit-learn; extra == "ml"
|
|
46
49
|
Requires-Dist: keras_tuner; extra == "ml"
|
|
47
50
|
Provides-Extra: examples
|
|
@@ -50,12 +53,8 @@ Requires-Dist: shapely; extra == "examples"
|
|
|
50
53
|
Provides-Extra: docs
|
|
51
54
|
Requires-Dist: sphinx; extra == "docs"
|
|
52
55
|
Requires-Dist: sphinx-gallery; extra == "docs"
|
|
53
|
-
Requires-Dist: pandoc; extra == "docs"
|
|
54
|
-
Requires-Dist: myst-parser; extra == "docs"
|
|
55
|
-
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
56
56
|
Requires-Dist: furo; extra == "docs"
|
|
57
57
|
Requires-Dist: ghp-import; extra == "docs"
|
|
58
|
-
Requires-Dist: tomli; python_version < "3.11" and extra == "docs"
|
|
59
58
|
Provides-Extra: jax-cuda
|
|
60
59
|
Requires-Dist: jax[cuda13]; extra == "jax-cuda"
|
|
61
60
|
Dynamic: license-file
|
|
@@ -230,17 +229,22 @@ First install Homebrew, then run:
|
|
|
230
229
|
|
|
231
230
|
## Alternative EM forward backends (anemone, SimPEG)
|
|
232
231
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
`
|
|
232
|
+
**anemone** is the default TDEM forward modeller. If it is not installed, INTEGRATE falls
|
|
233
|
+
back to GA-AEM and then SimPEG (preference: anemone, GA-AEM, SimPEG). Select a backend with
|
|
234
|
+
`method=` in `ig.forward_em()` / `ig.prior_data_em()` (or via the `EM_FORWARD_METHOD`
|
|
235
|
+
environment variable):
|
|
236
236
|
|
|
237
|
-
ig.prior_data_em(f_prior_h5, file_gex=gex
|
|
237
|
+
ig.prior_data_em(f_prior_h5, file_gex=gex) # default: anemone
|
|
238
238
|
ig.prior_data_em(f_prior_h5, file_gex=gex, method='anemone') # PyTorch, GPU-capable
|
|
239
|
+
ig.prior_data_em(f_prior_h5, file_gex=gex, method='ga-aem') # GA-AEM
|
|
239
240
|
ig.prior_data_em(f_prior_h5, file_gex=gex, method='simpeg') # SimPEG 1D layered TDEM
|
|
240
241
|
|
|
241
|
-
* **anemone** (
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
* **anemone** (PyTorch, GPU-capable): installed with `integrate_module` (core dependency
|
|
243
|
+
`anemone-core`, imported as `anemone`). Source: https://github.com/hydrogeophysicsgroup/anemone,
|
|
244
|
+
PyPI: https://pypi.org/project/anemone-core/. For GPU use, install a CUDA build of `torch`
|
|
245
|
+
for your hardware (https://pytorch.org).
|
|
246
|
+
* **SimPEG**: installed with `integrate_module` (core dependency, `simpeg>=0.25`).
|
|
247
|
+
Use `ig.forward_simpeg()` / `ig.prior_data_simpeg()`. The `.gex` low-pass filters
|
|
244
248
|
and gate integration are applied by INTEGRATE on top of SimPEG's
|
|
245
249
|
`Simulation1DLayered`; agreement with GA-AEM is ~1 % (LM) / ~0.2 % (HM) on Daugaard tTEM,
|
|
246
250
|
see `SIMPEG_VS_GAAEM.md`.
|
|
@@ -251,7 +255,7 @@ The `main` branch is the most stable, with less frequent updates but larger chan
|
|
|
251
255
|
|
|
252
256
|
The `develop` branch contains the current development code and may be updated frequently. Some functions and examples may be broken.
|
|
253
257
|
|
|
254
|
-
An extra set of tests and examples are located in the
|
|
258
|
+
An extra set of tests and examples are located in the `experimental` submodule repository: https://github.com/cultpenguin/integrate_module_experimental/.
|
|
255
259
|
Please ask the developers for access to this branch if needed. To clone the main repository with the experimental branch, use:
|
|
256
260
|
|
|
257
261
|
git clone --recurse-submodules git@github.com:AUProbGeo/integrate_module.git
|
|
@@ -168,17 +168,22 @@ First install Homebrew, then run:
|
|
|
168
168
|
|
|
169
169
|
## Alternative EM forward backends (anemone, SimPEG)
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
`
|
|
171
|
+
**anemone** is the default TDEM forward modeller. If it is not installed, INTEGRATE falls
|
|
172
|
+
back to GA-AEM and then SimPEG (preference: anemone, GA-AEM, SimPEG). Select a backend with
|
|
173
|
+
`method=` in `ig.forward_em()` / `ig.prior_data_em()` (or via the `EM_FORWARD_METHOD`
|
|
174
|
+
environment variable):
|
|
174
175
|
|
|
175
|
-
ig.prior_data_em(f_prior_h5, file_gex=gex
|
|
176
|
+
ig.prior_data_em(f_prior_h5, file_gex=gex) # default: anemone
|
|
176
177
|
ig.prior_data_em(f_prior_h5, file_gex=gex, method='anemone') # PyTorch, GPU-capable
|
|
178
|
+
ig.prior_data_em(f_prior_h5, file_gex=gex, method='ga-aem') # GA-AEM
|
|
177
179
|
ig.prior_data_em(f_prior_h5, file_gex=gex, method='simpeg') # SimPEG 1D layered TDEM
|
|
178
180
|
|
|
179
|
-
* **anemone** (
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
* **anemone** (PyTorch, GPU-capable): installed with `integrate_module` (core dependency
|
|
182
|
+
`anemone-core`, imported as `anemone`). Source: https://github.com/hydrogeophysicsgroup/anemone,
|
|
183
|
+
PyPI: https://pypi.org/project/anemone-core/. For GPU use, install a CUDA build of `torch`
|
|
184
|
+
for your hardware (https://pytorch.org).
|
|
185
|
+
* **SimPEG**: installed with `integrate_module` (core dependency, `simpeg>=0.25`).
|
|
186
|
+
Use `ig.forward_simpeg()` / `ig.prior_data_simpeg()`. The `.gex` low-pass filters
|
|
182
187
|
and gate integration are applied by INTEGRATE on top of SimPEG's
|
|
183
188
|
`Simulation1DLayered`; agreement with GA-AEM is ~1 % (LM) / ~0.2 % (HM) on Daugaard tTEM,
|
|
184
189
|
see `SIMPEG_VS_GAAEM.md`.
|
|
@@ -189,7 +194,7 @@ The `main` branch is the most stable, with less frequent updates but larger chan
|
|
|
189
194
|
|
|
190
195
|
The `develop` branch contains the current development code and may be updated frequently. Some functions and examples may be broken.
|
|
191
196
|
|
|
192
|
-
An extra set of tests and examples are located in the
|
|
197
|
+
An extra set of tests and examples are located in the `experimental` submodule repository: https://github.com/cultpenguin/integrate_module_experimental/.
|
|
193
198
|
Please ask the developers for access to this branch if needed. To clone the main repository with the experimental branch, use:
|
|
194
199
|
|
|
195
200
|
git clone --recurse-submodules git@github.com:AUProbGeo/integrate_module.git
|
|
@@ -45,7 +45,7 @@ _RHO = [
|
|
|
45
45
|
_RHO_DIST = ("select", ["log-uniform", "uniform", "normal", "lognormal"])
|
|
46
46
|
# smooth (L2): 'lognormal' keeps the historical correlated-GP-in-log output;
|
|
47
47
|
# 'log-uniform'/'uniform' swap the per-layer marginal via a Gaussian copula.
|
|
48
|
-
_RHO_DIST_L2 = ("select", ["lognormal", "log-uniform", "uniform"
|
|
48
|
+
_RHO_DIST_L2 = ("select", ["lognormal", "log-uniform", "uniform"])
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
# --------------------------------------------------------------------------- #
|
|
@@ -3,6 +3,8 @@ multiprocessing.freeze_support()
|
|
|
3
3
|
|
|
4
4
|
# Import rejection sampling functions from new module
|
|
5
5
|
from integrate.integrate_rejection import integrate_rejection
|
|
6
|
+
from integrate.integrate_rejection import integrate_rejection_em_height
|
|
7
|
+
from integrate.integrate_rejection import em_height_bins
|
|
6
8
|
from integrate.integrate_rejection import integrate_rejection_range
|
|
7
9
|
from integrate.integrate_rejection import integrate_posterior_chunk
|
|
8
10
|
from integrate.integrate_rejection import integrate_posterior_main
|
|
@@ -36,6 +38,8 @@ from integrate.anemone_forward import gex_to_anemone_system
|
|
|
36
38
|
from integrate.simpeg_forward import forward_simpeg
|
|
37
39
|
from integrate.simpeg_forward import prior_data_simpeg
|
|
38
40
|
from integrate.em_system import gex_to_em_system
|
|
41
|
+
from integrate.sr2_gex import gex_apply_sr2
|
|
42
|
+
from integrate.sr2_gex import sr2_effective_current
|
|
39
43
|
from integrate.integrate import synthetic_case
|
|
40
44
|
from integrate.integrate import prior_model_layered
|
|
41
45
|
from integrate.integrate import prior_model_workbench
|
|
@@ -68,6 +72,8 @@ from integrate.integrate_io import load_prior_data
|
|
|
68
72
|
from integrate.integrate_io import save_prior_data
|
|
69
73
|
from integrate.integrate_io import load_prior_model
|
|
70
74
|
from integrate.integrate_io import save_prior_model
|
|
75
|
+
from integrate.integrate_io import save_compute_time
|
|
76
|
+
from integrate.integrate_io import get_prior_timing
|
|
71
77
|
from integrate.integrate_io import load_data
|
|
72
78
|
from integrate.integrate_io import get_geometry
|
|
73
79
|
from integrate.integrate_io import extract_feature_at_elevation
|
|
@@ -121,6 +127,11 @@ from integrate.integrate_plot import plot_xy
|
|
|
121
127
|
from integrate.integrate_plot import find_points_along_line_segments
|
|
122
128
|
from integrate.integrate_plot import plot_boreholes
|
|
123
129
|
from integrate.integrate_plot import plot_voronoi_cells
|
|
130
|
+
from integrate.integrate_plot import post_to_voronoi_columns
|
|
131
|
+
from integrate.integrate_plot import voronoi_columns_to_grid
|
|
132
|
+
from integrate.integrate_plot import post_to_voronoi_grid
|
|
133
|
+
from integrate.integrate_plot import plot_voronoi_3d
|
|
134
|
+
from integrate.integrate_plot import plot_voronoi_slices
|
|
124
135
|
|
|
125
136
|
# Import from borehole module
|
|
126
137
|
from integrate.integrate_borehole import compute_P_obs_discrete
|
|
@@ -153,6 +164,7 @@ from integrate.integrate_query import query_test_llm
|
|
|
153
164
|
from integrate.integrate_query import voronoi_graph
|
|
154
165
|
from integrate.integrate_query import voronoi_cells_ordered
|
|
155
166
|
from integrate.integrate_query import cells_to_polygon
|
|
167
|
+
from integrate.integrate_query import touching_neighbors
|
|
156
168
|
from integrate.integrate_query import flag_edge_cells
|
|
157
169
|
from integrate.integrate_query import grow_connected_region
|
|
158
170
|
from integrate.integrate_query import find_coherent_area
|
|
@@ -17,7 +17,9 @@ from integrate.em_system import (_butter_rows, _polygon_area, # shared helpers
|
|
|
17
17
|
|
|
18
18
|
_IMPORT_HINT = (
|
|
19
19
|
"anemone backend requires 'anemone' and 'torch': "
|
|
20
|
-
"pip install
|
|
20
|
+
"pip install anemone-core "
|
|
21
|
+
"(https://pypi.org/project/anemone-core/, "
|
|
22
|
+
"https://github.com/hydrogeophysicsgroup/anemone)"
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
|
|
@@ -91,13 +93,57 @@ def _gex_signature(g):
|
|
|
91
93
|
return hashlib.md5(repr(sorted(str(d).encode())[:0] or str(d)).encode()).hexdigest()
|
|
92
94
|
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
from collections import OrderedDict
|
|
97
|
+
|
|
98
|
+
# Cache of anemone setups, one per (GEX, Tx height, device, tolerance), in
|
|
99
|
+
# least-recently-used order. With a varying flight height there is one setup
|
|
100
|
+
# per height bin (~50 MB of GPU memory each for SkyTEM), so on CUDA the cache
|
|
101
|
+
# is bounded by free GPU memory: the least recently used setups on the device
|
|
102
|
+
# are dropped while less than _CUDA_MIN_FREE_GB (or _CUDA_MIN_FREE_FRAC of
|
|
103
|
+
# the total) is free.
|
|
104
|
+
_FORWARD_CACHE = OrderedDict()
|
|
105
|
+
_CUDA_MIN_FREE_GB = 1.0
|
|
106
|
+
_CUDA_MIN_FREE_FRAC = 0.15
|
|
95
107
|
|
|
96
108
|
|
|
97
109
|
def _clear_forward_cache():
|
|
98
110
|
_FORWARD_CACHE.clear()
|
|
99
111
|
|
|
100
112
|
|
|
113
|
+
def _evict_cuda_cache(device, torch, all_entries=False):
|
|
114
|
+
"""Drop least recently used CUDA setups on ``device`` until enough GPU
|
|
115
|
+
memory is free (or all of them with ``all_entries``). Returns the number
|
|
116
|
+
of setups dropped."""
|
|
117
|
+
import gc
|
|
118
|
+
dev = torch.device(device)
|
|
119
|
+
if dev.type != "cuda" or not torch.cuda.is_available():
|
|
120
|
+
return 0
|
|
121
|
+
idx = dev.index if dev.index is not None else torch.cuda.current_device()
|
|
122
|
+
dev_keys = lambda: [k for k in _FORWARD_CACHE
|
|
123
|
+
if torch.device(k[2]).type == "cuda"
|
|
124
|
+
and (torch.device(k[2]).index or 0) == idx]
|
|
125
|
+
|
|
126
|
+
def low_memory():
|
|
127
|
+
free, total = torch.cuda.mem_get_info(idx)
|
|
128
|
+
return free < max(_CUDA_MIN_FREE_GB * 1024 ** 3, _CUDA_MIN_FREE_FRAC * total)
|
|
129
|
+
|
|
130
|
+
n = 0
|
|
131
|
+
while dev_keys() and (all_entries or low_memory()):
|
|
132
|
+
# Drop a few at a time; freed memory is only visible after
|
|
133
|
+
# gc + empty_cache.
|
|
134
|
+
for k in dev_keys()[:1 if not all_entries else None]:
|
|
135
|
+
del _FORWARD_CACHE[k]
|
|
136
|
+
n += 1
|
|
137
|
+
gc.collect()
|
|
138
|
+
torch.cuda.empty_cache()
|
|
139
|
+
return n
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _is_cuda_oom(err, torch):
|
|
143
|
+
oom = getattr(torch, "OutOfMemoryError", None) or getattr(torch.cuda, "OutOfMemoryError", ())
|
|
144
|
+
return isinstance(err, oom) or "CUDA out of memory" in str(err)
|
|
145
|
+
|
|
146
|
+
|
|
101
147
|
def _remake_loop(loop, tx_z, torch):
|
|
102
148
|
from anemone.system import Loop
|
|
103
149
|
if tx_z is None:
|
|
@@ -135,6 +181,15 @@ class _DampedLowPass:
|
|
|
135
181
|
def omega_filter(self, omega):
|
|
136
182
|
return self(omega / (2.0 * np.pi))
|
|
137
183
|
|
|
184
|
+
def poles(self):
|
|
185
|
+
"""Poles in rad/s (used by anemone's FilterChain.stepoff_response)."""
|
|
186
|
+
return 2.0 * np.pi * self.fcut * np.roots([1.0, 2.0 * self.damping, 1.0])
|
|
187
|
+
|
|
188
|
+
def stepoff_response(self, t):
|
|
189
|
+
"""Step-off response at times ``t`` (used by a one-filter FilterChain)."""
|
|
190
|
+
from anemone.system import allpole_stepoff_response
|
|
191
|
+
return allpole_stepoff_response(self.poles(), t)
|
|
192
|
+
|
|
138
193
|
|
|
139
194
|
# ---------------------------------------------------------------------------
|
|
140
195
|
# System response (.sr2) support
|
|
@@ -310,10 +365,27 @@ def _build_forward(system, tx_z, device):
|
|
|
310
365
|
"anemone backend: only 1 or 2 moments supported")
|
|
311
366
|
|
|
312
367
|
tx_z_key = "src" if tx_z is None else round(float(tx_z), 3)
|
|
313
|
-
key = (system["gex_signature"], tx_z_key, str(device))
|
|
368
|
+
key = (system["gex_signature"], tx_z_key, str(device), system.get("tolerance"))
|
|
314
369
|
if key in _FORWARD_CACHE:
|
|
370
|
+
_FORWARD_CACHE.move_to_end(key)
|
|
315
371
|
return _FORWARD_CACHE[key]
|
|
316
372
|
|
|
373
|
+
_evict_cuda_cache(device, torch)
|
|
374
|
+
try:
|
|
375
|
+
return _build_forward_uncached(system, tx_z, device, key)
|
|
376
|
+
except RuntimeError as err:
|
|
377
|
+
# Out of GPU memory: drop all cached setups on the device and retry once
|
|
378
|
+
if not _is_cuda_oom(err, torch) or _evict_cuda_cache(device, torch, all_entries=True) == 0:
|
|
379
|
+
raise
|
|
380
|
+
return _build_forward_uncached(system, tx_z, device, key)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def _build_forward_uncached(system, tx_z, device, key):
|
|
384
|
+
_, torch = _require_anemone()
|
|
385
|
+
from anemone.forwards import Forward
|
|
386
|
+
from anemone.system import Receiver
|
|
387
|
+
|
|
388
|
+
n_moments = len(system["moments"])
|
|
317
389
|
dev = torch.device(device)
|
|
318
390
|
|
|
319
391
|
# Hoist and build shared source, receiver, filterfunc from first moment
|
|
@@ -399,7 +471,7 @@ def gex_to_anemone_system(gex, showInfo=0, file_sr2=None, sr_filters=False,
|
|
|
399
471
|
``1/(1 + 2 zeta s + s^2)`` (see ``ISSUE_rx_coil_filter.md``):
|
|
400
472
|
|
|
401
473
|
* ``'two_pole'`` (default): two first-order poles at ``fcut/zeta``
|
|
402
|
-
(
|
|
474
|
+
(``rx_coil_lowpass`` in ``integrate.em_system``), the same filters
|
|
403
475
|
GA-AEM and SimPEG use;
|
|
404
476
|
* ``'damped2'``: the exact second-order response;
|
|
405
477
|
* ``'cascade'``: the earlier reading, every entry as a Butterworth
|
|
@@ -677,7 +749,7 @@ def _compress_batch(M, thickness):
|
|
|
677
749
|
return M_c, T_c
|
|
678
750
|
|
|
679
751
|
|
|
680
|
-
def _run_batched(fwr, M_t, T_t, batch_size, torch):
|
|
752
|
+
def _run_batched(fwr, M_t, T_t, batch_size, torch, progress=None):
|
|
681
753
|
"""Run ``fwr`` over the model axis of ``M_t``/``T_t`` in chunks.
|
|
682
754
|
|
|
683
755
|
anemone's intermediates scale linearly with the number of models
|
|
@@ -688,6 +760,8 @@ def _run_batched(fwr, M_t, T_t, batch_size, torch):
|
|
|
688
760
|
|
|
689
761
|
M_t: (nd, K) resistivity, T_t: (nd, K-1) thicknesses (both torch tensors
|
|
690
762
|
already on the target device). Returns raw as an (nd, n_gates) ndarray.
|
|
763
|
+
``progress(n)``, if given, is called with the number of models finished
|
|
764
|
+
after each batch (one call per batch, so it adds no per-model cost).
|
|
691
765
|
"""
|
|
692
766
|
nd = M_t.shape[0]
|
|
693
767
|
if not batch_size or batch_size <= 0 or batch_size >= nd:
|
|
@@ -699,6 +773,8 @@ def _run_batched(fwr, M_t, T_t, batch_size, torch):
|
|
|
699
773
|
raw = fwr(M_t[i0:i1].T, T_t[i0:i1].T).detach().cpu().numpy()
|
|
700
774
|
blocks.append(np.atleast_2d(raw)) # anemone squeezes for n_models==1
|
|
701
775
|
del raw
|
|
776
|
+
if progress is not None:
|
|
777
|
+
progress(i1 - i0)
|
|
702
778
|
return np.concatenate(blocks, axis=0) if len(blocks) > 1 else blocks[0]
|
|
703
779
|
|
|
704
780
|
|
|
@@ -788,12 +864,30 @@ def forward_anemone(M=np.array(()), thickness=np.array(()), file_gex=None,
|
|
|
788
864
|
showInfo=0, progress_callback=None, batch_size=1000,
|
|
789
865
|
file_sr2=None, sr_filters=False, n_previous_pulses=0,
|
|
790
866
|
rx_coil_filter="two_pole", gate_integration="centre",
|
|
791
|
-
tolerance=1e-6, **kwargs):
|
|
867
|
+
tolerance=1e-6, rescale_height=False, **kwargs):
|
|
792
868
|
"""Forward TDEM data for one or more resistivity models with anemone.
|
|
793
869
|
|
|
870
|
+
rescale_height : bool, optional
|
|
871
|
+
Only used when ``tx_height`` varies between soundings (default False).
|
|
872
|
+
anemone bakes the flight height into its setup, which takes about 1 s per
|
|
873
|
+
distinct height, so the default (one setup per ``altitude_bin_width``
|
|
874
|
+
bin) is slow for a wide height range. With ``rescale_height=True`` one
|
|
875
|
+
setup is made at the lowest height and the kernel is rescaled to each
|
|
876
|
+
model's exact height (``exp(-2*dh*lmb)``), so ``altitude_bin_width`` is
|
|
877
|
+
ignored. This is an approximation whose error grows with the height
|
|
878
|
+
spread: small for a spread of a few metres, a few percent of the peak
|
|
879
|
+
signal at 45 m; a ``UserWarning`` is given above 30 m. The reference
|
|
880
|
+
setup uses ``tolerance / 10`` (about 20% more kernel terms) to keep the
|
|
881
|
+
rescaling accurate. Has no effect for a fixed height.
|
|
882
|
+
altitude_bin_width : float, optional
|
|
883
|
+
Bin width in m (default 1.0) for a varying ``tx_height``: heights are
|
|
884
|
+
rounded to bins and one anemone setup is made per bin. ``0``/``None``
|
|
885
|
+
makes one setup per distinct height. Ignored with
|
|
886
|
+
``rescale_height=True`` and for a fixed height.
|
|
794
887
|
batch_size : int, optional
|
|
795
888
|
Number of soundings sent through anemone per call (default 1000).
|
|
796
889
|
Bounds peak (GPU) memory; ``0``/``None`` forwards everything at once.
|
|
890
|
+
|
|
797
891
|
file_sr2, sr_filters, n_previous_pulses
|
|
798
892
|
System-response / pulse options, see :func:`gex_to_anemone_system`.
|
|
799
893
|
A GEX with ``SystemResponseConvolution=1`` picks up ``<gex stem>.sr2``
|
|
@@ -804,6 +898,37 @@ def forward_anemone(M=np.array(()), thickness=np.array(()), file_gex=None,
|
|
|
804
898
|
tolerance : float or None
|
|
805
899
|
Kernel pruning tolerance (default ``1e-6``); larger is faster and less
|
|
806
900
|
accurate, see :func:`gex_to_anemone_system`.
|
|
901
|
+
|
|
902
|
+
Notes
|
|
903
|
+
-----
|
|
904
|
+
**Setup cache and GPU memory.** Each anemone setup (one per GEX, Tx
|
|
905
|
+
height, device and tolerance) is kept in a module cache and reused by
|
|
906
|
+
later calls. On CUDA a setup takes some tens of MB of GPU memory (about
|
|
907
|
+
50 MB for a dual-moment SkyTEM system), so with a varying flight height
|
|
908
|
+
(one setup per height bin, e.g. ~135 bins for 12-148 m) the cache alone
|
|
909
|
+
can exceed the GPU memory. The cache is therefore kept in
|
|
910
|
+
least-recently-used order, and before a new CUDA setup is built the least
|
|
911
|
+
recently used setups on that device are dropped until at least
|
|
912
|
+
``_CUDA_MIN_FREE_GB`` (1 GB) or ``_CUDA_MIN_FREE_FRAC`` (15 %) of the GPU
|
|
913
|
+
memory, whichever is larger, is free. If building a setup still runs out
|
|
914
|
+
of GPU memory, all cached setups on the device are dropped and the build
|
|
915
|
+
is retried once. Consequences:
|
|
916
|
+
|
|
917
|
+
* A fixed flight height uses one setup and is not affected.
|
|
918
|
+
* With more height bins than fit in the cache, a repeated call rebuilds
|
|
919
|
+
(almost) every setup, ~1 s each, because the bins are visited in the
|
|
920
|
+
same order every call (worst case for LRU).
|
|
921
|
+
* Free memory is measured on the whole GPU, so memory used by other
|
|
922
|
+
processes leads to more evictions (slower, not an error).
|
|
923
|
+
* Memory is only checked before building a setup, not while forwarding
|
|
924
|
+
the batches; lower ``batch_size`` if the forward itself runs out of
|
|
925
|
+
GPU memory.
|
|
926
|
+
* The CPU cache is not bounded.
|
|
927
|
+
|
|
928
|
+
The limits are module attributes, e.g.
|
|
929
|
+
``integrate.anemone_forward._CUDA_MIN_FREE_GB = 0.5``;
|
|
930
|
+
``integrate.anemone_forward._clear_forward_cache()`` empties the cache.
|
|
931
|
+
``rescale_height=True`` uses a single setup and avoids the cache churn.
|
|
807
932
|
"""
|
|
808
933
|
anemone, torch = _require_anemone()
|
|
809
934
|
import time
|
|
@@ -871,12 +996,20 @@ def forward_anemone(M=np.array(()), thickness=np.array(()), file_gex=None,
|
|
|
871
996
|
M_c = M
|
|
872
997
|
T_c = np.tile(np.asarray(thickness, dtype=float), (nd, 1))
|
|
873
998
|
|
|
999
|
+
# progress bar, same convention as ga-aem/simpeg (disabled when showInfo < 0);
|
|
1000
|
+
# advanced once per anemone batch, so the forward itself is unchanged
|
|
1001
|
+
from tqdm import tqdm
|
|
1002
|
+
pbar = tqdm(total=nd, mininterval=1, disable=(showInfo < 0), desc='anemone', leave=False)
|
|
874
1003
|
t0 = time.time()
|
|
875
|
-
if varying:
|
|
1004
|
+
if varying and rescale_height:
|
|
1005
|
+
D = _forward_rescaled_height(system, M_c, T_c, tx_height, scale, device,
|
|
1006
|
+
tolerance, progress_callback, showInfo,
|
|
1007
|
+
batch_size, progress=pbar.update)
|
|
1008
|
+
elif varying:
|
|
876
1009
|
D = _forward_varying_height(system, M_c, T_c, tx_height,
|
|
877
1010
|
altitude_bin_width, scale, device,
|
|
878
1011
|
progress_callback, showInfo,
|
|
879
|
-
batch_size) # Task 6
|
|
1012
|
+
batch_size, progress=pbar.update) # Task 6
|
|
880
1013
|
else:
|
|
881
1014
|
tx_z = None
|
|
882
1015
|
if tx_height.size >= 1:
|
|
@@ -887,12 +1020,14 @@ def forward_anemone(M=np.array(()), thickness=np.array(()), file_gex=None,
|
|
|
887
1020
|
dev = torch.device(device)
|
|
888
1021
|
M_t = torch.as_tensor(M_c, dtype=torch.float64).to(dev)
|
|
889
1022
|
T_t = torch.as_tensor(T_c, dtype=torch.float64).to(dev)
|
|
890
|
-
raw = np.asarray(_run_batched(fwr, M_t, T_t, batch_size, torch
|
|
1023
|
+
raw = np.asarray(_run_batched(fwr, M_t, T_t, batch_size, torch,
|
|
1024
|
+
progress=pbar.update),
|
|
891
1025
|
dtype=float)
|
|
892
1026
|
cols = []
|
|
893
1027
|
for s, sc in zip(slices, scale):
|
|
894
1028
|
cols.append(sc * raw[:, s])
|
|
895
1029
|
D = np.concatenate(cols, axis=1)
|
|
1030
|
+
pbar.close()
|
|
896
1031
|
|
|
897
1032
|
if showtime:
|
|
898
1033
|
print("forward_anemone: %.1f ms/model (%d models)"
|
|
@@ -909,7 +1044,7 @@ forward_anemone.last_sr2 = None
|
|
|
909
1044
|
|
|
910
1045
|
def _forward_varying_height(system, M_c, T_c, tx_height, bin_width, scale,
|
|
911
1046
|
device, progress_callback, showInfo,
|
|
912
|
-
batch_size=1000):
|
|
1047
|
+
batch_size=1000, progress=None):
|
|
913
1048
|
"""M_c (nd, K) resistivity, T_c (nd, K-1) per-sounding thicknesses
|
|
914
1049
|
(already layer-compressed by the caller)."""
|
|
915
1050
|
anemone, torch = _require_anemone()
|
|
@@ -935,7 +1070,7 @@ def _forward_varying_height(system, M_c, T_c, tx_height, bin_width, scale,
|
|
|
935
1070
|
for b in np.unique(bin_id):
|
|
936
1071
|
rows = np.where(bin_id == b)[0]
|
|
937
1072
|
fwr, slices = _build_forward(system, z_of(b), device)
|
|
938
|
-
raw = _run_batched(fwr, M_t[rows], T_t[rows], batch_size, torch)
|
|
1073
|
+
raw = _run_batched(fwr, M_t[rows], T_t[rows], batch_size, torch, progress=progress)
|
|
939
1074
|
cols = [(sc * raw[:, s]) for s, sc in zip(slices, scale)]
|
|
940
1075
|
block = np.concatenate(cols, axis=1)
|
|
941
1076
|
if D is None:
|
|
@@ -949,6 +1084,107 @@ def _forward_varying_height(system, M_c, T_c, tx_height, bin_width, scale,
|
|
|
949
1084
|
return D
|
|
950
1085
|
|
|
951
1086
|
|
|
1087
|
+
_RESCALE_MAX_SPREAD = 30.0 # m; above this rescale_height warns about accuracy
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
def _rescaled_batch(fwr, M_b, T_b, dh_b, torch):
|
|
1091
|
+
"""Response of one batch with a per-model height offset ``dh_b`` [m].
|
|
1092
|
+
|
|
1093
|
+
Same evaluation as ``Forward.__call__`` (reflection coefficient, then the
|
|
1094
|
+
``H2t`` matrix), except that each model's reflection coefficient is first
|
|
1095
|
+
multiplied by ``exp(-2*dh*lmb)``: Tx and Rx both move by ``dh``, so
|
|
1096
|
+
``sfield_dz`` grows by ``2*dh``. The primary field depends only on the
|
|
1097
|
+
Tx-Rx offset, which does not change, so ``fwr.primary`` is added as is.
|
|
1098
|
+
Returns an (n_models, n_gates) tensor.
|
|
1099
|
+
|
|
1100
|
+
Follows anemone-core >= 0.1.1: ``H2t`` already includes ``mu0``, and
|
|
1101
|
+
``Forward.__call__`` adds ``primary``.
|
|
1102
|
+
"""
|
|
1103
|
+
from anemone.physics import rte_raiche1999 as rte
|
|
1104
|
+
from anemone import cdtype, rdtype
|
|
1105
|
+
|
|
1106
|
+
rho = ((M_b.T + 0j)[..., None, None]).to(cdtype())
|
|
1107
|
+
thick = ((T_b.T + 0j)[..., None, None]).to(cdtype())
|
|
1108
|
+
cRTE = rte(1. / rho, thick, fwr.omega, fwr.lamda).reshape(M_b.shape[0], -1)
|
|
1109
|
+
cRTE = cRTE * torch.exp(-2. * dh_b[:, None] * fwr.lamda.real.reshape(1, -1))
|
|
1110
|
+
if fwr.H2t.dtype == rdtype(): # no filter: anemone keeps a real H2t
|
|
1111
|
+
cRTE = cRTE.real.to(rdtype())
|
|
1112
|
+
D = torch.einsum('ik,nk->ni', fwr.H2t, cRTE).real.to(rdtype())
|
|
1113
|
+
if torch.is_tensor(fwr.primary):
|
|
1114
|
+
D = D + fwr.primary
|
|
1115
|
+
return D
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
def _forward_rescaled_height(system, M_c, T_c, tx_height, scale, device,
|
|
1119
|
+
tolerance, progress_callback, showInfo,
|
|
1120
|
+
batch_size=1000, progress=None):
|
|
1121
|
+
"""Varying height from ONE anemone setup, rescaled to each model's height.
|
|
1122
|
+
|
|
1123
|
+
The setup (about 1 s) is made at the lowest height, so every height offset
|
|
1124
|
+
``dh`` is >= 0 and only attenuates the kernel. The kept kernel terms are
|
|
1125
|
+
chosen at the reference height, hence the reference uses ``tolerance / 10``.
|
|
1126
|
+
M_c (nd, K) resistivity, T_c (nd, K-1) thicknesses (already compressed).
|
|
1127
|
+
"""
|
|
1128
|
+
import warnings
|
|
1129
|
+
anemone, torch = _require_anemone()
|
|
1130
|
+
from integrate.integrate import _report_progress
|
|
1131
|
+
|
|
1132
|
+
tx_height = np.asarray(tx_height, dtype=float).ravel()
|
|
1133
|
+
nd = M_c.shape[0]
|
|
1134
|
+
z_ref = float(tx_height.min())
|
|
1135
|
+
spread = float(tx_height.max()) - z_ref
|
|
1136
|
+
if spread > _RESCALE_MAX_SPREAD:
|
|
1137
|
+
warnings.warn(
|
|
1138
|
+
"rescale_height: flight height spread is %.1f m (> %.0f m); the "
|
|
1139
|
+
"rescaling error grows with the spread (a few percent of the peak "
|
|
1140
|
+
"signal at 45 m). Consider rescale_height=False."
|
|
1141
|
+
% (spread, _RESCALE_MAX_SPREAD), UserWarning, stacklevel=3)
|
|
1142
|
+
|
|
1143
|
+
ref_system = system
|
|
1144
|
+
if tolerance is not None:
|
|
1145
|
+
ref_system = dict(system)
|
|
1146
|
+
ref_system["tolerance"] = tolerance / 10.
|
|
1147
|
+
fwr, slices = _build_forward(ref_system, z_ref, device)
|
|
1148
|
+
|
|
1149
|
+
dev = torch.device(device)
|
|
1150
|
+
M_t = torch.as_tensor(M_c, dtype=torch.float64).to(dev)
|
|
1151
|
+
T_t = torch.as_tensor(T_c, dtype=torch.float64).to(dev)
|
|
1152
|
+
dh_t = torch.as_tensor(tx_height - z_ref, dtype=torch.float64).to(dev)
|
|
1153
|
+
if batch_size is None or batch_size <= 0 or batch_size >= nd:
|
|
1154
|
+
batch_size = nd
|
|
1155
|
+
|
|
1156
|
+
with torch.no_grad():
|
|
1157
|
+
# guard against anemone internals changing: at dh=0 this path must
|
|
1158
|
+
# reproduce the Forward itself
|
|
1159
|
+
mine = _rescaled_batch(fwr, M_t[:1], T_t[:1], dh_t[:1] * 0., torch)
|
|
1160
|
+
mine = mine.detach().cpu().numpy()
|
|
1161
|
+
ref = np.atleast_2d(fwr(M_t[:1].T, T_t[:1].T).detach().cpu().numpy())
|
|
1162
|
+
err = np.max(np.abs(mine - ref)) / np.max(np.abs(ref))
|
|
1163
|
+
if not err < 1e-8:
|
|
1164
|
+
raise RuntimeError(
|
|
1165
|
+
"rescale_height: rescaled evaluation differs from anemone's "
|
|
1166
|
+
"Forward at dh=0 (relative error %.2e); the anemone internals "
|
|
1167
|
+
"have probably changed. Use rescale_height=False." % err)
|
|
1168
|
+
|
|
1169
|
+
blocks = []
|
|
1170
|
+
done = 0
|
|
1171
|
+
for i0 in range(0, nd, batch_size):
|
|
1172
|
+
i1 = min(i0 + batch_size, nd)
|
|
1173
|
+
raw = _rescaled_batch(fwr, M_t[i0:i1], T_t[i0:i1], dh_t[i0:i1], torch)
|
|
1174
|
+
blocks.append(raw.detach().cpu().numpy())
|
|
1175
|
+
done += i1 - i0
|
|
1176
|
+
if progress is not None:
|
|
1177
|
+
progress(i1 - i0)
|
|
1178
|
+
if progress_callback is not None:
|
|
1179
|
+
_report_progress(progress_callback, done, nd, "computing",
|
|
1180
|
+
"Forward modeling (%d/%d soundings)" % (done, nd))
|
|
1181
|
+
raw = np.concatenate(blocks, axis=0) if len(blocks) > 1 else blocks[0]
|
|
1182
|
+
cols = []
|
|
1183
|
+
for s, sc in zip(slices, scale):
|
|
1184
|
+
cols.append(sc * raw[:, s])
|
|
1185
|
+
return np.concatenate(cols, axis=1)
|
|
1186
|
+
|
|
1187
|
+
|
|
952
1188
|
def prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True,
|
|
953
1189
|
im=1, id=1, im_height=0, is_log=False,
|
|
954
1190
|
altitude_bin_width=1.0, device="cpu",
|
|
@@ -958,16 +1194,22 @@ def prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True,
|
|
|
958
1194
|
batch_size=1000, randomize=True, file_sr2=None,
|
|
959
1195
|
sr_filters=False, n_previous_pulses=0,
|
|
960
1196
|
rx_coil_filter="two_pole", gate_integration="centre",
|
|
961
|
-
tolerance=1e-6, **kwargs):
|
|
1197
|
+
tolerance=1e-6, rescale_height=False, **kwargs):
|
|
962
1198
|
"""Generate prior data ``/D{id}`` for the anemone TDEM forward backend.
|
|
963
1199
|
|
|
964
|
-
Mirrors :func:`integrate.prior_data_gaaem` but loads ``M{im}`` **as
|
|
1200
|
+
Mirrors :func:`integrate.gaaem_forward.prior_data_gaaem` but loads ``M{im}`` **as
|
|
965
1201
|
resistivity** (no ``1/``) and forwards it through :func:`forward_anemone`.
|
|
966
1202
|
``batch_size`` soundings are forwarded per anemone call (bounds peak GPU
|
|
967
1203
|
memory; ``0`` forwards all ``N`` at once). ``randomize`` controls whether a
|
|
968
1204
|
copy with ``N < N_in`` draws ``N`` random realizations (default) or the
|
|
969
1205
|
first ``N`` sequentially. ``rx_coil_filter``, ``gate_integration`` and
|
|
970
1206
|
``tolerance`` are passed to :func:`forward_anemone`.
|
|
1207
|
+
``rescale_height=True`` (varying ``M{im_height}`` only) does one anemone
|
|
1208
|
+
setup and rescales it to each model's height instead of one setup per
|
|
1209
|
+
``altitude_bin_width`` bin; much faster for varying flight height, see
|
|
1210
|
+
:func:`forward_anemone`. Setups are cached between calls; on CUDA the
|
|
1211
|
+
cache is bounded by free GPU memory (least recently used setups are
|
|
1212
|
+
dropped), see the Notes of :func:`forward_anemone`.
|
|
971
1213
|
Returns the path to the prior-data h5 (always the return value).
|
|
972
1214
|
"""
|
|
973
1215
|
import multiprocessing
|
|
@@ -975,6 +1217,7 @@ def prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True,
|
|
|
975
1217
|
import h5py
|
|
976
1218
|
import integrate as ig
|
|
977
1219
|
from integrate.integrate import _report_progress
|
|
1220
|
+
t0_compute = time.time() # stored as /D{id} attr compute_time
|
|
978
1221
|
|
|
979
1222
|
if multiprocessing.current_process().name != "MainProcess":
|
|
980
1223
|
return None
|
|
@@ -1027,7 +1270,7 @@ def prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True,
|
|
|
1027
1270
|
n_previous_pulses=n_previous_pulses,
|
|
1028
1271
|
rx_coil_filter=rx_coil_filter,
|
|
1029
1272
|
gate_integration=gate_integration,
|
|
1030
|
-
tolerance=tolerance)
|
|
1273
|
+
tolerance=tolerance, rescale_height=rescale_height)
|
|
1031
1274
|
if showInfo > -1:
|
|
1032
1275
|
dt = time.time() - t1
|
|
1033
1276
|
n_sound = M.shape[0]
|
|
@@ -1056,6 +1299,7 @@ def prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True,
|
|
|
1056
1299
|
a["id"] = id
|
|
1057
1300
|
a["is_log"] = bool(is_log)
|
|
1058
1301
|
a["altitude_bin_width"] = float(altitude_bin_width)
|
|
1302
|
+
a["rescale_height"] = bool(rescale_height)
|
|
1059
1303
|
a["device"] = str(device)
|
|
1060
1304
|
a["batch_size"] = int(batch_size or 0)
|
|
1061
1305
|
a["calibration"] = str(cal.get("mode") or "gex")
|
|
@@ -1073,6 +1317,7 @@ def prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True,
|
|
|
1073
1317
|
for name, rval in (cal.get("residual") or {}).items():
|
|
1074
1318
|
a["calibration_residual_%s" % name] = float(rval)
|
|
1075
1319
|
|
|
1320
|
+
ig.save_compute_time(f_prior_data_h5, Dname, time.time() - t0_compute, "prior_data_anemone", t0_compute)
|
|
1076
1321
|
ig.integrate_update_prior_attributes(f_prior_data_h5)
|
|
1077
1322
|
_report_progress(progress_callback, N, N, "completed",
|
|
1078
1323
|
"Forward data saved to %s" % f_prior_data_h5)
|
|
@@ -85,7 +85,7 @@ def forward_gaaem(C=np.array(()),
|
|
|
85
85
|
"""
|
|
86
86
|
from gatdaem1d import Earth;
|
|
87
87
|
from gatdaem1d import Geometry;
|
|
88
|
-
# Next should probably only be loaded if the DLL is not
|
|
88
|
+
# Next should probably only be loaded if the DLL is not already loaded!!!
|
|
89
89
|
from gatdaem1d import TDAEMSystem; # loads the DLL!!
|
|
90
90
|
import integrate as ig
|
|
91
91
|
from integrate.integrate import _report_progress
|
|
@@ -106,6 +106,7 @@ def forward_gaaem(C=np.array(()),
|
|
|
106
106
|
stmfiles = []
|
|
107
107
|
if file_gex is None:
|
|
108
108
|
file_gex = ''
|
|
109
|
+
tx_height = np.asarray(tx_height, dtype=float).ravel()
|
|
109
110
|
|
|
110
111
|
#print(stmfiles)
|
|
111
112
|
#print(file_gex)
|
|
@@ -455,6 +456,7 @@ def prior_data_gaaem(f_prior_h5, file_gex=None, stmfiles=None, N=0, doMakePriorC
|
|
|
455
456
|
import integrate as ig
|
|
456
457
|
from integrate.integrate import _report_progress
|
|
457
458
|
import os
|
|
459
|
+
t0_compute = time.time() # stored as /D{id} attr compute_time
|
|
458
460
|
# Safety guard: if somehow called from a worker process, do nothing.
|
|
459
461
|
if multiprocessing.current_process().name != 'MainProcess':
|
|
460
462
|
return None
|
|
@@ -542,7 +544,7 @@ def prior_data_gaaem(f_prior_h5, file_gex=None, stmfiles=None, N=0, doMakePriorC
|
|
|
542
544
|
if im_height>0:
|
|
543
545
|
if (showInfo>1):
|
|
544
546
|
print('Using M%d for height' % im_height)
|
|
545
|
-
tx_height = f_prior_r[Mheight][:]
|
|
547
|
+
tx_height = np.asarray(f_prior_r[Mheight][:], dtype=float).ravel()
|
|
546
548
|
|
|
547
549
|
# Get thickness
|
|
548
550
|
if 'x' in f_prior_r[Mname].attrs:
|
|
@@ -705,6 +707,7 @@ def prior_data_gaaem(f_prior_h5, file_gex=None, stmfiles=None, N=0, doMakePriorC
|
|
|
705
707
|
f_prior[Dname].attrs['Nhank'] = Nhank
|
|
706
708
|
f_prior[Dname].attrs['Nfreq'] = Nfreq
|
|
707
709
|
|
|
710
|
+
ig.save_compute_time(f_prior_data_h5, Dname, time.time() - t0_compute, "prior_data_gaaem", t0_compute)
|
|
708
711
|
ig.integrate_update_prior_attributes(f_prior_data_h5)
|
|
709
712
|
|
|
710
713
|
_report_progress(progress_callback, N, N,
|