Skip to content

Commit c908f96

Browse files
Merge branch 'master' into ckernels
2 parents fad27bb + cf758ce commit c908f96

25 files changed

Lines changed: 276 additions & 212 deletions

docs/index.rst

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -80,65 +80,73 @@ The best way to get started with Parcels is to have a look at the Jupyter notebo
8080

8181
* `Plotting tutorial <http://nbviewer.jupyter.org/github/OceanParcels/parcels/blob/master/parcels/examples/tutorial_plotting.ipynb>`_ for further explanation on the plotting capabilities of Parcels
8282

83-
.. _installing-linux-macos:
8483

85-
Installing Parcels on Linux and macOS
86-
=====================================
84+
.. _installing-parcels:
8785

88-
Parcels depends on a working Python installation, a netCDF installation, a C
89-
compiler, and various Python packages.
86+
Installing Parcels
87+
==================
9088

91-
The simplest way to install Parcels is to use Anaconda and Conda-Forge for all
92-
requirements. This is the “batteries-included” solution probably suitable for most users.
93-
Note that if you already have an existing Python setup that you wish to use for Parcels, you should follow the instructions at the bottom of this section.
89+
This is the “batteries-included” solution probably suitable for most users.
9490

95-
The five steps below are the installation instructions for Linux and macOS. Note that for Windows, steps 2 and 5 are slightly different, see :ref:`installing-windows` below.
91+
The simplest way to install Parcels is to use Anaconda and the Parcels Conda-Forge package with the latest release of Parcels. This package will automatically install (almost) all the requirements for a fully functional installaion of Parcels.
9692

97-
1. Install Anaconda's Miniconda following the steps at https://conda.io/docs/user-guide/install/. All the code below assumes that you download the Python-2 version.
93+
The steps below are the installation instructions for Linux / macOS and for Windows. If the commands for Linux / macOS and Windows differ, this is indicated with a comment at the end of the line.
9894

99-
2. Download Parcels' `environment.yml <https://raw.githubusercontent.com/OceanParcels/parcels/master/environment.yml>`_ file, navigate to the directory where you saved that file, and run::
95+
1. Install Anaconda's Miniconda following the steps at https://conda.io/docs/user-guide/install/. All the code below assumes that you download the Python-2 version. If you're on Linux / macOS, it also assumes that you installed Miniconda-2 to your home directory.
10096

101-
source $HOME/miniconda2/bin/activate root
102-
conda env create -f environment.yml -n py2_parcels
103-
source $HOME/miniconda2/bin/activate py2_parcels
104-
pip install git+https://github.com/OceanParcels/parcels.git@master
97+
2. Start a terminal (Linux / macOS) or the Anaconda prompt (Windows). Activate the root (or base) environment of your Miniconda and create an environment containing Parcels, all its essential dependencies, and the nice-to-have Jupyter and Basemap package::
10598

106-
3. Validate the installation by downloading the `example_peninsula.py <https://raw.githubusercontent.com/OceanParcels/parcels/master/parcels/examples/example_peninsula.py>`_ file, navigate to the directory where you saved that file, and then run::
99+
source $HOME/miniconda2/bin/activate root # Linux / macOS
100+
activate root # Windows
107101

108-
python example_peninsula.py --fieldset 100 100
102+
conda create -n py2_parcels -c conda-forge parcels jupyter basemap basemap-data-hires
103+
104+
3. Activate the newly created Parcels environment, get a copy of the the Parcels tutorials and examples, and run the simplest of the examples to validate that you have a working Parcels setup::
109105

110-
4. Optionally, if you want to run all the examples and tutorials, you can get tutorials and example data by running::
106+
source $HOME/miniconda2/bin/activate py2_parcels # Linux / macOS
107+
activate py2_parcels # Windows
111108

112109
parcels_get_examples parcels_examples
113110
cd parcels_examples
111+
112+
python example_peninsula.py --fieldset 100 100
113+
114+
4. Optionally, if you want to run all the examples and tutorials, start Jupyter and open the tutorial notebooks::
115+
114116
jupyter notebook
115117

