Skip to content

Commit 83315d4

Browse files
Fixing diffusion tutorial
1 parent 4b59f90 commit 83315d4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docs/user_guide/examples/tutorial_diffusion.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@
265265
"outputs": [],
266266
"source": [
267267
"testParticles = get_test_particles()\n",
268-
"testParticles.update_dt_dtype(\"timedelta64[ms]\")\n",
269268
"output_file = parcels.ParticleFile(\n",
270269
" store=\"M1_out.zarr\",\n",
271270
" chunks=(len(testParticles), 50),\n",
@@ -345,7 +344,6 @@
345344
"outputs": [],
346345
"source": [
347346
"testParticles = get_test_particles()\n",
348-
"testParticles.update_dt_dtype(\"timedelta64[ms]\")\n",
349347
"output_file = parcels.ParticleFile(\n",
350348
" store=\"EM_out.zarr\",\n",
351349
" chunks=(len(testParticles), 50),\n",
@@ -458,8 +456,12 @@
458456
" A = A / sq_deg_to_sq_m\n",
459457
" Kh = fieldset.Cs * A * np.sqrt(dudx**2 + 0.5 * (dudy + dvdx) ** 2 + dvdy**2)\n",
460458
"\n",
461-
" dlat = np.random.normal(0.0, 1.0, dt.shape) * np.sqrt(2 * np.fabs(dt) * Kh)\n",
462-
" dlon = np.random.normal(0.0, 1.0, dt.shape) * np.sqrt(2 * np.fabs(dt) * Kh)\n",
459+
" dlat = np.random.normal(0.0, 1.0, particles.dt.shape) * np.sqrt(\n",
460+
" 2 * np.fabs(particles.dt) * Kh\n",
461+
" )\n",
462+
" dlon = np.random.normal(0.0, 1.0, particles.dt.shape) * np.sqrt(\n",
463+
" 2 * np.fabs(particles.dt) * Kh\n",
464+
" )\n",
463465
" particles.dlat += dlat\n",
464466
" particles.dlon += dlon"
465467
]

src/parcels/_core/particleset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def _get_simulation_start_and_end_times(
633633

634634
def _get_start_time(first_release_time, time_interval, sign_dt, runtime):
635635
if time_interval is None:
636-
time_interval = TimeInterval(np.timedelta64(0, "s"), right=np.timedelta64(int(runtime), "s"))
636+
time_interval = TimeInterval(np.timedelta64(0, "s"), right=np.timedelta64(int(runtime * 1e9), "ns"))
637637

638638
if sign_dt == 1:
639639
fieldset_start = 0.0

0 commit comments

Comments
 (0)