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

Re-ordering of Kernel actions to vectorially sum particle displacements #1402

Merged
merged 90 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
762c72e
Update test_kernel_execution.py
erikvansebille Jun 18, 2023
74d6c80
Adding support for dcoord in JIT and Scipy mode
erikvansebille Jun 20, 2023
294e787
Renaming to particle_dlon, particle_dlat etc for easier use
erikvansebille Jun 23, 2023
57f4a4c
Merge branch 'master' into vectorial_summing_particle_moves_at_end_of…
erikvansebille Jul 4, 2023
b826fef
Also using particle_dlon and particle_dlat in advectiondiffusion kernels
erikvansebille Jul 5, 2023
ec9ead4
Making sure extra kernels are only compiled once in scipy
erikvansebille Jul 7, 2023
830b3a9
Making sure particle.dt can't get too small (zero) in RK45
erikvansebille Jul 10, 2023
caf7418
Using explicit Euler Forward in Recovery Kernel
erikvansebille Jul 10, 2023
a8b5745
Merge branch 'master' into vectorial_summing_zarr_approach
erikvansebille Jul 27, 2023
eb9e54f
Adding unit test for field sampling
erikvansebille Jul 27, 2023
737d90d
Removing Interpolation and sampling on time-varying Fields from tutor…
erikvansebille Jul 27, 2023
7ffb0d2
Support for vectorial summing in Analytical Advection kernel
erikvansebille Jul 27, 2023
c6669c0
Removing write_ondelete option from particlefiel
erikvansebille Jul 20, 2023
32ad39c
Adding extra variables lon_towrite, lat_towrite and depth_towrite
erikvansebille Jul 27, 2023
84a9bf0
Minor fixes to code
erikvansebille Jul 27, 2023
5c865fc
Fixing time-stepping for writing vectorial form
erikvansebille Jul 31, 2023
4d2f7f9
Fixing initialisation and printing of towrite variables
erikvansebille Jul 31, 2023
2bff74c
Changing AdvectionAnalytical to use particle.lon instead of dlon
erikvansebille Jul 31, 2023
1ecf030
Adding time_towrite to Particle
erikvansebille Aug 1, 2023
72a69e7
Updating timing of output in pset.execute
erikvansebille Aug 1, 2023
3e1e6a3
First attempt at rewrite of particle loop and Recovery-Kernels in scipy
erikvansebille Aug 1, 2023
84a8fa7
Fixing particle.time updates in the JIT loop
erikvansebille Aug 1, 2023
811c406
First update to codeconverter to remove RecoveryKernels
erikvansebille Aug 2, 2023
e4630ed
Fixing return error code in codeconverter
erikvansebille Aug 2, 2023
17ca3f7
Using time_towrite in soa-writing
erikvansebille Aug 2, 2023
b75acfb
Using particle.state throughout JIT loop
erikvansebille Aug 2, 2023
813dfc4
Updating parcels to work on test_fieldset_sampling and test_particle_…
erikvansebille Aug 2, 2023
6d7ba4b
Adding support for the test_advection unit tests
erikvansebille Aug 3, 2023
9391cc1
Minor fixes to code
erikvansebille Aug 3, 2023
19956c6
Fixing test_fieldset unit tests
erikvansebille Aug 3, 2023
d5aa50b
Using dt as first output timestep in particle loop
erikvansebille Aug 4, 2023
be97871
Using return in codegenerator (instead of particle.state)
erikvansebille Aug 4, 2023
c8fcefd
Fixing sign check if Kernel loop
erikvansebille Aug 4, 2023
6e778df
Increasing tolerance for test_fieldset_write
erikvansebille Aug 4, 2023
f46561d
Fixing last fieldset unit tests
erikvansebille Aug 4, 2023
46ade86
Fixing unit tests in test_grids
erikvansebille Aug 4, 2023
ed7b69a
Fixing unit tests in test_kernel_execution
erikvansebille Aug 4, 2023
4dc868a
Removing AOS from breaking test_fieldset
erikvansebille Aug 4, 2023
55a035d
Fixing unit tests in test_kernel_language
erikvansebille Aug 4, 2023
fda5b78
Fixing unit tests in test_particle_sets
erikvansebille Aug 4, 2023
7e294b8
Fixing unit tests in test_particles and test_interaction_kernel
erikvansebille Aug 4, 2023
e268ae1
Fixing where time is set for interaction kernels
erikvansebille Aug 4, 2023
7b642a4
Merge branch 'master' into vectorial_summing_zarr_approach
erikvansebille Aug 4, 2023
4e10ea4
Fixing flake8 errors
erikvansebille Aug 4, 2023
0121221
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2023
91cc712
Updating SubmergeParticle Kernel
erikvansebille Aug 7, 2023
3eede31
Merge branch 'vectorial_summing_zarr_approach' of https://github.com/…
erikvansebille Aug 7, 2023
6b0fdd8
Removing Recovery Kernels from Parcels
erikvansebille Aug 7, 2023
beb7505
Removing execute_once option from particleset
erikvansebille Aug 7, 2023
a125927
Removing SummedFields from parcels
erikvansebille Aug 7, 2023
f71423f
Setting all variables to zero in C code
erikvansebille Aug 8, 2023
116181c
Removing particlefile.close method
erikvansebille Aug 8, 2023
5c3b060
Simplifying statuscodes
erikvansebille Aug 8, 2023
51a1607
Removing Variable initialisation by Field
erikvansebille Aug 8, 2023
9b96c2d
Removing lasttime_written variable, as not needed anymore
erikvansebille Aug 8, 2023
8fba532
Fixing pydocstyle error
erikvansebille Aug 8, 2023
acd2afd
Removing redundant obs_written array in ParticleFile
erikvansebille Aug 8, 2023
deeaa04
Adding particlefile.write_latest_locations function
erikvansebille Aug 25, 2023
bea0148
Updating examples to new vectorial summing
erikvansebille Aug 25, 2023
6249c9e
Updating parcels_tutorial to new vectorial summing code
erikvansebille Aug 25, 2023
cac5e8d
Removing the SummedFields tutorial
erikvansebille Aug 25, 2023
86fbab6
Merge branch 'master' into vectorial_summing_zarr_approach
erikvansebille Aug 25, 2023
c22626f
Updating all the tutorials
erikvansebille Aug 25, 2023
6fc6d91
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 25, 2023
cc84151
Fixing pydocstyle error
erikvansebille Aug 25, 2023
d3b32c1
Fixing writing of Analytical Advection too
erikvansebille Aug 25, 2023
044012f
Removing lastexecution variable from particleset execution loop
erikvansebille Aug 25, 2023
2849496
Fixing analytical test_advection for very small negative times
erikvansebille Aug 25, 2023
301eb29
Adding todo for particle._next_dt Variable
erikvansebille Aug 29, 2023
7aa43c6
Getting test_advection to work for lon_nextloop approach
erikvansebille Aug 29, 2023
f7bbed3
Also updating other tests (except for interaction)
erikvansebille Sep 1, 2023
a746d05
Removing _next_dt from Particle class
erikvansebille Sep 1, 2023
ce33bc5
More removing of _next_dt from codegenerator
erikvansebille Sep 1, 2023
ac09b8c
Updating examples to next_loop
erikvansebille Sep 1, 2023
7d150bc
Updating interaction code to lon_towrite
erikvansebille Sep 1, 2023
56e69db
Removing redundant arguments to evaluate_particle
erikvansebille Sep 1, 2023
220ede5
Updating kernels to not use particle.lon etc
erikvansebille Sep 1, 2023
5b1dbe6
Adding first draft of kernelloop tutorial
erikvansebille Sep 2, 2023
34e99ee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2023
aa79977
Fixing broken tests in test_particle_sets
erikvansebille Sep 2, 2023
6245845
Expanding kernelloop tutorial with info on StatusCodes
erikvansebille Sep 2, 2023
8d3e31b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2023
b69a04f
Merge pull request #1422 from OceanParcels/from-lon_torwrite-to-lon_n…
erikvansebille Sep 2, 2023
1f51763
Merge branch 'vectorial_summing_zarr_approach' of https://github.com/…
erikvansebille Sep 2, 2023
eb47d55
Slight increase in tolerance for diffusion test
erikvansebille Sep 4, 2023
28a4f1c
Update tutorial_kernelloop.ipynb with suggestions
michaeldenes Sep 5, 2023
64e7788
Updating broken tutorial links and adding kernelloop icon
erikvansebille Sep 5, 2023
ae03c56
Added a basic wind example to the tutorial
michaeldenes Sep 6, 2023
8f439df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 6, 2023
af09027
Updating example code in tutorial_kernelloop
erikvansebille Sep 6, 2023
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
Binary file added docs/_static/loop-icon.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ def linkcode_resolve(domain, info):
'examples/tutorial_interaction': '_static/pulled_particles_twoatractors_line.gif',
'examples/documentation_LargeRunsOutput': '_static/harddrive.png',
'examples/tutorial_unitconverters': '_static/globe-icon.jpg',
'examples/documentation_geospatial': '_images/tutorial_geospatial_google_earth.png'
'examples/documentation_geospatial': '_images/tutorial_geospatial_google_earth.png',
'examples/tutorial_kernelloop': '_static/loop-icon.jpeg',
}
# -- Options for LaTeX output ---------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Parcels has several documentation and tutorial Jupyter notebooks which go throug
examples/documentation_indexing.ipynb
examples/tutorial_nemo_curvilinear.ipynb
examples/tutorial_nemo_3D.ipynb
examples/tutorial_SummedFields.ipynb
examples/tutorial_NestedFields.ipynb
examples/tutorial_timevaryingdepthdimensions.ipynb
examples/tutorial_periodic_boundaries.ipynb
Expand All @@ -47,6 +46,7 @@ Parcels has several documentation and tutorial Jupyter notebooks which go throug
examples/tutorial_particle_field_interaction.ipynb
examples/tutorial_interaction.ipynb
examples/tutorial_analyticaladvection.ipynb
examples/tutorial_kernelloop.ipynb