116118
5. The next time you start a terminal and want to work with Parcels, activate the environment with::
117119

118-
source $HOME/miniconda2/bin/activate py2_parcels
120+
source $HOME/miniconda2/bin/activate py2_parcels # Linux / macOS
121+
activate py2_parcels # Windows
122+
123+
124+
.. _installing-arbitrary-Git-reference:
125+
126+
Installing a non-released version of Parcels
127+
============================================
119128

120-
An alternative, more advanced option is to use an existing netCDF installation and
121-
C compiler, ``git clone`` the `master branch of Parcels
122-
<https://github.com/OceanParcels/parcels>`_
123-
and ``pip install`` the dependencies in the `environment.yml <https://raw.githubusercontent.com/OceanParcels/parcels/master/environment.yml>`_ file.
129+
There might be cases where you want to install a version of Parcels that has not been released yet. (Perhaps, if you want to use a bleeding-edge feature which already is included on Github, but not in the conda-forge package.)
124130

125-
.. _installing-windows:
131+
Then, just after step 2 of :ref:`installing-parcels` above, remove the conda-forge package again, and use Pip to install Parcels from Github::
132+
133+
source $HOME/miniconda2/bin/activate py2_parcels_master # Linux / macOS
134+
activate py2_parcels_master # Windows
135+
136+
conda remove parcels
137+
pip install git+https://github.com/OceanParcels/parcels.git@master
126138

127-
Installing Parcels on Windows
128-
=============================
129139

130-
The installation process and usage of Parcels is much the same as under :ref:`installing-linux-macos` above. **However, steps 2 and 5 will be different**, as detailed below:
140+
.. _installation-dev:
131141

132-
2. Download Parcels' `environment_win.yml <https://raw.githubusercontent.com/OceanParcels/parcels/master/environment_win.yml>`_ file from the main Parcels' directory, start the ``Anaconda Prompt`` from the Windows start menu, navigate to the directory where you saved that file, and then run::
142+
Installation for developers
143+
===========================
133144

134-
activate root
135-
conda env create -f environment_win.yml -n py2_parcels
136-
activate py2_parcels
137-
pip install git+https://github.com/OceanParcels/parcels.git@master
145+
Parcels depends on a working Python installation, a netCDF installation, a C compiler, and various Python packages. If you prefer to maintain your own Python installation providing all this, ``git clone`` the `master branch of Parcels <https://github.com/OceanParcels/parcels>`_ and manually ``pip install`` all packages lister under ``dependencies`` in the `environment.yml <https://raw.githubusercontent.com/OceanParcels/parcels/master/environment.yml>`_ file.
138146

139-
5. The next time you start the ``Anaconda Prompt`` and want to work with Parcels, activate the environment with::
147+
Then, install Parcels in an `editable way <https://pip.pypa.io/en/stable/reference/pip_install/?highlight=editable#cmdoption-e>`_ by running::
140148

141-
activate py2_parcels
149+
pip install -e .
142150

143151

144152
Getting involved

parcels/examples/example_decaying_moving_eddy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def true_values(t, x_0, y_0): # Calculate the expected values for particles at
5353
def decaying_moving_example(fieldset, mode='scipy', method=AdvectionRK4):
5454
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=start_lon, lat=start_lat)
5555

56-
endtime = delta(days=2)
56+
runtime = delta(days=2)
5757
dt = delta(minutes=5)
58-
interval = delta(hours=1)
58+
outputdt = delta(hours=1)
5959

60-
pset.execute(method, endtime=endtime, dt=dt, interval=interval,
61-
output_file=pset.ParticleFile(name="DecayingMovingParticle"), show_movie=False)
60+
pset.execute(method, runtime=runtime, dt=dt, moviedt=None,
61+
output_file=pset.ParticleFile(name="DecayingMovingParticle", outputdt=outputdt))
6262

6363
return pset
6464

parcels/examples/example_globcurrent.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ def test_globcurrent_particles(mode):
7373

