Skip to content

Commit 31e3402

Browse files
Removing JIT from tutorial notebooks
1 parent de2021a commit 31e3402

18 files changed

+105
-453
lines changed

docs/examples/parcels_tutorial.ipynb

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,18 @@
148148
"cell_type": "markdown",
149149
"metadata": {},
150150
"source": [
151-
"The next step is to define a `ParticleSet`. In this case, we start 2 particles at locations (330km, 100km) and (330km, 280km) using the `from_list` constructor method, that are advected on the `fieldset` we defined above. Note that we use `JITParticle` as `pclass`, because we will be executing the advection in JIT (Just-In-Time) mode. The alternative is to run in `scipy` mode, in which case `pclass` is `ScipyParticle`\n"
151+
"The next step is to define a `ParticleSet`. In this case, we start 2 particles at locations (330km, 100km) and (330km, 280km) using the `from_list` constructor method, that are advected on the `fieldset` we defined above. Note that we use `ScipyParticle` as `pclass`, which is the default choice for particle advection in Parcels.\n"
152152
]
153153
},
154154
{
155155
"cell_type": "code",
156-
"execution_count": 4,
156+
"execution_count": null,
157157
"metadata": {},
158158
"outputs": [],
159159
"source": [
160160
"pset = parcels.ParticleSet.from_list(\n",
161161
" fieldset=fieldset, # the fields on which the particles are advected\n",
162-
" pclass=parcels.JITParticle, # the type of particles (JITParticle or ScipyParticle)\n",
162+
" pclass=parcels.ScipyParticle, # the type of particles (ScipyParticle or a custom class)\n",
163163
" lon=[3.3e5, 3.3e5], # a vector of release longitudes\n",
164164
" lat=[1e5, 2.8e5], # a vector of release latitudes\n",
165165
")"
@@ -13447,7 +13447,7 @@
1344713447
},
1344813448
{
1344913449
"cell_type": "code",
13450-
"execution_count": 16,
13450+
"execution_count": null,
1345113451
"metadata": {},
1345213452
"outputs": [
1345313453
{
@@ -13461,7 +13461,10 @@
1346113461
],
1346213462
"source": [
1346313463
"pset = parcels.ParticleSet.from_list(\n",
13464-
" fieldset=fieldset, pclass=parcels.JITParticle, lon=[3.3e5, 3.3e5], lat=[1e5, 2.8e5]\n",
13464+
" fieldset=fieldset,\n",
13465+
" pclass=parcels.ScipyParticle,\n",
13466+
" lon=[3.3e5, 3.3e5],\n",
13467+
" lat=[1e5, 2.8e5],\n",
1346513468
")\n",
1346613469
"\n",
1346713470
"output_file = pset.ParticleFile(\n",
@@ -13604,13 +13607,13 @@
1360413607
},
1360513608
{
1360613609
"cell_type": "code",
13607-
"execution_count": 21,
13610+
"execution_count": null,
1360813611
"metadata": {},
1360913612
"outputs": [],
1361013613
"source": [
1361113614
"pset = parcels.ParticleSet.from_line(\n",
1361213615
" fieldset=fieldset,\n",
13613-
" pclass=parcels.JITParticle,\n",
13616+
" pclass=parcels.ScipyParticle,\n",
1361413617
" size=5, # releasing 5 particles\n",
1361513618
" start=(28, -33), # releasing on a line: the start longitude and latitude\n",
1361613619
" finish=(30, -33), # releasing on a line: the end longitude and latitude\n",
@@ -13729,24 +13732,11 @@
1372913732
},
1373013733
{
1373113734
"cell_type": "code",
13732-
"execution_count": 25,
13735+
"execution_count": null,
1373313736
"metadata": {},
1373413737
"outputs": [],
1373513738
"source": [
13736-
"SampleParticle = parcels.JITParticle.add_variable(\"p\")"
13737-
]
13738-
},
13739-
{
13740-
"cell_type": "markdown",
13741-
"metadata": {},
13742-
"source": [
13743-
"<div class=\"alert alert-info\">\n",
13744-
"\n",
13745-
"Note that if you get a `AttributeError: type object 'JITParticle' has no attribute 'add_variables'` error, you are probably using an old version of Parcels. Please update to the latest version of Parcels using `conda update -c conda-forge parcels`.\n",
13746-
"\n",
13747-
"Alternatively, you can refer to the <a href=\"https://docs.oceanparcels.org/en/v3.0.1/documentation.html\">Parcels v3.0.1 documentation</a>, which does not use the new `ParticleSet.add_variables()` method introduced in Parcels v3.0.2.\n",
13748-
"\n",
13749-
"</div>"
13739+
"SampleParticle = parcels.ScipyParticle.add_variable(\"p\")"
1375013740
]
1375113741
},
1375213742
{
@@ -13914,7 +13904,7 @@
1391413904
},
1391513905
{
1391613906
"cell_type": "code",
13917-
"execution_count": 30,
13907+
"execution_count": null,
1391813908
"metadata": {},
1391913909
"outputs": [],
1392013910
"source": [
@@ -13928,7 +13918,7 @@
1392813918
" ),\n",
1392913919
"]\n",
1393013920
"\n",
13931-
"DistParticle = parcels.JITParticle.add_variables(extra_vars)"
13921+
"DistParticle = parcels.ScipyParticle.add_variables(extra_vars)"
1393213922
]
1393313923
},
1393413924
{
@@ -14061,7 +14051,7 @@
1406114051
],
1406214052
"metadata": {
1406314053
"kernelspec": {
14064-
"display_name": "Python 3",
14054+
"display_name": "parcels",
1406514055
"language": "python",
1406614056
"name": "python3"
1406714057
},
@@ -14075,7 +14065,7 @@
1407514065
"name": "python",
1407614066
"nbconvert_exporter": "python",
1407714067
"pygments_lexer": "ipython3",
14078-
"version": "3.11.6"
14068+
"version": "3.12.3"
1407914069
}
1408014070
},
1408114071
"nbformat": 4,

docs/examples/tutorial_Argofloats.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
"cell_type": "code",
89-
"execution_count": 2,
89+
"execution_count": null,
9090
"metadata": {},
9191
"outputs": [
9292
{
@@ -122,7 +122,7 @@
122122
"\n",
123123
"\n",
124124
"# Define a new Particle type including extra Variables\n",
125-
"ArgoParticle = parcels.JITParticle.add_variables(\n",
125+
"ArgoParticle = parcels.ScipyParticle.add_variables(\n",
126126
" [\n",
127127
" # Phase of cycle:\n",
128128
" # init_descend=0,\n",
@@ -210,7 +210,7 @@
210210
],
211211
"metadata": {
212212
"kernelspec": {
213-
"display_name": "Python 3",
213+
"display_name": "parcels",
214214
"language": "python",
215215
"name": "python3"
216216
},
@@ -224,7 +224,7 @@
224224
"name": "python",
225225
"nbconvert_exporter": "python",
226226
"pygments_lexer": "ipython3",
227-
"version": "3.11.6"
227+
"version": "3.12.3"
228228
}
229229
},
230230
"nbformat": 4,

docs/examples/tutorial_NestedFields.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"\n",
3232
"This algorithm means that **the order of the fields in the 'NestedField' matters**. In particular, the smallest/finest resolution fields have to be listed _before_ the larger/coarser resolution fields.\n",
3333
"\n",
34-
"Note also that `pset.execute()` can be _much_ slower on `NestedField` objects than on normal `Fields`. This is because the handling of the `ErrorOutOfBounds` (step 3) happens outside the fast inner-JIT-loop in C; but instead is delt with in the slower python loop around it. This means that especially in cases where particles often move from one nest to another, simulations can become very slow.\n",
34+
"Note also that `pset.execute()` can be _much_ slower on `NestedField` objects than on normal `Fields`. This is because the search for the correct `Field` will always start with the first `Field` in the list. This means that especially in cases where many particles are in the outermost `Field`, simulations can become very slow.\n",
3535
"\n",
3636
"This tutorial shows how to use these `NestedField` with a very idealised example.\n"
3737
]
@@ -117,7 +117,7 @@
117117
},
118118
{
119119
"cell_type": "code",
120-
"execution_count": 5,
120+
"execution_count": null,
121121
"metadata": {},
122122
"outputs": [
123123
{
@@ -140,7 +140,7 @@
140140
}
141141
],
142142
"source": [
143-
"pset = parcels.ParticleSet(fieldset, pclass=parcels.JITParticle, lon=[0], lat=[1000])\n",
143+
"pset = parcels.ParticleSet(fieldset, pclass=parcels.ScipyParticle, lon=[0], lat=[1000])\n",
144144
"\n",
145145
"output_file = pset.ParticleFile(\n",
146146
" name=\"NestedFieldParticle.zarr\", outputdt=50, chunks=(1, 100)\n",
@@ -211,7 +211,7 @@
211211
},
212212
{
213213
"cell_type": "code",
214-
"execution_count": 7,
214+
"execution_count": null,
215215
"metadata": {},
216216
"outputs": [
217217
{
@@ -230,7 +230,7 @@
230230
" particle.f = fieldset.F[time, particle.depth, particle.lat, particle.lon]\n",
231231
"\n",
232232
"\n",
233-
"SampleParticle = parcels.JITParticle.add_variable(\"f\", dtype=np.int32)\n",
233+
"SampleParticle = parcels.ScipyParticle.add_variable(\"f\", dtype=np.int32)\n",
234234
"\n",
235235
"pset = parcels.ParticleSet(fieldset, pclass=SampleParticle, lon=[1000], lat=[500])\n",
236236
"pset.execute(SampleNestedFieldIndex, runtime=1)\n",
@@ -250,7 +250,7 @@
250250
],
251251
"metadata": {
252252
"kernelspec": {
253-
"display_name": "Python 3",
253+
"display_name": "parcels",
254254
"language": "python",
255255
"name": "python3"
256256
},
@@ -264,7 +264,7 @@
264264
"name": "python",
265265
"nbconvert_exporter": "python",
266266
"pygments_lexer": "ipython3",
267-
"version": "3.11.6"
267+
"version": "3.12.3"
268268
}
269269
},
270270
"nbformat": 4,

docs/examples/tutorial_analyticaladvection.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14679,7 +14679,7 @@
1467914679
},
1468014680
{
1468114681
"cell_type": "code",
14682-
"execution_count": 9,
14682+
"execution_count": null,
1468314683
"metadata": {},
1468414684
"outputs": [
1468514685
{
@@ -14691,7 +14691,7 @@
1469114691
}
1469214692
],
1469314693
"source": [
14694-
"psetRK4 = parcels.ParticleSet(fieldsetDG, pclass=parcels.JITParticle, lon=X, lat=Y)\n",
14694+
"psetRK4 = parcels.ParticleSet(fieldsetDG, pclass=parcels.ScipyParticle, lon=X, lat=Y)\n",
1469514695
"psetRK4.execute(parcels.AdvectionRK4, dt=0.01, runtime=3)"
1469614696
]
1469714697
},
@@ -27993,7 +27993,7 @@
2799327993
},
2799427994
{
2799527995
"cell_type": "code",
27996-
"execution_count": 16,
27996+
"execution_count": null,
2799727997
"metadata": {},
2799827998
"outputs": [
2799927999
{
@@ -28005,7 +28005,7 @@
2800528005
}
2800628006
],
2800728007
"source": [
28008-
"psetRK4 = parcels.ParticleSet(fieldsetBJ, pclass=parcels.JITParticle, lon=X, lat=Y)\n",
28008+
"psetRK4 = parcels.ParticleSet(fieldsetBJ, pclass=parcels.ScipyParticle, lon=X, lat=Y)\n",
2800928009
"\n",
2801028010
"psetRK4.execute(\n",
2801128011
" [parcels.AdvectionRK4, ZonalBC], dt=timedelta(minutes=5), runtime=timedelta(days=1)\n",
@@ -28046,7 +28046,7 @@
2804628046
],
2804728047
"metadata": {
2804828048
"kernelspec": {
28049-
"display_name": "Python 3",
28049+
"display_name": "parcels",
2805028050
"language": "python",
2805128051
"name": "python3"
2805228052
},
@@ -28060,7 +28060,7 @@
2806028060
"name": "python",
2806128061
"nbconvert_exporter": "python",
2806228062
"pygments_lexer": "ipython3",
28063-
"version": "3.11.5"
28063+
"version": "3.12.3"
2806428064
}
2806528065
},
2806628066
"nbformat": 4,

docs/examples/tutorial_croco_3D.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
},
113113
{
114114
"cell_type": "code",
115-
"execution_count": 3,
115+
"execution_count": null,
116116
"metadata": {},
117117
"outputs": [
118118
{
@@ -138,7 +138,7 @@
138138
"\n",
139139
"\n",
140140
"pset = parcels.ParticleSet(\n",
141-
" fieldset=fieldset, pclass=parcels.JITParticle, lon=X, lat=Y, depth=Z\n",
141+
" fieldset=fieldset, pclass=parcels.ScipyParticle, lon=X, lat=Y, depth=Z\n",
142142
")\n",
143143
"\n",
144144
"outputfile = pset.ParticleFile(name=\"croco_particles3D.zarr\", outputdt=5000)\n",
@@ -211,7 +211,7 @@
211211
},
212212
{
213213
"cell_type": "code",
214-
"execution_count": 5,
214+
"execution_count": null,
215215
"metadata": {},
216216
"outputs": [
217217
{
@@ -240,7 +240,7 @@
240240
"fieldset_noW.W.data[:] = 0.0\n",
241241
"\n",
242242
"pset_noW = parcels.ParticleSet(\n",
243-
" fieldset=fieldset_noW, pclass=parcels.JITParticle, lon=X, lat=Y, depth=Z\n",
243+
" fieldset=fieldset_noW, pclass=parcels.ScipyParticle, lon=X, lat=Y, depth=Z\n",
244244
")\n",
245245
"\n",
246246
"outputfile = pset.ParticleFile(name=\"croco_particles_noW.zarr\", outputdt=5000)\n",

0 commit comments

Comments
 (0)