|
15 | 15 | from parcels.application_kernels.advection import AdvectionRK4 |
16 | 16 | from parcels.compilation.codecompiler import GNUCompiler |
17 | 17 | from parcels.field import NestedField |
18 | | -from parcels.fieldset import FieldSet |
19 | 18 | from parcels.grid import CurvilinearGrid, GridType |
20 | 19 | from parcels.interaction.interactionkernel import InteractionKernel |
21 | 20 | from parcels.interaction.neighborsearch import ( |
@@ -175,7 +174,8 @@ def ArrayClass_init(self, *args, **kwargs): |
175 | 174 | raise NotImplementedError("If fieldset.time_origin is not a date, time of a particle must be a double") |
176 | 175 | time = np.array([self.time_origin.reltime(t) if _convert_to_reltime(t) else t for t in time]) |
177 | 176 | assert lon.size == time.size, "time and positions (lon, lat, depth) do not have the same lengths." |
178 | | - _warn_particle_times_outside_fieldset_time_bounds(time, fieldset) |
| 177 | + if not fieldset.U.allow_time_extrapolation: |
| 178 | + _warn_particle_times_outside_fieldset_time_bounds(time, fieldset.U.grid.time_full) |
179 | 179 |
|
180 | 180 | if lonlatdepth_dtype is None: |
181 | 181 | lonlatdepth_dtype = self.lonlatdepth_dtype_from_field_interp_method(fieldset.U) |
@@ -1254,15 +1254,15 @@ def _warn_outputdt_release_desync(outputdt: float, starttime: float, release_tim |
1254 | 1254 | ) |
1255 | 1255 |
|
1256 | 1256 |
|
1257 | | -def _warn_particle_times_outside_fieldset_time_bounds(time: np.ndarray, fieldset: FieldSet): |
1258 | | - if np.any(time): |
1259 | | - if np.any(time < fieldset.U.grid.time_full[0]) and not fieldset.U.allow_time_extrapolation: # type: ignore[attr-defined] |
| 1257 | +def _warn_particle_times_outside_fieldset_time_bounds(release_times: np.ndarray, time_full: np.ndarray): |
| 1258 | + if np.any(release_times): |
| 1259 | + if np.any(release_times < time_full[0]): |
1260 | 1260 | warnings.warn( |
1261 | 1261 | "Some particles are set to be released before the fieldset's first time and allow_time_extrapolation is set to False.", |
1262 | 1262 | ParticleSetWarning, |
1263 | 1263 | stacklevel=2, |
1264 | 1264 | ) |
1265 | | - if np.any(time > fieldset.U.grid.time_full[-1]) and not fieldset.U.allow_time_extrapolation: # type: ignore[attr-defined] |
| 1265 | + if np.any(release_times > time_full[-1]): |
1266 | 1266 | warnings.warn( |
1267 | 1267 | "Some particles are set to be released after the fieldset's last time and allow_time_extrapolation is set to False.", |
1268 | 1268 | ParticleSetWarning, |
|
0 commit comments