7474
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=lonstart, lat=latstart)
7575

76-
pset.execute(AdvectionRK4, runtime=delta(days=1), dt=delta(minutes=5),
77-
interval=delta(hours=1))
76+
pset.execute(AdvectionRK4, runtime=delta(days=1), dt=delta(minutes=5))
7877

7978
assert(abs(pset[0].lon - 23.8) < 1)
8079
assert(abs(pset[0].lat - -35.3) < 1)
@@ -88,5 +87,4 @@ def test_globcurrent_time_extrapolation_error(mode):
8887
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=[25], lat=[-35],
8988
time=fieldset.U.time[0]-delta(days=1).total_seconds())
9089

91-
pset.execute(AdvectionRK4, runtime=delta(days=1),
92-
dt=delta(minutes=5), interval=delta(hours=1))
90+
pset.execute(AdvectionRK4, runtime=delta(days=1), dt=delta(minutes=5))

parcels/examples/example_moving_eddies.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ def moving_eddies_example(fieldset, npart=2, mode='jit', verbose=False,
8484
print("Initial particle positions:\n%s" % pset)
8585

8686
# Execute for 1 week, with 1 hour timesteps and hourly output
87-
endtime = delta(days=7)
88-
print("MovingEddies: Advecting %d particles for %s" % (npart, str(endtime)))
89-
pset.execute(method, endtime=endtime, dt=delta(hours=1),
90-
output_file=pset.ParticleFile(name="EddyParticle"),
91-
interval=delta(hours=1), show_movie=False)
87+
runtime = delta(days=7)
88+
print("MovingEddies: Advecting %d particles for %s" % (npart, str(runtime)))
89+
pset.execute(method, runtime=runtime, dt=delta(hours=1),
90+
output_file=pset.ParticleFile(name="EddyParticle", outputdt=delta(hours=1)),
91+
moviedt=None)
9292

9393
if verbose:
9494
print("Final particle positions:\n%s" % pset)
@@ -106,16 +106,16 @@ def test_moving_eddies_fwdbwd(mode, npart=2):
106106
start=(3.3, 46.), finish=(3.3, 47.8))
107107

108108
# Execte for 14 days, with 30sec timesteps and hourly output
109-
endtime = delta(days=1)
109+
runtime = delta(days=1)
110110
dt = delta(minutes=5)
111-
interval = delta(hours=1)
112-
print("MovingEddies: Advecting %d particles for %s" % (npart, str(endtime)))
113-
pset.execute(method, endtime=endtime, dt=dt, interval=interval,
114-
output_file=pset.ParticleFile(name="EddyParticlefwd"))
111+
outputdt = delta(hours=1)
112+
print("MovingEddies: Advecting %d particles for %s" % (npart, str(runtime)))
113+
pset.execute(method, runtime=runtime, dt=dt,
114+
output_file=pset.ParticleFile(name="EddyParticlefwd", outputdt=outputdt))
115115

116116
print("Now running in backward time mode")
117-
pset.execute(method, endtime=0, dt=-dt, interval=-interval,
118-
output_file=pset.ParticleFile(name="EddyParticlebwd"))
117+
pset.execute(method, endtime=0, dt=-dt,
118+
output_file=pset.ParticleFile(name="EddyParticlebwd", outputdt=outputdt))
119119

120120
assert(pset[0].lon > 3.2 and 45.9 < pset[0].lat < 46.1)
121121
assert(pset[1].lon > 3.2 and 47.7 < pset[1].lat < 47.9)

parcels/examples/example_nemo_curvilinear.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def periodicBC(particle, pieldSet, time, dt):
3030
particle.lon -= 360
3131

3232
pset = ParticleSet.from_list(field_set, ptype[mode], lon=lonp, lat=latp)
33-
pfile = ParticleFile(outfile, pset)
33+
pfile = ParticleFile(outfile, pset, outputdt=delta(days=1))
3434
kernels = pset.Kernel(AdvectionRK4) + periodicBC
3535
pset.execute(kernels, runtime=delta(days=1)*160, dt=delta(hours=6),
36-
interval=delta(days=1), output_file=pfile)
36+
output_file=pfile)
3737
assert np.allclose([pset[i].lat - latp[i] for i in range(len(pset))], 0, atol=1e-3)
3838

