Skip to content

Commit 62cb3be

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 7bbdcd6 commit 62cb3be

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

asv_bench/benchmarks/benchmark_argofloat.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
import pandas as pd
55
import xarray as xr
6+
67
from parcels import AdvectionRK4, FieldSet, JITParticle, ParticleSet, StatusCode, Variable
78

89

@@ -56,10 +57,10 @@ def ArgoVerticalMovement(particle, fieldset, time):
5657
class ArgoFloatJIT:
5758
def setup(self):
5859
time = pd.date_range(start="2025-01-01", end="2025-02-16", freq="D")
59-
lon = np.linspace(-180,180,120)
60-
lat = np.linspace(-90,90,100)
60+
lon = np.linspace(-180, 180, 120)
61+
lat = np.linspace(-90, 90, 100)
6162

62-
Lon,Lat = np.meshgrid(lon,lat)
63+
Lon, Lat = np.meshgrid(lon, lat)
6364

6465
# Create large-scale gyre flow
6566
U_gyre = np.cos(np.radians(Lat)) * np.sin(np.radians(Lon)) # Zonal flow
@@ -78,28 +79,32 @@ def setup(self):
7879
U_final = U_coriolis + U_noise
7980
V_final = V_coriolis + V_noise
8081

81-
depth = np.linspace(0,2000,100)
82-
83-
U_val = np.tile(U_final[None,None, :, :], (len(time), len(depth),1, 1)) # Repeat for each time step
84-
V_val = np.tile(V_final[None,None, :, :], (len(time), len(depth),1, 1))
82+
depth = np.linspace(0, 2000, 100)
83+
84+
U_val = np.tile(U_final[None, None, :, :], (len(time), len(depth), 1, 1)) # Repeat for each time step
85+
V_val = np.tile(V_final[None, None, :, :], (len(time), len(depth), 1, 1))
8586

86-
U = xr.DataArray(U_val,
87-
dims = ['time','depth','lat','lon'],
88-
coords = {'time':time, 'depth':depth,'lat':lat, 'lon':lon},
89-
name='U_velocity')
87+
U = xr.DataArray(
88+
U_val,
89+
dims=["time", "depth", "lat", "lon"],
90+
coords={"time": time, "depth": depth, "lat": lat, "lon": lon},
91+
name="U_velocity",
92+
)
9093

91-
V = xr.DataArray(V_val,
92-
dims = ['time','depth','lat','lon'],
93-
coords = {'time':time, 'depth':depth,'lat':lat, 'lon':lon},
94-
name='V_velocity')
94+
V = xr.DataArray(
95+
V_val,
96+
dims=["time", "depth", "lat", "lon"],
97+
coords={"time": time, "depth": depth, "lat": lat, "lon": lon},
98+
name="V_velocity",
99+
)
95100

96-
ds = xr.Dataset({"U":U, "V":V})
101+
ds = xr.Dataset({"U": U, "V": V})
97102

98103
variables = {
99104
"U": "U",
100105
"V": "V",
101106
}
102-
dimensions = {"lat": "lat", "lon": "lon", "time": "time", "depth":"depth"}
107+
dimensions = {"lat": "lat", "lon": "lon", "time": "time", "depth": "depth"}
103108
fieldset = FieldSet.from_xarray_dataset(ds, variables, dimensions)
104109
# uppermost layer in the hydrodynamic data
105110
fieldset.mindepth = fieldset.U.depth[0]
@@ -114,8 +119,7 @@ def setup(self):
114119

115120
self.pset = ParticleSet(fieldset=fieldset, pclass=ArgoParticle, lon=[32], lat=[-31], depth=[0])
116121

117-
118122
def time_run_many_timesteps(self):
119-
self.pset.execute([ArgoVerticalMovement, AdvectionRK4], runtime=timedelta(seconds=1 * 30), dt=timedelta(seconds=30))
120-
121-
123+
self.pset.execute(
124+
[ArgoVerticalMovement, AdvectionRK4], runtime=timedelta(seconds=1 * 30), dt=timedelta(seconds=30)
125+
)

0 commit comments

Comments
 (0)