apsg 2.0.2__tar.gz → 2.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.
Files changed (57) hide show
  1. {apsg-2.0.2/src/apsg.egg-info → apsg-2.0.3}/PKG-INFO +125 -58
  2. apsg-2.0.3/README.md +196 -0
  3. {apsg-2.0.2 → apsg-2.0.3}/pyproject.toml +2 -2
  4. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/__init__.py +1 -1
  5. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/config.py +21 -0
  6. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/__init__.py +8 -0
  7. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/_container.py +66 -5
  8. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/_tensor2.py +111 -36
  9. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/_tensor3.py +139 -40
  10. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/math/_matrix.py +48 -30
  11. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereonet.py +1 -1
  12. {apsg-2.0.2 → apsg-2.0.3/src/apsg.egg-info}/PKG-INFO +125 -58
  13. {apsg-2.0.2 → apsg-2.0.3}/src/apsg.egg-info/requires.txt +1 -0
  14. {apsg-2.0.2 → apsg-2.0.3}/tests/test_containers.py +54 -4
  15. {apsg-2.0.2 → apsg-2.0.3}/tests/test_tensors.py +191 -1
  16. apsg-2.0.2/README.md +0 -130
  17. {apsg-2.0.2 → apsg-2.0.3}/LICENSE +0 -0
  18. {apsg-2.0.2 → apsg-2.0.3}/setup.cfg +0 -0
  19. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/database/__init__.py +0 -0
  20. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/database/_sdbmodels.py +0 -0
  21. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/database/_sdbsession.py +0 -0
  22. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/database/_websdbsession.py +0 -0
  23. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/database/_webtransport.py +0 -0
  24. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/_geodata.py +0 -0
  25. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/_paleomag.py +0 -0
  26. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/feature/_statistics.py +0 -0
  27. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/helpers/__init__.py +0 -0
  28. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/helpers/_helper.py +0 -0
  29. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/helpers/_math.py +0 -0
  30. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/helpers/_notation.py +0 -0
  31. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/math/__init__.py +0 -0
  32. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/math/_vector.py +0 -0
  33. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/pandas/__init__.py +0 -0
  34. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/pandas/_accessors.py +0 -0
  35. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/pandas/_gbfunctions.py +0 -0
  36. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/pandas/_pandas_api.py +0 -0
  37. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/__init__.py +0 -0
  38. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_fabricplot.py +0 -0
  39. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_paleomagplots.py +0 -0
  40. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_plot_artists.py +0 -0
  41. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_roseplot.py +0 -0
  42. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereo_engine/__init__.py +0 -0
  43. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereo_engine/_axes.py +0 -0
  44. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereo_engine/_stereogrid.py +0 -0
  45. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereo_engine/_transforms.py +0 -0
  46. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereo_engine/_utils.py +0 -0
  47. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_stereogrid.py +0 -0
  48. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/plotting/_styles.py +0 -0
  49. {apsg-2.0.2 → apsg-2.0.3}/src/apsg/shell.py +0 -0
  50. {apsg-2.0.2 → apsg-2.0.3}/src/apsg.egg-info/SOURCES.txt +0 -0
  51. {apsg-2.0.2 → apsg-2.0.3}/src/apsg.egg-info/dependency_links.txt +0 -0
  52. {apsg-2.0.2 → apsg-2.0.3}/src/apsg.egg-info/entry_points.txt +0 -0
  53. {apsg-2.0.2 → apsg-2.0.3}/src/apsg.egg-info/top_level.txt +0 -0
  54. {apsg-2.0.2 → apsg-2.0.3}/tests/test_apsg.py +0 -0
  55. {apsg-2.0.2 → apsg-2.0.3}/tests/test_pandas.py +0 -0
  56. {apsg-2.0.2 → apsg-2.0.3}/tests/test_plotting.py +0 -0
  57. {apsg-2.0.2 → apsg-2.0.3}/tests/test_websdb.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apsg
3
- Version: 2.0.2
3
+ Version: 2.0.3
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>
@@ -26,6 +26,7 @@ Requires-Dist: pandas
26
26
  Requires-Dist: pygeomag
