plagioclase 1.0.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.
- plagioclase-1.0.0/.gitignore +62 -0
- plagioclase-1.0.0/LICENSE +47 -0
- plagioclase-1.0.0/PKG-INFO +143 -0
- plagioclase-1.0.0/README.md +55 -0
- plagioclase-1.0.0/pyproject.toml +132 -0
- plagioclase-1.0.0/src/plag/__init__.py +120 -0
- plagioclase-1.0.0/src/plag/core.py +557 -0
- plagioclase-1.0.0/src/plag/data/cherniak_watson_1994.csv +46 -0
- plagioclase-1.0.0/src/plag/data/example_data.csv +260 -0
- plagioclase-1.0.0/src/plag/data/faak_2013.csv +78 -0
- plagioclase-1.0.0/src/plag/data/giletti_1994.csv +123 -0
- plagioclase-1.0.0/src/plag/data/grocolas_2025.csv +28 -0
- plagioclase-1.0.0/src/plag/data/van_orman_2014.csv +25 -0
- plagioclase-1.0.0/src/plag/diffusivities.py +1451 -0
- plagioclase-1.0.0/src/plag/example_data.py +110 -0
- plagioclase-1.0.0/src/plag/experimental_data.py +158 -0
- plagioclase-1.0.0/src/plag/model.py +3371 -0
- plagioclase-1.0.0/src/plag/partitioning.py +1034 -0
- plagioclase-1.0.0/src/plag/plotting.py +522 -0
- plagioclase-1.0.0/src/plag/py.typed +0 -0
- plagioclase-1.0.0/src/plag/solvers.py +1031 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
wheels/
|
|
12
|
+
MANIFEST
|
|
13
|
+
|
|
14
|
+
# Installer logs
|
|
15
|
+
pip-log.txt
|
|
16
|
+
pip-delete-this-directory.txt
|
|
17
|
+
|
|
18
|
+
# Virtual environments
|
|
19
|
+
.venv/
|
|
20
|
+
venv/
|
|
21
|
+
ENV/
|
|
22
|
+
env/
|
|
23
|
+
|
|
24
|
+
# IDE / editor
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
*.swp
|
|
28
|
+
*.swo
|
|
29
|
+
*~
|
|
30
|
+
.DS_Store
|
|
31
|
+
|
|
32
|
+
# Testing / coverage
|
|
33
|
+
.pytest_cache/
|
|
34
|
+
.test_output/
|
|
35
|
+
htmlcov/
|
|
36
|
+
.coverage
|
|
37
|
+
.coverage.*
|
|
38
|
+
coverage.xml
|
|
39
|
+
*.cover
|
|
40
|
+
|
|
41
|
+
# Jupyter
|
|
42
|
+
.ipynb_checkpoints/
|
|
43
|
+
|
|
44
|
+
# mypy / type checking
|
|
45
|
+
.mypy_cache/
|
|
46
|
+
.pytype/
|
|
47
|
+
|
|
48
|
+
# Ruff
|
|
49
|
+
.ruff_cache/
|
|
50
|
+
|
|
51
|
+
# MkDocs site output
|
|
52
|
+
site/
|
|
53
|
+
|
|
54
|
+
# tox / nox
|
|
55
|
+
.tox/
|
|
56
|
+
.nox/
|
|
57
|
+
|
|
58
|
+
# cache files
|
|
59
|
+
.cache
|
|
60
|
+
|
|
61
|
+
# kiro
|
|
62
|
+
.kiro
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
License
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
Unless otherwise noted, This project is in the public domain in the United
|
|
5
|
+
States because it contains materials that originally came from the United
|
|
6
|
+
States Geological Survey, an agency of the United States Department of
|
|
7
|
+
Interior. For more information, see the official USGS copyright policy at
|
|
8
|
+
https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits
|
|
9
|
+
|
|
10
|
+
Additionally, we waive copyright and related rights in the work
|
|
11
|
+
worldwide through the CC0 1.0 Universal public domain dedication.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
CC0 1.0 Universal Summary
|
|
15
|
+
-------------------------
|
|
16
|
+
|
|
17
|
+
This is a human-readable summary of the
|
|
18
|
+
[Legal Code (read the full text)][1].
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### No Copyright
|
|
22
|
+
|
|
23
|
+
The person who associated a work with this deed has dedicated the work to
|
|
24
|
+
the public domain by waiving all of his or her rights to the work worldwide
|
|
25
|
+
under copyright law, including all related and neighboring rights, to the
|
|
26
|
+
extent allowed by law.
|
|
27
|
+
|
|
28
|
+
You can copy, modify, distribute and perform the work, even for commercial
|
|
29
|
+
purposes, all without asking permission.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Other Information
|
|
33
|
+
|
|
34
|
+
In no way are the patent or trademark rights of any person affected by CC0,
|
|
35
|
+
nor are the rights that other persons may have in the work or in how the
|
|
36
|
+
work is used, such as publicity or privacy rights.
|
|
37
|
+
|
|
38
|
+
Unless expressly stated otherwise, the person who associated a work with
|
|
39
|
+
this deed makes no warranties about the work, and disclaims liability for
|
|
40
|
+
all uses of the work, to the fullest extent permitted by applicable law.
|
|
41
|
+
When using or citing the work, you should not imply endorsement by the
|
|
42
|
+
author or the affirmer.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
[1]: https://creativecommons.org/publicdomain/zero/1.0/legalcode
|
|
47
|
+
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: plagioclase
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: For modeling diffusion in plagioclase
|
|
5
|
+
Project-URL: Homepage, https://vsc.code-pages.usgs.gov/petro/tools/plag
|
|
6
|
+
Project-URL: Repository, https://code.usgs.gov/vsc/petro/tools/plag
|
|
7
|
+
Author-email: Jordan Lubbers <jelubber@gmail.com>
|
|
8
|
+
License: License
|
|
9
|
+
=======
|
|
10
|
+
|
|
11
|
+
Unless otherwise noted, This project is in the public domain in the United
|
|
12
|
+
States because it contains materials that originally came from the United
|
|
13
|
+
States Geological Survey, an agency of the United States Department of
|
|
14
|
+
Interior. For more information, see the official USGS copyright policy at
|
|
15
|
+
https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits
|
|
16
|
+
|
|
17
|
+
Additionally, we waive copyright and related rights in the work
|
|
18
|
+
worldwide through the CC0 1.0 Universal public domain dedication.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
CC0 1.0 Universal Summary
|
|
22
|
+
-------------------------
|
|
23
|
+
|
|
24
|
+
This is a human-readable summary of the
|
|
25
|
+
[Legal Code (read the full text)][1].
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### No Copyright
|
|
29
|
+
|
|
30
|
+
The person who associated a work with this deed has dedicated the work to
|
|
31
|
+
the public domain by waiving all of his or her rights to the work worldwide
|
|
32
|
+
under copyright law, including all related and neighboring rights, to the
|
|
33
|
+
extent allowed by law.
|
|
34
|
+
|
|
35
|
+
You can copy, modify, distribute and perform the work, even for commercial
|
|
36
|
+
purposes, all without asking permission.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Other Information
|
|
40
|
+
|
|
41
|
+
In no way are the patent or trademark rights of any person affected by CC0,
|
|
42
|
+
nor are the rights that other persons may have in the work or in how the
|
|
43
|
+
work is used, such as publicity or privacy rights.
|
|
44
|
+
|
|
45
|
+
Unless expressly stated otherwise, the person who associated a work with
|
|
46
|
+
this deed makes no warranties about the work, and disclaims liability for
|
|
47
|
+
all uses of the work, to the fullest extent permitted by applicable law.
|
|
48
|
+
When using or citing the work, you should not imply endorsement by the
|
|
49
|
+
author or the affirmer.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
[1]: https://creativecommons.org/publicdomain/zero/1.0/legalcode
|
|
54
|
+
|
|
55
|
+
License-File: LICENSE
|
|
56
|
+
Keywords: diffusion modeling,geochemistry,plagioclase,trace elements
|
|
57
|
+
Classifier: Development Status :: 4 - Beta
|
|
58
|
+
Classifier: Operating System :: OS Independent
|
|
59
|
+
Classifier: Programming Language :: Python :: 3
|
|
60
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
61
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
62
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
63
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
64
|
+
Classifier: Topic :: Scientific/Engineering
|
|
65
|
+
Requires-Python: >=3.10
|
|
66
|
+
Requires-Dist: joblib>=1.3
|
|
67
|
+
Requires-Dist: matplotlib>=3.7
|
|
68
|
+
Requires-Dist: numba>=0.58
|
|
69
|
+
Requires-Dist: numpy>=1.24
|
|
70
|
+
Requires-Dist: openpyxl>=3.1
|
|
71
|
+
Requires-Dist: pandas>=2.0
|
|
72
|
+
Requires-Dist: scipy>=1.10
|
|
73
|
+
Requires-Dist: statsmodels>=0.14
|
|
74
|
+
Requires-Dist: tqdm>=4.60
|
|
75
|
+
Provides-Extra: dev
|
|
76
|
+
Requires-Dist: arviz>=0.15; extra == 'dev'
|
|
77
|
+
Requires-Dist: lasertram; extra == 'dev'
|
|
78
|
+
Requires-Dist: pymc>=5.0; extra == 'dev'
|
|
79
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
80
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
81
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
82
|
+
Provides-Extra: docs
|
|
83
|
+
Requires-Dist: mkdocs-jupyter; extra == 'docs'
|
|
84
|
+
Requires-Dist: mkdocs-material<10,>=9.7.5; extra == 'docs'
|
|
85
|
+
Requires-Dist: mkdocs<2,>=1.6; extra == 'docs'
|
|
86
|
+
Requires-Dist: mkdocstrings[python]; extra == 'docs'
|
|
87
|
+
Description-Content-Type: text/markdown
|
|
88
|
+
|
|
89
|
+
# `plag` — diffusion modeling in plagioclase
|
|
90
|
+
|
|
91
|
+
A Python library for building and running trace-element diffusion models in plagioclase feldspar.
|
|
92
|
+
|
|
93
|
+
For complete documentation please see [vsc.code-pages.usgs.gov/petro/tools/plag](https://vsc.code-pages.usgs.gov/petro/tools/plag).
|
|
94
|
+
|
|
95
|
+
*docs only available on internal USGS network for now, but will be made public in the future*
|
|
96
|
+
|
|
97
|
+
## Motivation
|
|
98
|
+
|
|
99
|
+
Diffusion chronometry in plagioclase is a powerful tool for constraining the timescales of magmatic processes. It is fairly ubiquitous in igneous systems, crystallizing over a wide range of $P-T-X-fO_2$ conditions, and has chronometers that span orders of magnitude allowing for the quantification of a range of timescales (i.e., days - millennia). Furthermore, many parameters to help aid in petrologic investigations (partition coefficients for calculating melt composition proxies) and diffusion studies (diffusion coefficients) can be calculated by only having knowledge of the plagioclase composition, temperature, and basic melt composition, making it a powerful tool in the petrologist toolkit. This, however, is where the fun seemingly ends. While these observations are incredibly useful, their numerical implementation is not exactly straightforward, and setting up forward diffusion models involves many interrelated steps: choosing partitioning and diffusivity models, constructing initial profiles, running finite-difference simulations, and propagating analytical and temperature uncertainties through Monte Carlo resampling.
|
|
100
|
+
|
|
101
|
+
`plag` wraps this entire workflow into a single, coherent API so that you can focus on the science rather than the bookkeeping.
|
|
102
|
+
|
|
103
|
+
### Goals
|
|
104
|
+
|
|
105
|
+
1. Provide a structured, reproducible workflow for calculations involving trace-element diffusion modeling in plagioclase.
|
|
106
|
+
2. Make it easy to compare different partitioning and diffusivity parameterisations from the literature.
|
|
107
|
+
3. Propagate uncertainties rigorously via Monte Carlo methods with random sampling that incorporates the covariance structure of the data that determines all the parameters utilized in the random sampling (e.g., $RT\ln{K_d} = A(\pm \sigma_A)\cdot X_{An} + B(\pm \sigma_B)$).
|
|
108
|
+
4. Take advantage of `numba` accelerated finite-difference solvers for fast forward modeling on a standard personal computer.
|
|
109
|
+
|
|
110
|
+
## Installation
|
|
111
|
+
|
|
112
|
+
It is recommended to do this in a fresh virtual environment:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Create a virtual environment (conda example)
|
|
116
|
+
conda create -n diffusion-modeling python=3.13
|
|
117
|
+
conda activate diffusion-modeling
|
|
118
|
+
|
|
119
|
+
# Install from PyPI
|
|
120
|
+
pip install plagioclase
|
|
121
|
+
|
|
122
|
+
# Install from source
|
|
123
|
+
git clone https://code.usgs.gov/vsc/petro/tools/plag.git
|
|
124
|
+
cd plag
|
|
125
|
+
pip install .
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For development (includes pytest, pytest-cov, ruff):
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install -e ".[dev]"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Citation
|
|
135
|
+
|
|
136
|
+
If you use `plag` in your research, please cite it:
|
|
137
|
+
|
|
138
|
+
> Lubbers, J. (2026) `plag`, version 1.0.0: U.S. Geological Survey software release https://doi.org/10.5066/P13OEK4A
|
|
139
|
+
|
|
140
|
+
## To do
|
|
141
|
+
|
|
142
|
+
See [todo.md](todo.md) for the full list of outstanding work items, each annotated with implementation guidance.
|
|
143
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# `plag` — diffusion modeling in plagioclase
|
|
2
|
+
|
|
3
|
+
A Python library for building and running trace-element diffusion models in plagioclase feldspar.
|
|
4
|
+
|
|
5
|
+
For complete documentation please see [vsc.code-pages.usgs.gov/petro/tools/plag](https://vsc.code-pages.usgs.gov/petro/tools/plag).
|
|
6
|
+
|
|
7
|
+
*docs only available on internal USGS network for now, but will be made public in the future*
|
|
8
|
+
|
|
9
|
+
## Motivation
|
|
10
|
+
|
|
11
|
+
Diffusion chronometry in plagioclase is a powerful tool for constraining the timescales of magmatic processes. It is fairly ubiquitous in igneous systems, crystallizing over a wide range of $P-T-X-fO_2$ conditions, and has chronometers that span orders of magnitude allowing for the quantification of a range of timescales (i.e., days - millennia). Furthermore, many parameters to help aid in petrologic investigations (partition coefficients for calculating melt composition proxies) and diffusion studies (diffusion coefficients) can be calculated by only having knowledge of the plagioclase composition, temperature, and basic melt composition, making it a powerful tool in the petrologist toolkit. This, however, is where the fun seemingly ends. While these observations are incredibly useful, their numerical implementation is not exactly straightforward, and setting up forward diffusion models involves many interrelated steps: choosing partitioning and diffusivity models, constructing initial profiles, running finite-difference simulations, and propagating analytical and temperature uncertainties through Monte Carlo resampling.
|
|
12
|
+
|
|
13
|
+
`plag` wraps this entire workflow into a single, coherent API so that you can focus on the science rather than the bookkeeping.
|
|
14
|
+
|
|
15
|
+
### Goals
|
|
16
|
+
|
|
17
|
+
1. Provide a structured, reproducible workflow for calculations involving trace-element diffusion modeling in plagioclase.
|
|
18
|
+
2. Make it easy to compare different partitioning and diffusivity parameterisations from the literature.
|
|
19
|
+
3. Propagate uncertainties rigorously via Monte Carlo methods with random sampling that incorporates the covariance structure of the data that determines all the parameters utilized in the random sampling (e.g., $RT\ln{K_d} = A(\pm \sigma_A)\cdot X_{An} + B(\pm \sigma_B)$).
|
|
20
|
+
4. Take advantage of `numba` accelerated finite-difference solvers for fast forward modeling on a standard personal computer.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
It is recommended to do this in a fresh virtual environment:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Create a virtual environment (conda example)
|
|
28
|
+
conda create -n diffusion-modeling python=3.13
|
|
29
|
+
conda activate diffusion-modeling
|
|
30
|
+
|
|
31
|
+
# Install from PyPI
|
|
32
|
+
pip install plagioclase
|
|
33
|
+
|
|
34
|
+
# Install from source
|
|
35
|
+
git clone https://code.usgs.gov/vsc/petro/tools/plag.git
|
|
36
|
+
cd plag
|
|
37
|
+
pip install .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For development (includes pytest, pytest-cov, ruff):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e ".[dev]"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Citation
|
|
47
|
+
|
|
48
|
+
If you use `plag` in your research, please cite it:
|
|
49
|
+
|
|
50
|
+
> Lubbers, J. (2026) `plag`, version 1.0.0: U.S. Geological Survey software release https://doi.org/10.5066/P13OEK4A
|
|
51
|
+
|
|
52
|
+
## To do
|
|
53
|
+
|
|
54
|
+
See [todo.md](todo.md) for the full list of outstanding work items, each annotated with implementation guidance.
|
|
55
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "plagioclase"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
authors = [{name = "Jordan Lubbers", email = "jelubber@gmail.com"}]
|
|
9
|
+
description = "For modeling diffusion in plagioclase"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"numpy>=1.24",
|
|
15
|
+
"numba>=0.58",
|
|
16
|
+
"matplotlib>=3.7",
|
|
17
|
+
"statsmodels>=0.14",
|
|
18
|
+
"scipy>=1.10",
|
|
19
|
+
"pandas>=2.0",
|
|
20
|
+
"openpyxl>=3.1",
|
|
21
|
+
"tqdm>=4.60",
|
|
22
|
+
"joblib>=1.3",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
# How mature is this project? Common values are
|
|
26
|
+
# 3 - Alpha
|
|
27
|
+
# 4 - Beta
|
|
28
|
+
# 5 - Production/Stable
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Topic :: Scientific/Engineering",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
|
|
38
|
+
]
|
|
39
|
+
keywords = ["plagioclase","diffusion modeling","geochemistry","trace elements"]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://vsc.code-pages.usgs.gov/petro/tools/plag"
|
|
43
|
+
Repository = "https://code.usgs.gov/vsc/petro/tools/plag"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
[project.optional-dependencies]
|
|
47
|
+
dev = [
|
|
48
|
+
"pytest>=7.0",
|
|
49
|
+
"pytest-cov",
|
|
50
|
+
"ruff",
|
|
51
|
+
"pymc>=5.0",
|
|
52
|
+
"arviz>=0.15",
|
|
53
|
+
"lasertram",
|
|
54
|
+
]
|
|
55
|
+
docs = [
|
|
56
|
+
"mkdocs>=1.6,<2",
|
|
57
|
+
"mkdocs-material>=9.7.5,<10",
|
|
58
|
+
"mkdocstrings[python]",
|
|
59
|
+
"mkdocs-jupyter",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
addopts = "-v --tb=short -m 'not notebooks'"
|
|
66
|
+
markers = [
|
|
67
|
+
"slow: computationally expensive tests (solvers, MC, convergence)",
|
|
68
|
+
"notebooks: end-to-end notebook execution tests (slow, requires docs extras)",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.hatch.version]
|
|
72
|
+
path = "src/plag/__init__.py"
|
|
73
|
+
|
|
74
|
+
[tool.hatch.build.targets.sdist]
|
|
75
|
+
include = [
|
|
76
|
+
"/src",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.hatch.build.targets.wheel]
|
|
80
|
+
packages = ["src/plag"]
|
|
81
|
+
|
|
82
|
+
# ── Linting & Formatting ─────────────────────────────────────────────
|
|
83
|
+
[tool.ruff]
|
|
84
|
+
target-version = "py310"
|
|
85
|
+
line-length = 100
|
|
86
|
+
src = ["src", "tests"]
|
|
87
|
+
|
|
88
|
+
[tool.ruff.lint]
|
|
89
|
+
select = [
|
|
90
|
+
"E", # pycodestyle errors
|
|
91
|
+
"W", # pycodestyle warnings
|
|
92
|
+
"F", # pyflakes
|
|
93
|
+
"I", # isort
|
|
94
|
+
"UP", # pyupgrade
|
|
95
|
+
"B", # flake8-bugbear
|
|
96
|
+
"SIM", # flake8-simplify
|
|
97
|
+
"NPY", # numpy-specific rules
|
|
98
|
+
]
|
|
99
|
+
ignore = [
|
|
100
|
+
"E501", # line too long (handled by formatter)
|
|
101
|
+
"B905", # zip-strict (not needed for scientific code)
|
|
102
|
+
"SIM108", # ternary operator (readability preference)
|
|
103
|
+
"SIM102", # collapsible-if (readability preference for guard clauses)
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
[tool.ruff.lint.isort]
|
|
107
|
+
known-first-party = ["plag"]
|
|
108
|
+
|
|
109
|
+
[tool.ruff.lint.per-file-ignores]
|
|
110
|
+
"docs/examples/*.ipynb" = [
|
|
111
|
+
"E402", # module-level import not at top of cell (normal in notebooks)
|
|
112
|
+
"E741", # ambiguous variable name 'l' (common loop var for plot labels)
|
|
113
|
+
"NPY002", # legacy np.random (gradual migration)
|
|
114
|
+
]
|
|
115
|
+
"tests/*" = [
|
|
116
|
+
"NPY002", # legacy np.random in test fixtures (gradual migration)
|
|
117
|
+
]
|
|
118
|
+
"src/plag/core.py" = [
|
|
119
|
+
"NPY002", # fallback path for backward compat when no rng passed
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[tool.ruff.format]
|
|
123
|
+
quote-style = "double"
|
|
124
|
+
|
|
125
|
+
# ── Coverage ─────────────────────────────────────────────────────────
|
|
126
|
+
[tool.coverage.run]
|
|
127
|
+
source = ["plag"]
|
|
128
|
+
|
|
129
|
+
[tool.coverage.report]
|
|
130
|
+
show_missing = true
|
|
131
|
+
omit = ["tests/*"]
|
|
132
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""
|
|
2
|
+
plag — diffusion modelling in plagioclase.
|
|
3
|
+
|
|
4
|
+
A Python toolkit for trace-element diffusion chronometry in
|
|
5
|
+
plagioclase feldspar. Provides diffusivity parameterisations,
|
|
6
|
+
partitioning models, explicit finite-difference solvers, and
|
|
7
|
+
Monte-Carlo uncertainty propagation.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
__version__ = "1.0.0"
|
|
13
|
+
|
|
14
|
+
# Bundled experimental data (lazy submodule)
|
|
15
|
+
from . import experimental_data
|
|
16
|
+
|
|
17
|
+
# Core utilities
|
|
18
|
+
from .core import (
|
|
19
|
+
cl_to_cs,
|
|
20
|
+
cs_to_cl,
|
|
21
|
+
cs_to_rtlncl,
|
|
22
|
+
fit_model,
|
|
23
|
+
linear_regression_with_uncertainty,
|
|
24
|
+
make_tgrid,
|
|
25
|
+
random_profile,
|
|
26
|
+
rtlncl_to_cs,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Diffusion coefficients
|
|
30
|
+
from .diffusivities import (
|
|
31
|
+
cherniak_watson_diffusivity,
|
|
32
|
+
cherniak_watson_diffusivity_random,
|
|
33
|
+
costa_diffusivity,
|
|
34
|
+
faak_diffusivity,
|
|
35
|
+
faak_diffusivity_random,
|
|
36
|
+
giletti_casserly_diffusivity,
|
|
37
|
+
giletti_casserly_diffusivity_druitt,
|
|
38
|
+
giletti_diffusivity_random,
|
|
39
|
+
grocolas_diffusivity,
|
|
40
|
+
grocolas_diffusivity_random,
|
|
41
|
+
van_orman_diffusivity,
|
|
42
|
+
van_orman_diffusivity_random,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Example datasets
|
|
46
|
+
from .example_data import load_example_data
|
|
47
|
+
|
|
48
|
+
# Main model class
|
|
49
|
+
from .model import PlagDiffusionModel
|
|
50
|
+
|
|
51
|
+
# Partitioning / Kd models
|
|
52
|
+
from .partitioning import (
|
|
53
|
+
bindeman_kd_calc,
|
|
54
|
+
dohmen_activity_calc,
|
|
55
|
+
dohmen_kd_calc,
|
|
56
|
+
dohmen_kd_calc_lepr,
|
|
57
|
+
generate_random_activities,
|
|
58
|
+
mutch_A_calc,
|
|
59
|
+
mutch_B_calc,
|
|
60
|
+
mutch_kd_calc,
|
|
61
|
+
plag_activity_calc,
|
|
62
|
+
plag_eq_prof,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Numerical solvers
|
|
66
|
+
from .solvers import (
|
|
67
|
+
diffuse_forward_plag,
|
|
68
|
+
diffuse_forward_plag_cn,
|
|
69
|
+
diffuse_forward_plag_lazy,
|
|
70
|
+
diffuse_forward_plag_lazy_cn,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
74
|
+
|
|
75
|
+
__all__ = [
|
|
76
|
+
# core
|
|
77
|
+
"fit_model",
|
|
78
|
+
"make_tgrid",
|
|
79
|
+
"random_profile",
|
|
80
|
+
"linear_regression_with_uncertainty",
|
|
81
|
+
"cs_to_rtlncl",
|
|
82
|
+
"rtlncl_to_cs",
|
|
83
|
+
"cs_to_cl",
|
|
84
|
+
"cl_to_cs",
|
|
85
|
+
# diffusivities
|
|
86
|
+
"faak_diffusivity",
|
|
87
|
+
"faak_diffusivity_random",
|
|
88
|
+
"van_orman_diffusivity",
|
|
89
|
+
"costa_diffusivity",
|
|
90
|
+
"giletti_casserly_diffusivity",
|
|
91
|
+
"giletti_casserly_diffusivity_druitt",
|
|
92
|
+
"cherniak_watson_diffusivity",
|
|
93
|
+
"cherniak_watson_diffusivity_random",
|
|
94
|
+
"grocolas_diffusivity",
|
|
95
|
+
"giletti_diffusivity_random",
|
|
96
|
+
"grocolas_diffusivity_random",
|
|
97
|
+
"van_orman_diffusivity_random",
|
|
98
|
+
# partitioning
|
|
99
|
+
"bindeman_kd_calc",
|
|
100
|
+
"dohmen_kd_calc",
|
|
101
|
+
"dohmen_kd_calc_lepr",
|
|
102
|
+
"mutch_kd_calc",
|
|
103
|
+
"mutch_A_calc",
|
|
104
|
+
"mutch_B_calc",
|
|
105
|
+
"plag_activity_calc",
|
|
106
|
+
"dohmen_activity_calc",
|
|
107
|
+
"plag_eq_prof",
|
|
108
|
+
"generate_random_activities",
|
|
109
|
+
# solvers
|
|
110
|
+
"diffuse_forward_plag",
|
|
111
|
+
"diffuse_forward_plag_cn",
|
|
112
|
+
"diffuse_forward_plag_lazy",
|
|
113
|
+
"diffuse_forward_plag_lazy_cn",
|
|
114
|
+
# model
|
|
115
|
+
"PlagDiffusionModel",
|
|
116
|
+
# example data
|
|
117
|
+
"load_example_data",
|
|
118
|
+
# experimental data
|
|
119
|
+
"experimental_data",
|
|
120
|
+
]
|