tidewater 0.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 (164) hide show
  1. tidewater-0.1.0/.gitignore +18 -0
  2. tidewater-0.1.0/CITATION.cff +19 -0
  3. tidewater-0.1.0/LICENSE +29 -0
  4. tidewater-0.1.0/PKG-INFO +438 -0
  5. tidewater-0.1.0/README.md +400 -0
  6. tidewater-0.1.0/docs/api.md +226 -0
  7. tidewater-0.1.0/docs/conf.py +27 -0
  8. tidewater-0.1.0/docs/contract.md +7 -0
  9. tidewater-0.1.0/docs/conventions.md +73 -0
  10. tidewater-0.1.0/docs/data.md +127 -0
  11. tidewater-0.1.0/docs/examples.md +134 -0
  12. tidewater-0.1.0/docs/figures/data/greenland_ne50m.csv +491 -0
  13. tidewater-0.1.0/docs/figures/greenland_coast.py +32 -0
  14. tidewater-0.1.0/docs/figures/results.py +501 -0
  15. tidewater-0.1.0/docs/figures/schematics.py +377 -0
  16. tidewater-0.1.0/docs/figures/style.py +147 -0
  17. tidewater-0.1.0/docs/getting-started.md +7 -0
  18. tidewater-0.1.0/docs/hosts-glogem.md +152 -0
  19. tidewater-0.1.0/docs/hosts-pygem.md +165 -0
  20. tidewater-0.1.0/docs/hosts.md +178 -0
  21. tidewater-0.1.0/docs/how-it-works.md +86 -0
  22. tidewater-0.1.0/docs/img/calving-front.png +0 -0
  23. tidewater-0.1.0/docs/img/calving-front.svg +2942 -0
  24. tidewater-0.1.0/docs/img/coupling-routes.png +0 -0
  25. tidewater-0.1.0/docs/img/coupling-routes.svg +3524 -0
  26. tidewater-0.1.0/docs/img/example-calibration.png +0 -0
  27. tidewater-0.1.0/docs/img/example-calibration.svg +2486 -0
  28. tidewater-0.1.0/docs/img/example-forcing.png +0 -0
  29. tidewater-0.1.0/docs/img/example-forcing.svg +2360 -0
  30. tidewater-0.1.0/docs/img/example-historical.png +0 -0
  31. tidewater-0.1.0/docs/img/example-historical.svg +2498 -0
  32. tidewater-0.1.0/docs/img/example-map.png +0 -0
  33. tidewater-0.1.0/docs/img/example-map.svg +4050 -0
  34. tidewater-0.1.0/docs/img/example-ocean.png +0 -0
  35. tidewater-0.1.0/docs/img/example-ocean.svg +1747 -0
  36. tidewater-0.1.0/docs/img/example-projection.png +0 -0
  37. tidewater-0.1.0/docs/img/example-projection.svg +5258 -0
  38. tidewater-0.1.0/docs/img/example-scatter.png +0 -0
  39. tidewater-0.1.0/docs/img/example-scatter.svg +2067 -0
  40. tidewater-0.1.0/docs/img/host-contract.png +0 -0
  41. tidewater-0.1.0/docs/img/host-contract.svg +2167 -0
  42. tidewater-0.1.0/docs/img/model-years.png +0 -0
  43. tidewater-0.1.0/docs/img/model-years.svg +2714 -0
  44. tidewater-0.1.0/docs/img/nested-laws.png +0 -0
  45. tidewater-0.1.0/docs/img/nested-laws.svg +2934 -0
  46. tidewater-0.1.0/docs/img/overview.png +0 -0
  47. tidewater-0.1.0/docs/img/overview.svg +3433 -0
  48. tidewater-0.1.0/docs/index.md +49 -0
  49. tidewater-0.1.0/docs/laws.md +11 -0
  50. tidewater-0.1.0/docs/project.md +13 -0
  51. tidewater-0.1.0/docs/references.md +227 -0
  52. tidewater-0.1.0/docs/regions.md +69 -0
  53. tidewater-0.1.0/docs/spec.md +2 -0
  54. tidewater-0.1.0/examples/README.md +19 -0
  55. tidewater-0.1.0/examples/case.json +45 -0
  56. tidewater-0.1.0/examples/example_case.py +68 -0
  57. tidewater-0.1.0/examples/glogem/README.md +44 -0
  58. tidewater-0.1.0/examples/glogem/run_glogem.py +46 -0
  59. tidewater-0.1.0/examples/oggm/README.md +39 -0
  60. tidewater-0.1.0/examples/oggm/run_oggm.py +73 -0
  61. tidewater-0.1.0/examples/pygem/README.md +50 -0
  62. tidewater-0.1.0/examples/pygem/run_pygem.py +64 -0
  63. tidewater-0.1.0/examples/results/05-09345/README.md +22 -0
  64. tidewater-0.1.0/examples/results/05-09345/forcing.csv +3061 -0
  65. tidewater-0.1.0/examples/results/05-09345/forcing.json +85 -0
  66. tidewater-0.1.0/examples/results/05-09345/glogem.csv +550 -0
  67. tidewater-0.1.0/examples/results/05-09345/map/front.csv +2 -0
  68. tidewater-0.1.0/examples/results/05-09345/map/ocean_cells.csv +2 -0
  69. tidewater-0.1.0/examples/results/05-09345/map/outline.csv +876 -0
  70. tidewater-0.1.0/examples/results/05-09345/map/water_depth.nc +0 -0
  71. tidewater-0.1.0/examples/results/05-09345/oggm.csv +469 -0
  72. tidewater-0.1.0/examples/results/05-09345/pygem.csv +469 -0
  73. tidewater-0.1.0/examples/results/synthetic/calibration.csv +7 -0
  74. tidewater-0.1.0/examples/results/synthetic/forcing.csv +4909 -0
  75. tidewater-0.1.0/examples/results/synthetic/forcing.json +53 -0
  76. tidewater-0.1.0/examples/results/synthetic/map/flowline.csv +31 -0
  77. tidewater-0.1.0/examples/results/synthetic/map/front.csv +3 -0
  78. tidewater-0.1.0/examples/results/synthetic/map/ocean_cells.csv +8 -0
  79. tidewater-0.1.0/examples/results/synthetic/map/outline.csv +81 -0
  80. tidewater-0.1.0/examples/results/synthetic/map/water_depth.nc +0 -0
  81. tidewater-0.1.0/examples/results/synthetic/toy_factor_table.csv +365 -0
  82. tidewater-0.1.0/examples/results/synthetic/toy_law_each_step.csv +365 -0
  83. tidewater-0.1.0/examples/results/synthetic/toy_yearly_constant.csv +365 -0
  84. tidewater-0.1.0/examples/synthetic/README.md +32 -0
  85. tidewater-0.1.0/examples/synthetic/make_inputs.py +177 -0
  86. tidewater-0.1.0/examples/synthetic/run.py +86 -0
  87. tidewater-0.1.0/examples/synthetic/toy_host.py +165 -0
  88. tidewater-0.1.0/pyproject.toml +73 -0
  89. tidewater-0.1.0/src/tidewater/__init__.py +6 -0
  90. tidewater-0.1.0/src/tidewater/bed.py +264 -0
  91. tidewater-0.1.0/src/tidewater/calibration/__init__.py +23 -0
  92. tidewater-0.1.0/src/tidewater/calibration/covariates.py +307 -0
  93. tidewater-0.1.0/src/tidewater/calibration/dynamic.py +751 -0
  94. tidewater-0.1.0/src/tidewater/calibration/permutation.py +50 -0
  95. tidewater-0.1.0/src/tidewater/calibration/static.py +410 -0
  96. tidewater-0.1.0/src/tidewater/calibration/targets.py +310 -0
  97. tidewater-0.1.0/src/tidewater/config.py +213 -0
  98. tidewater-0.1.0/src/tidewater/export.py +411 -0
  99. tidewater-0.1.0/src/tidewater/forcing/__init__.py +8 -0
  100. tidewater-0.1.0/src/tidewater/forcing/__main__.py +5 -0
  101. tidewater-0.1.0/src/tidewater/forcing/bands.py +437 -0
  102. tidewater-0.1.0/src/tidewater/forcing/bias.py +72 -0
  103. tidewater-0.1.0/src/tidewater/forcing/build.py +210 -0
  104. tidewater-0.1.0/src/tidewater/forcing/cli.py +147 -0
  105. tidewater-0.1.0/src/tidewater/forcing/discharge.py +83 -0
  106. tidewater-0.1.0/src/tidewater/forcing/fill.py +306 -0
  107. tidewater-0.1.0/src/tidewater/forcing/footprint.py +388 -0
  108. tidewater-0.1.0/src/tidewater/forcing/io.py +532 -0
  109. tidewater-0.1.0/src/tidewater/forcing/products.py +203 -0
  110. tidewater-0.1.0/src/tidewater/forcing/seaice.py +177 -0
  111. tidewater-0.1.0/src/tidewater/hosts/__init__.py +1 -0
  112. tidewater-0.1.0/src/tidewater/hosts/glogem/__init__.py +12 -0
  113. tidewater-0.1.0/src/tidewater/hosts/glogem/idl/tidewater_laws.pro +210 -0
  114. tidewater-0.1.0/src/tidewater/hosts/glogem/idl/tw_spec_check.pro +121 -0
  115. tidewater-0.1.0/src/tidewater/hosts/glogem/idl/tw_table_factor.pro +105 -0
  116. tidewater-0.1.0/src/tidewater/hosts/glogem/tables.py +164 -0
  117. tidewater-0.1.0/src/tidewater/hosts/oggm/__init__.py +42 -0
  118. tidewater-0.1.0/src/tidewater/hosts/oggm/bed.py +836 -0
  119. tidewater-0.1.0/src/tidewater/hosts/oggm/calibration.py +499 -0
  120. tidewater-0.1.0/src/tidewater/hosts/oggm/errors.py +50 -0
  121. tidewater-0.1.0/src/tidewater/hosts/oggm/forcing.py +332 -0
  122. tidewater-0.1.0/src/tidewater/hosts/oggm/inversion.py +731 -0
  123. tidewater-0.1.0/src/tidewater/hosts/oggm/laws.py +503 -0
  124. tidewater-0.1.0/src/tidewater/hosts/oggm/params.py +164 -0
  125. tidewater-0.1.0/src/tidewater/hosts/oggm/shop_bed.py +270 -0
  126. tidewater-0.1.0/src/tidewater/hosts/oggm/tasks.py +26 -0
  127. tidewater-0.1.0/src/tidewater/hosts/pygem/__init__.py +15 -0
  128. tidewater-0.1.0/src/tidewater/hosts/pygem/calibration.py +174 -0
  129. tidewater-0.1.0/src/tidewater/hosts/pygem/dynamics.py +333 -0
  130. tidewater-0.1.0/src/tidewater/hosts/pygem/glaciers.py +143 -0
  131. tidewater-0.1.0/src/tidewater/ids.py +160 -0
  132. tidewater-0.1.0/src/tidewater/laws.py +1187 -0
  133. tidewater-0.1.0/src/tidewater/periods.py +65 -0
  134. tidewater-0.1.0/src/tidewater/physics.py +365 -0
  135. tidewater-0.1.0/src/tidewater/spec/SPEC.md +306 -0
  136. tidewater-0.1.0/src/tidewater/spec/__init__.py +0 -0
  137. tidewater-0.1.0/src/tidewater/spec/make_vectors.py +264 -0
  138. tidewater-0.1.0/src/tidewater/spec/reference_vectors.csv +679 -0
  139. tidewater-0.1.0/src/tidewater/timeconv.py +348 -0
  140. tidewater-0.1.0/src/tidewater/units.py +90 -0
  141. tidewater-0.1.0/tests/conftest.py +5 -0
  142. tidewater-0.1.0/tests/hosts/glogem/test_glogem_host.py +277 -0
  143. tidewater-0.1.0/tests/hosts/oggm/test_oggm_host.py +2120 -0
  144. tidewater-0.1.0/tests/hosts/pygem/test_pygem_helpers.py +164 -0
  145. tidewater-0.1.0/tests/hosts/pygem/test_pygem_host.py +453 -0
  146. tidewater-0.1.0/tests/test_bed.py +163 -0
  147. tidewater-0.1.0/tests/test_calibration_covariates.py +173 -0
  148. tidewater-0.1.0/tests/test_calibration_dynamic.py +452 -0
  149. tidewater-0.1.0/tests/test_calibration_static.py +334 -0
  150. tidewater-0.1.0/tests/test_examples.py +116 -0
  151. tidewater-0.1.0/tests/test_export.py +204 -0
  152. tidewater-0.1.0/tests/test_forcing_build.py +346 -0
  153. tidewater-0.1.0/tests/test_forcing_fill.py +165 -0
  154. tidewater-0.1.0/tests/test_forcing_footprint.py +209 -0
  155. tidewater-0.1.0/tests/test_forcing_io.py +263 -0
  156. tidewater-0.1.0/tests/test_forcing_seaice.py +119 -0
  157. tidewater-0.1.0/tests/test_ids.py +99 -0
  158. tidewater-0.1.0/tests/test_laws.py +988 -0
  159. tidewater-0.1.0/tests/test_no_host_imports.py +49 -0
  160. tidewater-0.1.0/tests/test_periods.py +82 -0
  161. tidewater-0.1.0/tests/test_physics.py +377 -0
  162. tidewater-0.1.0/tests/test_spec.py +202 -0
  163. tidewater-0.1.0/tests/test_timeconv.py +231 -0
  164. tidewater-0.1.0/tests/test_units.py +116 -0
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ docs/_build/
6
+ dist/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+ .coverage
11
+ htmlcov/
12
+ .venv/
13
+ venv/
14
+ .ipynb_checkpoints/
15
+ .DS_Store
16
+ *.nc
17
+ !examples/results/*/map/*.nc
18
+ /glogem_tables/
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it using the metadata below."
3
+ title: "tidewater: ocean-forced frontal ablation for glacier models"
4
+ type: software
5
+ version: 0.1.0
6
+ date-released: 2026-10-11
7
+ license: BSD-3-Clause
8
+ repository-code: "https://github.com/MuhammadShafeeque/tidewater"
9
+ url: "https://tidewater.readthedocs.io"
10
+ authors:
11
+ - family-names: Shafeeque
12
+ given-names: Muhammad
13
+ - name: "tidewater contributors"
14
+ keywords:
15
+ - glacier model
16
+ - frontal ablation
17
+ - calving
18
+ - ocean thermal forcing
19
+ # A DOI and the preferred citation are added at the first archived release.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Muhammad Shafeeque and tidewater contributors
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its contributors
17
+ may be used to endorse or promote products derived from this software
18
+ without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,438 @@
1
+ Metadata-Version: 2.5
2
+ Name: tidewater
3
+ Version: 0.1.0
4
+ Summary: ocean-forced frontal ablation for glacier models
5
+ Project-URL: Documentation, https://tidewater.readthedocs.io
6
+ Project-URL: Repository, https://github.com/MuhammadShafeeque/tidewater
7
+ Project-URL: Issues, https://github.com/MuhammadShafeeque/tidewater/issues
8
+ Author: Muhammad Shafeeque, tidewater contributors
9
+ License-Expression: BSD-3-Clause
10
+ License-File: LICENSE
11
+ Keywords: calving,frontal ablation,glacier,ocean thermal forcing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: cftime
22
+ Requires-Dist: netcdf4
23
+ Requires-Dist: numpy
24
+ Requires-Dist: pandas
25
+ Requires-Dist: scipy
26
+ Requires-Dist: xarray
27
+ Provides-Extra: docs
28
+ Requires-Dist: furo; extra == 'docs'
29
+ Requires-Dist: myst-parser; extra == 'docs'
30
+ Requires-Dist: sphinx>=7; extra == 'docs'
31
+ Provides-Extra: plot
32
+ Requires-Dist: matplotlib; extra == 'plot'
33
+ Provides-Extra: teos10
34
+ Requires-Dist: gsw; extra == 'teos10'
35
+ Provides-Extra: test
36
+ Requires-Dist: pytest; extra == 'test'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # tidewater
40
+
41
+ **Ocean-forced frontal ablation for glacier models.**
42
+
43
+ [![PyPI](https://img.shields.io/pypi/v/tidewater.svg)](https://pypi.org/project/tidewater/)
44
+ [![Documentation](https://readthedocs.org/projects/tidewater/badge/?version=latest)](https://tidewater.readthedocs.io)
45
+ [![Tests](https://github.com/MuhammadShafeeque/tidewater/actions/workflows/tests.yml/badge.svg)](https://github.com/MuhammadShafeeque/tidewater/actions/workflows/tests.yml)
46
+ [![License: BSD-3-Clause](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/LICENSE)
47
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/pyproject.toml)
48
+ [![Status: alpha](https://img.shields.io/badge/status-alpha-orange.svg)](#project-status)
49
+
50
+ <!-- docs: intro -->
51
+ `tidewater` makes the frontal ablation of a marine-terminating glacier depend
52
+ on the ocean in front of it. It turns an ocean product into a thermal forcing
53
+ at each calving front, turns that forcing into a frontal ablation flux or a
54
+ dimensionless ocean factor, and calibrates the calving constant against
55
+ observed frontal ablation. It is a library for glacier models, not a glacier
56
+ model: the host model keeps its geometry, its dynamics and its mass budget.
57
+
58
+ - **Host-neutral.** The core imports no glacier model. Adapters for
59
+ [OGGM](https://github.com/OGGM/oggm),
60
+ [PyGEM](https://github.com/PyGEM-Community/PyGEM) and
61
+ [GloGEM](https://github.com/eth-vaw-glaciology/GloGEM) are included, and any
62
+ other model can couple through a plain-text table or the written spec.
63
+ - **Global.** No region, hemisphere, ocean product, bed product, observation
64
+ dataset, glacier inventory version or year convention is built in. They are
65
+ arguments.
66
+ - **Reproducible across languages.** The laws come with a specification and
67
+ 678 reference vectors, so an implementation in IDL, MATLAB or Fortran can be
68
+ checked against the Python one.
69
+
70
+ ## Contents
71
+
72
+ - [What it does](#what-it-does)
73
+ - [Supported glacier models](#supported-glacier-models)
74
+ - [Installation](#installation)
75
+ - [Quick start](#quick-start)
76
+ - [The laws](#the-laws)
77
+ - [Host integration contract](#host-integration-contract)
78
+ - [Bringing your own data](#bringing-your-own-data)
79
+ - [Documentation](#documentation)
80
+ - [Package layout](#package-layout)
81
+ - [Testing](#testing)
82
+ - [Project status](#project-status)
83
+ - [Contributing](#contributing)
84
+ - [Citing](#citing)
85
+ - [References](#references)
86
+ - [Licence and acknowledgements](#licence-and-acknowledgements)
87
+
88
+ <!-- docs: overview -->
89
+ ## What it does
90
+
91
+ ![From an ocean product to the host model: footprint, depth range, thermal
92
+ forcing, bias correction, ocean factor, law and host](https://raw.githubusercontent.com/MuhammadShafeeque/tidewater/v0.1.0/docs/img/overview.png)
93
+
94
+ | Step | What you get | Module |
95
+ |---|---|---|
96
+ | Ocean forcing | The thermal forcing of an ocean product in depth bands in front of each terminus, with sea-ice cover, optional subglacial discharge and an optional bias offset onto a reference product | `tidewater.forcing` |
97
+ | Frontal ablation | The flux of one of five nested laws, or the ocean factor `(max(TF, 0) / TF_ref)^gamma` that scales a host's own calving constant | `tidewater.laws` |
98
+ | Calibration | The calving constant `k` from observed frontal ablation, on the inverted front and through the host's dynamic model, and a constant for glaciers without an observation | `tidewater.calibration` |
99
+ | Hand-over to the host | Model years in the host's convention, glacier ids in the host's form, and files the host can read | `tidewater.timeconv`, `tidewater.ids`, `tidewater.export` |
100
+
101
+ ## Supported glacier models
102
+
103
+ | Model | Language | How it couples | What the host needs |
104
+ |---|---|---|---|
105
+ | [OGGM](https://github.com/OGGM/oggm) | Python | `tidewater.hosts.oggm`: the laws are called at every time step of the flowline model; ocean-aware inversion and dynamic calibration of `k` are OGGM tasks | the branch [`oggm-tidewater`](https://github.com/MuhammadShafeeque/oggmHydro/tree/oggm-tidewater), which adds four small hooks to OGGM |
106
+ | [PyGEM](https://github.com/PyGEM-Community/PyGEM) | Python | `tidewater.hosts.pygem`: a law on PyGEM's OGGM dynamics, or a yearly constant on its mass-redistribution model | released PyGEM 1.1.0, or the branch [`pygem-tidewater`](https://github.com/MuhammadShafeeque/PyGEM-tidewater/tree/pygem-tidewater) with a calving-law hook; both give the same results. The branch [`pygem-tidewater-rgi7`](https://github.com/MuhammadShafeeque/PyGEM-tidewater/tree/pygem-tidewater-rgi7) adds RGI 7.0 to it |
107
+ | [GloGEM](https://github.com/eth-vaw-glaciology/GloGEM), GloGEMflow | IDL | `tidewater.hosts.glogem`: yearly ocean factor tables that scale GloGEM's own frontal ablation | branch [`glogem-tidewater`](https://github.com/MuhammadShafeeque/GloGEM-tidewater/tree/glogem-tidewater) (a calving factor hook, off by default) and the IDL files shipped with this package |
108
+ | Any other model | any | a factor table, a reimplementation from the spec, or an offline diagnostic | see [docs/hosts.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts.md) |
109
+
110
+ The host branches carry generic hooks only. They contain no ocean code and do
111
+ not import `tidewater`, so a user who does not install this package gets the
112
+ host model's own results.
113
+
114
+ <!-- docs: getting-started -->
115
+ ## Installation
116
+
117
+ `tidewater` needs Python 3.11 or later:
118
+
119
+ ```bash
120
+ pip install tidewater # core
121
+ pip install "tidewater[teos10]" # adds the TEOS-10 freezing point (gsw)
122
+ pip install "tidewater[plot]" # adds matplotlib, for the examples' figures
123
+ ```
124
+
125
+ Core dependencies: numpy, pandas, xarray, netCDF4, cftime, scipy.
126
+
127
+ The examples and the tests are in the repository, not in the installed
128
+ package. To run them or to change the code, install from a clone:
129
+
130
+ ```bash
131
+ git clone https://github.com/MuhammadShafeeque/tidewater.git
132
+ pip install -e "tidewater[test,plot]"
133
+ ```
134
+
135
+ A host model is installed separately, into the same environment. For OGGM:
136
+
137
+ ```bash
138
+ git clone -b oggm-tidewater https://github.com/MuhammadShafeeque/oggmHydro.git
139
+ pip install -e "oggmHydro[full]"
140
+ pip install tidewater
141
+ ```
142
+
143
+ Released OGGM 1.6.3 and earlier are not supported by the OGGM adapter. PyGEM
144
+ pins its own OGGM and numpy versions, so give PyGEM an environment of its own.
145
+
146
+ ## Quick start
147
+
148
+ ### On its own
149
+
150
+ No glacier model is needed to compute a forcing, a factor or a flux:
151
+
152
+ ```python
153
+ import numpy as np
154
+ import pandas as pd
155
+ from tidewater.laws import TFPower, tf_power_mean
156
+ from tidewater.timeconv import yearly_ocean_factor
157
+
158
+ time = pd.date_range("1995-01-01", "2014-12-01", freq="MS")
159
+ tf = pd.Series(3.0 + np.sin(2 * np.pi * time.month / 12), index=time) # degC
160
+ tf_ref = tf_power_mean(tf.to_numpy(), gamma=1.18) # degC
161
+
162
+ # a host with its own calving law: one factor per glacier and model year
163
+ factor = yearly_ocean_factor(tf.to_frame("RGI60-05.00001"), tf_ref, start_month=10,
164
+ incomplete="drop")
165
+
166
+ # a host that calls the law at each time step
167
+ years = time.year + (time.month - 0.5) / 12
168
+ law = TFPower(years, tf.to_numpy(), tf_ref=tf_ref, k0=0.6) # k0 in yr-1
169
+ q = law.flux(h=250.0, d=180.0, w=1500.0, yr=2001.5) # m3 ice s-1
170
+ ```
171
+
172
+ ### With OGGM
173
+
174
+ ```python
175
+ from oggm import cfg
176
+ import tidewater.hosts.oggm
177
+ from tidewater.hosts.oggm import tasks as tw_tasks
178
+
179
+ cfg.initialize()
180
+ tidewater.hosts.oggm.register() # files, parameters, calving inversion
181
+ # ... glacier directories, then for example
182
+ # tw_tasks.process_ocean_data(gdir, ...)
183
+ # tw_tasks.run_with_ocean_forcing(gdir, calving_law='tf_power', ...)
184
+ # tw_tasks.run_dynamic_calving_k_calibration(gdir, ref_fa=..., ref_fa_err=...)
185
+ ```
186
+
187
+ Call `register()` once, before the glacier directories are opened. The tasks
188
+ and the settings they read are listed in [docs/hosts.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts.md#oggm).
189
+
190
+ ### With PyGEM
191
+
192
+ ```python
193
+ import sys
194
+ from pygem.bin.run import run_simulation
195
+ from tidewater.hosts.pygem import laws_from_forcing
196
+ from tidewater.hosts.pygem.dynamics import ocean_dynamics
197
+
198
+ laws = laws_from_forcing({"1.03622": "ocean/RGI60-01.03622.nc"}, "tf_power")
199
+ sys.argv = ["run_simulation", "-rgi_glac_number", "1.03622",
200
+ "-option_dynamics", "OGGM"]
201
+ with ocean_dynamics(laws):
202
+ run_simulation.main()
203
+ ```
204
+
205
+ Glaciers without an entry, and land-terminating glaciers, run as before.
206
+ Details, the two routes and the calibration tables are in
207
+ [docs/hosts-pygem.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts-pygem.md).
208
+
209
+ ### With GloGEM
210
+
211
+ ```python
212
+ from tidewater.hosts import glogem
213
+
214
+ factor, info = glogem.write_ocean_factor_tables(
215
+ "ocean_factor", tf_monthly, tf_ref, gamma=1.18,
216
+ time_resolution="monthly", incomplete="drop")
217
+ ```
218
+
219
+ This writes one `ocean_factor_<region>.dat` per RGI region in GloGEM's model
220
+ years. GloGEM, on the branch `glogem-tidewater`, is then run as usual with
221
+ three more lines in its `config.pro`:
222
+
223
+ ```
224
+ !PATH = !PATH + ':<tidewater>/hosts/glogem/idl'
225
+ calving_factor_function = 'tw_table_factor'
226
+ calving_factor_dir = 'ocean_factor'
227
+ ```
228
+
229
+ GloGEM keeps its own calving law and calibrated constant and multiplies its
230
+ frontal ablation by the factor of each glacier and year. Without these lines
231
+ it gives its stock results. The model-year rules and a note for MATLAB hosts
232
+ are in [docs/hosts-glogem.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts-glogem.md).
233
+
234
+ ## The laws
235
+
236
+ Five laws form a nested family around the constant-k law `q = k d h w`
237
+ (`d` water depth, `h` ice thickness, `w` width at the front):
238
+
239
+ | Name | Law |
240
+ |---|---|
241
+ | `constant` | `q = k d h w` |
242
+ | `tf_power` | `k(t) = k0 ((1 - a) + a (TF(t) / TF_ref)^gamma)` |
243
+ | `melt_calving` | a submarine melt rate after Rignot et al. (2016) added to the calving term, `q = w d (k_c h + lambda m)` |
244
+ | `sea_ice` | `melt_calving` with the melt term multiplied by the open-water fraction to the power `delta` |
245
+ | `larger_of` | the larger of the two speeds, `q = w d max(k_c h, lambda m)`, after Malles et al. (2025) |
246
+
247
+ Each law reduces to the one before it for a value of its parameters
248
+ (`TF = TF_ref`, `gamma = 0` or `a = 0`; `lambda = 0`; `delta = 0`), and
249
+ `larger_of` reduces to the constant-k law at `lambda = 0`. A host can therefore
250
+ switch the ocean on gradually and compare each step with its present results.
251
+ The thermal forcing is clipped at zero before any power. The freezing point is
252
+ linear in salinity and depth by default; the TEOS-10 form is available with
253
+ the `teos10` extra.
254
+
255
+ The equations, their limits and the reference vectors are in
256
+ [`src/tidewater/spec/SPEC.md`](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/src/tidewater/spec/SPEC.md).
257
+
258
+ ## Host integration contract
259
+
260
+ A host model supplies, at the calving front and at each of its time steps:
261
+
262
+ | The host supplies | Unit |
263
+ |---|---|
264
+ | ice thickness at the terminus | m |
265
+ | water depth at the terminus | m |
266
+ | width of the front | m |
267
+ | time, on the host's own model-year convention | float years |
268
+ | glacier id | string, any inventory |
269
+ | terminus longitude and latitude | degrees east, degrees north |
270
+
271
+ It gets back one of:
272
+
273
+ | The host receives | Unit |
274
+ |---|---|
275
+ | frontal ablation flux | m3 ice s-1, or m3 ice yr-1 |
276
+ | the dimensionless ocean factor, to multiply its own calving constant | 1 |
277
+
278
+ Three points complete the contract:
279
+
280
+ - **One front per glacier.** A host whose glacier has several marine fronts
281
+ calls the law once per front and adds the fluxes.
282
+ - **The yearly factor is a mean of monthly factors** over the model year
283
+ (`tidewater.timeconv.yearly_ocean_factor`), not the factor of the yearly
284
+ mean thermal forcing.
285
+ - **The host keeps the glacier.** Capping the flux by the available ice,
286
+ removing the mass, moving the front and the accounting of the removed volume
287
+ stay with the host. `tidewater` never changes the state of a host glacier
288
+ outside a host adapter.
289
+
290
+ The coupling routes for Python hosts and for hosts that cannot import Python
291
+ are compared in [docs/hosts.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts.md).
292
+
293
+ ## Bringing your own data
294
+
295
+ Ocean products on regular, curvilinear and unstructured grids are read into
296
+ one neutral layout; variable names, units and depth direction are declared or
297
+ taken from CF metadata. Per-glacier forcing files are built in Python or from
298
+ the command line:
299
+
300
+ ```bash
301
+ tidewater-forcing build ocean_*.nc --glaciers glaciers.csv --out forcing/
302
+ tidewater-forcing validate forcing/
303
+ ```
304
+
305
+ `glaciers.csv` holds a glacier id and the terminus longitude and latitude,
306
+ with an optional front depth. Bed products and frontal-ablation datasets are
307
+ brought in the same way, through a column mapping and a stated unit. See
308
+ [docs/data.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/data.md), and [docs/regions.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/regions.md) for the
309
+ parameters to set per region: the defaults are the values of the Greenland
310
+ application the package was developed on, and each is marked.
311
+
312
+ ## Documentation
313
+
314
+ | Document | Content |
315
+ |---|---|
316
+ | [docs/how-it-works.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/how-it-works.md) | the method in six diagrams: forcing, the front, the laws, the contract, the coupling routes, time |
317
+ | [docs/examples.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/examples.md) and [examples/](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/examples/) | one glacier through the whole chain, an example per host model, and its figures |
318
+ | [docs/hosts.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts.md) | coupling a host model: the routes, how to choose one, and the OGGM adapter |
319
+ | [docs/hosts-pygem.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts-pygem.md) | the PyGEM adapter: two routes, the two dynamics models, calibration |
320
+ | [docs/hosts-glogem.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/hosts-glogem.md) | GloGEM and GloGEMflow: factor tables, model years, the IDL files |
321
+ | [docs/data.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/data.md) | bringing an ocean product, a bed product or a frontal-ablation dataset |
322
+ | [docs/regions.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/regions.md) | parameters with a regional origin and how to set them elsewhere |
323
+ | [docs/conventions.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/conventions.md) | units, periods, model years, glacier ids and file formats |
324
+ | [docs/references.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/references.md) | the source of every equation and constant in the code, with full references |
325
+ | [src/tidewater/spec/SPEC.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/src/tidewater/spec/SPEC.md) | the laws as equations, with reference vectors for other languages |
326
+
327
+ The same pages, with an API reference generated from the docstrings, are
328
+ online at [tidewater.readthedocs.io](https://tidewater.readthedocs.io). To
329
+ build the site locally:
330
+
331
+ ```bash
332
+ pip install -e ".[docs]"
333
+ sphinx-build -W docs docs/_build/html
334
+ ```
335
+
336
+ ## Package layout
337
+
338
+ | Layer | Module | What it does |
339
+ |---|---|---|
340
+ | Physics | `tidewater.physics` | freezing point, thermal forcing, depth-band averages, open-water fraction, flotation and front geometry |
341
+ | Laws | `tidewater.laws` | the frontal ablation laws and the dimensionless ocean factor |
342
+ | Forcing | `tidewater.forcing` | from an ocean product to a per-glacier forcing record |
343
+ | Calibration | `tidewater.calibration` | the calving constant against observed frontal ablation |
344
+ | Time, ids, export | `tidewater.timeconv`, `tidewater.ids`, `tidewater.export` | host model years, glacier ids, files for hosts |
345
+ | Parameters, units, periods | `tidewater.config`, `tidewater.units`, `tidewater.periods` | every parameter as an argument, one unit converter, one period convention |
346
+ | Host adapters | `tidewater.hosts` | the only place that imports a glacier model |
347
+ | Spec | `tidewater.spec` | reference vectors for hosts that reimplement the law in another language |
348
+
349
+ Outside the package: `examples/` (the example glacier, a script per host and
350
+ the result files the figures read) and `docs/figures/` (the scripts that draw
351
+ every figure of the documentation into `docs/img/`).
352
+
353
+ <!-- docs: project -->
354
+ ## Testing
355
+
356
+ ```bash
357
+ pip install -e ".[test]"
358
+ pytest
359
+ ```
360
+
361
+ The core tests need no glacier model and no download. The host tests under
362
+ `tests/hosts/` run when their host is installed and skip otherwise, each with
363
+ the reason:
364
+
365
+ - **OGGM**: installed from the branch above. The tests take OGGM's options
366
+ (`pytest --run-slow`). Run them with `HOME` set to a scratch directory,
367
+ because OGGM's test helpers delete other directories under their test
368
+ directory.
369
+ - **PyGEM**: released PyGEM or the branch; the test ids state which route ran.
370
+ - **GloGEM**: the IDL files run when `idl` or `gdl` is on the path, or when
371
+ the environment variable `TIDEWATER_IDL` names an interpreter. `GLOGEM_DIR`,
372
+ a GloGEM checkout with the hook, adds a test of GloGEM's calving routine.
373
+
374
+ ## Project status
375
+
376
+ Version 0.1.0, the first release: names and signatures may still change.
377
+
378
+ | Part | State |
379
+ |---|---|
380
+ | Core (laws, forcing, calibration, export) | tested on synthetic data; the laws are checked against the reference vectors |
381
+ | OGGM adapter | reproduces, number for number, the scheme's original implementation on OGGM for two glaciers in the Greenland periphery, including the dynamic calibration of `k` |
382
+ | PyGEM adapter | reproduces PyGEM's own frontal ablation for one sample glacier when the ocean factor is 1, on both of PyGEM's dynamics options |
383
+ | GloGEM, GloGEMflow | the IDL code matches the reference vectors and scales GloGEM's calving routine by exactly the tabled factor; GloGEM runs in full, in IDL; GloGEMflow has not been run |
384
+
385
+ All three hosts run the example glacier, RGI2000-v7.0-G-05-09345, with and
386
+ without the ocean term: calibration on 2000-2009, evaluation on 2010-2019 and
387
+ two scenarios to 2100. The results and their figures are in
388
+ [docs/examples.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/examples.md).
389
+
390
+ Known limits of this version: one calving front per glacier; runs on several
391
+ processes with PyGEM need forked workers; in GloGEMflow the frontal ablation
392
+ does not yet change the flow model's geometry. The scheme is experimental,
393
+ like the calving parameterizations it extends.
394
+
395
+ ## Contributing
396
+
397
+ Bug reports, questions and pull requests are welcome through the issue
398
+ tracker of this repository. Three rules keep the package portable:
399
+
400
+ - nothing outside `src/tidewater/hosts/` imports a glacier model (a test
401
+ enforces it);
402
+ - every parameter is an argument with a documented default, never a global;
403
+ - a change to a law comes with updated reference vectors
404
+ (`python -m tidewater.spec.make_vectors`) and a test.
405
+
406
+ A new host adapter goes in `src/tidewater/hosts/<host>/` with its tests in
407
+ `tests/hosts/<host>/` and a page in `docs/`.
408
+
409
+ ## Citing
410
+
411
+ Please cite the software using [CITATION.cff](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/CITATION.cff). A DOI and the
412
+ preferred citation will be added with the first archived release.
413
+
414
+ ## References
415
+
416
+ The two works the laws build on most directly are listed here. The source of
417
+ every equation and constant in the code is in
418
+ [docs/references.md](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/docs/references.md).
419
+
420
+ - Malles, J.-H., Marzeion, B., and Myers, P. G. (2025). Freshwater input from
421
+ glacier melt outside Greenland alters modeled northern high-latitude ocean
422
+ circulation. *Earth System Dynamics*, 16, 347-377.
423
+ https://doi.org/10.5194/esd-16-347-2025
424
+ - Rignot, E., Xu, Y., Menemenlis, D., Mouginot, J., Scheuchl, B., Li, X.,
425
+ Morlighem, M., Seroussi, H., van den Broeke, M., Fenty, I., Cai, C., An, L.,
426
+ and de Fleurian, B. (2016). Modeling of ocean-induced ice melt rates of five
427
+ west Greenland glaciers over the past two decades. *Geophysical Research
428
+ Letters*, 43, 6374-6382. https://doi.org/10.1002/2016GL068784
429
+
430
+ ## Licence and acknowledgements
431
+
432
+ BSD-3-Clause, see [LICENSE](https://github.com/MuhammadShafeeque/tidewater/blob/v0.1.0/LICENSE).
433
+
434
+ `tidewater` was developed first as the `ocean_calving` scheme (version 1.0) on
435
+ the Open Global Glacier Model (OGGM), and it builds on the k-calving
436
+ parameterization that OGGM, PyGEM and GloGEM each provide. It is an
437
+ independent project and is not developed or endorsed by the teams of those
438
+ models.