apsg 2.0.5__tar.gz → 2.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 (127) hide show
  1. {apsg-2.0.5/src/apsg.egg-info → apsg-2.1.0}/PKG-INFO +22 -12
  2. {apsg-2.0.5 → apsg-2.1.0}/README.md +16 -4
  3. {apsg-2.0.5 → apsg-2.1.0}/pyproject.toml +8 -7
  4. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/__init__.py +67 -1
  5. apsg-2.1.0/src/apsg/ams/__init__.py +96 -0
  6. apsg-2.1.0/src/apsg/ams/_model.py +217 -0
  7. apsg-2.1.0/src/apsg/ams/_plots.py +427 -0
  8. apsg-2.1.0/src/apsg/ams/_readers.py +703 -0
  9. apsg-2.1.0/src/apsg/ams/_specimen.py +410 -0
  10. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/config.py +213 -40
  11. apsg-2.1.0/src/apsg/data/__init__.py +138 -0
  12. apsg-2.1.0/src/apsg/data/_catalog.py +222 -0
  13. apsg-2.1.0/src/apsg/data/_loaders.py +323 -0
  14. apsg-2.1.0/src/apsg/data/files/ams_table.txt +4 -0
  15. apsg-2.1.0/src/apsg/data/files/ams_table_no_tensor.txt +7 -0
  16. apsg-2.1.0/src/apsg/data/files/faults.csv +95 -0
  17. apsg-2.1.0/src/apsg/data/files/melechov.zip +0 -0
  18. apsg-2.1.0/src/apsg/data/files/pmdata.zip +0 -0
  19. apsg-2.1.0/src/apsg/data/files/published.json +1163 -0
  20. apsg-2.1.0/src/apsg/data/files/rs3_components.zip +0 -0
  21. apsg-2.1.0/src/apsg/data/files/structures.csv +254 -0
  22. apsg-2.1.0/src/apsg/data/files/structures_wide.csv +133 -0
  23. apsg-2.1.0/src/apsg/data/files/synthetic.json +3727 -0
  24. apsg-2.1.0/src/apsg/data/files/trebic.zip +0 -0
  25. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/database/_sdbsession.py +189 -244
  26. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/database/_websdbsession.py +122 -195
  27. apsg-2.1.0/src/apsg/feature/__init__.py +219 -0
  28. apsg-2.1.0/src/apsg/feature/_container/__init__.py +49 -0
  29. apsg-2.1.0/src/apsg/feature/_container/_base.py +487 -0
  30. apsg-2.1.0/src/apsg/feature/_container/_cluster.py +421 -0
  31. apsg-2.1.0/src/apsg/feature/_container/_othersets.py +100 -0
  32. apsg-2.1.0/src/apsg/feature/_container/_pairsets.py +594 -0
  33. apsg-2.1.0/src/apsg/feature/_container/_tensorsets.py +615 -0
  34. apsg-2.1.0/src/apsg/feature/_container/_vectorsets.py +2083 -0
  35. apsg-2.1.0/src/apsg/feature/_distributions/__init__.py +97 -0
  36. apsg-2.1.0/src/apsg/feature/_distributions/_axial.py +571 -0
  37. apsg-2.1.0/src/apsg/feature/_distributions/_base.py +485 -0
  38. apsg-2.1.0/src/apsg/feature/_distributions/_circular.py +833 -0
  39. apsg-2.1.0/src/apsg/feature/_distributions/_frames.py +258 -0
  40. apsg-2.1.0/src/apsg/feature/_distributions/_mixtures.py +395 -0
  41. apsg-2.1.0/src/apsg/feature/_distributions/_rotations.py +209 -0
  42. apsg-2.1.0/src/apsg/feature/_distributions/_special.py +393 -0
  43. apsg-2.1.0/src/apsg/feature/_distributions/_spherical.py +588 -0
  44. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/feature/_geodata.py +201 -197
  45. apsg-2.1.0/src/apsg/feature/_grainmodels.py +414 -0
  46. apsg-2.1.0/src/apsg/feature/_hypothesis.py +909 -0
  47. apsg-2.1.0/src/apsg/feature/_sampling.py +95 -0
  48. apsg-2.1.0/src/apsg/feature/_statistics.py +551 -0
  49. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/feature/_tensor2.py +21 -16
  50. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/feature/_tensor3.py +159 -56
  51. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/helpers/__init__.py +0 -2
  52. apsg-2.1.0/src/apsg/helpers/_helper.py +65 -0
  53. apsg-2.1.0/src/apsg/helpers/_math.py +76 -0
  54. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/helpers/_notation.py +11 -5
  55. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/math/_matrix.py +25 -12
  56. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/math/_vector.py +73 -47
  57. apsg-2.1.0/src/apsg/paleomag/__init__.py +72 -0
  58. apsg-2.1.0/src/apsg/paleomag/_components.py +497 -0
  59. apsg-2.1.0/src/apsg/paleomag/_inclination.py +224 -0
  60. apsg-2.1.0/src/apsg/paleomag/_plots.py +963 -0
  61. apsg-2.1.0/src/apsg/paleomag/_procedures.py +237 -0
  62. apsg-2.1.0/src/apsg/paleomag/_readers.py +595 -0
  63. apsg-2.1.0/src/apsg/paleomag/_specimen.py +2377 -0
  64. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/pandas/_gbfunctions.py +3 -5
  65. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/__init__.py +4 -0
  66. apsg-2.1.0/src/apsg/plotting/_confidence.py +164 -0
  67. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_fabricplot.py +91 -131
  68. apsg-2.1.0/src/apsg/plotting/_figureplot.py +141 -0
  69. apsg-2.1.0/src/apsg/plotting/_layout.py +335 -0
  70. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_plot_artists.py +176 -68
  71. apsg-2.1.0/src/apsg/plotting/_qqplot.py +125 -0
  72. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_roseplot.py +164 -114
  73. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereo_engine/_axes.py +91 -50
  74. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereo_engine/_stereogrid.py +29 -4
  75. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereo_engine/_utils.py +28 -1
  76. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereogrid.py +33 -2
  77. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereonet.py +228 -184
  78. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_styles.py +4 -4
  79. {apsg-2.0.5 → apsg-2.1.0/src/apsg.egg-info}/PKG-INFO +22 -12
  80. apsg-2.1.0/src/apsg.egg-info/SOURCES.txt +117 -0
  81. {apsg-2.0.5 → apsg-2.1.0}/src/apsg.egg-info/requires.txt +5 -7
  82. apsg-2.1.0/tests/test_ams.py +1691 -0
  83. {apsg-2.0.5 → apsg-2.1.0}/tests/test_apsg.py +6 -2
  84. apsg-2.1.0/tests/test_bingham_numerics.py +172 -0
  85. apsg-2.1.0/tests/test_constructors.py +146 -0
  86. {apsg-2.0.5 → apsg-2.1.0}/tests/test_containers.py +243 -56
  87. apsg-2.1.0/tests/test_data.py +273 -0
  88. apsg-2.1.0/tests/test_distributions.py +1590 -0
  89. apsg-2.1.0/tests/test_hypothesis.py +548 -0
  90. apsg-2.1.0/tests/test_lisle_numerics.py +156 -0
  91. apsg-2.1.0/tests/test_mixtures.py +322 -0
  92. apsg-2.1.0/tests/test_paleomag.py +1851 -0
  93. apsg-2.1.0/tests/test_paleomag_components.py +424 -0
  94. apsg-2.1.0/tests/test_paleomag_procedures.py +245 -0
  95. apsg-2.1.0/tests/test_paleomag_readers.py +613 -0
  96. {apsg-2.0.5 → apsg-2.1.0}/tests/test_pandas.py +24 -11
  97. {apsg-2.0.5 → apsg-2.1.0}/tests/test_plotting.py +630 -55
  98. apsg-2.1.0/tests/test_qqplot.py +91 -0
  99. apsg-2.1.0/tests/test_robustness.py +650 -0
  100. apsg-2.1.0/tests/test_rotations.py +131 -0
  101. apsg-2.1.0/tests/test_sdb.py +136 -0
  102. {apsg-2.0.5 → apsg-2.1.0}/tests/test_tensors.py +45 -8
  103. {apsg-2.0.5 → apsg-2.1.0}/tests/test_websdb.py +60 -1
  104. apsg-2.1.0/tests/test_weights.py +208 -0
  105. apsg-2.0.5/src/apsg/feature/__init__.py +0 -117
  106. apsg-2.0.5/src/apsg/feature/_container.py +0 -2976
  107. apsg-2.0.5/src/apsg/feature/_paleomag.py +0 -419
  108. apsg-2.0.5/src/apsg/feature/_statistics.py +0 -546
  109. apsg-2.0.5/src/apsg/helpers/_helper.py +0 -18
  110. apsg-2.0.5/src/apsg/helpers/_math.py +0 -46
  111. apsg-2.0.5/src/apsg/plotting/_paleomagplots.py +0 -74
  112. apsg-2.0.5/src/apsg.egg-info/SOURCES.txt +0 -54
  113. {apsg-2.0.5 → apsg-2.1.0}/LICENSE +0 -0
  114. {apsg-2.0.5 → apsg-2.1.0}/setup.cfg +0 -0
  115. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/database/__init__.py +0 -0
  116. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/database/_sdbmodels.py +0 -0
  117. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/database/_webtransport.py +0 -0
  118. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/math/__init__.py +0 -0
  119. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/pandas/__init__.py +0 -0
  120. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/pandas/_accessors.py +0 -0
  121. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/pandas/_pandas_api.py +0 -0
  122. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereo_engine/__init__.py +0 -0
  123. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/plotting/_stereo_engine/_transforms.py +0 -0
  124. {apsg-2.0.5 → apsg-2.1.0}/src/apsg/shell.py +0 -0
  125. {apsg-2.0.5 → apsg-2.1.0}/src/apsg.egg-info/dependency_links.txt +0 -0
  126. {apsg-2.0.5 → apsg-2.1.0}/src/apsg.egg-info/entry_points.txt +0 -0
  127. {apsg-2.0.5 → apsg-2.1.0}/src/apsg.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apsg