.. nbgallery::
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/example_brownian.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_brownian_example(mode, mesh, npart=3000):
ys = pset.lat * mesh_conversion(mesh)
xs = pset.lon * mesh_conversion(mesh) # since near equator, we do not need to care about curvature effect

tol = 200 # 200m tolerance
tol = 250 # 250m tolerance
assert np.allclose(np.std(xs), expected_std_x, atol=tol)
assert np.allclose(np.std(ys), expected_std_y, atol=tol)
assert np.allclose(np.mean(xs), 0, atol=tol)
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/example_dask_chunk_OCMs.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@

def periodicBC(particle, fieldSet, time):
if particle.lon > 15.0:
particle.lon -= 15.0
particle_dlon -= 15.0 # noqa

Check warning on line 186 in docs/examples/example_dask_chunk_OCMs.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_dask_chunk_OCMs.py#L186

Added line #L186 was not covered by tests
if particle.lon < 0:
particle.lon += 15.0
particle_dlon += 15.0 # noqa

Check warning on line 188 in docs/examples/example_dask_chunk_OCMs.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_dask_chunk_OCMs.py#L188

Added line #L188 was not covered by tests
if particle.lat > 60.0:
particle.lat -= 11.0
particle_dlat -= 11.0 # noqa

Check warning on line 190 in docs/examples/example_dask_chunk_OCMs.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_dask_chunk_OCMs.py#L190