3939

parcels/examples/example_ofam.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def test_ofam_particles(mode):
4242

4343
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=lonstart, lat=latstart, depth=depstart)
4444

45-
pset.execute(AdvectionRK4, runtime=delta(days=10), dt=delta(minutes=5),
46-
interval=delta(hours=6))
45+
pset.execute(AdvectionRK4, runtime=delta(days=10), dt=delta(minutes=5))
4746

4847
assert(abs(pset[0].lon - 173) < 1)
4948
assert(abs(pset[0].lat - 11) < 1)

parcels/examples/example_peninsula.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ def __repr__(self):
109109
dt = delta(minutes=5)
110110
k_adv = pset.Kernel(method)
111111
k_p = pset.Kernel(UpdateP)
112-
out = pset.ParticleFile(name="MyParticle") if output else None
113-
interval = delta(hours=1) if output else -1
112+
out = pset.ParticleFile(name="MyParticle", outputdt=delta(hours=1)) if output else None
114113
print("Peninsula: Advecting %d particles for %s" % (npart, str(time)))
115-
pset.execute(k_adv + k_p, endtime=time, dt=dt, output_file=out, interval=interval)
114+
pset.execute(k_adv + k_p, runtime=time, dt=dt, output_file=out)
116115

117116
if verbose:
118117
print("Final particle positions:\n%s" % pset)

parcels/examples/example_radial_rotation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ def rotation_example(fieldset, mode='jit', method=AdvectionRK4):
5555
start=(30., 30.),
5656
finish=(30., 50.)) # One particle in centre, one on periphery of Field.
5757

58-
endtime = delta(hours=17)
58+
runtime = delta(hours=17)
5959
dt = delta(minutes=5)
60-
interval = delta(hours=1)
60+
outputdt = delta(hours=1)
6161

62-
pset.execute(method, endtime=endtime, dt=dt, interval=interval,
63-
output_file=pset.ParticleFile(name="RadialParticle"), show_movie=False)
62+
pset.execute(method, runtime=runtime, dt=dt, moviedt=None,
63+
output_file=pset.ParticleFile(name="RadialParticle", outputdt=outputdt))
6464

6565
return pset
6666

parcels/examples/example_stommel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ class MyParticle(ParticleClass):
9393
# Execute for 30 days, with 1hour timesteps and 12-hourly output
9494
runtime = delta(days=30)
9595
dt = delta(hours=1)
96-
interval = delta(hours=12)
96+
outputdt = delta(hours=12)
9797
print("Stommel: Advecting %d particles for %s" % (npart, runtime))
9898
timer.psetinit.stop()
9999
timer.psetrun = timer.Timer('Pset_run', parent=timer.pset)
100-
pset.execute(method + pset.Kernel(UpdateP), runtime=runtime, dt=dt, interval=interval,
101-
output_file=pset.ParticleFile(name="StommelParticle"), show_movie=False)
100+
pset.execute(method + pset.Kernel(UpdateP), runtime=runtime, dt=dt,
101+
moviedt=None, output_file=pset.ParticleFile(name="StommelParticle", outputdt=outputdt))
102102

103103
if verbose:
104104
print("Final particle positions:\n%s" % pset)

