Skip to content

Commit 21d7c73

Browse files
Further speeding up access pattern creation in XLinear
1 parent a0c0573 commit 21d7c73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

parcels/application_kernels/interpolation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def XLinear(
5252
axis_dim = field.grid.get_axis_dim_mapping(field.data.dims)
5353
data = field.data
5454

55-
lenT = 2 if any(tau > 0) else 1
56-
lenZ = 2 if any(zeta > 0) else 1
55+
lenT = 2 if np.any(tau > 0) else 1
56+
lenZ = 2 if np.any(zeta > 0) else 1
5757

5858
# Time coordinates: 8 points at ti, then 8 points at ti+1
5959
if lenT == 1:
@@ -68,10 +68,10 @@ def XLinear(
6868
zi = np.tile(np.stack([zi, zi, zi, zi, zi + 1, zi + 1, zi + 1, zi + 1], axis=1).flatten(), lenT)
6969

7070
# Y coordinates: [yi, yi, yi+1, yi+1] pattern repeated
71-
yi = np.tile(np.stack([yi, yi, yi + 1, yi + 1], axis=1).flatten(), (lenT) * (lenZ))
71+
yi = np.tile(np.repeat([yi, yi + 1], 2), (lenT) * (lenZ))
7272

7373
# X coordinates: [xi, xi+1] for each spatial point, repeated for time/depth
74-
xi = np.tile(np.stack([xi, xi + 1], axis=1).flatten(), 2 * (lenT) * (lenZ))
74+
xi = np.repeat([xi, xi + 1], 2 * (lenT) * (lenZ))
7575

7676
# Clip indices to valid ranges
7777
ti = np.clip(ti, 0, data.shape[0] - 1)

0 commit comments

Comments
 (0)