veris 0.1.1__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 (37) hide show
  1. veris-0.1.1/LICENSE +21 -0
  2. veris-0.1.1/PKG-INFO +46 -0
  3. veris-0.1.1/README.md +20 -0
  4. veris-0.1.1/setup.cfg +19 -0
  5. veris-0.1.1/setup.py +61 -0
  6. veris-0.1.1/veris/__init__.py +24 -0
  7. veris-0.1.1/veris/_version.py +21 -0
  8. veris-0.1.1/veris/advection.py +175 -0
  9. veris-0.1.1/veris/area_mass.py +28 -0
  10. veris-0.1.1/veris/averaging.py +19 -0
  11. veris-0.1.1/veris/clean_up.py +47 -0
  12. veris-0.1.1/veris/dynamics_routines.py +304 -0
  13. veris-0.1.1/veris/dynsolver.py +94 -0
  14. veris-0.1.1/veris/evp_solver.py +327 -0
  15. veris-0.1.1/veris/fill_overlap.py +23 -0
  16. veris-0.1.1/veris/freedrift_solver.py +62 -0
  17. veris-0.1.1/veris/global_sum.py +4 -0
  18. veris-0.1.1/veris/growth.py +397 -0
  19. veris-0.1.1/veris/heat_flux_CESM.py +522 -0
  20. veris-0.1.1/veris/heat_flux_MITgcm.py +123 -0
  21. veris-0.1.1/veris/model.py +9 -0
  22. veris-0.1.1/veris/ocean_stress.py +41 -0
  23. veris-0.1.1/veris/set_inits.py +52 -0
  24. veris-0.1.1/veris/settings.py +170 -0
  25. veris-0.1.1/veris/setup/__init__.py +0 -0
  26. veris-0.1.1/veris/setup/seaice_global_4deg/__init__.py +1 -0
  27. veris-0.1.1/veris/setup/seaice_global_4deg/assets.json +26 -0
  28. veris-0.1.1/veris/setup/seaice_global_4deg/seaice_global_4deg.py +980 -0
  29. veris-0.1.1/veris/solve4temp.py +174 -0
  30. veris-0.1.1/veris/variables.py +103 -0
  31. veris-0.1.1/veris.egg-info/PKG-INFO +46 -0
  32. veris-0.1.1/veris.egg-info/SOURCES.txt +36 -0
  33. veris-0.1.1/veris.egg-info/dependency_links.txt +1 -0
  34. veris-0.1.1/veris.egg-info/entry_points.txt +2 -0
  35. veris-0.1.1/veris.egg-info/requires.txt +1 -0
  36. veris-0.1.1/veris.egg-info/top_level.txt +1 -0
  37. veris-0.1.1/versioneer.py +2205 -0
