<jupyter_start><jupyter_text>Tutorial showing how to create Parcels in Agulhas animated gif This brief tutorial shows how to recreate the [animated gif](http://oceanparcels.org/animated-gifs/globcurrent_fullyseeded.gif) showing particles in the Agulhas region south of Africa. We start with importing the relevant modules<jupyter_code>from parcels import FieldSet, ParticleSet, JITParticle, AdvectionRK4, ErrorCode
from datetime import timedelta
import numpy as np<jupyter_output><empty_output><jupyter_text>Now load the Globcurrent fields from the `GlobCurrent_example_data` directory (note that unlike in the main Parcels tutorial we don't use a dictionary for the filenames here; as they are the same for all variables, we don't need to)<jupyter_code>filenames = "GlobCurrent_example_data/20*.nc"
variables = {'U': 'eastward_eulerian_current_velocity',
             'V': 'northward_eulerian_current_velocity'}
dimensions = {'lat': 'lat',
              'lon': 'lon',
              'time': 'time'}
fieldset = FieldSet.from_netcdf(filenames, variables, dimensions)<jupyter_output>WARNING: Casting lon data to np.float32
WARNING: Casting lat data to np.float32
WARNING: Casting depth data to np.float32<jupyter_text>Now create vectors of Longitude and Latitude starting locations on a regular mesh, and use these to initialise a `ParticleSet` object.<jupyter_code>lons, lats = np.meshgrid(range(15, 35), range(-40, -30))
pset = ParticleSet(fieldset=fieldset, pclass=JITParticle, lon=lons, lat=lats)<jupyter_output><empty_output><jupyter_text>Now we want to advect the particles. However, the Globcurrent data that we loaded in is only for a limited, regional domain and particles might be able to leave this domain. We therefore need to tell Parcels that particles that leave the domain need to be deleted. We do that using a `Recovery Kernel`, which will be invoked when a particle encounters an `ErrorOutOfBounds` error:<jupyter_code>def DeleteParticle(particle, fieldset, time):
    particle.delete()<jupyter_output><empty_output><jupyter_text>Now we can advect the particles. Note that we do this inside a `for`-loop, so we can save a plot every six hours (which is the value of `runtime`). See the [plotting tutorial](http://nbviewer.jupyter.org/github/OceanParcels/parcels/blob/master/examples/tutorial_plotting.ipynb) for more information on the `pset.show()` method.<jupyter_code>for cnt in range(3):
    # First plot the particles
    pset.show(savefile='particles'+str(cnt).zfill(2), field='vector', land=True, vmax=2.0)

    # Then advect the particles for 6 hours
    pset.execute(AdvectionRK4,
                 runtime=timedelta(hours=6),  # runtime controls the interval of the plots
                 dt=timedelta(minutes=5),
                 recovery={ErrorCode.ErrorOutOfBounds: DeleteParticle})  # the recovery kernel<jupyter_output>/Users/erik/miniconda2/envs/py2_parcels_cartopy/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py:1744: RuntimeWarning: invalid value encountered in less
  u, v = self.projection.transform_vectors(t, x, y, u, v)
/Users/erik/miniconda2/envs/py2_parcels_cartopy/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py:1744: RuntimeWarning: invalid value encountered in greater
  u, v = self.projection.transform_vectors(t, x, y, u, v)
INFO: Plot saved to particles00.png
INFO: Compiled JITParticleAdvectionRK4 ==> /var/folders/r2/8593q8z93kd7t4j9kbb_f7p00000gr/T/parcels-504/de5d5c9b14f1551d894b622aa4ca7898.so
100% (21600.0 of 21600.0) |##############| Elapsed Time: 0:00:00 Time:  0:00:00
INFO: Plot saved to particles01.png
100% (21600.0 of 21600.0) |##############| Elapsed Time: 0:00:00 Time:  0:00:00
INFO: Plot saved to particles02.png
100% (21600.0 of 21600.0) |##############| Elapsed Time: 0:00:00 Time:  0:00:00
{'fraction_non_alphanumeric': 0.1051792828685259, 'fraction_numerical': 0.04329349269588313, 'mean_word_length': 5.30820770519263, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '65807', 'license': 'MIT', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1222, 'n_words': 365, 'path': 'parcels/examples/tutorial_Agulhasparticles.ipynb', 'repo_name': 'jelletreep/parcels', 'size': '3765'}