3
- Version: 2.0.5
3
+ Version: 2.1.0
4
4
  Summary: APSG - The package for structural geologists
5
5
  Author-email: Ondrej Lexa <lexa.ondrej@gmail.com>
6
6
  Maintainer-email: Ondrej Lexa <lexa.ondrej@gmail.com>
@@ -32,14 +32,12 @@ Requires-Dist: pytest; extra == "tests"
32
32
  Requires-Dist: pytest-cov; extra == "tests"
33
33
  Requires-Dist: pytest-xdist; extra == "tests"
34
34
  Provides-Extra: docs
35
- Requires-Dist: sphinx>=7.0; extra == "docs"
36
- Requires-Dist: shibuya; extra == "docs"
37
- Requires-Dist: sphinx-copybutton; extra == "docs"
38
- Requires-Dist: sphinx-design; extra == "docs"
39
- Requires-Dist: nbsphinx; extra == "docs"
40
- Requires-Dist: pandoc; extra == "docs"
35
+ Requires-Dist: mkdocs>=1.6; extra == "docs"
36
+ Requires-Dist: mkdocs-material>=9.6; extra == "docs"
37
+ Requires-Dist: mkdocstrings[python]>=0.29; extra == "docs"
38
+ Requires-Dist: mkdocs-jupyter>=0.25; extra == "docs"
39
+ Requires-Dist: pymdown-extensions; extra == "docs"
41
40
  Requires-Dist: ipykernel; extra == "docs"