27
27
  Provides-Extra: lab
28
28
  Requires-Dist: jupyterlab; extra == "lab"
29
+ Requires-Dist: openpyxl; extra == "lab"
29
30
  Provides-Extra: tests
30
31
  Requires-Dist: pytest; extra == "tests"
31
32
  Requires-Dist: pytest-cov; extra == "tests"
@@ -55,13 +56,11 @@ Dynamic: license-file
55
56
  [![codecov](https://codecov.io/gh/ondrolexa/apsg/graph/badge.svg?token=YKXWmJJHw3)](https://codecov.io/gh/ondrolexa/apsg)
56
57
  [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.593586-blue)](https://doi.org/10.5281/zenodo.593586)
57
58
 
58
- ## 🤔 What is APSG?
59
-
60
- APSG is the package for structural geologists. It defines several new python classes to easily manage, analyze and visualize orientation structural geology data.
59
+ APSG is the package for structural geologists. It defines several new Python classes to easily manage, analyze and visualize orientation structural geology data.
61
60
 
62
61
  Check [CHANGELOG.md](https://github.com/ondrolexa/apsg/blob/master/CHANGELOG.md) for recent updates.
63
62
 
64
- ## 📈 Quick example
63
+ ## Quick example
65
64
 
66
65
  ```python
67
66
  from apsg import *
@@ -74,100 +73,168 @@ s.contour(f)
74
73
  s.show()
75
74
  ```
76
75
 
77
- ``StereoNet`` supports both equal-area (Schmidt, default) and equal-angle (Wulff) projections,
78
- lower and upper hemisphere, and rotating the whole net independently of the plotted data --
79
- see the stereonet tutorial in the [documentation](https://apsg.readthedocs.org) for examples.
76
+ `StereoNet` supports both equal-area (Schmidt, default) and equal-angle (Wulff) projections,
77
+ 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.
80
79
 
81
- ## 🛠️ Requirements
80
+ ## Requirements
82
81
 
83
- You need Python 3.12 or later to run APSG. The package requires [NumPy](https://numpy.org/),
84
- [SciPy](https://scipy.org/), [Matplotlib](https://matplotlib.org/), [SQLAlchemy](https://www.sqlalchemy.org/),
85
- [pandas](https://pandas.pydata.org/) and [pygeomag](https://github.com/boxpet/pygeomag).
82
+ APSG requires Python 3.12 or later. It depends on [NumPy](https://numpy.org/),
83
+ [SciPy](https://scipy.org/), [Matplotlib](https://matplotlib.org/),
84
+ [SQLAlchemy](https://www.sqlalchemy.org/), [pandas](https://pandas.pydata.org/),
85
+ [pygeomag](https://github.com/boxpet/pygeomag). The installers below take care of these.
86
86
 
87
- ## 🚀 How to install
87
+ ## Installation
88
88
 
89
- It is strongly suggested to install **apsg** into separate environment. You can create
90
- Python virtual environment. For Linux and macOS use:
89
+ Install APSG into a separate environment. Pick one of the options below. uv is the default
90
+ and the fastest; pip and conda/mamba are alternatives.
91
91
 
92
- python -m venv .venv
93
- source .venv/bin/activate
92
+ ### With uv (recommended)
94
93
 
95
- for Windows use Command Prompt or PowerShell:
94
+ Install [uv](https://docs.astral.sh/uv/), then create a virtual environment and install APSG
95
+ into it:
96
96
 
97
- python -m venv .venv
98
- .venv\Scripts\activate
97
+ ```sh
98
+ uv venv
99
+ uv pip install apsg
100
+ ```
99
101
 
100
- > **Note:** On Microsoft Windows, it may be required to set the execution policy in PowerShell for the user.
101
- > You can do this by issuing the following PowerShell command:
102
- > ```
103
- > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
104
- > ```
102
+ Activate the environment on Linux and macOS:
103
+
104
+ ```sh
105
+ source .venv/bin/activate
106
+ ```
107
+
108
+ On Windows (Command Prompt or PowerShell):
109
+
110
+ ```powershell
111
+ .venv\Scripts\activate
112
+ ```
113
+
114
+ To include JupyterLab and [openpyxl](https://openpyxl.readthedocs.io/) (needed to read Excel files), use the `lab` extra:
115
+
116
+ ```sh
117
+ uv pip install "apsg[lab]"
118
+ ```
119
+
120
+ In an existing project with a `pyproject.toml`, add APSG as a dependency instead:
121
+
122
+ ```sh
123
+ uv add apsg
124
+ ```
125
+
126
+ To use APSG from the command line, install it as a tool. This puts an isolated copy of APSG
127
+ on your `PATH`, without activating an environment:
128
+
129
+ ```sh
130
+ uv tool install apsg
131
+ ```
132
+
133
+ Then start the interactive APSG shell, which runs `from apsg import *` for you:
105
134
 
106
- and install latest stable version of **apsg** using pip within the environment:
135
+ ```sh
136
+ iapsg
137
+ ```
107
138
 
108
- pip install apsg
139
+ To try the shell without installing, run `uvx --from apsg iapsg`. Add the `lab` extra with
140
+ `uv tool install "apsg[lab]"` to include JupyterLab.
109
141
 
110
- To include jupyterlab in installation, use `lab` extra:
142
+ ### Development install
111
143
 
112
- pip install apsg[lab]
144
+ To work on APSG itself, clone the repository and install it in editable mode with all extras
145
+ and development tools:
146
+
147
+ ```sh
148
+ git clone https://github.com/ondrolexa/apsg.git
149
+ cd apsg
150
+ uv sync --all-extras --dev
151
+ ```
113
152
 
114
- Or install **master** with:
153
+ Run the test suite with `uv run pytest`.
154
+
155
+ ### With pip
156
+
157
+ Create and activate a virtual environment. On Linux and macOS:
158
+
159
+ ```sh
160
+ python -m venv .venv
161
+ source .venv/bin/activate
162
+ ```
115
163
 
116
- pip install git+https://github.com/ondrolexa/apsg.git
164
+ On Windows (Command Prompt or PowerShell):
117
165
 
118
- Alternatively, you can clone the repository and do a local install with [uv](https://docs.astral.sh/uv/) (recommended for dev):
166
+ ```powershell
167
+ python -m venv .venv
168
+ .venv\Scripts\activate
169
+ ```
119
170
 
120
- git clone https://github.com/ondrolexa/apsg.git
121
- cd apsg
122
- uv sync --all-extras --dev
171
+ > **Note:** On Windows, PowerShell may refuse to run the activation script. To allow it for
172
+ > the current user, run:
173
+ >
174
+ > ```powershell
175
+ > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
176
+ > ```
123
177
 
124
- #### Upgrading via pip
178
+ Install the latest stable release from PyPI:
125
179
 
126
- To upgrade an existing version of APSG from PyPI, execute:
180
+ ```sh
181
+ pip install apsg
182
+ ```
127
183
 
128
- pip install apsg --upgrade --no-deps
184
+ To include JupyterLab and [openpyxl](https://openpyxl.readthedocs.io/) (needed to read Excel files), use the `lab` extra:
129
185
 
130
- #### Comments on system-wide installations on Debian systems
186
+ ```sh
187
+ pip install "apsg[lab]"
188
+ ```
131
189
 
132
- Latest Debian-based systems do not allow installing non-Debian packages system-wide.
133
- However, installing all requirements allows to force install APSG system-wide without troubles.
190
+ To upgrade an existing installation without touching its dependencies:
134
191
 
135
- Install requirements using apt:
192
+ ```sh
193
+ pip install --upgrade --no-deps apsg
194
+ ```
136
195
 
137
- sudo apt install python3-numpy python3-matplotlib python3-scipy python3-sqlalchemy python3-pandas
196
+ To install the master branch from GitHub:
138
197
 
139
- and then install apsg using pip:
198
+ ```sh
199
+ pip install git+https://github.com/ondrolexa/apsg.git
200
+ ```
140
201
 
141
- pip install --break-system-packages apsg
202
+ ### With conda or mamba
142
203
 
143
- ### I'm using conda or mamba to manage environments
204
+ If you already use conda or mamba, add the `conda-forge` channel and create an environment
205
+ with APSG:
144
206
 
145
- If you already have conda or mamba installed, you can create environment with:
207
+ ```sh
208
+ conda config --add channels conda-forge
209
+ conda create -n apsg python apsg jupyterlab
210
+ ```
146
211
 
147
- conda config --add channels conda-forge
148
- conda create -n apsg python apsg jupyterlab
212
+ or with mamba:
149
213
 
150
- or using mamba
214
+ ```sh
215
+ mamba create -n apsg python apsg jupyterlab
216
+ ```
151
217
 
152
- mamba create -n apsg python apsg jupyterlab
218
+ To install APSG into an existing environment, run `conda install apsg` (or
219
+ `mamba install apsg`).
153
220
 
154
- #### Current release info
221
+ ### Current release
155
222
 
156
223
  | Name | Downloads | Version | Platforms |
157
224
  | --- | --- | --- | --- |
158
225
  | [![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) |
159
226
 
160
- ## 📘 Documentation
227
+ ## Documentation
161
228
 
162
- You can explore all the features of APSG in [documentation](https://apsg.readthedocs.org).
229
+ Explore all features of APSG in the [documentation](https://apsg.readthedocs.org).
163
230
 
164
- ## 💻 Contributing
231
+ ## Contributing
165
232
 
166
- Most discussion happens on [Github](https://github.com/ondrolexa/apsg). Feel free to open [an issue](https://github.com/ondrolexa/apsg/issues/new) or comment on any open issue or pull request. Check [CONTRIBUTING.md](https://github.com/ondrolexa/apsg/blob/master/CONTRIBUTING.md) for more details.
233
+ Most discussion happens on [GitHub](https://github.com/ondrolexa/apsg). Feel free to open [an issue](https://github.com/ondrolexa/apsg/issues/new) or comment on any open issue or pull request. See [CONTRIBUTING.md](https://github.com/ondrolexa/apsg/blob/master/CONTRIBUTING.md) for more details.
167
234
 
168
- ## 🪙 Donate
235
+ ## Donate
169
236
 
170
- APSG is an open-source project, available for you for free. It took a lot of time and resources to build this software. If you find this software useful and want to support its future development please consider donating to me.
237
+ APSG is an open-source project, available for free. It took a lot of time and resources to build this software. If you find it useful and want to support its future development, please consider donating.
171
238
 
172
239
  [![Donate via PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=QTYZWVUNDUAH8&item_name=APSG+development+donation&currency_code=EUR&source=url)
173
240
 
apsg-2.0.3/README.md ADDED
@@ -0,0 +1,196 @@
1
+ <picture>
2
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_dark.svg">
3
+ <img alt="APSG logo" src="https://raw.githubusercontent.com/ondrolexa/apsg/master/docs/images/apsg_banner_light.svg">
4
+ </picture>
5
+
6
+ [![PyPI - Version](https://img.shields.io/pypi/v/apsg)](https://pypi.org/project/apsg)
7
+ [![Conda](https://img.shields.io/conda/v/conda-forge/apsg)](https://anaconda.org/conda-forge/apsg)
8
+ [![Documentation Status](https://readthedocs.org/projects/apsg/badge/?version=stable)](https://apsg.readthedocs.io/en/stable/?badge=stable)
9
+ [![codecov](https://codecov.io/gh/ondrolexa/apsg/graph/badge.svg?token=YKXWmJJHw3)](https://codecov.io/gh/ondrolexa/apsg)
10
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.593586-blue)](https://doi.org/10.5281/zenodo.593586)
11
+
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
+
14
+ Check [CHANGELOG.md](https://github.com/ondrolexa/apsg/blob/master/CHANGELOG.md) for recent updates.
15
+
16
+ ## Quick example
17
+
18
+ ```python
19
+ from apsg import *
20
+
21
+ f = folset.random_fisher(position=fol(130, 60))
22
+ s = StereoNet()
23
+ s.great_circle(f)
24
+ s.point(f)
25
+ s.contour(f)
26
+ s.show()
27
+ ```
28
+
29
+ `StereoNet` supports both equal-area (Schmidt, default) and equal-angle (Wulff) projections,
30
+ 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.
32
+
33
+ ## Requirements
34
+
35
+ APSG requires Python 3.12 or later. It depends on [NumPy](https://numpy.org/),
36
+ [SciPy](https://scipy.org/), [Matplotlib](https://matplotlib.org/),
37
+ [SQLAlchemy](https://www.sqlalchemy.org/), [pandas](https://pandas.pydata.org/),
38
+ [pygeomag](https://github.com/boxpet/pygeomag). The installers below take care of these.
39
+
40
+ ## Installation
41
+
42
+ Install APSG into a separate environment. Pick one of the options below. uv is the default
43
+ and the fastest; pip and conda/mamba are alternatives.
44
+
45
+ ### With uv (recommended)
46
+
47
+ Install [uv](https://docs.astral.sh/uv/), then create a virtual environment and install APSG
48
+ into it:
49
+
50
+ ```sh
51
+ uv venv
52
+ uv pip install apsg
53
+ ```
54
+
55
+ Activate the environment on Linux and macOS:
56
+
57
+ ```sh
58
+ source .venv/bin/activate
59
+ ```
60
+
61
+ On Windows (Command Prompt or PowerShell):
62
+
63
+ ```powershell
64
+ .venv\Scripts\activate
65
+ ```
66
+
67
+ To include JupyterLab and [openpyxl](https://openpyxl.readthedocs.io/) (needed to read Excel files), use the `lab` extra:
68
+
69
+ ```sh
70
+ uv pip install "apsg[lab]"
71
+ ```
72
+
73
+ In an existing project with a `pyproject.toml`, add APSG as a dependency instead:
74
+
75
+ ```sh
76
+ uv add apsg
77
+ ```
78
+
79
+ To use APSG from the command line, install it as a tool. This puts an isolated copy of APSG
80
+ on your `PATH`, without activating an environment:
81
+
82
+ ```sh
83
+ uv tool install apsg
84
+ ```
85
+
86
+ Then start the interactive APSG shell, which runs `from apsg import *` for you:
87
+
88
+ ```sh
89
+ iapsg
90
+ ```
91
+
92
+ To try the shell without installing, run `uvx --from apsg iapsg`. Add the `lab` extra with
93
+ `uv tool install "apsg[lab]"` to include JupyterLab.
94
+
95
+ ### Development install
96
+
97
+ To work on APSG itself, clone the repository and install it in editable mode with all extras
98
+ and development tools:
99
+
100
+ ```sh
101
+ git clone https://github.com/ondrolexa/apsg.git
102
+ cd apsg
103
+ uv sync --all-extras --dev
104
+ ```
105
+
106
+ Run the test suite with `uv run pytest`.
107
+
108
+ ### With pip
109
+
110
+ Create and activate a virtual environment. On Linux and macOS:
111
+
112
+ ```sh
113
+ python -m venv .venv
114
+ source .venv/bin/activate
115
+ ```
116
+
117
+ On Windows (Command Prompt or PowerShell):
118
+
119
+ ```powershell
120
+ python -m venv .venv
121
+ .venv\Scripts\activate
122
+ ```
123
+
124
+ > **Note:** On Windows, PowerShell may refuse to run the activation script. To allow it for
125
+ > the current user, run:
126
+ >
127
+ > ```powershell
128
+ > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
129
+ > ```
130
+
131
+ Install the latest stable release from PyPI:
132
+
133
+ ```sh
134
+ pip install apsg
135
+ ```
136
+
137
+ To include JupyterLab and [openpyxl](https://openpyxl.readthedocs.io/) (needed to read Excel files), use the `lab` extra:
138
+
139
+ ```sh
140
+ pip install "apsg[lab]"
141
+ ```
142
+
143
+ To upgrade an existing installation without touching its dependencies:
144
+
145
+ ```sh
146
+ pip install --upgrade --no-deps apsg
147
+ ```
148
+
149
+ To install the master branch from GitHub:
150
+
151
+ ```sh
152
+ pip install git+https://github.com/ondrolexa/apsg.git
153
+ ```
154
+
155
+ ### With conda or mamba
156
+
157
+ If you already use conda or mamba, add the `conda-forge` channel and create an environment
158
+ with APSG:
159
+
160
+ ```sh
161
+ conda config --add channels conda-forge
162
+ conda create -n apsg python apsg jupyterlab
163
+ ```
164
+
165
+ or with mamba:
166
+
167
+ ```sh
168
+ mamba create -n apsg python apsg jupyterlab
169
+ ```
170
+
171
+ To install APSG into an existing environment, run `conda install apsg` (or
172
+ `mamba install apsg`).
173
+
174
+ ### Current release
175
+
176
+ | Name | Downloads | Version | Platforms |
177
+ | --- | --- | --- | --- |
178
+ | [![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) |
179
+
180
+ ## Documentation
181
+
182
+ Explore all features of APSG in the [documentation](https://apsg.readthedocs.org).
183
+
184
+ ## Contributing
185
+
186
+ Most discussion happens on [GitHub](https://github.com/ondrolexa/apsg). Feel free to open [an issue](https://github.com/ondrolexa/apsg/issues/new) or comment on any open issue or pull request. See [CONTRIBUTING.md](https://github.com/ondrolexa/apsg/blob/master/CONTRIBUTING.md) for more details.
187
+
188
+ ## Donate
189
+
190
+ APSG is an open-source project, available for free. It took a lot of time and resources to build this software. If you find it useful and want to support its future development, please consider donating.
191
+
192
+ [![Donate via PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=QTYZWVUNDUAH8&item_name=APSG+development+donation&currency_code=EUR&source=url)
193
+
194
+ ## License
195
+
196
+ APSG is free software: you can redistribute it and/or modify it under the terms of the MIT License. A copy of this license is provided in the [LICENSE](https://github.com/ondrolexa/apsg/blob/master/LICENSE) file.
@@ -18,7 +18,7 @@ classifiers = [
18
18
  dependencies = ["numpy", "matplotlib>=3.9", "scipy", "sqlalchemy", "pandas", "pygeomag"]
19
19
 
20
20
  [project.optional-dependencies]
21
- lab = ["jupyterlab"]
21
+ lab = ["jupyterlab", "openpyxl"]
22
22
  tests = ["pytest", "pytest-cov", "pytest-xdist"]
23
23
  docs = [
24
24
  "sphinx>=7.0",
@@ -56,7 +56,7 @@ addopts = ["-n", "auto"]
56
56
 
57
57
  [tool.ruff]
58
58
  line-length = 88
59
- target-version = "py310"
59
+ target-version = "py312"
60
60
  exclude = [".venv", "docs", ".git"]
61
61
 
62
62
  [tool.ruff.lint]
@@ -195,6 +195,6 @@ __all__ = (
195
195
  "velgrad2",
196
196
  )
197
197
 
198
- __version__ = "2.0.2"
198
+ __version__ = "2.0.3"
199
199
  __author__ = "Ondrej Lexa"
200
200
  __email__ = "lexa.ondrej@gmail.com"
@@ -388,6 +388,7 @@ class AppConfig(BaseConfig):
388
388
  """Top-level application configuration."""
389
389
 
390
390
  notation: str = "dd"
391
+ stress_convention: str = "geological"
391
392
  vec2geo: bool = False
392
393
  ndigits: int = 3
393
394
  figsize: tuple = (8, 6)
@@ -444,6 +445,26 @@ class AppConfig(BaseConfig):
444
445
 
445
446
  apsg_conf = AppConfig()
446
447
 
448
+ STRESS_CONVENTIONS = ("geological", "mechanical")
449
+
450
+
451
+ def stress_sign():
452
+ """Sign that maps the canonical (mechanical, tension-positive) stress matrix
453
+ to the active ``apsg_conf.stress_convention``.
454
+
455
+ Returns:
456
+ float: -1.0 for ``"geological"`` (compression positive), +1.0 for
457
+ ``"mechanical"`` (tension positive). The mapping is its own inverse.
458
+ """
459
+ convention = apsg_conf.stress_convention
460
+ if convention == "geological":
461
+ return -1.0
462
+ if convention == "mechanical":
463
+ return 1.0
464
+ raise ValueError(
465
+ f"Unknown stress_convention {convention!r}, expected one of {STRESS_CONVENTIONS}"
466
+ )
467
+
447
468
 
448
469
  @contextmanager
449
470
  def apsg_conf_context(**kwargs):
@@ -1,5 +1,7 @@
1
1
  import sys
2
2
 
3
+ import numpy as np
4
+
3
5
  from apsg.feature._container import (
4
6
  ArcSet,
5
7
  ClusterSet,
@@ -106,4 +108,10 @@ def feature_from_json(obj_json):
106
108
  else:
107
109
  args.append(arg)
108
110
  kwargs = obj_json.get("kwargs", {})
111
+ if dtype_cls in (Stress2, Stress3):
112
+ coefs = args[0]
113
+ if "stress_convention" not in obj_json:
114
+ # files written before the mechanical storage hold the geological matrix
115
+ coefs = (-np.asarray(coefs, dtype=float)).tolist()
116
+ return dtype_cls._from_canonical(coefs, **kwargs)
109
117
  return dtype_cls(*args, **kwargs)
@@ -4,6 +4,7 @@ from os.path import basename
4
4
 
5
5
  import matplotlib.pyplot as plt
6
6
  import numpy as np
7
+ from scipy import linalg as spla
7
8
  from scipy import stats
8
9
  from scipy.cluster.hierarchy import dendrogram, fcluster, linkage
9
10
  from scipy.integrate import quad
@@ -11,7 +12,7 @@ from scipy.optimize import root_scalar
11
12
  from scipy.spatial.distance import cdist
12
13
  from scipy.spatial.transform import Rotation
13
14
 
14
- from apsg.config import apsg_conf
15
+ from apsg.config import apsg_conf, stress_sign
15
16
  from apsg.feature._geodata import (
16
17
  Arc,
17
18
  Cone,
@@ -33,7 +34,7 @@ from apsg.feature._tensor3 import (
33
34
  Rotation3,
34
35
  Stress3,
35
36
  )
36
- from apsg.helpers._math import acosd, atand
37
+ from apsg.helpers._math import acosd, atan2d, atand, cosd, sind
37
38
  from apsg.math._vector import Axial2, Axial3, Vector2, Vector3
38
39
 
39
40
  _WATSON_U2_ALPHA = np.array([0.005, 0.01, 0.025, 0.05, 0.10])
@@ -71,12 +72,17 @@ def _mean_tensor(tensor_set, level, normalize, anisoft):
71
72
  Shared implementation of ``EllipsoidSet.mean_tensor`` and
72
73
  ``Stress3Set.mean_tensor``.
73
74
  """
75
+ tensor_cls = tensor_set.__feature_class__
74
76
  result = jelinek_statistics(
75
77
  np.array([np.asarray(t) for t in tensor_set]),
76
78
  level=level,
77
79
  normalize=normalize,
78
80
  anisoft=anisoft,
79
81
  )
82
+ eigenvalues = result["eigenvalues"]
83
+ if issubclass(tensor_cls, (Stress2, Stress3)):
84
+ # internal matrices are mechanical; report eigenvalues in the active convention
85
+ eigenvalues = stress_sign() * eigenvalues
80
86
  ellipses = tuple(
81
87
  {
82
88
  "mu": Vector3(e["mu"]),
@@ -87,8 +93,8 @@ def _mean_tensor(tensor_set, level, normalize, anisoft):
87
93
  for which, e in enumerate(result["ellipses"])
88
94
  )
89
95
  return {
90
- "mean": tensor_set.__feature_class__(result["mean"]),
91
- "eigenvalues": result["eigenvalues"],
96
+ "mean": tensor_cls._from_canonical(result["mean"]),
97
+ "eigenvalues": eigenvalues,
92
98
  "ellipses": ellipses,
93
99
  "n": result["n"],
94
100
  "level": result["level"],
@@ -2263,6 +2269,45 @@ class EllipseSet(FeatureSet):
2263
2269
  """
2264
2270
  return type(self)([e.transform(F) for e in self], name=self.name)
2265
2271
 
2272
+ def rfphi(self) -> Ellipse:
2273
+ """Return strain ellipse from the Rf/phi analytical vector-mean method.
2274
+
2275
+ Doubles each ellipse orientation (ellipses have 180° periodicity) and
2276
+ averages ``ln(Rf)`` in that doubled-angle Cartesian space before
2277
+ converting back, following the standard Rf/phi vector-mean technique:
2278
+
2279
+ x_i = ln(Rf_i) * cos(2 * phi_i)
2280
+ y_i = ln(Rf_i) * sin(2 * phi_i)
2281
+ Rs = exp(sqrt(mean(x)**2 + mean(y)**2))
2282
+ phi_s = atan2d(mean(y), mean(x)) / 2
2283
+
2284
+ Returns:
2285
+ Ellipse: strain ellipse with axial ratio ``Rs`` and orientation ``phi_s``.
2286
+ """
2287
+ phi2 = np.radians(2 * self.orientation)
2288
+ x = np.log(self.ar) * np.cos(phi2)
2289
+ y = np.log(self.ar) * np.sin(phi2)
2290
+ xbar, ybar = x.mean(), y.mean()
2291
+ Rs = np.exp(np.sqrt(xbar**2 + ybar**2))
2292
+ phi_s = atan2d(ybar, xbar) / 2
2293
+ c, s = cosd(phi_s), sind(phi_s)
2294
+ R = np.array([[c, -s], [s, c]])
2295
+ return Ellipse(R @ np.diag([Rs, 1 / Rs]) @ R.T)
2296
+
2297
+ def robin(self) -> Ellipse:
2298
+ """Return mean strain ellipse using the log-matrix method of Robin (1977).
2299
+
2300
+ Averages the matrix logarithms of all tensors in this set and maps the
2301
+ result back with the matrix exponential (the log-Euclidean tensor mean),
2302
+ avoiding the distortion a naive linear average of the tensors themselves
2303
+ would introduce for anisotropic/high-strain ellipses.
2304
+
2305
+ Returns:
2306
+ Ellipse: mean strain ellipse.
2307
+ """
2308
+ mean_log = np.mean([spla.logm(np.asarray(e)) for e in self], axis=0)
2309
+ return Ellipse(spla.expm(mean_log).real)
2310
+
2266
2311
 
2267
2312
  class OrientationTensor2Set(EllipseSet):
2268
2313
  """
@@ -2515,6 +2560,20 @@ class EllipsoidSet(FeatureSet):
2515
2560
  """
2516
2561
  return type(self)([e.transform(F) for e in self], name=self.name)
2517
2562
 
2563
+ def robin(self) -> Ellipsoid:
2564
+ """Return mean strain ellipsoid using the log-matrix method of Robin (1977).
2565
+
2566
+ Averages the matrix logarithms of all tensors in this set and maps the
2567
+ result back with the matrix exponential (the log-Euclidean tensor mean),
2568
+ avoiding the distortion a naive linear average of the tensors themselves
2569
+ would introduce for anisotropic/high-strain ellipsoids.
2570
+
2571
+ Returns:
2572
+ Ellipsoid: mean strain ellipsoid.
2573
+ """
2574
+ mean_log = np.mean([spla.logm(np.asarray(e)) for e in self], axis=0)
2575
+ return Ellipsoid(spla.expm(mean_log).real)
2576
+
2518
2577
 
2519
2578
  class OrientationTensor3Set(EllipsoidSet):
2520
2579
  """
@@ -2713,7 +2772,9 @@ class Stress3Set(FeatureSet):
2713
2772
 
2714
2773
  Returns:
2715
2774
  dict: with keys ``mean`` (mean tensor), ``eigenvalues`` (of the
2716
- mean tensor, descending), ``ellipses`` (tuple of three dicts, one
2775
+ mean tensor, descending; for stress sets the sign follows
2776
+ ``apsg_conf.stress_convention``, index-aligned with ``ellipses``),
2777
+ ``ellipses`` (tuple of three dicts, one
2717
2778
  for each principal axis of the mean tensor, 0 is the largest
2718
2779
  eigenvalue, with keys ``mu`` (principal axis), ``axes`` (tuple of
2719
2780
  the two ellipse axes, perpendicular to ``mu``), ``gamma`` (tuple