|
23 | 23 | "cell_type": "markdown", |
24 | 24 | "metadata": {}, |
25 | 25 | "source": [ |
26 | | - "Let's first import the relevant modules, and generate a simple dataset on a 2D spherical mesh, with `U`, `V` and `temperature` data arrays, with the velocities 1 m/s and the temperature 20C.\n" |
| 26 | + "Let's first import the relevant modules, and generate a simple dataset on a 2D spherical mesh, with `U`, `V` and `temperature` data arrays, with the velocities 1 m s<sup>-1</sup> and the temperature 20°C.\n" |
27 | 27 | ] |
28 | 28 | }, |
29 | 29 | { |
|
67 | 67 | "When using a `FieldSet` method for a specific dataset, such as `from_copernicusmarine()`, the grid information is known and parsed by Parcels, so we do not have to add the `mesh` argument.\n", |
68 | 68 | "```\n", |
69 | 69 | "\n", |
70 | | - "Plotting the `U` field indeed shows a uniform 1 m/s eastward flow.\n" |
| 70 | + "Plotting the `U` field indeed shows a uniform 1 m s<sup>-1</sup> eastward flow.\n" |
71 | 71 | ] |
72 | 72 | }, |
73 | 73 | { |
|
107 | 107 | "However, printing the velocites directly shows something perhaps surprising. Here, we use the square-bracket field-interpolation notation to print the field value at (5W, 40N, 0m depth) at time 0. \n", |
108 | 108 | "\n", |
109 | 109 | "```{note}\n", |
110 | | - "Sampling a velocity in Parcels is done by calling the `fieldset.UV` VectorField; see the [Field Sampling tutorial](https://docs.oceanparcels.org/en/latest/examples/tutorial_sampling.html#Sampling-velocity-fields) for more information._\n", |
| 110 | + "Sampling a velocity in Parcels is done by calling the `fieldset.UV` VectorField; see also the section \"Sampling U and V separately\" below.\n", |
111 | 111 | "```\n" |
112 | 112 | ] |
113 | 113 | }, |
|
133 | 133 | "cell_type": "markdown", |
134 | 134 | "metadata": {}, |
135 | 135 | "source": [ |
136 | | - "While the temperature field indeed is 20C, as we defined, these printed velocities are much smaller.\n", |
| 136 | + "While the temperature field indeed is 20°C, as we defined, these printed velocities are much smaller.\n", |
137 | 137 | "\n", |
138 | | - "This is because Parcels converts under the hood from m/s to degrees/s.\n" |
| 138 | + "This is because Parcels converts under the hood from m s<sup>-1</sup> to degrees s<sup>-1</sup>." |
139 | 139 | ] |
140 | 140 | }, |
141 | 141 | { |
142 | 142 | "attachments": {}, |
143 | 143 | "cell_type": "markdown", |
144 | 144 | "metadata": {}, |
145 | 145 | "source": [ |
146 | | - "Indeed, if we multiply the value of the U field with 1852 \\* 60 \\* cos(lat) (the number of meters in 1 degree of longitude), we get the expected 1 m/s.\n" |
| 146 | + "Indeed, if we multiply the value of the U field with 1852 \\* 60 \\* cos(lat) (the number of meters in 1 degree of longitude), we get the expected 1 m s<sup>-1</sup>.\n" |
147 | 147 | ] |
148 | 148 | }, |
149 | 149 | { |
|
196 | 196 | ")" |
197 | 197 | ] |
198 | 198 | }, |
| 199 | + { |
| 200 | + "cell_type": "markdown", |
| 201 | + "metadata": {}, |
| 202 | + "source": [ |
| 203 | + "## Don't sample U and V separately" |
| 204 | + ] |
| 205 | + }, |
| 206 | + { |
| 207 | + "cell_type": "markdown", |
| 208 | + "metadata": {}, |
| 209 | + "source": [ |
| 210 | + "Sampling `U` and `V` separately will _not_ convert to degrees s<sup>-1</sup>, so these velocities cannot be used directly for advection on spherical coordinates. This is one of the main reasons to always use the `UV` VectorField for velocity sampling in Parcels.\n" |
| 211 | + ] |
| 212 | + }, |
| 213 | + { |
| 214 | + "cell_type": "code", |
| 215 | + "execution_count": null, |
| 216 | + "metadata": {}, |
| 217 | + "outputs": [], |
| 218 | + "source": [ |
| 219 | + "for fld in [fieldset.U, fieldset.V]:\n", |
| 220 | + " print(f\"{fld.name}: {fld.eval(time, z, lat, lon)}\")" |
| 221 | + ] |
| 222 | + }, |
199 | 223 | { |
200 | 224 | "cell_type": "markdown", |
201 | 225 | "metadata": {}, |
|
0 commit comments