Skip to content

Commit 6f5981f

Browse files
Make _position_update a class procedure and remove _make_position_update
1 parent bde21c6 commit 6f5981f

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

src/parcels/_core/kernel.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ def __init__(
8080

8181
self._kernels: list[Callable] = kernels
8282

83-
self._position_update = self._make_position_update()
84-
8583
@property #! Ported from v3. To be removed in v4? (/find another way to name kernels in output file)
8684
def funcname(self):
8785
ret = ""
@@ -107,23 +105,19 @@ def remove_deleted(self, pset):
107105
if len(indices) > 0:
108106
pset.remove_indices(indices)
109107

110-
def _make_position_update(self):
111-
# Adding kernels that set and update the coordinate changes
112-
def PositionUpdate(particles, fieldset): # pragma: no cover
113-
particles.lon += particles.dlon
114-
particles.lat += particles.dlat
115-
particles.z += particles.dz
116-
particles.time += particles.dt
117-
118-
particles.dlon = 0
119-
particles.dlat = 0
120-
particles.dz = 0
108+
def _position_update(self, particles, fieldset):
109+
particles.lon += particles.dlon
110+
particles.lat += particles.dlat
111+
particles.z += particles.dz
112+
particles.time += particles.dt
121113

122-
if hasattr(self.fieldset, "RK45_tol"):
123-
# Update dt in case it's increased in RK45 kernel
124-
particles.dt = particles.next_dt
114+
particles.dlon = 0
115+
particles.dlat = 0
116+
particles.dz = 0
125117

126-
return PositionUpdate
118+
if hasattr(self.fieldset, "RK45_tol"):
119+
# Update dt in case it's increased in RK45 kernel
120+
particles.dt = particles.next_dt
127121

128122
def check_fieldsets_in_kernels(self, kernel): # TODO v4: this can go into another method? assert_is_compatible()?
129123
"""

0 commit comments

Comments
 (0)