Skip to content

Commit 0dd60fd

Browse files
Fixing a warn_outputdt_release_desync bug
Fixing a bug where `warn_outputdt_release_desync()` was unintentially raised when startime was not 0.
1 parent e728d46 commit 0dd60fd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

parcels/particleset.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,9 +1085,6 @@ def execute(
10851085
raise ValueError("Output interval should not have finer precision than 1e-6 s")
10861086
outputdt = timedelta_to_float(output_file.outputdt) if output_file else np.inf
10871087

1088-
if np.isfinite(outputdt):
1089-
_warn_outputdt_release_desync(outputdt, self.particledata.data["time_nextloop"])
1090-
10911088
if callbackdt is not None:
10921089
callbackdt = timedelta_to_float(callbackdt)
10931090

@@ -1124,6 +1121,9 @@ def execute(
11241121
"ParticleSet.execute() will not do anything."
11251122
)
11261123

1124+
if np.isfinite(outputdt):
1125+
_warn_outputdt_release_desync(outputdt, starttime, self.particledata.data["time_nextloop"])
1126+
11271127
self.particledata._data["dt"][:] = dt
11281128

11291129
if callbackdt is None:
@@ -1240,12 +1240,13 @@ def execute(
12401240
pbar.close()
12411241

12421242

1243-
def _warn_outputdt_release_desync(outputdt: float, release_times: Iterable[float]):
1243+
def _warn_outputdt_release_desync(outputdt: float, starttime: float, release_times: Iterable[float]):
12441244
"""Gives the user a warning if the release time isn't a multiple of outputdt."""
1245-
if any((np.isfinite(t) and t % outputdt != 0) for t in release_times):
1245+
if any((np.isfinite(t) and (t-starttime) % outputdt != 0) for t in release_times):
12461246
warnings.warn(
1247-
"Some of the particles have a start time that is not a multiple of outputdt. "
1248-
"This could cause the first output to be at a different time than expected.",
1247+
"Some of the particles have a start time difference that is not a multiple of outputdt. "
1248+
"This could cause the first output of some of the particles that start later "
1249+
"in the simulation to be at a different time than expected.",
12491250
FileWarning,
12501251
stacklevel=2,
12511252
)

0 commit comments

Comments
 (0)