Added line #L190 was not covered by tests
if particle.lat < 49.0:
particle.lat += 11.0
particle_dlat += 11.0 # noqa

Check warning on line 192 in docs/examples/example_dask_chunk_OCMs.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_dask_chunk_OCMs.py#L192

Added line #L192 was not covered by tests

pset = ParticleSet.from_list(field_set, ptype[mode], lon=lonp, lat=latp)
pfile = ParticleFile("nemo_particles_chunk", pset, outputdt=delta(days=1))
Expand Down
31 changes: 6 additions & 25 deletions docs/examples/example_globcurrent.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from parcels import (
AdvectionRK4,
ErrorCode,
Field,
FieldSet,
JITParticle,
Expand Down Expand Up @@ -68,8 +67,8 @@
fieldsetall = set_globcurrent_fieldset(files[0:10], deferred_load=False, use_xarray=use_xarray)
psetall = ParticleSet.from_list(fieldset=fieldsetall, pclass=ptype[mode], lon=[lonstart], lat=[latstart])
if dt < 0:
psetsub[0].time = fieldsetsub.U.grid.time[-1]
psetall[0].time = fieldsetall.U.grid.time[-1]
psetsub[0].time_nextloop = fieldsetsub.U.grid.time[-1]
psetall[0].time_nextloop = fieldsetall.U.grid.time[-1]

psetsub.execute(AdvectionRK4, runtime=delta(days=7), dt=dt)
psetall.execute(AdvectionRK4, runtime=delta(days=7), dt=dt)
Expand Down Expand Up @@ -101,7 +100,7 @@
fieldset = set_globcurrent_fieldset(time_periodic=delta(days=365), deferred_load=deferred_load)

class MyParticle(ptype[mode]):
sample_var = Variable('sample_var', initial=fieldset.U)
sample_var = Variable('sample_var', initial=0.)

pset = ParticleSet(fieldset, pclass=MyParticle, lon=25, lat=-35, time=fieldset.U.grid.time[0])

Expand Down Expand Up @@ -184,20 +183,6 @@
pset.execute(AdvectionRK4, dt=0.)


@pytest.mark.parametrize('mode', ['scipy', 'jit'])
@pytest.mark.parametrize('dt', [-300, 300])
@pytest.mark.parametrize('use_xarray', [True, False])
def test_globcurrent_variable_fromfield(mode, dt, use_xarray):
fieldset = set_globcurrent_fieldset(use_xarray=use_xarray)

class MyParticle(ptype[mode]):
sample_var = Variable('sample_var', initial=fieldset.U)
time = fieldset.U.grid.time[0] if dt > 0 else fieldset.U.grid.time[-1]
pset = ParticleSet(fieldset, pclass=MyParticle, lon=[25], lat=[-35], time=time)

pset.execute(AdvectionRK4, runtime=delta(days=1), dt=dt)


@pytest.mark.parametrize('mode', ['scipy', 'jit'])
@pytest.mark.parametrize('dt', [-300, 300])
@pytest.mark.parametrize('with_starttime', [True, False])
Expand Down Expand Up @@ -235,10 +220,7 @@

def DeleteP0(particle, fieldset, time):
if particle.id == 0:
return ErrorCode.ErrorOutOfBounds # we want to pass through recov loop

def DeleteParticle(particle, fieldset, time):
particle.delete()
particle.delete()

Check warning on line 223 in docs/examples/example_globcurrent.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_globcurrent.py#L223

Added line #L223 was not covered by tests

pset0 = ParticleSet(fieldset, pclass=ptype[mode],
lon=[25, 25],
Expand All @@ -247,8 +229,7 @@

pset0.execute(pset0.Kernel(DeleteP0)+AdvectionRK4,
runtime=delta(days=rundays),
dt=delta(minutes=5),
recovery={ErrorCode.ErrorOutOfBounds: DeleteParticle})
dt=delta(minutes=5))

pset1 = ParticleSet(fieldset, pclass=ptype[mode],
lon=[25, 25],
Expand All @@ -273,7 +254,7 @@
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=25, lat=-35)
pfile = pset.ParticleFile(filename, outputdt=delta(hours=6))
pset.execute(AdvectionRK4, runtime=delta(days=1), dt=dt, output_file=pfile)
pfile.close()
pfile.write_latest_locations(pset, max(pset.time_nextloop))

restarttime = np.nanmax if dt > 0 else np.nanmin
pset_new = ParticleSet.from_particlefile(fieldset, pclass=ptype[mode], filename=filename, restarttime=restarttime)
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/example_mitgcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

def periodicBC(particle, fieldset, time):
if particle.lon < 0:
particle.lon += fieldset.domain_width
particle_dlon += fieldset.domain_width # noqa

Check warning on line 38 in docs/examples/example_mitgcm.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_mitgcm.py#L38

Added line #L38 was not covered by tests
elif particle.lon > fieldset.domain_width:
particle.lon -= fieldset.domain_width
particle_dlon -= fieldset.domain_width # noqa

Check warning on line 40 in docs/examples/example_mitgcm.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_mitgcm.py#L40

Added line #L40 was not covered by tests

# Release particles 5 cells away from the Eastern boundary
pset = ParticleSet.from_line(
Expand All @@ -54,7 +54,6 @@
pset.execute(
kernels, runtime=delta(days=5), dt=delta(minutes=30), output_file=pfile
)
pfile.close()


def test_mitgcm_output_compare():
Expand Down
23 changes: 16 additions & 7 deletions docs/examples/example_moving_eddies.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@
pset.execute(method, endtime=0, dt=-dt,
output_file=pset.ParticleFile(name=outfile, outputdt=outputdt))

# Also include last timestep
for var in ['lon', 'lat', 'depth', 'time']:
pset.collection.setallvardata(f"{var}", pset.collection.getvardata(f"{var}_nextloop"))

assert np.allclose(pset.lon, lons)
assert np.allclose(pset.lat, lats)
return pset


@pytest.mark.parametrize('mode', ['scipy', 'jit'])
Expand All @@ -177,6 +180,9 @@
fieldset = moving_eddies_fieldset(mesh=mesh)
outfile = tmpdir.join("EddyParticle")
pset = moving_eddies_example(fieldset, outfile, 2, mode=mode)
# Also include last timestep
for var in ['lon', 'lat', 'depth', 'time']:
pset.collection.setallvardata(f"{var}", pset.collection.getvardata(f"{var}_nextloop"))
if mesh == 'flat':
assert (pset[0].lon < 2.2e5 and 1.1e5 < pset[0].lat < 1.2e5)
assert (pset[1].lon < 2.2e5 and 3.7e5 < pset[1].lat < 3.8e5)
Expand All @@ -200,6 +206,9 @@
fieldset = FieldSet.from_parcels(fieldsetfile(mesh, tmpdir), extra_fields={'P': 'P'})
outfile = tmpdir.join("EddyParticle")
pset = moving_eddies_example(fieldset, outfile, 2, mode=mode)
# Also include last timestep
for var in ['lon', 'lat', 'depth', 'time']:
pset.collection.setallvardata(f"{var}", pset.collection.getvardata(f"{var}_nextloop"))
if mesh == 'flat':
assert (pset[0].lon < 2.2e5 and 1.1e5 < pset[0].lat < 1.2e5)
assert (pset[1].lon < 2.2e5 and 3.7e5 < pset[1].lat < 3.8e5)
Expand All @@ -226,17 +235,17 @@

def periodicBC(particle, fieldset, time):
if particle.lon < fieldset.halo_west:
particle.lon += fieldset.halo_east - fieldset.halo_west
particle_dlon += fieldset.halo_east - fieldset.halo_west # noqa

Check warning on line 238 in docs/examples/example_moving_eddies.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_moving_eddies.py#L238

Added line #L238 was not covered by tests
elif particle.lon > fieldset.halo_east:
particle.lon -= fieldset.halo_east - fieldset.halo_west
particle_dlon -= fieldset.halo_east - fieldset.halo_west # noqa

Check warning on line 240 in docs/examples/example_moving_eddies.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_moving_eddies.py#L240

Added line #L240 was not covered by tests
if particle.lat < fieldset.halo_south:
particle.lat += fieldset.halo_north - fieldset.halo_south
particle_dlat += fieldset.halo_north - fieldset.halo_south # noqa

Check warning on line 242 in docs/examples/example_moving_eddies.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_moving_eddies.py#L242

Added line #L242 was not covered by tests
elif particle.lat > fieldset.halo_north:
particle.lat -= fieldset.halo_north - fieldset.halo_south
particle_dlat -= fieldset.halo_north - fieldset.halo_south # noqa

Check warning on line 244 in docs/examples/example_moving_eddies.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_moving_eddies.py#L244

Added line #L244 was not covered by tests

def slowlySouthWestward(particle, fieldset, time):
particle.lon = particle.lon - 5 * particle.dt / 1e5
particle.lat -= 3 * particle.dt / 1e5
particle_dlon -= 5 * particle.dt / 1e5 # noqa
particle_dlat -= 3 * particle.dt / 1e5 # noqa

Check warning on line 248 in docs/examples/example_moving_eddies.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_moving_eddies.py#L247-L248

Added lines #L247 - L248 were not covered by tests

kernels = pset.Kernel(AdvectionRK4)+slowlySouthWestward+periodicBC
pset.execute(kernels, runtime=delta(days=6), dt=delta(hours=1))
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/example_nemo_curvilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

def periodicBC(particle, fieldSet, time):
if particle.lon > 180:
particle.lon -= 360
particle_dlon -= 360 # noqa

Check warning on line 52 in docs/examples/example_nemo_curvilinear.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_nemo_curvilinear.py#L52

Added line #L52 was not covered by tests

pset = ParticleSet.from_list(field_set, ptype[mode], lon=lonp, lat=latp)
pfile = ParticleFile(outfile, pset, outputdt=delta(days=1))
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/example_peninsula.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@


def UpdateP(particle, fieldset, time):
if time == 0:
particle.p_start = fieldset.P[time, particle.depth, particle.lat, particle.lon]

Check warning on line 102 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L101-L102

Added lines #L101 - L102 were not covered by tests
particle.p = fieldset.P[time, particle.depth, particle.lat, particle.lon]


Expand Down Expand Up @@ -132,7 +134,7 @@
# JIT compilation requires a-priori knowledge of the particle
# data structure, so we define additional variables here.
p = Variable('p', dtype=np.float32, initial=0.)
p_start = Variable('p_start', dtype=np.float32, initial=fieldset.P)
p_start = Variable('p_start', dtype=np.float32, initial=0)

# Initialise particles
if fieldset.U.grid.mesh == 'flat':
Expand Down
68 changes: 0 additions & 68 deletions docs/examples/example_recursive_errorhandling.py

This file was deleted.

16 changes: 10 additions & 6 deletions docs/examples/example_stommel.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
timer,
)

pset_modes = ['soa', 'aos']
pset_modes = ['soa']
ptype = {'scipy': ScipyParticle, 'jit': JITParticle}
method = {'RK4': AdvectionRK4, 'EE': AdvectionEE, 'RK45': AdvectionRK45}
pset_type = {'soa': {'pset': ParticleSetSOA, 'pfile': ParticleFileSOA, 'kernel': KernelSOA},
Expand Down Expand Up @@ -77,6 +77,8 @@


def UpdateP(particle, fieldset, time):
if time == 0:
particle.p_start = fieldset.P[time, particle.depth, particle.lat, particle.lon]

Check warning on line 81 in docs/examples/example_stommel.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_stommel.py#L80-L81

Added lines #L80 - L81 were not covered by tests
particle.p = fieldset.P[time, particle.depth, particle.lat, particle.lon]


Expand All @@ -100,9 +102,15 @@
timer.psetinit = timer.Timer('Pset_init', parent=timer.pset)
ParticleClass = JITParticle if mode == 'jit' else ScipyParticle

# Execute for 600 days, with 1-hour timesteps and 5-day output
runtime = delta(days=600)
dt = delta(hours=1)
outputdt = delta(days=5)

class MyParticle(ParticleClass):
p = Variable('p', dtype=np.float32, initial=0.)
p_start = Variable('p_start', dtype=np.float32, initial=fieldset.P)
p_start = Variable('p_start', dtype=np.float32, initial=0.)
next_dt = Variable('next_dt', dtype=np.float64, initial=dt.total_seconds())
age = Variable('age', dtype=np.float32, initial=0.)

pset = pset_type[pset_mode]['pset'].from_line(fieldset, size=npart, pclass=MyParticle, repeatdt=repeatdt,
Expand All @@ -111,10 +119,6 @@
if verbose:
print(f"Initial particle positions:\n{pset}")

# Execute for 30 days, with 1hour timesteps and 12-hourly output
runtime = delta(days=600)
dt = delta(hours=1)
outputdt = delta(days=5)
maxage = runtime.total_seconds() if maxage is None else maxage
fieldset.add_constant('maxage', maxage)
print("Stommel: Advecting %d particles for %s" % (npart, runtime))
Expand Down
164 changes: 81 additions & 83 deletions docs/examples/parcels_tutorial.ipynb

Large diffs are not rendered by default.

Loading
Loading