Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvansebille authored Jun 18, 2024
2 parents 9aceb95 + 6d72df7 commit 3b9aa3e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions parcels/fieldset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ def computeTimeChunk(self, time=0., dt=1):
Default is 1.
"""
signdt = np.sign(dt)
nextTime = np.infty if dt > 0 else -np.infty
nextTime = np.inf if dt > 0 else -np.inf

for g in self.gridset.grids:
g.update_status = 'not_updated'
Expand Down Expand Up @@ -1320,7 +1320,7 @@ def computeTimeChunk(self, time=0., dt=1):
depth_data = f.grid.depth_field.data
f.grid.depth = depth_data if isinstance(depth_data, np.ndarray) else np.array(depth_data)

if abs(nextTime) == np.infty or np.isnan(nextTime): # Second happens when dt=0
if abs(nextTime) == np.inf or np.isnan(nextTime): # Second happens when dt=0
return nextTime
else:
nSteps = int((nextTime - time) / dt)
Expand Down
2 changes: 1 addition & 1 deletion parcels/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def add_Sdepth_periodic_halo(self, zonal, meridional, halosize):
assert self.depth.shape[2] == self.ydim, "Third dim must be y."

def computeTimeChunk(self, f, time, signdt):
nextTime_loc = np.infty if signdt >= 0 else -np.infty
nextTime_loc = np.inf if signdt >= 0 else -np.inf
periods = self.periods.value if isinstance(self.periods, c_int) else self.periods
prev_time_indices = self.time
if self.update_status == 'not_updated':
Expand Down
2 changes: 1 addition & 1 deletion parcels/particlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ParticleFile(ABC):
time_origin = None
lonlatdepth_dtype = None

def __init__(self, name, particleset, outputdt=np.infty, chunks=None, create_new_zarrfile=True):
def __init__(self, name, particleset, outputdt=np.inf, chunks=None, create_new_zarrfile=True):

self.outputdt = outputdt.total_seconds() if isinstance(outputdt, delta) else outputdt
self.chunks = chunks
Expand Down
8 changes: 4 additions & 4 deletions parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def execute(self, pyfunc=AdvectionRK4, pyfunc_inter=None, endtime=None, runtime=
raise ValueError('Time step dt is too small')
if (dt * 1e6) % 1 != 0:
raise ValueError('Output interval should not have finer precision than 1e-6 s')
outputdt = output_file.outputdt if output_file else np.infty
outputdt = output_file.outputdt if output_file else np.inf
if isinstance(outputdt, delta):
outputdt = outputdt.total_seconds()
if isinstance(callbackdt, delta):
Expand Down Expand Up @@ -920,19 +920,19 @@ def execute(self, pyfunc=AdvectionRK4, pyfunc_inter=None, endtime=None, runtime=
self.particledata._data['dt'][:] = dt

if callbackdt is None:
interupt_dts = [np.infty, outputdt]
interupt_dts = [np.inf, outputdt]
if self.repeatdt is not None:
interupt_dts.append(self.repeatdt)
callbackdt = np.min(np.array(interupt_dts))
time = starttime
if self.repeatdt:
next_prelease = self.repeat_starttime + (abs(time - self.repeat_starttime) // self.repeatdt + 1) * self.repeatdt * np.sign(dt)
else:
next_prelease = np.infty if dt > 0 else - np.infty
next_prelease = np.inf if dt > 0 else - np.inf
if output_file:
next_output = time + dt
else:
next_output = time + np.infty if dt > 0 else - np.infty
next_output = time + np.inf if dt > 0 else - np.inf
next_callback = time + callbackdt if dt > 0 else time - callbackdt
next_input = self.fieldset.computeTimeChunk(time, np.sign(dt)) if self.fieldset is not None else np.inf

Expand Down

0 comments on commit 3b9aa3e

Please sign in to comment.