ladim 2.0.9__py3-none-any.whl → 2.1.6__py3-none-any.whl
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.
- ladim/__init__.py +1 -1
- ladim/config.py +1 -3
- ladim/forcing.py +462 -9
- ladim/grid.py +6 -3
- ladim/gridforce/ROMS.py +1 -1
- ladim/ibms/__init__.py +22 -10
- ladim/model.py +21 -86
- ladim/output.py +5 -7
- ladim/release.py +268 -130
- ladim/solver.py +12 -8
- ladim/state.py +20 -46
- ladim/tracker.py +13 -11
- ladim/utilities.py +28 -0
- {ladim-2.0.9.dist-info → ladim-2.1.6.dist-info}/METADATA +5 -2
- ladim-2.1.6.dist-info/RECORD +32 -0
- {ladim-2.0.9.dist-info → ladim-2.1.6.dist-info}/WHEEL +1 -1
- ladim-2.0.9.dist-info/RECORD +0 -32
- {ladim-2.0.9.dist-info → ladim-2.1.6.dist-info}/entry_points.txt +0 -0
- {ladim-2.0.9.dist-info → ladim-2.1.6.dist-info/licenses}/LICENSE +0 -0
- {ladim-2.0.9.dist-info → ladim-2.1.6.dist-info}/top_level.txt +0 -0
ladim/state.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
2
|
import numpy as np
|
|
3
|
-
from .model import Model, Module
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
class State
|
|
5
|
+
class State:
|
|
7
6
|
"""
|
|
8
7
|
The state module contains static and dynamic particle properties
|
|
9
8
|
|
|
@@ -12,19 +11,24 @@ class State(Module):
|
|
|
12
11
|
depth of all particles by 1, use state['Z'] += 1
|
|
13
12
|
"""
|
|
14
13
|
|
|
14
|
+
def __init__(self):
|
|
15
|
+
self._num_released = 0
|
|
16
|
+
self._varnames = set()
|
|
17
|
+
self._data = pd.DataFrame()
|
|
18
|
+
|
|
15
19
|
@property
|
|
16
20
|
def size(self):
|
|
17
21
|
"""
|
|
18
22
|
Current number of particles
|
|
19
23
|
"""
|
|
20
|
-
|
|
24
|
+
return len(self._data)
|
|
21
25
|
|
|
22
26
|
@property
|
|
23
27
|
def released(self):
|
|
24
28
|
"""
|
|
25
29
|
Total number of released particles
|
|
26
30
|
"""
|
|
27
|
-
|
|
31
|
+
return self._num_released
|
|
28
32
|
|
|
29
33
|
def append(self, particles: dict):
|
|
30
34
|
"""
|
|
@@ -34,41 +38,6 @@ class State(Module):
|
|
|
34
38
|
|
|
35
39
|
:param particles: A mapping from variable names to values
|
|
36
40
|
"""
|
|
37
|
-
raise NotImplementedError
|
|
38
|
-
|
|
39
|
-
def remove(self, particles):
|
|
40
|
-
"""
|
|
41
|
-
Remove particles
|
|
42
|
-
|
|
43
|
-
:param particles: Boolean index of particles to remove
|
|
44
|
-
:return:
|
|
45
|
-
"""
|
|
46
|
-
raise NotImplementedError
|
|
47
|
-
|
|
48
|
-
def __getitem__(self, item):
|
|
49
|
-
raise NotImplementedError
|
|
50
|
-
|
|
51
|
-
def __setitem__(self, key, value):
|
|
52
|
-
raise NotImplementedError
|
|
53
|
-
|
|
54
|
-
def __len__(self):
|
|
55
|
-
return self.size
|
|
56
|
-
|
|
57
|
-
def __contains__(self, item):
|
|
58
|
-
raise NotImplementedError
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class DynamicState(State):
|
|
62
|
-
def __init__(self):
|
|
63
|
-
self._num_released = 0
|
|
64
|
-
self._varnames = set()
|
|
65
|
-
self._data = pd.DataFrame()
|
|
66
|
-
|
|
67
|
-
@property
|
|
68
|
-
def released(self):
|
|
69
|
-
return self._num_released
|
|
70
|
-
|
|
71
|
-
def append(self, particles: dict):
|
|
72
41
|
# If there are no new particles, do nothing
|
|
73
42
|
if not particles:
|
|
74
43
|
return
|
|
@@ -92,22 +61,30 @@ class DynamicState(State):
|
|
|
92
61
|
self._num_released += num_new_particles
|
|
93
62
|
|
|
94
63
|
def remove(self, particles):
|
|
64
|
+
"""
|
|
65
|
+
Remove particles
|
|
66
|
+
|
|
67
|
+
:param particles: Boolean index of particles to remove
|
|
68
|
+
:return:
|
|
69
|
+
"""
|
|
95
70
|
if not np.any(particles):
|
|
96
71
|
return
|
|
97
72
|
|
|
98
73
|
keep = ~particles
|
|
99
74
|
self._data = self._data.iloc[keep]
|
|
100
75
|
|
|
101
|
-
@property
|
|
102
|
-
def size(self):
|
|
103
|
-
return len(self._data)
|
|
104
|
-
|
|
105
76
|
def __getitem__(self, item):
|
|
106
77
|
return self._data[item].values
|
|
107
78
|
|
|
108
79
|
def __setitem__(self, item, value):
|
|
109
80
|
self._data[item] = value
|
|
110
81
|
|
|
82
|
+
def __len__(self):
|
|
83
|
+
return self.size
|
|
84
|
+
|
|
85
|
+
def __contains__(self, item):
|
|
86
|
+
return item in self._data
|
|
87
|
+
|
|
111
88
|
def __getattr__(self, item):
|
|
112
89
|
if item not in self:
|
|
113
90
|
raise AttributeError(f'Attribute not defined: {item}')
|
|
@@ -124,6 +101,3 @@ class DynamicState(State):
|
|
|
124
101
|
self._data[item] = value
|
|
125
102
|
else:
|
|
126
103
|
raise AttributeError(f"Attribute not defined: '{item}'")
|
|
127
|
-
|
|
128
|
-
def __contains__(self, item):
|
|
129
|
-
return item in self._data
|
ladim/tracker.py
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
from .model import Model, Module
|
|
2
1
|
import numpy as np
|
|
2
|
+
import typing
|
|
3
|
+
if typing.TYPE_CHECKING:
|
|
4
|
+
from .model import Model
|
|
3
5
|
|
|
4
6
|
|
|
5
|
-
class Tracker
|
|
6
|
-
pass
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class HorizontalTracker:
|
|
7
|
+
class Tracker:
|
|
10
8
|
"""The physical particle tracking kernel"""
|
|
9
|
+
def __init__(self, integrator, diffusion):
|
|
10
|
+
self.integrator = integrator
|
|
11
|
+
self.diffusion = diffusion # [m2.s-1]
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
@staticmethod
|
|
14
|
+
def from_config(method, diffusion):
|
|
13
15
|
if not diffusion:
|
|
14
16
|
method += "_nodiff"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
integrator = StochasticDifferentialEquationIntegrator.from_keyword(method)
|
|
18
|
+
return Tracker(integrator, diffusion)
|
|
17
19
|
|
|
18
|
-
def update(self, model: Model):
|
|
20
|
+
def update(self, model: "Model"):
|
|
19
21
|
state = model.state
|
|
20
22
|
grid = model.grid
|
|
21
23
|
forcing = model.forcing
|
|
@@ -31,7 +33,7 @@ class HorizontalTracker:
|
|
|
31
33
|
# Set diffusion function
|
|
32
34
|
def mixing(t, r):
|
|
33
35
|
_ = t
|
|
34
|
-
stddev = (2 * self.
|
|
36
|
+
stddev = (2 * self.diffusion) ** 0.5
|
|
35
37
|
u_diff = stddev / dx
|
|
36
38
|
return np.broadcast_to(u_diff, r.shape)
|
|
37
39
|
|
ladim/utilities.py
CHANGED
|
@@ -30,3 +30,31 @@ def ingrid(x: float, y: float, subgrid: List[int]) -> bool:
|
|
|
30
30
|
def read_timedelta(conf) -> np.timedelta64:
|
|
31
31
|
time_value, time_unit = conf
|
|
32
32
|
return np.timedelta64(time_value, time_unit)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load_class(name):
|
|
36
|
+
import importlib.util
|
|
37
|
+
import sys
|
|
38
|
+
from pathlib import Path
|
|
39
|
+
|
|
40
|
+
pkg, cls = name.rsplit(sep='.', maxsplit=1)
|
|
41
|
+
|
|
42
|
+
# Check if "pkg" is an existing file
|
|
43
|
+
spec = None
|
|
44
|
+
module_name = None
|
|
45
|
+
file_name = pkg + '.py'
|
|
46
|
+
if Path(file_name).exists():
|
|
47
|
+
# This can return None if there were import errors
|
|
48
|
+
module_name = pkg
|
|
49
|
+
spec = importlib.util.spec_from_file_location(module_name, file_name)
|
|
50
|
+
|
|
51
|
+
# If pkg can not be interpreted as a file, use regular import
|
|
52
|
+
if spec is None:
|
|
53
|
+
return getattr(importlib.import_module(pkg), cls)
|
|
54
|
+
|
|
55
|
+
# File import
|
|
56
|
+
else:
|
|
57
|
+
module = importlib.util.module_from_spec(spec)
|
|
58
|
+
sys.modules[module_name] = module
|
|
59
|
+
spec.loader.exec_module(module)
|
|
60
|
+
return getattr(module, cls)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ladim
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.6
|
|
4
4
|
Summary: Lagrangian Advection and Diffusion Model
|
|
5
5
|
Home-page: https://github.com/pnsaevik/ladim
|
|
6
6
|
Author: Bjørn Ådlandsvik
|
|
@@ -18,6 +18,8 @@ Requires-Python: >=3.7
|
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: netCDF4
|
|
21
|
+
Requires-Dist: numba
|
|
22
|
+
Requires-Dist: numexpr
|
|
21
23
|
Requires-Dist: numpy
|
|
22
24
|
Requires-Dist: pandas
|
|
23
25
|
Requires-Dist: pyarrow
|
|
@@ -25,6 +27,7 @@ Requires-Dist: pyproj
|
|
|
25
27
|
Requires-Dist: pyyaml
|
|
26
28
|
Requires-Dist: scipy
|
|
27
29
|
Requires-Dist: xarray
|
|
30
|
+
Dynamic: license-file
|
|
28
31
|
|
|
29
32
|
LADiM – the Lagrangian Advection and Diffusion Model
|
|
30
33
|
====================================================
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
ladim/__init__.py,sha256=4K0u0bGFAIfFFuiQ5hs1xrHxa8YmuIGeFH2JKcDKM-I,51
|
|
2
|
+
ladim/__main__.py,sha256=I1AOHBQDwQNe3fVmDMyC84JcriqidOEURoeoJSOCTzg,24
|
|
3
|
+
ladim/config.py,sha256=A-yLStNqqDwh_wMCIsmd8cmaXuUvz698IMlYvGZT5tE,5710
|
|
4
|
+
ladim/forcing.py,sha256=DgBi2qEH5etOHTL3fWbPjjUvnLPDU50tknHWdWaNqeI,19061
|
|
5
|
+
ladim/grid.py,sha256=WAfvYYLiiiO8MnMkqCqKSSrVpyooymffqFWTWfF9qLM,20945
|
|
6
|
+
ladim/main.py,sha256=jsrJY7G37oCzQQDXLrlzc_I_jM7a1a-vmmQx9cuLRms,2906
|
|
7
|
+
ladim/model.py,sha256=fJNjCoK4FL45KAEUQUksRgKinehsiZre0RfKYgog-3k,2377
|
|
8
|
+
ladim/output.py,sha256=AlP3_FGKU_bmSLRyiR3cbbNCwMVkYcuwOjoy0397-CI,8307
|
|
9
|
+
ladim/release.py,sha256=P9KnZminvFPMfAJPizo72d6z8-X5ttM9Qw9p_yPtfpQ,13150
|
|
10
|
+
ladim/sample.py,sha256=n8wRGd_VsW_qyQe1ZoTpmfZcdcwB929vsM8PoKG6JTs,8292
|
|
11
|
+
ladim/solver.py,sha256=bfpb2z5ZU0k8eoFWliMMbafYddL7-AfoTvNONO43apo,785
|
|
12
|
+
ladim/state.py,sha256=xDP3DfuG7NZyYOkFr-KUotrbwPIGUVHhqy9Gisl-85Q,2872
|
|
13
|
+
ladim/tracker.py,sha256=Dpf26jAyu1xAuySRsv3-sOCXJhY3sDvmzUiUyMRUYqU,5118
|
|
14
|
+
ladim/utilities.py,sha256=a3ZK3OuJRfzjEDAfASsuEKItyWC-4GsGUWKEZp1hg0E,1790
|
|
15
|
+
ladim/gridforce/ROMS.py,sha256=VzvKXyyYSdQayCszTZQOh36aXyTaCJ7rxOhGDRjbPhE,27796
|
|
16
|
+
ladim/gridforce/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
ladim/gridforce/analytical.py,sha256=qI-1LJdjmnwwanzOdrsDZqwGgo73bT75CB7pMaxbHKM,1094
|
|
18
|
+
ladim/gridforce/zROMS.py,sha256=4bnrmcXiWpCAUch9uqd_0XmyKRh-Ll6sFvIHiTbTOOg,23996
|
|
19
|
+
ladim/ibms/__init__.py,sha256=YUbvHnFXfSJ0lTl6elc-ajyIh1LDqWYlX7Q_MHuNce4,939
|
|
20
|
+
ladim/ibms/light.py,sha256=POltHmKkX8-q3t9wXyfcseCKEq9Bq-kX1WEJYsr1lNQ,2737
|
|
21
|
+
ladim/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
ladim-2.1.6.dist-info/licenses/LICENSE,sha256=BgtXyjNr6Ly9nQ7ZLXKpV3r5kWRLnh5MiN0dxp0Bvfc,1085
|
|
23
|
+
postladim/__init__.py,sha256=ND-wa5_GNg01Tp0p_1zA1VD804zbfP3o4Cmd8pWU7OE,113
|
|
24
|
+
postladim/cellcount.py,sha256=nCFu9iJmprubn4YmPB4W0VO02GfEb90Iif7D49w1Kss,2054
|
|
25
|
+
postladim/kde_plot.py,sha256=GvMWzT6VxIeXKh1cnqaGzR-4jGG_WIHGMLPpRMXIpo4,1628
|
|
26
|
+
postladim/particlefile.py,sha256=0aif9wYUJ-VrpQKeCef8wB5VCiBB-gWY6sxNCUYviTA,4889
|
|
27
|
+
postladim/variable.py,sha256=-2aihoppYMMmpSpCqaF31XvpinTMaH3Y01-USDIkbBc,6587
|
|
28
|
+
ladim-2.1.6.dist-info/METADATA,sha256=YI0UNYhSahzPv8Za-ekBBFHEMv_yhilg5KAR4i-PVI4,1950
|
|
29
|
+
ladim-2.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
ladim-2.1.6.dist-info/entry_points.txt,sha256=JDlNJo87GJaOkH0-BpAzTPLCrZcuPSdSlHNQ4XmnoRg,41
|
|
31
|
+
ladim-2.1.6.dist-info/top_level.txt,sha256=TK8Gl7d6MsrAQvqKG4b6YJCbB4UL46Se3SzsI-sJAuc,16
|
|
32
|
+
ladim-2.1.6.dist-info/RECORD,,
|
ladim-2.0.9.dist-info/RECORD
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
ladim/__init__.py,sha256=yknbApyGLwkuXI_tlmaf1pWerT0JYcqsUX1925PumLM,51
|
|
2
|
-
ladim/__main__.py,sha256=I1AOHBQDwQNe3fVmDMyC84JcriqidOEURoeoJSOCTzg,24
|
|
3
|
-
ladim/config.py,sha256=l20q8C-TPTM8HkVbdYyDCaTD2jszPQPFwnAEdL8i9vs,5769
|
|
4
|
-
ladim/forcing.py,sha256=880ZtuQkkyZsHKD08ogRC__oGAfu-Y_MrHm7uoZoDGU,3153
|
|
5
|
-
ladim/grid.py,sha256=aZl8HUrY5oJSUKoVEY40reOfAEjClHuNlpzNO1GJK8k,20897
|
|
6
|
-
ladim/main.py,sha256=jsrJY7G37oCzQQDXLrlzc_I_jM7a1a-vmmQx9cuLRms,2906
|
|
7
|
-
ladim/model.py,sha256=zTGZtpXFsVlhT8OqaGFMteMc_nsCJEv3ENehhzKuG60,4221
|
|
8
|
-
ladim/output.py,sha256=1d7p2f3fP5flsRaMdGgGAMU3FaQJg-0OASBAF_cN1II,8317
|
|
9
|
-
ladim/release.py,sha256=lYpuwVYXHntW1Q-jFjkVbveGl7SSIb-EfsJfEZutbXs,8339
|
|
10
|
-
ladim/sample.py,sha256=n8wRGd_VsW_qyQe1ZoTpmfZcdcwB929vsM8PoKG6JTs,8292
|
|
11
|
-
ladim/solver.py,sha256=vOfVUzuQnAylPvtgdP6Ez7_pQGbYDCIYgYfXIbJJ-6M,765
|
|
12
|
-
ladim/state.py,sha256=RkKZQn1G9SbhdA3CTq4jpiN-8YIv1QXDRgI6RZlI7U0,3436
|
|
13
|
-
ladim/tracker.py,sha256=hSlCKlBRyLVEYP40QIGKub6mDYFOApyGhUypLrrP9w8,4977
|
|
14
|
-
ladim/utilities.py,sha256=r7-zShqJhh0cBctDUmtfw-GBOk1eTTYR4S72b0ouiSQ,994
|
|
15
|
-
ladim/gridforce/ROMS.py,sha256=yjEf6KM-nxSn4Hexr-5YctQ0rqjzxMDeL4mmQe3w7Vk,27788
|
|
16
|
-
ladim/gridforce/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
ladim/gridforce/analytical.py,sha256=qI-1LJdjmnwwanzOdrsDZqwGgo73bT75CB7pMaxbHKM,1094
|
|
18
|
-
ladim/gridforce/zROMS.py,sha256=4bnrmcXiWpCAUch9uqd_0XmyKRh-Ll6sFvIHiTbTOOg,23996
|
|
19
|
-
ladim/ibms/__init__.py,sha256=LLKhHJgEu-W6cbFjzg2apc-MPoY9wJF2z7S9W2EeWA0,698
|
|
20
|
-
ladim/ibms/light.py,sha256=POltHmKkX8-q3t9wXyfcseCKEq9Bq-kX1WEJYsr1lNQ,2737
|
|
21
|
-
ladim/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
postladim/__init__.py,sha256=ND-wa5_GNg01Tp0p_1zA1VD804zbfP3o4Cmd8pWU7OE,113
|
|
23
|
-
postladim/cellcount.py,sha256=nCFu9iJmprubn4YmPB4W0VO02GfEb90Iif7D49w1Kss,2054
|
|
24
|
-
postladim/kde_plot.py,sha256=GvMWzT6VxIeXKh1cnqaGzR-4jGG_WIHGMLPpRMXIpo4,1628
|
|
25
|
-
postladim/particlefile.py,sha256=0aif9wYUJ-VrpQKeCef8wB5VCiBB-gWY6sxNCUYviTA,4889
|
|
26
|
-
postladim/variable.py,sha256=-2aihoppYMMmpSpCqaF31XvpinTMaH3Y01-USDIkbBc,6587
|
|
27
|
-
ladim-2.0.9.dist-info/LICENSE,sha256=BgtXyjNr6Ly9nQ7ZLXKpV3r5kWRLnh5MiN0dxp0Bvfc,1085
|
|
28
|
-
ladim-2.0.9.dist-info/METADATA,sha256=ftaYR5SRvCDWj_8rb7EW-tk_RbpBmjmOGYOg7UP9sVs,1884
|
|
29
|
-
ladim-2.0.9.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
30
|
-
ladim-2.0.9.dist-info/entry_points.txt,sha256=JDlNJo87GJaOkH0-BpAzTPLCrZcuPSdSlHNQ4XmnoRg,41
|
|
31
|
-
ladim-2.0.9.dist-info/top_level.txt,sha256=TK8Gl7d6MsrAQvqKG4b6YJCbB4UL46Se3SzsI-sJAuc,16
|
|
32
|
-
ladim-2.0.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|