veris-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 TeamOcean
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.
veris-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.1
2
+ Name: veris
3
+ Version: 0.1.1
4
+ Summary: Sea-ice plugin for Veros, the versatile ocean simulator
5
+ Home-page: https://veris.readthedocs.io
6
+ Author: Jan Gärtner (AWI Bremen)
7
+ Author-email: jph.gaertner@gmail.com
8
+ License: MIT
9
+ Keywords: oceanography python parallel numpy multi-core geophysics ocean-model mpi4py jax
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Operating System :: Microsoft :: Windows
20
+ Classifier: Operating System :: POSIX
21
+ Classifier: Operating System :: Unix
22
+ Classifier: Operating System :: MacOS
23
+ Requires-Python: >=3.7
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+
27
+ # Veris
28
+ Sea ice plugin for Veros, based on SEAICE package of MITgcm model
29
+
30
+ ## Quick usage
31
+
32
+ ```bash
33
+ $ pip install veros
34
+ $ git clone https://github.com/team-ocean/veris.git
35
+ $ cd veris
36
+ $ pip install -e .
37
+ $ veros copy-setup seaice_global_4deg --to /tmp/seaice_4deg
38
+ $ cd /tmp/seaice_4deg
39
+ $ veros run seaice_global_4deg.py
40
+ ```
41
+
42
+ ## Credits
43
+
44
+ Veris is based on [SEAICE package](https://mitgcm.readthedocs.io/en/latest/phys_pkgs/seaice.html) by [Martin Losch et al.](https://www.awi.de/ueber-uns/organisation/mitarbeiter/detailseite/martin-losch.html), Alfred Wegener institute.
45
+
46
+ [Jan Philipp Gärtner](https://github.com/jpgaertner) created Veris plugin as a part of his Master's thesis.
veris-0.1.1/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # Veris
2
+ Sea ice plugin for Veros, based on SEAICE package of MITgcm model
3
+
4
+ ## Quick usage
5
+
6
+ ```bash
7
+ $ pip install veros
8
+ $ git clone https://github.com/team-ocean/veris.git
9
+ $ cd veris
10
+ $ pip install -e .
11
+ $ veros copy-setup seaice_global_4deg --to /tmp/seaice_4deg
12
+ $ cd /tmp/seaice_4deg
13
+ $ veros run seaice_global_4deg.py
14
+ ```
15
+
16
+ ## Credits
17
+
18
+ Veris is based on [SEAICE package](https://mitgcm.readthedocs.io/en/latest/phys_pkgs/seaice.html) by [Martin Losch et al.](https://www.awi.de/ueber-uns/organisation/mitarbeiter/detailseite/martin-losch.html), Alfred Wegener institute.
19
+
20
+ [Jan Philipp Gärtner](https://github.com/jpgaertner) created Veris plugin as a part of his Master's thesis.
veris-0.1.1/setup.cfg ADDED
@@ -0,0 +1,19 @@
1
+ [metadata]
2
+ description-file = README.md
3
+
4
+ [versioneer]
5
+ VCS = git
6
+ style = pep440
7
+ versionfile_source = veris/_version.py
8
+ versionfile_build = veris/_version.py
9
+ tag_prefix = v
10
+
11
+ [flake8]
12
+ max-line-length = 120
13
+ select = C,E,F,W,B,B950
14
+ extend-ignore = E203, E501
15
+
16
+ [egg_info]
17
+ tag_build =
18
+ tag_date = 0
19
+
veris-0.1.1/setup.py ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env python
2
+ # coding=utf-8
3
+
4
+ from setuptools import setup, find_packages
5
+ from codecs import open
6
+ import sys
7
+ import os
8
+
9
+
10
+ here = os.path.abspath(os.path.dirname(__file__))
11
+ sys.path.append(here)
12
+ import versioneer # noqa: E402
13
+
14
+
15
+ CLASSIFIERS = """
16
+ Development Status :: 3 - Alpha
17
+ Intended Audience :: Science/Research
18
+ License :: OSI Approved :: MIT License
19
+ Programming Language :: Python :: 3
20
+ Programming Language :: Python :: 3.7
21
+ Programming Language :: Python :: 3.8
22
+ Programming Language :: Python :: 3.9
23
+ Programming Language :: Python :: 3.10
24
+ Topic :: Scientific/Engineering
25
+ Operating System :: Microsoft :: Windows
26
+ Operating System :: POSIX
27
+ Operating System :: Unix
28
+ Operating System :: MacOS
29
+ """
30
+
31
+ INSTALL_REQUIRES = [
32
+ "veros>=1.4.4"
33
+ ]
34
+
35
+ with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
36
+ long_description = f.read()
37
+
38
+
39
+ setup(
40
+ name="veris",
41
+ license="MIT",
42
+ author="Jan Gärtner (AWI Bremen)",
43
+ author_email="jph.gaertner@gmail.com",
44
+ keywords="oceanography python parallel numpy multi-core geophysics ocean-model mpi4py jax",
45
+ description="Sea-ice plugin for Veros, the versatile ocean simulator",
46
+ long_description=long_description,
47
+ long_description_content_type="text/markdown",
48
+ url='https://veris.readthedocs.io',
49
+ python_requires=">=3.7",
50
+ version=versioneer.get_version(),
51
+ cmdclass=versioneer.get_cmdclass(),
52
+ packages=find_packages(),
53
+ install_requires=INSTALL_REQUIRES,
54
+ entry_points={
55
+ "veros.setup_dirs": [
56
+ "seaice = veris.setup"
57
+ ]
58
+ },
59
+ package_data={"veris": ["setup/*/assets.json"]},
60
+ classifiers=[c for c in CLASSIFIERS.split("\n") if c],
61
+ )
@@ -0,0 +1,24 @@
1
+ try:
2
+ import veros # noqa: F401
3
+ except ImportError:
4
+ raise RuntimeError(
5
+ 'Veris needs Veros to be installed (try `pip install veros`)'
6
+ )
7
+
8
+ from . import _version
9
+ __version__ = _version.get_versions()['version']
10
+
11
+ from veris.model import model
12
+ from veris.set_inits import set_inits
13
+ from veris.variables import VARIABLES
14
+ from veris.settings import SETTINGS
15
+
16
+
17
+ __VEROS_INTERFACE__ = dict(
18
+ name = 'veris',
19
+ setup_entrypoint = set_inits,
20
+ run_entrypoint = model,
21
+ settings = SETTINGS,
22
+ variables = VARIABLES,
23
+ )
24
+
@@ -0,0 +1,21 @@
1
+
2
+ # This file was generated by 'versioneer.py' (0.28) from
3
+ # revision-control system data, or from the parent directory name of an
4
+ # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
+ # of this file.
6
+
7
+ import json
8
+
9
+ version_json = '''
10
+ {
11
+ "date": "2023-05-23T13:58:38+0200",
12
+ "dirty": false,
13
+ "error": null,
14
+ "full-revisionid": "d83026db00905d9742fe90f38ba4ef16cff23e5f",
15
+ "version": "0.1.1"
16
+ }
17
+ ''' # END VERSION_JSON
18
+
19
+
20
+ def get_versions():
21
+ return json.loads(version_json)
@@ -0,0 +1,175 @@
1
+ from veros.core.operators import numpy as npx
2
+ from veros.core.operators import update, at
3
+ from veros import veros_kernel
4
+
5
+ from veris.fill_overlap import fill_overlap
6
+
7
+ # in this routine, the thermodynamic time step is used instead of the dynamic one.
8
+ # this has historical reasons as with lower resolutions, the dynamics change much
9
+ # slower than the thermodynamics (thermodynamics have a daily cycle). calculating
10
+ # the ice velocity as often as the thermodynamics was unnecessarily expensive but
11
+ # the advection is still done with the faster thermodynamic timestep as the ice
12
+ # thickness changes inbetween dynamics timesteps.
13
+
14
+
15
+ @veros_kernel
16
+ def Advection(state):
17
+ """retrieve changes in sea ice fields"""
18
+
19
+ vs = state.variables
20
+
21
+ hIceMean = calc_Advection(state, vs.hIceMean)
22
+ hSnowMean = calc_Advection(state, vs.hSnowMean)
23
+ Area = calc_Advection(state, vs.Area)
24
+
25
+ return hIceMean, hSnowMean, Area
26
+
27
+
28
+ @veros_kernel
29
+ def calc_Advection(state, field):
30
+ """calculate change in sea ice field due to advection"""
31
+
32
+ vs = state.variables
33
+ sett = state.settings
34
+
35
+ # retrieve cell faces
36
+ xA = vs.dyG * vs.iceMaskU
37
+ yA = vs.dxG * vs.iceMaskV
38
+
39
+ # calculate ice transport
40
+ uTrans = vs.uIce * xA
41
+ vTrans = vs.vIce * yA
42
+
43
+ # make local copy of field prior to advective changes
44
+ fieldLoc = field
45
+
46
+ # calculate zonal advective fluxes
47
+ ZonalFlux = calc_ZonalFlux(state, fieldLoc, uTrans)
48
+
49
+ # update field according to zonal fluxes
50
+ if sett.extensiveFld:
51
+ fieldLoc = fieldLoc - sett.deltatTherm * vs.maskInC * vs.recip_rA * (
52
+ npx.roll(ZonalFlux, -1, 0) - ZonalFlux
53
+ )
54
+ else:
55
+ fieldLoc = (
56
+ fieldLoc
57
+ - sett.deltatTherm
58
+ * vs.maskInC
59
+ * vs.recip_rA
60
+ * vs.recip_hIceMean
61
+ * (
62
+ (npx.roll(ZonalFlux, -1, 1) - ZonalFlux)
63
+ - (npx.roll(vs.uTrans, -1, 0) - vs.uTrans) * field
64
+ )
65
+ )
66
+
67
+ # calculate meridional advective fluxes
68
+ MeridionalFlux = calc_MeridionalFlux(state, fieldLoc, vTrans)
69
+
70
+ # update field according to meridional fluxes
71
+ if sett.extensiveFld:
72
+ fieldLoc = fieldLoc - sett.deltatTherm * vs.maskInC * vs.recip_rA * (
73
+ npx.roll(MeridionalFlux, -1, 1) - MeridionalFlux
74
+ )
75
+ else:
76
+ fieldLoc = (
77
+ fieldLoc
78
+ - sett.deltatTherm
79
+ * vs.maskInC
80
+ * vs.recip_rA
81
+ * vs.recip_hIceMean
82
+ * (
83
+ (npx.roll(MeridionalFlux, -1, 0) - MeridionalFlux)
84
+ - (npx.roll(vs.vTrans, -1, 1) - vs.vTrans) * field
85
+ )
86
+ )
87
+
88
+ # apply mask
89
+ fieldLoc = fieldLoc * vs.iceMask
90
+
91
+ return fieldLoc
92
+
93
+
94
+ @veros_kernel
95
+ def calc_ZonalFlux(state, field, uTrans):
96
+ """calculate the zonal advective flux using the second order flux limiter method"""
97
+
98
+ vs = state.variables
99
+ sett = state.settings
100
+
101
+ maskLocW = vs.iceMaskU * vs.maskInU
102
+
103
+ # CFL number of zonal flow
104
+ uCFL = npx.abs(vs.uIce * sett.deltatTherm * vs.recip_dxC)
105
+
106
+ # calculate slope ratio Cr
107
+ Rjp = (field[3:, :] - field[2:-1, :]) * maskLocW[3:, :]
108
+ Rj = (field[2:-1, :] - field[1:-2, :]) * maskLocW[2:-1, :]
109
+ Rjm = (field[1:-2, :] - field[:-3, :]) * maskLocW[1:-2, :]
110
+
111
+ Cr = npx.where(uTrans[2:-1, :] > 0, Rjm, Rjp)
112
+ Cr = npx.where(
113
+ npx.abs(Rj) * sett.CrMax > npx.abs(Cr),
114
+ Cr / Rj,
115
+ npx.sign(Cr) * sett.CrMax * npx.sign(Rj),
116
+ )
117
+ Cr = limiter(Cr)
118
+
119
+ # zonal advective flux for the given field
120
+ ZonalFlux = npx.zeros_like(vs.iceMask)
121
+ ZonalFlux = update(
122
+ ZonalFlux,
123
+ at[2:-1, :],
124
+ uTrans[2:-1, :] * (field[2:-1, :] + field[1:-2, :]) * 0.5
125
+ - npx.abs(uTrans[2:-1, :]) * ((1 - Cr) + uCFL[2:-1, :] * Cr) * Rj * 0.5,
126
+ )
127
+ ZonalFlux = fill_overlap(state, ZonalFlux)
128
+
129
+ return ZonalFlux
130
+
131
+
132
+ @veros_kernel
133
+ def calc_MeridionalFlux(state, field, vTrans):
134
+ """calculate the meridional advective flux using the second order flux limiter method"""
135
+
136
+ vs = state.variables
137
+ sett = state.settings
138
+
139
+ maskLocS = vs.iceMaskV * vs.maskInV
140
+
141
+ # CFL number of meridional flow
142
+ vCFL = npx.abs(vs.vIce * sett.deltatTherm * vs.recip_dyC)
143
+
144
+ # calculate slope ratio Cr
145
+ Rjp = (field[:, 3:] - field[:, 2:-1]) * maskLocS[:, 3:]
146
+ Rj = (field[:, 2:-1] - field[:, 1:-2]) * maskLocS[:, 2:-1]
147
+ Rjm = (field[:, 1:-2] - field[:, :-3]) * maskLocS[:, 1:-2]
148
+
149
+ Cr = npx.where(vTrans[:, 2:-1] > 0, Rjm, Rjp)
150
+ Cr = npx.where(
151
+ npx.abs(Rj) * sett.CrMax > npx.abs(Cr),
152
+ Cr / Rj,
153
+ npx.sign(Cr) * sett.CrMax * npx.sign(Rj),
154
+ )
155
+ Cr = limiter(Cr)
156
+
157
+ # meridional advective flux for the given field
158
+ MeridionalFlux = npx.zeros_like(vs.iceMask)
159
+ MeridionalFlux = update(
160
+ MeridionalFlux,
161
+ at[:, 2:-1],
162
+ vTrans[:, 2:-1] * (field[:, 2:-1] + field[:, 1:-2]) * 0.5
163
+ - npx.abs(vTrans[:, 2:-1]) * ((1 - Cr) + vCFL[:, 2:-1] * Cr) * Rj * 0.5,
164
+ )
165
+ MeridionalFlux = fill_overlap(state, MeridionalFlux)
166
+
167
+ return MeridionalFlux
168
+
169
+
170
+ @veros_kernel
171
+ def limiter(Cr):
172
+ # return 0 (upwind)
173
+ # return 1 (Lax-Wendroff)
174
+ # return np.max((0, np.min((1, Cr)))) (Min-Mod)
175
+ return npx.maximum(0, npx.maximum(npx.minimum(1, 2 * Cr), npx.minimum(2, Cr)))
@@ -0,0 +1,28 @@
1
+ from veros.core.operators import numpy as npx
2
+ from veros import veros_kernel
3
+
4
+
5
+ @veros_kernel
6
+ def AreaWS(state):
7
+ """calculate sea ice cover fraction centered around velocity points"""
8
+
9
+ vs = state.variables
10
+
11
+ AreaW = 0.5 * (vs.Area + npx.roll(vs.Area, 1, 0))
12
+ AreaS = 0.5 * (vs.Area + npx.roll(vs.Area, 1, 1))
13
+
14
+ return AreaW, AreaS
15
+
16
+
17
+ @veros_kernel
18
+ def SeaIceMass(state):
19
+ """calculate mass of the ice-snow system centered around c-, u-, and v-points"""
20
+
21
+ vs = state.variables
22
+ sett = state.settings
23
+
24
+ SeaIceMassC = sett.rhoIce * vs.hIceMean + sett.rhoSnow * vs.hSnowMean
25
+ SeaIceMassU = 0.5 * (SeaIceMassC + npx.roll(SeaIceMassC, 1, 0))
26
+ SeaIceMassV = 0.5 * (SeaIceMassC + npx.roll(SeaIceMassC, 1, 1))
27
+
28
+ return SeaIceMassC, SeaIceMassU, SeaIceMassV
@@ -0,0 +1,19 @@
1
+ from veros.core.operators import numpy as npx
2
+
3
+
4
+ def c_point_to_z_point(state, Cfield, noSlip=True):
5
+ """calculates value at z-point by averaging c-point values"""
6
+
7
+ vs = state.variables
8
+
9
+ sumNorm = vs.iceMask + npx.roll(vs.iceMask, 1, 0)
10
+ sumNorm = sumNorm + npx.roll(sumNorm, 1, 1)
11
+ if noSlip:
12
+ sumNorm = npx.where(sumNorm > 0, 1.0 / sumNorm, 0.0)
13
+ else:
14
+ sumNorm = npx.where(sumNorm == 4.0, 0.25, 0.0)
15
+
16
+ Zfield = Cfield + npx.roll(Cfield, 1, 0)
17
+ Zfield = sumNorm * (Zfield + npx.roll(Zfield, 1, 1))
18
+
19
+ return Zfield
@@ -0,0 +1,47 @@
1
+ from veros.core.operators import numpy as npx
2
+ from veros import veros_kernel
3
+
4
+
5
+ @veros_kernel
6
+ def clean_up_advection(state):
7
+ """clean up overshoots and other pathological cases after advection"""
8
+
9
+ vs = state.variables
10
+ sett = state.settings
11
+
12
+ # case 1: negative values
13
+ # calculate overshoots of ice and snow thickness
14
+ os_hIceMean = npx.maximum(-vs.hIceMean, 0)
15
+ os_hSnowMean = npx.maximum(-vs.hSnowMean, 0)
16
+
17
+ # cut off thicknesses and area at zero
18
+ hIceMean = npx.maximum(vs.hIceMean, 0)
19
+ hSnowMean = npx.maximum(vs.hSnowMean, 0)
20
+ Area = npx.maximum(vs.Area, 0)
21
+
22
+ # case 2: very thin ice
23
+ # set thicknesses to zero if the ice thickness is very small
24
+ thinIce = hIceMean <= sett.hIce_min
25
+ hIceMean *= ~thinIce
26
+ hSnowMean *= ~thinIce
27
+ TSurf = npx.where(thinIce, sett.celsius2K, vs.TSurf)
28
+
29
+ # case 3: area but no ice and snow
30
+ # set area to zero if no ice or snow is present
31
+ Area = npx.where((hIceMean == 0) & (hSnowMean == 0), 0, Area)
32
+
33
+ # case 4: very small area
34
+ # introduce lower boundary for the area (if ice or snow is present)
35
+ Area = npx.where(
36
+ (hIceMean > 0) | (hSnowMean > 0), npx.maximum(Area, sett.Area_min), Area
37
+ )
38
+
39
+ return hIceMean, hSnowMean, Area, TSurf, os_hIceMean, os_hSnowMean
40
+
41
+
42
+ @veros_kernel
43
+ def ridging(state):
44
+ """cut off ice cover fraction at 1 after advection to account for ridging"""
45
+ Area = npx.minimum(state.variables.Area, 1)
46
+
47
+ return Area