mesas 2.0.0a1__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.
- mesas-2.0.0a1/.gitignore +41 -0
- mesas-2.0.0a1/CITATION.cff +32 -0
- mesas-2.0.0a1/LICENSE.txt +22 -0
- mesas-2.0.0a1/PKG-INFO +83 -0
- mesas-2.0.0a1/README.md +40 -0
- mesas-2.0.0a1/doc/Makefile +19 -0
- mesas-2.0.0a1/doc/concepts.rst +128 -0
- mesas-2.0.0a1/doc/conf.py +80 -0
- mesas-2.0.0a1/doc/config.rst +55 -0
- mesas-2.0.0a1/doc/fig/QS.png +0 -0
- mesas-2.0.0a1/doc/fig/sas_spec.png +0 -0
- mesas-2.0.0a1/doc/functions.rst +6 -0
- mesas-2.0.0a1/doc/index.rst +77 -0
- mesas-2.0.0a1/doc/inputs.rst +153 -0
- mesas-2.0.0a1/doc/installation.rst +49 -0
- mesas-2.0.0a1/doc/make.bat +35 -0
- mesas-2.0.0a1/doc/model.rst +6 -0
- mesas-2.0.0a1/doc/options.rst +95 -0
- mesas-2.0.0a1/doc/quickstart.rst +162 -0
- mesas-2.0.0a1/doc/results.rst +140 -0
- mesas-2.0.0a1/doc/sasspec.rst +245 -0
- mesas-2.0.0a1/doc/solspec.rst +91 -0
- mesas-2.0.0a1/doc/specs.rst +5 -0
- mesas-2.0.0a1/examples/data.csv +101 -0
- mesas-2.0.0a1/examples/quickstart.py +31 -0
- mesas-2.0.0a1/mesas/__init__.py +13 -0
- mesas-2.0.0a1/mesas/me/__init__.py +0 -0
- mesas-2.0.0a1/mesas/me/recursive_split.py +514 -0
- mesas-2.0.0a1/mesas/sas/__init__.py +0 -0
- mesas-2.0.0a1/mesas/sas/_solve_numba.py +1297 -0
- mesas-2.0.0a1/mesas/sas/functions.py +828 -0
- mesas-2.0.0a1/mesas/sas/model.py +1193 -0
- mesas-2.0.0a1/mesas/sas/specs.py +471 -0
- mesas-2.0.0a1/mesas/utils/__init__.py +0 -0
- mesas-2.0.0a1/mesas/utils/vis.py +361 -0
- mesas-2.0.0a1/pyproject.toml +116 -0
- mesas-2.0.0a1/test/MeSASInputHourly.csv +35066 -0
- mesas-2.0.0a1/test/__init__.py +0 -0
- mesas-2.0.0a1/test/conftest.py +13 -0
- mesas-2.0.0a1/test/test_benchmark.py +711 -0
- mesas-2.0.0a1/test/test_benchmark2.py +769 -0
- mesas-2.0.0a1/test/test_evapoconcentration.py +98 -0
- mesas-2.0.0a1/test/test_examples.py +40 -0
- mesas-2.0.0a1/test/test_gamma_table.py +123 -0
- mesas-2.0.0a1/test/test_phase1_fixes.py +167 -0
- mesas-2.0.0a1/test/test_phase4_validation.py +125 -0
- mesas-2.0.0a1/test/test_record_options.py +241 -0
- mesas-2.0.0a1/test/test_stage0_benchmarks.py +233 -0
- mesas-2.0.0a1/test/test_stage0_edge_cases.py +203 -0
- mesas-2.0.0a1/test/test_stage0_examples.py +76 -0
- mesas-2.0.0a1/test/test_stage0_mass_balance.py +203 -0
- mesas-2.0.0a1/test/test_stage0_performance.py +104 -0
- mesas-2.0.0a1/test/test_stage6_property.py +288 -0
- mesas-2.0.0a1/test/test_stage6_recursive_split.py +172 -0
- mesas-2.0.0a1/test/test_stage6_sas_functions.py +428 -0
- mesas-2.0.0a1/test/test_stage6_time_varying.py +414 -0
- mesas-2.0.0a1/test/test_time.py +741 -0
- mesas-2.0.0a1/test/test_time2.py +791 -0
- mesas-2.0.0a1/test/test_vis_smoke.py +120 -0
- mesas-2.0.0a1/test/unsteady_data.csv +5844 -0
mesas-2.0.0a1/.gitignore
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
build/
|
|
3
|
+
builddir/
|
|
4
|
+
dist/
|
|
5
|
+
mesas.egg-info/
|
|
6
|
+
*.so
|
|
7
|
+
*.pyc
|
|
8
|
+
__pycache__/
|
|
9
|
+
|
|
10
|
+
# Editor/IDE
|
|
11
|
+
*.swo
|
|
12
|
+
*.swp
|
|
13
|
+
/.idea/
|
|
14
|
+
/.vscode/
|
|
15
|
+
/.claude/
|
|
16
|
+
|
|
17
|
+
# Project-specific excludes
|
|
18
|
+
misc/
|
|
19
|
+
/mesas/junk/
|
|
20
|
+
/mesas/dev/
|
|
21
|
+
/doc/_build/
|
|
22
|
+
*/_build/*
|
|
23
|
+
examples/benchmark/Ciaran/
|
|
24
|
+
examples/miniLEO
|
|
25
|
+
debug/
|
|
26
|
+
|
|
27
|
+
# Generated files
|
|
28
|
+
*.log
|
|
29
|
+
test/test.log
|
|
30
|
+
test/*.pdf
|
|
31
|
+
examples/Archive.zip
|
|
32
|
+
examples/data_with_results.csv
|
|
33
|
+
test/MESASct.py
|
|
34
|
+
.coverage
|
|
35
|
+
*.egg-info/
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
|
|
38
|
+
# Hypothesis property-testing cache
|
|
39
|
+
.hypothesis/
|
|
40
|
+
.ruff_cache/
|
|
41
|
+
.DS_Store
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it using the metadata from this file, and cite the accompanying paper (see preferred-citation)."
|
|
3
|
+
type: software
|
|
4
|
+
title: "mesas.py: Multiscale Estimation of StorAge Selection"
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: "Harman"
|
|
7
|
+
given-names: "Ciaran J."
|
|
8
|
+
orcid: "https://orcid.org/0000-0002-3185-002X"
|
|
9
|
+
affiliation: "Johns Hopkins University"
|
|
10
|
+
- family-names: "Xu Fei"
|
|
11
|
+
given-names: "Esther"
|
|
12
|
+
affiliation: "Johns Hopkins University"
|
|
13
|
+
repository-code: "https://github.com/charman2/mesas"
|
|
14
|
+
url: "https://mesas.readthedocs.io/"
|
|
15
|
+
license: MIT
|
|
16
|
+
preferred-citation:
|
|
17
|
+
type: article
|
|
18
|
+
title: "mesas.py v1.0: a flexible Python package for modeling solute transport and transit times using StorAge Selection functions"
|
|
19
|
+
authors:
|
|
20
|
+
- family-names: "Harman"
|
|
21
|
+
given-names: "Ciaran J."
|
|
22
|
+
orcid: "https://orcid.org/0000-0002-3185-002X"
|
|
23
|
+
affiliation: "Johns Hopkins University"
|
|
24
|
+
- family-names: "Xu Fei"
|
|
25
|
+
given-names: "Esther"
|
|
26
|
+
affiliation: "Johns Hopkins University"
|
|
27
|
+
journal: "Geoscientific Model Development"
|
|
28
|
+
volume: 17
|
|
29
|
+
start: 477
|
|
30
|
+
end: 495
|
|
31
|
+
year: 2024
|
|
32
|
+
doi: "10.5194/gmd-17-477-2024"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Ciaran J. Harman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
mesas-2.0.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mesas
|
|
3
|
+
Version: 2.0.0a1
|
|
4
|
+
Summary: MESAS - Multiscale Estimation of StorAge Selection.
|
|
5
|
+
Project-URL: homepage, https://mesas.readthedocs.io/
|
|
6
|
+
Project-URL: documentation, https://mesas.readthedocs.io/
|
|
7
|
+
Project-URL: repository, https://github.com/charman2/mesas
|
|
8
|
+
Author: Ciaran J. Harman
|
|
9
|
+
Author-email: charman1@jhu.edu
|
|
10
|
+
Maintainer: Ciaran J. Harman
|
|
11
|
+
Maintainer-email: charman1@jhu.edu
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE.txt
|
|
14
|
+
Keywords: SAS,Storage selection functions,hydrology
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: matplotlib
|
|
27
|
+
Requires-Dist: numba
|
|
28
|
+
Requires-Dist: numpy>1.22
|
|
29
|
+
Requires-Dist: pandas
|
|
30
|
+
Requires-Dist: scipy
|
|
31
|
+
Provides-Extra: docs
|
|
32
|
+
Requires-Dist: sphinx-copybutton; extra == 'docs'
|
|
33
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
|
|
34
|
+
Requires-Dist: sphinx>=7.0; extra == 'docs'
|
|
35
|
+
Provides-Extra: estimation
|
|
36
|
+
Requires-Dist: scikit-learn; extra == 'estimation'
|
|
37
|
+
Provides-Extra: test
|
|
38
|
+
Requires-Dist: hypothesis; extra == 'test'
|
|
39
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
|
40
|
+
Requires-Dist: pytest>=7.0; extra == 'test'
|
|
41
|
+
Requires-Dist: scikit-learn; extra == 'test'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# mesas.py
|
|
45
|
+
|
|
46
|
+
StorAge Selection is a theoretical framework for modeling transport through control volumes. It is appropriate if you are interested a system that can be treated as a single control volume (or a collection of such), and wish to make minimal assumptions about the internal organization of the transport. SAS assumes that the material leaving a system is some combination of the material that entered at earlier times. This can be useful for constructing simple models of very complicated flow systems, and for inferring the emergent transport properties of a system from tracer data.
|
|
47
|
+
|
|
48
|
+
For more information see the free HydroLearn course: [Tracers and transit times in time-variable hydrologic systems: A gentle introduction to the StorAge Selection (SAS) approach](https://edx.hydrolearn.org/courses/course-v1:JHU+570.412+Sp2020)
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
### Stable release (v1.0, Fortran)
|
|
53
|
+
|
|
54
|
+
The current stable release on conda-forge is the older Fortran-based v1.0:
|
|
55
|
+
|
|
56
|
+
conda install -c conda-forge mesas
|
|
57
|
+
|
|
58
|
+
This installs any additional dependencies at the same time.
|
|
59
|
+
|
|
60
|
+
### v2.0 (pure Python, in beta)
|
|
61
|
+
|
|
62
|
+
Version 2.0 is a pure Python reimplementation whose numerical solver is
|
|
63
|
+
JIT-compiled with [Numba](https://numba.pydata.org/) -- no Fortran compiler
|
|
64
|
+
needed. It is currently in beta. Install the latest development version from
|
|
65
|
+
source:
|
|
66
|
+
|
|
67
|
+
git clone https://github.com/charman2/mesas.git
|
|
68
|
+
cd mesas
|
|
69
|
+
pip install -e .
|
|
70
|
+
|
|
71
|
+
Further instructions can be found here: https://mesas.readthedocs.io/en/latest/installation.html
|
|
72
|
+
|
|
73
|
+
## Documentation
|
|
74
|
+
|
|
75
|
+
Documentation for the code is available here: https://mesas.readthedocs.io/en/latest/
|
|
76
|
+
|
|
77
|
+
## Citation
|
|
78
|
+
|
|
79
|
+
If you use mesas.py in your research, please cite:
|
|
80
|
+
|
|
81
|
+
Harman, C. J. and Xu Fei, E.: mesas.py v1.0: a flexible Python package for modeling solute transport and transit times using StorAge Selection functions, Geosci. Model Dev., 17, 477-495, https://doi.org/10.5194/gmd-17-477-2024, 2024.
|
|
82
|
+
|
|
83
|
+
[](https://zenodo.org/badge/latestdoi/183813641)
|
mesas-2.0.0a1/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# mesas.py
|
|
2
|
+
|
|
3
|
+
StorAge Selection is a theoretical framework for modeling transport through control volumes. It is appropriate if you are interested a system that can be treated as a single control volume (or a collection of such), and wish to make minimal assumptions about the internal organization of the transport. SAS assumes that the material leaving a system is some combination of the material that entered at earlier times. This can be useful for constructing simple models of very complicated flow systems, and for inferring the emergent transport properties of a system from tracer data.
|
|
4
|
+
|
|
5
|
+
For more information see the free HydroLearn course: [Tracers and transit times in time-variable hydrologic systems: A gentle introduction to the StorAge Selection (SAS) approach](https://edx.hydrolearn.org/courses/course-v1:JHU+570.412+Sp2020)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Stable release (v1.0, Fortran)
|
|
10
|
+
|
|
11
|
+
The current stable release on conda-forge is the older Fortran-based v1.0:
|
|
12
|
+
|
|
13
|
+
conda install -c conda-forge mesas
|
|
14
|
+
|
|
15
|
+
This installs any additional dependencies at the same time.
|
|
16
|
+
|
|
17
|
+
### v2.0 (pure Python, in beta)
|
|
18
|
+
|
|
19
|
+
Version 2.0 is a pure Python reimplementation whose numerical solver is
|
|
20
|
+
JIT-compiled with [Numba](https://numba.pydata.org/) -- no Fortran compiler
|
|
21
|
+
needed. It is currently in beta. Install the latest development version from
|
|
22
|
+
source:
|
|
23
|
+
|
|
24
|
+
git clone https://github.com/charman2/mesas.git
|
|
25
|
+
cd mesas
|
|
26
|
+
pip install -e .
|
|
27
|
+
|
|
28
|
+
Further instructions can be found here: https://mesas.readthedocs.io/en/latest/installation.html
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
Documentation for the code is available here: https://mesas.readthedocs.io/en/latest/
|
|
33
|
+
|
|
34
|
+
## Citation
|
|
35
|
+
|
|
36
|
+
If you use mesas.py in your research, please cite:
|
|
37
|
+
|
|
38
|
+
Harman, C. J. and Xu Fei, E.: mesas.py v1.0: a flexible Python package for modeling solute transport and transit times using StorAge Selection functions, Geosci. Model Dev., 17, 477-495, https://doi.org/10.5194/gmd-17-477-2024, 2024.
|
|
39
|
+
|
|
40
|
+
[](https://zenodo.org/badge/latestdoi/183813641)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line.
|
|
5
|
+
SPHINXOPTS =
|
|
6
|
+
SPHINXBUILD = sphinx-build
|
|
7
|
+
SOURCEDIR = .
|
|
8
|
+
BUILDDIR = _build
|
|
9
|
+
|
|
10
|
+
# Put it first so that "make" without argument is like "make help".
|
|
11
|
+
help:
|
|
12
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
13
|
+
|
|
14
|
+
.PHONY: help Makefile
|
|
15
|
+
|
|
16
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
17
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
18
|
+
%: Makefile
|
|
19
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
.. _concepts:
|
|
2
|
+
|
|
3
|
+
========
|
|
4
|
+
Concepts
|
|
5
|
+
========
|
|
6
|
+
|
|
7
|
+
This page introduces the StorAge Selection (SAS) framework at a level
|
|
8
|
+
appropriate for users of the package. For the full mathematical
|
|
9
|
+
treatment, see `Harman (2015) <https://doi.org/10.1002/2014WR015707>`_
|
|
10
|
+
and `Benettin et al. (2022) <https://doi.org/10.5194/gmd-15-3881-2022>`_
|
|
11
|
+
and `Harman and Xu Fei (2024) <https://gmd.copernicus.org/articles/17/477/2024/>`_.
|
|
12
|
+
|
|
13
|
+
What is StorAge Selection?
|
|
14
|
+
==========================
|
|
15
|
+
|
|
16
|
+
StorAge Selection (SAS) is a framework for modeling transport through a
|
|
17
|
+
control volume — a catchment, a soil column, a lake, or any system
|
|
18
|
+
where fluid enters, is stored, and eventually leaves.
|
|
19
|
+
|
|
20
|
+
The key idea is simple: **at each moment in time, the water leaving a
|
|
21
|
+
system is a mixture of water that entered at different times in the
|
|
22
|
+
past.** The SAS function describes *which ages of water are
|
|
23
|
+
preferentially selected for discharge*.
|
|
24
|
+
|
|
25
|
+
Age-ranked storage
|
|
26
|
+
==================
|
|
27
|
+
|
|
28
|
+
The foundation of SAS is the concept of **age-ranked storage**. At any
|
|
29
|
+
time :math:`t`, the water in storage can be sorted by how long it has been
|
|
30
|
+
in the system. We define:
|
|
31
|
+
|
|
32
|
+
.. math::
|
|
33
|
+
|
|
34
|
+
S_T(T, t) = \int_0^T s_T(\tau, t)\, d\tau
|
|
35
|
+
|
|
36
|
+
where :math:`s_T(\tau, t)` is the density of water of age :math:`\tau`
|
|
37
|
+
in storage at time :math:`t`, and :math:`S_T(T, t)` is the cumulative
|
|
38
|
+
storage up to age :math:`T`. The total storage is
|
|
39
|
+
:math:`S(t) = S_T(\infty, t)`.
|
|
40
|
+
|
|
41
|
+
The SAS function
|
|
42
|
+
================
|
|
43
|
+
|
|
44
|
+
The **SAS function** :math:`\Omega_Q(S_T, t)` is a cumulative
|
|
45
|
+
distribution function that maps age-ranked storage to cumulative
|
|
46
|
+
probability:
|
|
47
|
+
|
|
48
|
+
.. math::
|
|
49
|
+
|
|
50
|
+
\Omega_Q(S_T, t) = P(\text{discharged water has age-ranked storage} \leq S_T)
|
|
51
|
+
|
|
52
|
+
When :math:`\Omega_Q` is a straight line from 0 to :math:`S(t)`, all
|
|
53
|
+
ages of water are equally likely to be discharged — this is the
|
|
54
|
+
**well-mixed** case. When :math:`\Omega_Q` rises steeply at small
|
|
55
|
+
:math:`S_T`, young water is preferentially discharged. When it rises
|
|
56
|
+
steeply near :math:`S(t)`, old water is preferred.
|
|
57
|
+
|
|
58
|
+
The backward transit time distribution for outflow :math:`Q` is:
|
|
59
|
+
|
|
60
|
+
.. math::
|
|
61
|
+
|
|
62
|
+
p_Q(T, t) = \frac{\partial \Omega_Q}{\partial S_T} \cdot s_T(T, t)
|
|
63
|
+
|
|
64
|
+
Types of SAS functions
|
|
65
|
+
======================
|
|
66
|
+
|
|
67
|
+
MESAS supports several types of SAS functions:
|
|
68
|
+
|
|
69
|
+
**Piecewise-linear**
|
|
70
|
+
Defined by breakpoints in :math:`(S_T, P)` space. The simplest is a
|
|
71
|
+
uniform distribution: ``"ST": [0, S_max]``. Adding more breakpoints
|
|
72
|
+
creates more complex shapes.
|
|
73
|
+
|
|
74
|
+
**Gamma distribution**
|
|
75
|
+
A flexible one-parameter family. The shape parameter :math:`a`
|
|
76
|
+
controls whether young water (:math:`a < 1`) or intermediate-aged
|
|
77
|
+
water (:math:`a > 1`) is preferentially discharged.
|
|
78
|
+
Specified with ``"func": "gamma"``.
|
|
79
|
+
|
|
80
|
+
**Beta distribution**
|
|
81
|
+
Defined over a finite interval, useful when total storage volume is
|
|
82
|
+
known. Has two shape parameters :math:`a` and :math:`b`.
|
|
83
|
+
Specified with ``"func": "beta"``.
|
|
84
|
+
|
|
85
|
+
**Kumaraswamy distribution**
|
|
86
|
+
Similar to the beta but with a closed-form CDF, making it
|
|
87
|
+
computationally efficient.
|
|
88
|
+
Specified with ``"func": "kumaraswamy"``.
|
|
89
|
+
|
|
90
|
+
All distribution-based SAS functions accept ``loc`` and ``scale``
|
|
91
|
+
parameters that shift and stretch the distribution along the
|
|
92
|
+
:math:`S_T` axis.
|
|
93
|
+
|
|
94
|
+
Solute transport
|
|
95
|
+
================
|
|
96
|
+
|
|
97
|
+
Once the water fluxes are solved, solute transport follows
|
|
98
|
+
directly. The concentration of water of a given age in storage
|
|
99
|
+
determines the concentration of the outflow:
|
|
100
|
+
|
|
101
|
+
.. math::
|
|
102
|
+
|
|
103
|
+
C_Q(t) = \int_0^\infty \frac{m_T(T,t)}{s_T(T,t)} \, p_Q(T,t) \, dT
|
|
104
|
+
|
|
105
|
+
where :math:`m_T(T,t)` is the age-ranked solute mass in storage.
|
|
106
|
+
|
|
107
|
+
MESAS also supports:
|
|
108
|
+
|
|
109
|
+
- **First-order reactions** via ``k1`` and ``C_eq`` parameters
|
|
110
|
+
- **Evapoconcentration** via the ``alpha`` parameter
|
|
111
|
+
- **Multiple solutes** tracked simultaneously
|
|
112
|
+
|
|
113
|
+
Time-varying parameters
|
|
114
|
+
========================
|
|
115
|
+
|
|
116
|
+
Any SAS function or solute parameter can be made time-varying by
|
|
117
|
+
setting its value to a string that names a column in the input
|
|
118
|
+
DataFrame. For example, setting ``"scale": "S_0"`` in a gamma
|
|
119
|
+
specification causes the scale parameter to be read from the ``"S_0"``
|
|
120
|
+
column at each timestep.
|
|
121
|
+
|
|
122
|
+
Further reading
|
|
123
|
+
===============
|
|
124
|
+
|
|
125
|
+
- `Harman (2015) <https://doi.org/10.1002/2014WR015707>`_ — Original SAS theory paper
|
|
126
|
+
- `Harman and Xu Fei (2024) <https://gmd.copernicus.org/articles/17/477/2024/>`_ — Unified framework for age and transit time distributions
|
|
127
|
+
- `Benettin et al. (2022) <https://doi.org/10.5194/gmd-15-3881-2022>`_ — MESAS model description paper (GMD)
|
|
128
|
+
- `HydroLearn course <https://edx.hydrolearn.org/courses/course-v1:JHU+570.412+Sp2020>`_ — Free online course on SAS theory
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
# Make the package importable for autodoc
|
|
7
|
+
sys.path.insert(0, os.path.abspath(".."))
|
|
8
|
+
|
|
9
|
+
# -- Project information -----------------------------------------------------
|
|
10
|
+
|
|
11
|
+
project = "MESAS"
|
|
12
|
+
copyright = "2019–2026, Ciaran J. Harman"
|
|
13
|
+
author = "Ciaran J. Harman"
|
|
14
|
+
|
|
15
|
+
# Pull version from pyproject.toml metadata
|
|
16
|
+
try:
|
|
17
|
+
from importlib.metadata import version as _get_version
|
|
18
|
+
|
|
19
|
+
release = _get_version("mesas")
|
|
20
|
+
except Exception:
|
|
21
|
+
release = "dev"
|
|
22
|
+
version = release
|
|
23
|
+
|
|
24
|
+
# -- General configuration ---------------------------------------------------
|
|
25
|
+
|
|
26
|
+
extensions = [
|
|
27
|
+
"sphinx.ext.autodoc",
|
|
28
|
+
"sphinx.ext.doctest",
|
|
29
|
+
"sphinx.ext.intersphinx",
|
|
30
|
+
"sphinx.ext.mathjax",
|
|
31
|
+
"sphinx.ext.viewcode",
|
|
32
|
+
"sphinx.ext.napoleon",
|
|
33
|
+
"sphinx_copybutton",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
templates_path = ["_templates"]
|
|
37
|
+
source_suffix = ".rst"
|
|
38
|
+
master_doc = "index"
|
|
39
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
40
|
+
pygments_style = "sphinx"
|
|
41
|
+
|
|
42
|
+
# -- Autodoc configuration ---------------------------------------------------
|
|
43
|
+
|
|
44
|
+
autodoc_member_order = "bysource"
|
|
45
|
+
autodoc_typehints = "description"
|
|
46
|
+
autodoc_default_options = {
|
|
47
|
+
"members": True,
|
|
48
|
+
"show-inheritance": True,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# -- Napoleon (NumPy docstring) configuration --------------------------------
|
|
52
|
+
|
|
53
|
+
napoleon_google_docstring = False
|
|
54
|
+
napoleon_numpy_docstring = True
|
|
55
|
+
napoleon_use_param = True
|
|
56
|
+
napoleon_use_rtype = True
|
|
57
|
+
|
|
58
|
+
# -- Options for HTML output -------------------------------------------------
|
|
59
|
+
|
|
60
|
+
html_theme = "sphinx_rtd_theme"
|
|
61
|
+
html_theme_options = {
|
|
62
|
+
"logo_only": False,
|
|
63
|
+
"prev_next_buttons_location": "bottom",
|
|
64
|
+
"style_nav_header_background": "#1E74AE",
|
|
65
|
+
"collapse_navigation": False,
|
|
66
|
+
"sticky_navigation": True,
|
|
67
|
+
"navigation_depth": 4,
|
|
68
|
+
"includehidden": False,
|
|
69
|
+
"titles_only": False,
|
|
70
|
+
}
|
|
71
|
+
html_static_path = ["_static"]
|
|
72
|
+
|
|
73
|
+
# -- Options for intersphinx -------------------------------------------------
|
|
74
|
+
|
|
75
|
+
intersphinx_mapping = {
|
|
76
|
+
"python": ("https://docs.python.org/3/", None),
|
|
77
|
+
"numpy": ("https://numpy.org/doc/stable/", None),
|
|
78
|
+
"pandas": ("https://pandas.pydata.org/docs/", None),
|
|
79
|
+
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
|
|
80
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.. _config:
|
|
2
|
+
|
|
3
|
+
=====================
|
|
4
|
+
Configuring the model
|
|
5
|
+
=====================
|
|
6
|
+
|
|
7
|
+
To run `mesas.py` the user must provide some information about how the model is to be configured. First, at least one SAS function must be specified. In addition you may wish to provide information about solutes to be transported through the system, and/or modify the default model options.
|
|
8
|
+
|
|
9
|
+
The recommended way of providing configuration data is in a text file formatted using the `JSON standard <https://www.json.org/json-en.html>`_. Typically this file is called something like ``config.json``. The contents look very much like a python ``dict``, with some differences. A minimal example of a configuration file is a text file containing the following text:
|
|
10
|
+
|
|
11
|
+
.. code-block:: json
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
"sas_specs":{
|
|
15
|
+
"Flux out":{
|
|
16
|
+
"SAS fun":{
|
|
17
|
+
"ST": [0, 100]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
This specifies a single uniform SAS function between 0 and 100 associated with the flux named ``"Flux out"``.
|
|
25
|
+
|
|
26
|
+
`mesas.py` looks for three top-level entries in the file:
|
|
27
|
+
|
|
28
|
+
* ``"sas_specs"``: spcification of the SAS functions (see :ref:`sasspec`)
|
|
29
|
+
* ``"solute_parameters"``: information about solutes to be transported through the system (see :ref:`solspec`)
|
|
30
|
+
* ``"options"``: optional arguments for customizing the model run (see :ref:`options`)
|
|
31
|
+
|
|
32
|
+
For more information click the links above. Here is an example of the contents of a ``config.json`` file that uses all three of these top-level fields.
|
|
33
|
+
|
|
34
|
+
.. code-block:: json
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
"sas_specs":{
|
|
38
|
+
"Flux out":{
|
|
39
|
+
"SAS fun":{
|
|
40
|
+
"ST": [0, 100]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
"solute_parameters":{
|
|
46
|
+
"solute A":{
|
|
47
|
+
"C_old": 0.5
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
"options":{
|
|
52
|
+
"dt": 3600
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
.. MESAS documentation master file, created by sphinx-quickstart on Thu Sep 12 19:57:56 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive.
|
|
2
|
+
|
|
3
|
+
=====
|
|
4
|
+
MESAS
|
|
5
|
+
=====
|
|
6
|
+
Multiscale Estimation of StorAge Selection functions
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
What are StorAge Selection functions?
|
|
10
|
+
-------------------------------------
|
|
11
|
+
|
|
12
|
+
StorAge Selection is a theoretical framework for modeling transport through control volumes. It is appropriate if you are interested a system that can be treated as a single control volume (or a collection of such), and wish to make minimal assumptions about the internal organization of the transport. SAS assumes that the material leaving a system is some combination of the material that entered at earlier times. This can be useful for constructing simple models of very complicated flow systems, and for inferring the emergent transport properties of a system from tracer data.
|
|
13
|
+
|
|
14
|
+
SAS is a very general framework -- at heart, it is composed of two parts: a way of keeping track of changes in the age structure of the 'population' of fluid parcels in a system, and a rule (or rules) that determines how that age structure changes. By using tracers to investigate what rule best mimics the behaviour of a given system, we can learn important information about that system -- most directly, something about the volume of tracer-transporting fluid that is actively 'turning over'. SAS is a generalization of commonly-used transit time theory to the case where fluxes vary in time, and there may be more than one outflow (e.g. discharge and ET).
|
|
15
|
+
|
|
16
|
+
For more information see the free HydroLearn course: `Tracers and transit times in time-variable hydrologic systems: A gentle introduction to the StorAge Selection (SAS) approach <https://edx.hydrolearn.org/courses/course-v1:JHU+570.412+Sp2020>`_
|
|
17
|
+
|
|
18
|
+
What is mesas.py?
|
|
19
|
+
-----------------
|
|
20
|
+
|
|
21
|
+
The package will eventually include a number of component tools for building SAS models and using them to analyze tracer data.
|
|
22
|
+
|
|
23
|
+
Currently the main repository codebase includes three submodules:
|
|
24
|
+
|
|
25
|
+
mesas.sas
|
|
26
|
+
The main submodule for building and running SAS models
|
|
27
|
+
mesas.utils
|
|
28
|
+
Tools for manipulating SAS model input data and results
|
|
29
|
+
mesas.utils.vis
|
|
30
|
+
Visualization of SAS model results
|
|
31
|
+
|
|
32
|
+
I hope to expand these in the future, and welcome contributors through the `GitHub repository <https://github.com/charman2/mesas>`_
|
|
33
|
+
|
|
34
|
+
Support, bugs, suggestions, etc.
|
|
35
|
+
--------------------------------
|
|
36
|
+
If you find a bug please open an issue on GitHub here: https://github.com/charman2/mesas/issues
|
|
37
|
+
|
|
38
|
+
You can also use the issue tracer to make suggestions to improve the code.
|
|
39
|
+
|
|
40
|
+
If you need further help using the code or interpreting the results, please get in touch: charman1 at jhu dot edu
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Table of contents
|
|
44
|
+
-----------------
|
|
45
|
+
.. toctree::
|
|
46
|
+
:maxdepth: 2
|
|
47
|
+
:caption: Getting started
|
|
48
|
+
|
|
49
|
+
installation
|
|
50
|
+
quickstart
|
|
51
|
+
concepts
|
|
52
|
+
|
|
53
|
+
.. toctree::
|
|
54
|
+
:maxdepth: 2
|
|
55
|
+
:caption: User guide
|
|
56
|
+
|
|
57
|
+
inputs
|
|
58
|
+
config
|
|
59
|
+
sasspec
|
|
60
|
+
solspec
|
|
61
|
+
options
|
|
62
|
+
results
|
|
63
|
+
|
|
64
|
+
.. toctree::
|
|
65
|
+
:maxdepth: 2
|
|
66
|
+
:caption: Reference
|
|
67
|
+
|
|
68
|
+
functions.rst
|
|
69
|
+
specs.rst
|
|
70
|
+
model.rst
|
|
71
|
+
|
|
72
|
+
Indices and tables
|
|
73
|
+
==================
|
|
74
|
+
|
|
75
|
+
* :ref:`genindex`
|
|
76
|
+
* :ref:`modindex`
|
|
77
|
+
* :ref:`search`
|