42
- Requires-Dist: autodocsumm; extra == "docs"
43
41
  Provides-Extra: dev
44
42
  Requires-Dist: apsg[docs,lab,tests]; extra == "dev"
45
43
  Requires-Dist: ruff; extra == "dev"
@@ -47,6 +45,7 @@ Dynamic: license-file
47
45
 
48
46
  <picture>
49
47
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_dark.svg">
48
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_light.svg">
50
49
  <img alt="APSG logo" src="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_light.svg">
51
50
  </picture>
52
51
 
@@ -56,7 +55,12 @@ Dynamic: license-file
56
55
  [![codecov](https://codecov.io/gh/ondrolexa/apsg/graph/badge.svg?token=YKXWmJJHw3)](https://codecov.io/gh/ondrolexa/apsg)
57
56
  [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.593586-blue)](https://doi.org/10.5281/zenodo.593586)
58
57
 
59
- APSG is the package for structural geologists. It defines several new Python classes to easily manage, analyze and visualize orientation structural geology data.
58
+ APSG is the Python toolbox for structural geologists. Turn lineations, foliations, faults and
59
+ stress tensors into beautiful stereonets, rose diagrams and fabric plots in a few lines of code.
60
+ Back every interpretation with solid statistics: fit and simulate orientation distributions,
61
+ split data into fracture sets, correct sampling bias, draw confidence regions and test your
62
+ hypotheses. From a field CSV, a pandas table or your
63
+ structural database to publication-ready figures and answers, in minutes.
60
64
 
61
65
  Check [CHANGELOG.md](https://github.com/ondrolexa/apsg/blob/master/CHANGELOG.md) for recent updates.
62
66
 
@@ -65,7 +69,7 @@ Check [CHANGELOG.md](https://github.com/ondrolexa/apsg/blob/master/CHANGELOG.md)
65
69
  ```python
66
70
  from apsg import *
67
71
 
68
- f = folset.random_fisher(position=fol(130, 60))
72
+ f = folset.random_fisher(mean=fol(130, 60))
69
73
  s = StereoNet()
70
74
  s.great_circle(f)
71
75
  s.point(f)
@@ -75,17 +79,20 @@ s.show()
75
79
 
76
80
  `StereoNet` supports both equal-area (Schmidt, default) and equal-angle (Wulff) projections,
77
81
  lower and upper hemisphere, and rotating the whole net independently of the plotted data.
78
- See the stereonet tutorial in the [documentation](https://apsg.readthedocs.org) for examples.
82
+ See the [stereonet tutorial](https://apsg.readthedocs.io/en/stable/notebooks/03_apsg_stereonet/) for examples.
79
83
 
80
84
  ## Requirements
81
85
 
86
+ <!-- --8<-- [start:requirements] -->
82
87
  APSG requires Python 3.12 or later. It depends on [NumPy](https://numpy.org/),
83
88
  [SciPy](https://scipy.org/), [Matplotlib](https://matplotlib.org/),
84
89
  [SQLAlchemy](https://www.sqlalchemy.org/), [pandas](https://pandas.pydata.org/),
85
90
  [pygeomag](https://github.com/boxpet/pygeomag). The installers below take care of these.
91
+ <!-- --8<-- [end:requirements] -->
86
92
 
87
93
  ## Installation
88
94
 
95
+ <!-- --8<-- [start:install] -->
89
96
  Install APSG into a separate environment. Pick one of the options below. uv is the default
90
97
  and the fastest; pip and conda/mamba are alternatives.
91
98
 
@@ -223,10 +230,13 @@ To install APSG into an existing environment, run `conda install apsg` (or
223
230
  | Name | Downloads | Version | Platforms |
224
231
  | --- | --- | --- | --- |
225
232
  | [![Conda Recipe](https://img.shields.io/badge/recipe-apsg-green.svg)](https://anaconda.org/conda-forge/apsg) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/apsg.svg)](https://anaconda.org/conda-forge/apsg) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/apsg.svg)](https://anaconda.org/conda-forge/apsg) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/apsg.svg)](https://anaconda.org/conda-forge/apsg) |
233
+ <!-- --8<-- [end:install] -->
226
234
 
227
235
  ## Documentation
228
236
 
229
- Explore all features of APSG in the [documentation](https://apsg.readthedocs.org).
237
+ Explore all features of APSG in the [documentation](https://apsg.readthedocs.io), with
238
+ [tutorials](https://apsg.readthedocs.io/en/stable/tutorials/) and the
239
+ [API reference](https://apsg.readthedocs.io/en/stable/api/).
230
240
 
231
241
  ## Contributing
232
242
 
@@ -1,5 +1,6 @@
1
1
  <picture>
2
2
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_dark.svg">
3
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_light.svg">
3
4
  <img alt="APSG logo" src="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_light.svg">
4
5
  </picture>
5
6
 
@@ -9,7 +10,12 @@
9
10
  [![codecov](https://codecov.io/gh/ondrolexa/apsg/graph/badge.svg?token=YKXWmJJHw3)](https://codecov.io/gh/ondrolexa/apsg)
10
11
  [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.593586-blue)](https://doi.org/10.5281/zenodo.593586)
11
12
 
12
- APSG is the package for structural geologists. It defines several new Python classes to easily manage, analyze and visualize orientation structural geology data.
13
+ APSG is the Python toolbox for structural geologists. Turn lineations, foliations, faults and
14
+ stress tensors into beautiful stereonets, rose diagrams and fabric plots in a few lines of code.
15
+ Back every interpretation with solid statistics: fit and simulate orientation distributions,
16
+ split data into fracture sets, correct sampling bias, draw confidence regions and test your
17
+ hypotheses. From a field CSV, a pandas table or your
18
+ structural database to publication-ready figures and answers, in minutes.
13
19
 
14
20
  Check [CHANGELOG.md](https://github.com/ondrolexa/apsg/blob/master/CHANGELOG.md) for recent updates.
15
21
 
@@ -18,7 +24,7 @@ Check [CHANGELOG.md](https://github.com/ondrolexa/apsg/blob/master/CHANGELOG.md)
18
24
  ```python
19
25
  from apsg import *
20
26
 
21
- f = folset.random_fisher(position=fol(130, 60))
27
+ f = folset.random_fisher(mean=fol(130, 60))
22
28
  s = StereoNet()
23
29
  s.great_circle(f)
24
30
  s.point(f)
@@ -28,17 +34,20 @@ s.show()
28
34
 
29
35
  `StereoNet` supports both equal-area (Schmidt, default) and equal-angle (Wulff) projections,
30
36
  lower and upper hemisphere, and rotating the whole net independently of the plotted data.
31
- See the stereonet tutorial in the [documentation](https://apsg.readthedocs.org) for examples.
37
+ See the [stereonet tutorial](https://apsg.readthedocs.io/en/stable/notebooks/03_apsg_stereonet/) for examples.
32
38
 
33
39
  ## Requirements
34
40
 
41
+ <!-- --8<-- [start:requirements] -->
35
42
  APSG requires Python 3.12 or later. It depends on [NumPy](https://numpy.org/),
36
43
  [SciPy](https://scipy.org/), [Matplotlib](https://matplotlib.org/),
37
44
  [SQLAlchemy](https://www.sqlalchemy.org/), [pandas](https://pandas.pydata.org/),
38
45
  [pygeomag](https://github.com/boxpet/pygeomag). The installers below take care of these.
46
+ <!-- --8<-- [end:requirements] -->
39
47
 
40
48
  ## Installation
41
49
 
50
+ <!-- --8<-- [start:install] -->
42
51
  Install APSG into a separate environment. Pick one of the options below. uv is the default
43
52
  and the fastest; pip and conda/mamba are alternatives.
44
53
 
@@ -176,10 +185,13 @@ To install APSG into an existing environment, run `conda install apsg` (or
176
185
  | Name | Downloads | Version | Platforms |
177
186
  | --- | --- | --- | --- |
178
187
  | [![Conda Recipe](https://img.shields.io/badge/recipe-apsg-green.svg)](https://anaconda.org/conda-forge/apsg) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/apsg.svg)](https://anaconda.org/conda-forge/apsg) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/apsg.svg)](https://anaconda.org/conda-forge/apsg) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/apsg.svg)](https://anaconda.org/conda-forge/apsg) |
188
+ <!-- --8<-- [end:install] -->
179
189
 
180
190
  ## Documentation
181
191
 
182
- Explore all features of APSG in the [documentation](https://apsg.readthedocs.org).
192
+ Explore all features of APSG in the [documentation](https://apsg.readthedocs.io), with
193
+ [tutorials](https://apsg.readthedocs.io/en/stable/tutorials/) and the
194
+ [API reference](https://apsg.readthedocs.io/en/stable/api/).
183
195
 
184
196
  ## Contributing
185
197
 
@@ -21,14 +21,12 @@ dependencies = ["numpy", "matplotlib>=3.9", "scipy", "sqlalchemy", "pandas", "py
21
21
  lab = ["jupyterlab", "openpyxl"]
22
22
  tests = ["pytest", "pytest-cov", "pytest-xdist"]
23
23
  docs = [
24
- "sphinx>=7.0",
25
- "shibuya",
26
- "sphinx-copybutton",
27
- "sphinx-design",
28
- "nbsphinx",
29
- "pandoc",
24
+ "mkdocs>=1.6",
25
+ "mkdocs-material>=9.6",
26
+ "mkdocstrings[python]>=0.29",
27
+ "mkdocs-jupyter>=0.25",
28
+ "pymdown-extensions",
30
29
  "ipykernel",
31
- "autodocsumm",
32
30
  ]
33
31
  dev = ["apsg[lab,tests,docs]", "ruff"]
34
32
 
@@ -46,6 +44,9 @@ iapsg = "apsg.shell:main"
46
44
  requires = ["setuptools >= 61.0"]
47
45
  build-backend = "setuptools.build_meta"
48
46
 
47
+ [tool.setuptools.package-data]
48
+ "apsg.data" = ["files/*"]
49
+
49
50
  [tool.setuptools.dynamic]
50
51
  version = { attr = "apsg.__version__" }
51
52
 
@@ -1,10 +1,28 @@
1
1
  from apsg.config import apsg_conf, apsg_conf_context
2
+ from apsg.feature import (
3
+ ACG as dist_acg,
4
+ )
5
+ from apsg.feature import (
6
+ ESAG as dist_esag,
7
+ )
2
8
  from apsg.feature import (
3
9
  Arc as arc,
4
10
  )
5
11
  from apsg.feature import (
6
12
  ArcSet as arcset,
7
13
  )
14
+ from apsg.feature import (
15
+ AxialVonMises as dist_axial_vonmises,
16
+ )
17
+ from apsg.feature import (
18
+ Bingham as dist_bingham,
19
+ )
20
+ from apsg.feature import (
21
+ BinghamMixture as dist_bingham_mixture,
22
+ )
23
+ from apsg.feature import (
24
+ Cardioid as dist_cardioid,
25
+ )
8
26
  from apsg.feature import (
9
27
  ClusterSet as cluster,
10
28
  )
@@ -51,12 +69,24 @@ from apsg.feature import (
51
69
  FoliationSet as folset,
52
70
  )
53
71
  from apsg.feature import G
72
+ from apsg.feature import (
73
+ JonesPewsey as dist_jones_pewsey,
74
+ )
75
+ from apsg.feature import (
76
+ Kent as dist_kent,
77
+ )
54
78
  from apsg.feature import (
55
79
  Lineation as lin,
56
80
  )
57
81
  from apsg.feature import (
58
82
  LineationSet as linset,
59
83
  )
84
+ from apsg.feature import (
85
+ Lisle as dist_lisle,
86
+ )
87
+ from apsg.feature import (
88
+ MatrixFisher as dist_matrix_fisher,
89
+ )
60
90
  from apsg.feature import (
61
91
  OrientationTensor2 as ortensor2,
62
92
  )
@@ -81,6 +111,9 @@ from apsg.feature import (
81
111
  from apsg.feature import (
82
112
  Rotation3 as rotation,
83
113
  )
114
+ from apsg.feature import (
115
+ RotationSet as rotationset,
116
+ )
84
117
  from apsg.feature import (
85
118
  Stress2 as stress2,
86
119
  )
@@ -105,6 +138,21 @@ from apsg.feature import (
105
138
  from apsg.feature import (
106
139
  VelocityGradient3 as velgrad,
107
140
  )
141
+ from apsg.feature import (
142
+ VonMises as dist_vonmises,
143
+ )
144
+ from apsg.feature import (
145
+ VonMisesFisher as dist_fisher,
146
+ )
147
+ from apsg.feature import (
148
+ Watson as dist_watson,
149
+ )
150
+ from apsg.feature import (
151
+ WrappedCauchy as dist_wrapped_cauchy,
152
+ )
153
+ from apsg.feature import (
154
+ WrappedNormal as dist_wrapped_normal,
155
+ )
108
156
  from apsg.math import (
109
157
  Matrix2 as matrix2,
110
158
  )
@@ -121,6 +169,7 @@ from apsg.plotting import (
121
169
  FabricPlotStyleFactory as fabricplot_styles,
122
170
  )
123
171
  from apsg.plotting import (
172
+ FisherQQPlot,
124
173
  FlinnPlot,
125
174
  HsuPlot,
126
175
  RamsayPlot,
@@ -139,6 +188,7 @@ from apsg.plotting import (
139
188
  )
140
189
 
141
190
  __all__ = (
191
+ "FisherQQPlot",
142
192
  "FlinnPlot",
143
193
  "G",
144
194
  "HsuPlot",
@@ -158,6 +208,21 @@ __all__ = (
158
208
  "defgrad2",
159
209
  "dir2",
160
210
  "dir2set",
211
+ "dist_acg",
212
+ "dist_axial_vonmises",
213
+ "dist_bingham",
214
+ "dist_bingham_mixture",
215
+ "dist_cardioid",
216
+ "dist_esag",
217
+ "dist_fisher",
218
+ "dist_jones_pewsey",
219
+ "dist_kent",
220
+ "dist_lisle",
221
+ "dist_matrix_fisher",
222
+ "dist_vonmises",
223
+ "dist_watson",
224
+ "dist_wrapped_cauchy",
225
+ "dist_wrapped_normal",
161
226
  "ellipse",
162
227
  "ellipseset",
163
228
  "ellipsoid",
@@ -182,6 +247,7 @@ __all__ = (
182
247
  "rotation",
183
248
  "rotation2",
184
249
  "rotation_from_axis_angle",
250
+ "rotationset",
185
251
  "stereonet_styles",
186
252
  "stress",
187
253
  "stress2",
@@ -195,6 +261,6 @@ __all__ = (
195
261
  "velgrad2",
196
262
  )
197
263
 
198
- __version__ = "2.0.5"
264
+ __version__ = "2.1.0"
199
265
  __author__ = "Ondrej Lexa"
200
266
  __email__ = "lexa.ondrej@gmail.com"
@@ -0,0 +1,96 @@
1
+ """Anisotropy of magnetic susceptibility (AMS): grain models and statistics.
2
+
3
+ Not imported by ``from apsg import *``; use ``from apsg.ams import *``.
4
+
5
+ Grain models (kinematic coefficient ``grain_K``, ``VelocityGradient3.pseudo``,
6
+ the March/Willis distribution ``ACG.from_displacement`` and the susceptibility
7
+ tensor ``ams_from_orientation``/``ams_from_grains``) predict the fabric of a
8
+ population of non-interacting grains in a homogeneous flow.
9
+ """
10
+
11
+ from apsg.ams._model import (
12
+ AMSEvolution,
13
+ AMSModel,
14
+ GrainPopulation,
15
+ jeffery_evolution,
16
+ )
17
+ from apsg.ams._plots import (
18
+ AMSPlot,
19
+ AMSStereoPlot,
20
+ BootstrapPlot,
21
+ LFPlot,
22
+ ModelPlot,
23
+ PjTPlot,
24
+ PTPlot,
25
+ )
26
+ from apsg.ams._readers import (
27
+ from_dataframe,
28
+ read_aex,
29
+ read_ams,
30
+ read_anisoft_table,
31
+ read_asc,
32
+ read_csv,
33
+ read_ran,
34
+ read_sufar,
35
+ to_dataframe,
36
+ )
37
+ from apsg.ams._specimen import AMSSite, AMSSpecimen
38
+ from apsg.feature import (
39
+ TensorBootstrap,
40
+ compare_tensor_means,
41
+ tensor_bootstrap,
42
+ tensor_error_bootstrap,
43
+ )
44
+ from apsg.feature._distributions import ACG
45
+ from apsg.feature._grainmodels import (
46
+ ams_from_grains,
47
+ ams_from_orientation,
48
+ ams_from_rotations,
49
+ grain_anisotropy,
50
+ grain_K,
51
+ grain_susceptibilities,
52
+ jeffery_rotations,
53
+ kinematic_K,
54
+ orientation_tensor_from_ams,
55
+ osborn_factors,
56
+ )
57
+
58
+ __all__ = (
59
+ "ACG",
60
+ "AMSEvolution",
61
+ "AMSModel",
62
+ "AMSPlot",
63
+ "AMSSite",
64
+ "AMSSpecimen",
65
+ "AMSStereoPlot",
66
+ "BootstrapPlot",
67
+ "GrainPopulation",
68
+ "LFPlot",
69
+ "ModelPlot",
70
+ "PTPlot",
71
+ "PjTPlot",
72
+ "TensorBootstrap",
73
+ "ams_from_grains",
74
+ "ams_from_orientation",
75
+ "ams_from_rotations",
76
+ "compare_tensor_means",
77
+ "from_dataframe",
78
+ "grain_K",
79
+ "grain_anisotropy",
80
+ "grain_susceptibilities",
81
+ "jeffery_evolution",
82
+ "jeffery_rotations",
83
+ "kinematic_K",
84
+ "orientation_tensor_from_ams",
85
+ "osborn_factors",
86
+ "read_aex",
87
+ "read_ams",
88
+ "read_anisoft_table",
89
+ "read_asc",
90
+ "read_csv",
91
+ "read_ran",
92
+ "read_sufar",
93
+ "tensor_bootstrap",
94
+ "tensor_error_bootstrap",
95
+ "to_dataframe",
96
+ )
@@ -0,0 +1,217 @@
1
+ """Forward models of the AMS of grains in a flow."""
2
+
3
+ from dataclasses import dataclass
4
+
5
+ import numpy as np
6
+
7
+ from apsg.feature import Ellipsoid, EllipsoidSet, VelocityGradient3
8
+ from apsg.feature._distributions import ACG
9
+ from apsg.feature._grainmodels import (
10
+ ams_from_grains,
11
+ ams_from_rotations,
12
+ grain_K,
13
+ grain_susceptibilities,
14
+ jeffery_rotations,
15
+ )
16
+ from apsg.feature._statistics import jelinek_shape
17
+
18
+ __all__ = ("AMSEvolution", "AMSModel", "GrainPopulation", "jeffery_evolution")
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class GrainPopulation:
23
+ """Population of uniaxial grains of one shape.
24
+
25
+ Attributes:
26
+ kind: ``"prolate"`` (long axis is the unique axis) or ``"oblate"``
27
+ (the pole of the flat grain).
28
+ ratio: axial ratio of the spheroid, ``>= 1``.
29
+ K: susceptibility perpendicular to the unique axis.
30
+ delta: ``K_axis - K_transverse``; positive for prolate (default 0.3),
31
+ negative for oblate (default -0.3) grains when None.
32
+ weight: weight of the population in the rock.
33
+ """
34
+
35
+ kind: str
36
+ ratio: float
37
+ K: float = 1.0
38
+ delta: float | None = None
39
+ weight: float = 1.0
40
+
41
+ def __post_init__(self):
42
+ if self.kind not in ("prolate", "oblate"):
43
+ raise ValueError(f"kind must be 'prolate' or 'oblate', got {self.kind!r}")
44
+ grain_K(self.kind, self.ratio)
45
+ if self.delta is None:
46
+ object.__setattr__(self, "delta", 0.3 if self.kind == "prolate" else -0.3)
47
+ if (self.delta > 0) != (self.kind == "prolate") and self.delta != 0:
48
+ raise ValueError("delta must be positive for prolate, negative for oblate")
49
+ if self.weight < 0 or self.K <= 0:
50
+ raise ValueError("weight must be non-negative and K positive")
51
+
52
+ @classmethod
53
+ def from_susceptibility(cls, kind, ratio, k, weight=1.0):
54
+ """Population of grains of intrinsic susceptibility `k` and shape anisotropy.
55
+
56
+ The grain susceptibilities follow from the demagnetising factors
57
+ (``grain_susceptibilities``), so the grain anisotropy is controlled by
58
+ its shape, as for magnetite.
59
+ """
60
+ Ka, Kb = grain_susceptibilities(k, ratio, kind)
61
+ return cls(kind, ratio, K=Kb, delta=Ka - Kb, weight=weight)
62
+
63
+ @property
64
+ def kinematic_K(self):
65
+ """float: kinematic coefficient of the grain shape (`grain_K`)."""
66
+ return grain_K(self.kind, self.ratio)
67
+
68
+
69
+ @dataclass(frozen=True, eq=False)
70
+ class AMSEvolution:
71
+ """AMS tensors of a model at a sequence of times.
72
+
73
+ Attributes:
74
+ times: ``(n,)`` times (or strains).
75
+ tensors: ``(n, 3, 3)`` susceptibility tensors.
76
+ """
77
+
78
+ times: np.ndarray
79
+ tensors: np.ndarray
80
+
81
+ def __len__(self):
82
+ return len(self.times)
83
+
84
+ def __repr__(self):
85
+ return f"AMSEvolution({len(self)} steps, t = {self.times[0]:g} to {self.times[-1]:g})"
86
+
87
+ def ellipsoids(self):
88
+ """Return the tensors as `EllipsoidSet`."""
89
+ return EllipsoidSet([Ellipsoid(t) for t in self.tensors], name="model")
90
+
91
+ def table(self):
92
+ """Return a `DataFrame` of the time, the parameters of Jelinek (1981) and
93
+ the plunge and azimuth of ``k1`` and ``k3``."""
94
+ import pandas as pd
95
+
96
+ rows = []
97
+ for t, T in zip(self.times, self.tensors, strict=True):
98
+ e = Ellipsoid(T)
99
+ lins = e.eigenlins()
100
+ row = {"time": float(t), **jelinek_shape(np.linalg.eigvalsh(T))}
101
+ iso = (
102
+ row["P"] - 1 < 1e-9
103
+ ) # axes and shape of an isotropic tensor are undefined
104
+ if iso:
105
+ row["T"] = row["U"] = np.nan
106
+ for i in (0, 2):
107
+ azi, inc = lins[i].geo
108
+ row[f"k{i + 1}_azi"] = np.nan if iso else float(azi)
109
+ row[f"k{i + 1}_inc"] = np.nan if iso else float(inc)
110
+ rows.append(row)
111
+ return pd.DataFrame(rows)
112
+
113
+ def switch(self):
114
+ """Return the first time at which a horizontal ``k1`` becomes steeper than
115
+ 45 degrees (the switch of the lineation), or None."""
116
+ inc = self.table()["k1_inc"].abs().to_numpy()
117
+ flat = np.nonzero(inc <= 45)[0]
118
+ if len(flat) == 0:
119
+ return None
120
+ steep = np.nonzero(inc[flat[0] :] > 45)[0]
121
+ return float(self.times[flat[0] + steep[0]]) if len(steep) else None
122
+
123
+
124
+ class AMSModel:
125
+ """AMS of non-interacting grains carried by a homogeneous flow.
126
+
127
+ Each population turns like a material line in the pseudo-velocity-gradient
128
+ ``K E + W`` of its shape (Willis, 1977), and starting from a uniform
129
+ distribution of axes its orientation is an angular central Gaussian
130
+ (``ACG.from_displacement``); the susceptibility tensor of the rock is the
131
+ weighted sum of the populations (Jezek and Hrouda, 2002).
132
+
133
+ Args:
134
+ flow: ``VelocityGradient3`` or a 3x3 array, the velocity gradient with
135
+ time in the units of the model (``defgrad(time)`` integrates it).
136
+ populations: ``GrainPopulation`` or a sequence of them.
137
+
138
+ Examples:
139
+ >>> L = VelocityGradient3([[0, 1, 0], [0, 0, 0], [0, 0, 0]]) # doctest: +SKIP
140
+ >>> model = AMSModel(L, GrainPopulation("prolate", 3)) # doctest: +SKIP
141
+ >>> model.evolve(np.linspace(0.1, 10, 50)).table() # doctest: +SKIP
142
+ """
143
+
144
+ def __init__(self, flow, populations):
145
+ self.flow = (
146
+ flow if isinstance(flow, VelocityGradient3) else VelocityGradient3(flow)
147
+ )
148
+ if isinstance(populations, GrainPopulation):
149
+ populations = [populations]
150
+ self.populations = list(populations)
151
+ if not self.populations or not all(
152
+ isinstance(p, GrainPopulation) for p in self.populations
153
+ ):
154
+ raise TypeError("populations must be GrainPopulation objects")
155
+ if sum(p.weight for p in self.populations) <= 0:
156
+ raise ValueError("weights must have a positive sum")
157
+
158
+ def fabric(self, time, population=0):
159
+ """Return the `ACG` distribution of the grain axes of a population at `time`."""
160
+ p = self.populations[population]
161
+ D = np.asarray(self.flow.pseudo(p.kinematic_K).defgrad(time))
162
+ return ACG.from_displacement(D, "lines" if p.kind == "prolate" else "poles")
163
+
164
+ def tensor(self, time):
165
+ """Return the susceptibility tensor of the rock at `time` as `Ellipsoid`."""
166
+ return ams_from_grains(
167
+ (p.weight, self.fabric(time, i), p.K, p.delta)
168
+ for i, p in enumerate(self.populations)
169
+ )
170
+
171
+ def evolve(self, times):
172
+ """Return the `AMSEvolution` at the given times."""
173
+ t = np.asarray(times, dtype=float)
174
+ if t.ndim != 1 or len(t) == 0 or not np.all(np.isfinite(t)) or np.any(t < 0):
175
+ raise ValueError(
176
+ "times must be a non-empty 1-D array of non-negative values"
177
+ )
178
+ return AMSEvolution(t, np.array([np.asarray(self.tensor(x)) for x in t]))
179
+
180
+
181
+ def jeffery_evolution(
182
+ flow, semi_axes, susceptibilities, times, n=500, rng=None, rtol=1e-9
183
+ ):
184
+ """AMS of triaxial ellipsoids rotating in a flow according to Jeffery (1922).
185
+
186
+ `n` grains start with uniformly random orientations and are carried by
187
+ the flow (``jeffery_rotations``); the susceptibility tensor is the mean of
188
+ the grains', each having the principal susceptibilities
189
+ `susceptibilities` along its axes. Unlike `AMSModel` it works for any
190
+ three semi-axes, but the result is a sample, so use a few hundred grains
191
+ and a seed. Triaxial grains in shear do not return to their orientation
192
+ after a fixed strain (Hrouda and Jezek, 1999).
193
+
194
+ Args:
195
+ flow: ``VelocityGradient3`` or 3x3 array.
196
+ semi_axes: three positive semi-axes (axis 1 longest, by convention).
197
+ susceptibilities: principal susceptibilities along the three axes.
198
+ times: increasing times, starting at 0 (undeformed).
199
+ n: number of grains.
200
+ rng: None, an integer seed or a ``numpy.random.Generator``.
201
+ rtol: tolerance of the integrator.
202
+
203
+ Returns:
204
+ AMSEvolution: tensors at `times`.
205
+ """
206
+ from scipy.spatial.transform import Rotation
207
+
208
+ from apsg.feature._distributions._base import as_rng
209
+
210
+ t = np.asarray(times, dtype=float)
211
+ rng = as_rng(rng)
212
+ seed = int(rng.integers(0, 2**31 - 1))
213
+ R0 = Rotation.random(int(n), random_state=seed).as_matrix()
214
+ R = jeffery_rotations(np.asarray(flow), semi_axes, R0, t, rtol=rtol)
215
+ return AMSEvolution(
216
+ t, np.array([np.asarray(ams_from_rotations(Rt, susceptibilities)) for Rt in R])
217
+ )