|
41 | 41 | "\n", |
42 | 42 | " def SinkingPhase(p):\n", |
43 | 43 | " \"\"\"Phase 0: Sinking with vertical_speed until depth is driftdepth\"\"\"\n", |
44 | | - " p.ddepth += vertical_speed * dt\n", |
45 | | - " p.cycle_phase = np.where(p.depth + p.ddepth >= driftdepth, 1, p.cycle_phase)\n", |
46 | | - " p.ddepth = np.where(\n", |
47 | | - " p.depth + p.ddepth >= driftdepth, driftdepth - p.depth, p.ddepth\n", |
48 | | - " )\n", |
| 44 | + " p.dz += vertical_speed * dt\n", |
| 45 | + " p.cycle_phase = np.where(p.z + p.dz >= driftdepth, 1, p.cycle_phase)\n", |
| 46 | + " p.dz = np.where(p.z + p.dz >= driftdepth, driftdepth - p.z, p.dz)\n", |
49 | 47 | "\n", |
50 | 48 | " SinkingPhase(particles[particles.cycle_phase == 0])\n", |
51 | 49 | "\n", |
|
67 | 65 | "\n", |
68 | 66 | " def SecondSinkingPhase(p):\n", |
69 | 67 | " \"\"\"Phase 2: Sinking further to maxdepth\"\"\"\n", |
70 | | - " p.ddepth += vertical_speed * dt\n", |
71 | | - " p.cycle_phase = np.where(p.depth + p.ddepth >= maxdepth, 3, p.cycle_phase)\n", |
72 | | - " p.ddepth = np.where(\n", |
73 | | - " p.depth + p.ddepth >= maxdepth, maxdepth - p.depth, p.ddepth\n", |
74 | | - " )\n", |
| 68 | + " p.dz += vertical_speed * dt\n", |
| 69 | + " p.cycle_phase = np.where(p.z + p.dz >= maxdepth, 3, p.cycle_phase)\n", |
| 70 | + " p.dz = np.where(p.z + p.dz >= maxdepth, maxdepth - p.z, p.dz)\n", |
75 | 71 | "\n", |
76 | 72 | " SecondSinkingPhase(particles[particles.cycle_phase == 2])\n", |
77 | 73 | "\n", |
|
81 | 77 | "\n", |
82 | 78 | " def RisingPhase(p):\n", |
83 | 79 | " \"\"\"Phase 3: Rising with vertical_speed until at surface\"\"\"\n", |
84 | | - " p.ddepth -= vertical_speed * dt\n", |
85 | | - " p.temp = fieldset.thetao[p.time, p.depth, p.lat, p.lon]\n", |
86 | | - " p.cycle_phase = np.where(\n", |
87 | | - " p.depth + p.ddepth <= fieldset.mindepth, 4, p.cycle_phase\n", |
88 | | - " )\n", |
89 | | - " p.ddepth = np.where(\n", |
90 | | - " p.depth + p.ddepth <= fieldset.mindepth,\n", |
91 | | - " fieldset.mindepth - p.depth,\n", |
92 | | - " p.ddepth,\n", |
| 80 | + " p.dz -= vertical_speed * dt\n", |
| 81 | + " p.temp = fieldset.thetao[p.time, p.z, p.lat, p.lon]\n", |
| 82 | + " p.cycle_phase = np.where(p.z + p.dz <= fieldset.mindepth, 4, p.cycle_phase)\n", |
| 83 | + " p.dz = np.where(\n", |
| 84 | + " p.z + p.dz <= fieldset.mindepth,\n", |
| 85 | + " fieldset.mindepth - p.z,\n", |
| 86 | + " p.dz,\n", |
93 | 87 | " )\n", |
94 | 88 | "\n", |
95 | 89 | " RisingPhase(particles[particles.cycle_phase == 3])\n", |
|
163 | 157 | " pclass=ArgoParticle,\n", |
164 | 158 | " lon=[32],\n", |
165 | 159 | " lat=[-31],\n", |
166 | | - " depth=[fieldset.mindepth],\n", |
| 160 | + " z=[fieldset.mindepth],\n", |
167 | 161 | ")\n", |
168 | 162 | "\n", |
169 | 163 | "# combine Argo vertical movement kernel with built-in Advection kernel\n", |
|
174 | 168 | " ArgoPhase4,\n", |
175 | 169 | " ArgoPhase5,\n", |
176 | 170 | " ArgoPhase6,\n", |
177 | | - " parcels.AdvectionRK4,\n", |
| 171 | + " parcels.kernels.AdvectionRK4,\n", |
178 | 172 | "]\n", |
179 | 173 | "\n", |
180 | 174 | "# Create a ParticleFile object to store the output\n", |
|
209 | 203 | "metadata": {}, |
210 | 204 | "outputs": [], |
211 | 205 | "source": [ |
212 | | - "ds_out = xr.open_zarr(\n", |
213 | | - " output_file.store, decode_times=False\n", |
214 | | - ") # TODO fix without using decode_times=False\n", |
| 206 | + "ds_out = xr.open_zarr(output_file.store)\n", |
215 | 207 | "x = ds_out[\"lon\"][:].squeeze()\n", |
216 | 208 | "y = ds_out[\"lat\"][:].squeeze()\n", |
217 | 209 | "z = ds_out[\"z\"][:].squeeze()\n", |
|
268 | 260 | ], |
269 | 261 | "metadata": { |
270 | 262 | "kernelspec": { |
271 | | - "display_name": "parcels-v4", |
| 263 | + "display_name": "test-notebooks", |
272 | 264 | "language": "python", |
273 | 265 | "name": "python3" |
274 | 266 | }, |
|
0 commit comments