From eccb24e5bfcbcef8bca207d2087706a68b9312f0 Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Fri, 25 Oct 2024 11:40:48 +0200 Subject: [PATCH 1/2] Fixing bug when warning is raised if release_times are NaN --- parcels/particleset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parcels/particleset.py b/parcels/particleset.py index e6c819c69..c4e10d4e5 100644 --- a/parcels/particleset.py +++ b/parcels/particleset.py @@ -1078,7 +1078,7 @@ def execute( outputdt = output_file.outputdt if output_file else np.inf if isinstance(outputdt, timedelta): outputdt = outputdt.total_seconds() - if outputdt is not None: + if np.isfinite(outputdt) is not None: _warn_outputdt_release_desync(outputdt, self.particledata.data["time_nextloop"]) if isinstance(callbackdt, timedelta): @@ -1235,7 +1235,7 @@ def execute( 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): 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.", From 64bda71e9f0137b44ca81da7536739e38b1f165d Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Mon, 28 Oct 2024 09:02:58 +0100 Subject: [PATCH 2/2] Update parcels/particleset.py Co-authored-by: Vecko <36369090+VeckoTheGecko@users.noreply.github.com> --- parcels/particleset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parcels/particleset.py b/parcels/particleset.py index c4e10d4e5..706126066 100644 --- a/parcels/particleset.py +++ b/parcels/particleset.py @@ -1078,7 +1078,7 @@ def execute( outputdt = output_file.outputdt if output_file else np.inf if isinstance(outputdt, timedelta): outputdt = outputdt.total_seconds() - if np.isfinite(outputdt) is not None: + if np.isfinite(outputdt): _warn_outputdt_release_desync(outputdt, self.particledata.data["time_nextloop"]) if isinstance(callbackdt, timedelta):