parcels/examples/parcels_tutorial.ipynb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@
383383
"pset.execute(AdvectionRK4, # the kernel (which defines how particles move)\n",
384384
" runtime=timedelta(days=6), # the total length of the run\n",
385385
" dt=timedelta(minutes=5), # the timestep of the kernel\n",
386-
" interval=timedelta(hours=1), # the interval at which output is stored\n",
387-
" output_file=pset.ParticleFile(name=\"EddyParticles\")) # the name of the output file"
386+
" output_file=pset.ParticleFile(name=\"EddyParticles\", outputdt=timedelta(hours=1))) # the file name and the time step of the outputs"
388387
]
389388
},
390389
{
@@ -981,7 +980,7 @@
981980
"editable": true
982981
},
983982
"source": [
984-
"Now one of the neat features of Parcels is that the particles can be plotted as a movie *during execution*, which is great for debugging. To rerun the particles while plotting them on top of the zonal velocity field (`fieldset.U`), first reinitialise the `ParticleSet` and then re-execute. However, now rather than saving the output to a file, display a movie using the `show_movie` keyword, in this case with the zonal velocity `fieldset.U` as background"
983+
"Now one of the neat features of Parcels is that the particles can be plotted as a movie *during execution*, which is great for debugging. To rerun the particles while plotting them on top of the zonal velocity field (`fieldset.U`), first reinitialise the `ParticleSet` and then re-execute. However, now rather than saving the output to a file, display a movie using the `moviedt` display frequency, in this case with the zonal velocity `fieldset.U` as background"
985984
]
986985
},
987986
{
@@ -1000,8 +999,8 @@
1000999
"# pset.execute(AdvectionRK4,\n",
10011000
"# runtime=timedelta(days=6),\n",
10021001
"# dt=timedelta(minutes=5),\n",
1003-
"# interval=timedelta(hours=1),\n",
1004-
"# show_movie=fieldset.U)"
1002+
"# moviedt=timedelta(hours=1),\n",
1003+
"# movie_background_field=fieldset.U)"
10051004
]
10061005
},
10071006
{
@@ -1036,9 +1035,8 @@
10361035
"source": [
10371036
"pset.execute(AdvectionRK4,\n",
10381037
" dt=-timedelta(minutes=5), # negative timestep for backward run\n",
1039-
" endtime=timedelta(days=0), # the end time of the run\n",
1040-
" interval=-timedelta(hours=1), # negative interval for backward run\n",
1041-
" output_file=pset.ParticleFile(name=\"EddyParticles_Bwd\")) # the name of the output file"
1038+
" runtime=timedelta(days=0), # the run time\n",
1039+
" output_file=pset.ParticleFile(name=\"EddyParticles_Bwd\", outputdt=timedelta(hours=1))) # the file name and the time step of the outputs"
10421040
]
10431041
},
10441042
{
@@ -1165,8 +1163,7 @@
11651163
"pset.execute(AdvectionRK4 + k_WestVel, # simply add kernels using the + operator\n",
11661164
" runtime=timedelta(days=3),\n",
11671165
" dt=timedelta(minutes=5),\n",
1168-
" interval=timedelta(hours=1),\n",
1169-
" output_file=pset.ParticleFile(name=\"EddyParticles_WestVel\"))"
1166+
" output_file=pset.ParticleFile(name=\"EddyParticles_WestVel\", outputdt=timedelta(hours=1)))"
11701167
]
11711168
},
11721169
{
@@ -1385,8 +1382,7 @@
13851382
"pset.execute(AdvectionRK4,\n",
13861383
" runtime=timedelta(days=10),\n",
13871384
" dt=timedelta(minutes=5),\n",
1388-
" interval=timedelta(hours=6),\n",
1389-
" output_file=pset.ParticleFile(name=\"GlobCurrentParticles\"))"
1385+
" output_file=pset.ParticleFile(name=\"GlobCurrentParticles\", outputdt=timedelta(hours=6)))"
13901386
]
13911387
},
13921388
{
@@ -1773,8 +1769,7 @@
17731769
"pset.execute(AdvectionRK4 + k_dist, # Add kernels using the + operator.\n",
17741770
" runtime=timedelta(days=6),\n",
17751771
" dt=timedelta(minutes=5),\n",
1776-
" interval=timedelta(hours=1),\n",
1777-
" output_file=pset.ParticleFile(name=\"EddyParticles_Dist\"))"
1772+
" output_file=pset.ParticleFile(name=\"EddyParticles_Dist\", outputdt=timedelta(hours=1)))"
17781773
]
17791774
},
17801775
{

0 commit comments

Comments
 (0)