Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,9 +1085,6 @@ def execute(
raise ValueError("Output interval should not have finer precision than 1e-6 s")
outputdt = timedelta_to_float(output_file.outputdt) if output_file else np.inf

if np.isfinite(outputdt):
_warn_outputdt_release_desync(outputdt, self.particledata.data["time_nextloop"])

if callbackdt is not None:
callbackdt = timedelta_to_float(callbackdt)

Expand Down Expand Up @@ -1124,6 +1121,9 @@ def execute(
"ParticleSet.execute() will not do anything."
)

if np.isfinite(outputdt):
_warn_outputdt_release_desync(outputdt, starttime, self.particledata.data["time_nextloop"])

self.particledata._data["dt"][:] = dt

if callbackdt is None:
Expand Down Expand Up @@ -1240,12 +1240,13 @@ def execute(
pbar.close()


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