Skip to content

Commit 1fcb075

Browse files
Merge branch 'v4-dev' into using_fieldset_from_sgrid_in_tutorials
2 parents d672fba + ca4df74 commit 1fcb075

21 files changed

+1442
-192
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def linkcode_resolve(domain, info):
533533

534534
# -- Options for autoapi --------------------------------------------------
535535
autoapi_dirs = ["../src/parcels"]
536-
# autoapi_add_toctree_entry = False
536+
autoapi_add_toctree_entry = False
537537
autoapi_root = "reference"
538538
autoapi_options = [
539539
"members",

docs/development/policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We accept that Parcels developers have their own motivation for using (or not us
1010
1111
Remember that reviews are done by human maintainers - asking us to review code that an AI wrote but you don't understand isn't kind to these maintainers.
1212

13-
The [CLAUDE.md](/CLAUDE.md) file in the repository has additional instructions for AI agents to follow when contributing to Parcels.
13+
The [CLAUDE.md](https://github.com/Parcels-code/Parcels/blob/HEAD/CLAUDE.md) file in the repository has additional instructions for AI agents to follow when contributing to Parcels.
1414

1515
## Versioning
1616

docs/getting_started/explanation_concepts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A Parcels simulation is generally built up from four different components:
1717
3. [**Kernels**](#3-kernels). Kernels perform some specific operation on the particles every time step (e.g. advect the particles with the three-dimensional flow; or interpolate the temperature field to the particle location).
1818
4. [**Execute**](#4-execute). Execute the simulation. The core method which integrates the operations defined in Kernels for a given runtime and timestep, and writes output to a ParticleFile.
1919

20-
We discuss each component in more detail below. The subsections titled **"Learn how to"** link to more detailed [how-to guide notebooks](../user_guide/index.md) and more detailed _explanations_ of Parcels functionality are included under **"Read more about"** subsections. The full list of classes and methods is in the [API reference](../reference.md). If you want to learn by doing, check out the [quickstart tutorial](./tutorial_quickstart.md) to start creating your first Parcels simulation.
20+
We discuss each component in more detail below. The subsections titled **"Learn how to"** link to more detailed [how-to guide notebooks](../user_guide/index.md) and more detailed _explanations_ of Parcels functionality are included under **"Read more about"** subsections. The full list of classes and methods is in the [API reference](../reference/parcels/index.rst). If you want to learn by doing, check out the [quickstart tutorial](./tutorial_quickstart.md) to start creating your first Parcels simulation.
2121

2222
```{figure} ../_static/concepts_diagram.png
2323
:alt: Parcels concepts diagram
@@ -190,6 +190,6 @@ There are many ways to analyze particle output, and although we provide [a short
190190

191191
```{admonition} 🖥️ Learn how to run a simulation
192192
:class: seealso
193-
- [Choose an appropriate timestep and integrator](../user_guide/examples/tutorial_numerical_accuracy.ipynb)
193+
- [Choose an appropriate timestep and integrator](../user_guide/examples/tutorial_dt_integrators.ipynb)
194194
- [Work with Parcels output](./tutorial_output.ipynb)
195195
```

docs/getting_started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ conda activate parcels
3333
The next time you start a terminal and want to work with Parcels, activate the environment with `conda activate parcels`.
3434
```
3535

36-
**Step 4:** Create a Jupyter Notebook or Python script to set up your first Parcels simulation! The [quickstart tutorial](tutorial_quickstart.md) is a great way to get started immediately. You can also first read about the core [Parcels concepts](concepts_overview.md) to familiarize yourself with the classes and methods you will use.
36+
**Step 4:** Create a Jupyter Notebook or Python script to set up your first Parcels simulation! The [quickstart tutorial](tutorial_quickstart.md) is a great way to get started immediately. You can also first read about the core [Parcels concepts](./explanation_concepts.md) to familiarize yourself with the classes and methods you will use.
3737

3838
## Installation for developers
3939

docs/getting_started/tutorial_quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ kernelspec:
99
Welcome to the **Parcels** quickstart tutorial, in which we will go through all the necessary steps to run a simulation.
1010
The code in this notebook can be used as a starting point to run Parcels in your own environment. Along the way we will
1111
familiarize ourselves with some specific classes and methods. If you are ever confused about one of these and want to
12-
read more, we have a [concepts overview](concepts_overview.md) discussing them in more detail. Let's dive in!
12+
read more, we have a [concepts overview](./explanation_concepts.md) discussing them in more detail. Let's dive in!
1313

1414
## Imports
1515

docs/user_guide/examples/tutorial_Argofloats.ipynb

Lines changed: 50 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,62 @@
2626
"source": [
2727
"import numpy as np\n",
2828
"\n",
29-
"# Define the new Kernels that mimic Argo vertical movement\n",
29+
"# Define the new Kernel that mimics Argo vertical movement\n",
3030
"driftdepth = 1000 # maximum depth in m\n",
3131
"maxdepth = 2000 # maximum depth in m\n",
3232
"vertical_speed = 0.10 # sink and rise speed in m/s\n",
3333
"cycletime = 10 * 86400 # total time of cycle in seconds\n",
3434
"drifttime = 9 * 86400 # time of deep drift in seconds\n",
3535
"\n",
3636
"\n",
37-
"def ArgoPhase1(particles, fieldset):\n",
38-
" def SinkingPhase(p):\n",
39-
" \"\"\"Phase 0: Sinking with vertical_speed until depth is driftdepth\"\"\"\n",
40-
" p.dz += vertical_speed * particles.dt\n",
41-
" p.cycle_phase = np.where(p.z + p.dz >= driftdepth, 1, p.cycle_phase)\n",
42-
" p.dz = np.where(p.z + p.dz >= driftdepth, driftdepth - p.z, p.dz)\n",
37+
"def ArgoVerticalMovement(particles, fieldset):\n",
38+
" # Split particles based on their current cycle_phase\n",
39+
" ptcls0 = particles[particles.cycle_phase == 0]\n",
40+
" ptcls1 = particles[particles.cycle_phase == 1]\n",
41+
" ptcls2 = particles[particles.cycle_phase == 2]\n",
42+
" ptcls3 = particles[particles.cycle_phase == 3]\n",
43+
" ptcls4 = particles[particles.cycle_phase == 4]\n",
44+
"\n",
45+
" # Phase 0: Sinking with vertical_speed until depth is driftdepth\n",
46+
" ptcls0.dz += vertical_speed * ptcls0.dt\n",
47+
" ptcls0.cycle_phase = np.where(\n",
48+
" ptcls0.z + ptcls0.dz >= driftdepth, 1, ptcls0.cycle_phase\n",
49+
" )\n",
50+
" ptcls0.dz = np.where(\n",
51+
" ptcls0.z + ptcls0.dz >= driftdepth, driftdepth - ptcls0.z, ptcls0.dz\n",
52+
" )\n",
53+
"\n",
54+
" # Phase 1: Drifting at depth for drifttime seconds\n",
55+
" ptcls1.drift_age += ptcls1.dt\n",
56+
" ptcls1.cycle_phase = np.where(ptcls1.drift_age >= drifttime, 2, ptcls1.cycle_phase)\n",
57+
" ptcls1.drift_age = np.where(ptcls1.drift_age >= drifttime, 0, ptcls1.drift_age)\n",
58+
"\n",
59+
" # Phase 2: Sinking further to maxdepth\n",
60+
" ptcls2.dz += vertical_speed * ptcls2.dt\n",
61+
" ptcls2.cycle_phase = np.where(\n",
62+
" ptcls2.z + ptcls2.dz >= maxdepth, 3, ptcls2.cycle_phase\n",
63+
" )\n",
64+
" ptcls2.dz = np.where(\n",
65+
" ptcls2.z + ptcls2.dz >= maxdepth, maxdepth - ptcls2.z, ptcls2.dz\n",
66+
" )\n",
67+
"\n",
68+
" # Phase 3: Rising with vertical_speed until at surface\n",
69+
" ptcls3.dz -= vertical_speed * ptcls3.dt\n",
70+
" ptcls3.temp = fieldset.thetao[ptcls3.time, ptcls3.z, ptcls3.lat, ptcls3.lon]\n",
71+
" ptcls3.cycle_phase = np.where(\n",
72+
" ptcls3.z + ptcls3.dz <= fieldset.mindepth, 4, ptcls3.cycle_phase\n",
73+
" )\n",
74+
" ptcls3.dz = np.where(\n",
75+
" ptcls3.z + ptcls3.dz <= fieldset.mindepth,\n",
76+
" fieldset.mindepth - ptcls3.z,\n",
77+
" ptcls3.dz,\n",
78+
" )\n",
79+
"\n",
80+
" # Phase 4: Transmitting at surface until cycletime is reached\n",
81+
" ptcls4.cycle_phase = np.where(ptcls4.cycle_age >= cycletime, 0, ptcls4.cycle_phase)\n",
82+
" ptcls4.cycle_age = np.where(ptcls4.cycle_age >= cycletime, 0, ptcls4.cycle_age)\n",
83+
" ptcls4.temp = np.nan # no temperature measurement when at surface\n",
4384
"\n",
44-
" SinkingPhase(particles[particles.cycle_phase == 0])\n",
45-
"\n",
46-
"\n",
47-
"def ArgoPhase2(particles, fieldset):\n",
48-
" def DriftingPhase(p):\n",
49-
" \"\"\"Phase 1: Drifting at depth for drifttime seconds\"\"\"\n",
50-
" p.drift_age += particles.dt\n",
51-
" p.cycle_phase = np.where(p.drift_age >= drifttime, 2, p.cycle_phase)\n",
52-
" p.drift_age = np.where(p.drift_age >= drifttime, 0, p.drift_age)\n",
53-
"\n",
54-
" DriftingPhase(particles[particles.cycle_phase == 1])\n",
55-
"\n",
56-
"\n",
57-
"def ArgoPhase3(particles, fieldset):\n",
58-
" def SecondSinkingPhase(p):\n",
59-
" \"\"\"Phase 2: Sinking further to maxdepth\"\"\"\n",
60-
" p.dz += vertical_speed * particles.dt\n",
61-
" p.cycle_phase = np.where(p.z + p.dz >= maxdepth, 3, p.cycle_phase)\n",
62-
" p.dz = np.where(p.z + p.dz >= maxdepth, maxdepth - p.z, p.dz)\n",
63-
"\n",
64-
" SecondSinkingPhase(particles[particles.cycle_phase == 2])\n",
65-
"\n",
66-
"\n",
67-
"def ArgoPhase4(particles, fieldset):\n",
68-
" def RisingPhase(p):\n",
69-
" \"\"\"Phase 3: Rising with vertical_speed until at surface\"\"\"\n",
70-
" p.dz -= vertical_speed * particles.dt\n",
71-
" p.temp = fieldset.thetao[p.time, p.z, p.lat, p.lon]\n",
72-
" p.cycle_phase = np.where(p.z + p.dz <= fieldset.mindepth, 4, p.cycle_phase)\n",
73-
" p.dz = np.where(\n",
74-
" p.z + p.dz <= fieldset.mindepth,\n",
75-
" fieldset.mindepth - p.z,\n",
76-
" p.dz,\n",
77-
" )\n",
78-
"\n",
79-
" RisingPhase(particles[particles.cycle_phase == 3])\n",
80-
"\n",
81-
"\n",
82-
"def ArgoPhase5(particles, fieldset):\n",
83-
" def TransmittingPhase(p):\n",
84-
" \"\"\"Phase 4: Transmitting at surface until cycletime is reached\"\"\"\n",
85-
" p.cycle_phase = np.where(p.cycle_age >= cycletime, 0, p.cycle_phase)\n",
86-
" p.cycle_age = np.where(p.cycle_age >= cycletime, 0, p.cycle_age)\n",
87-
" p.temp = np.nan # no temperature measurement when at surface\n",
88-
"\n",
89-
" TransmittingPhase(particles[particles.cycle_phase == 4])\n",
90-
"\n",
91-
"\n",
92-
"def ArgoPhase6(particles, fieldset):\n",
9385
" particles.cycle_age += particles.dt # update cycle_age"
9486
]
9587
},
@@ -136,9 +128,7 @@
136128
"ArgoParticle = parcels.Particle.add_variable(\n",
137129
" [\n",
138130
" parcels.Variable(\"cycle_phase\", dtype=np.int32, initial=0.0),\n",
139-
" parcels.Variable(\n",
140-
" \"cycle_age\", dtype=np.float32, initial=0.0\n",
141-
" ), # TODO update to \"timedelta64[s]\"\n",
131+
" parcels.Variable(\"cycle_age\", dtype=np.float32, initial=0.0),\n",
142132
" parcels.Variable(\"drift_age\", dtype=np.float32, initial=0.0),\n",
143133
" parcels.Variable(\"temp\", dtype=np.float32, initial=np.nan),\n",
144134
" ]\n",
@@ -155,12 +145,7 @@
155145
"\n",
156146
"# combine Argo vertical movement kernel with built-in Advection kernel\n",
157147
"kernels = [\n",
158-
" ArgoPhase1,\n",
159-
" ArgoPhase2,\n",
160-
" ArgoPhase3,\n",
161-
" ArgoPhase4,\n",
162-
" ArgoPhase5,\n",
163-
" ArgoPhase6,\n",
148+
" ArgoVerticalMovement,\n",
164149
" parcels.kernels.AdvectionRK4,\n",
165150
"]\n",
166151
"\n",

0 commit comments

Comments
 (0)