Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix warn_outputdt_release_desync for NaN release times #1744

Merged
merged 3 commits into from
Oct 28, 2024
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
5 changes: 2 additions & 3 deletions parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,9 @@
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 = timedelta_to_float(output_file.outputdt) if output_file else np.inf

if outputdt is not None:
if np.isfinite(outputdt):

Check warning on line 1083 in parcels/particleset.py

View check run for this annotation

Codecov / codecov/patch

parcels/particleset.py#L1083

Added line #L1083 was not covered by tests
_warn_outputdt_release_desync(outputdt, self.particledata.data["time_nextloop"])

if callbackdt is not None:
Expand Down Expand Up @@ -1238,7 +1237,7 @@

def _warn_outputdt_release_desync(outputdt: float, release_times: Iterable[float]):
"""Gives the user a warning if the release time isn't a multiple of outputdt."""
if any(t % outputdt != 0 for t in release_times):
if any((np.isfinite(t) and t % outputdt != 0) for t in release_times):

Check warning on line 1240 in parcels/particleset.py

View check run for this annotation

Codecov / codecov/patch

parcels/particleset.py#L1240

Added line #L1240 was not covered by tests
VeckoTheGecko marked this conversation as resolved.
Show resolved Hide resolved
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.",
Expand Down
Loading