You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user_guide/examples/tutorial_unitconverters.ipynb
+6-29Lines changed: 6 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,9 @@
15
15
"source": [
16
16
"In most applications, Parcels works with `spherical` meshes, where longitude and latitude are given in degrees, while depth is given in meters. But it is also possible to use `flat` meshes, where longitude and latitude are given in meters (note that the dimensions are then still called `longitude` and `latitude` for consistency reasons).\n",
17
17
"\n",
18
-
"In all cases, velocities are given in m/s. Parcels seamlessly converts between meters and degrees, under the hood. For transparency, this guide explains how this works.\n"
18
+
"In all cases, velocities are given in m s<sup>-1</sup>. But for advection (such as `particles.dlat = v * particles.dt`), the velocity needs to be in degrees s<sup>-1</sup>. \n",
19
+
"\n",
20
+
"Parcels seamlessly converts between meters s<sup>-1</sup> and degrees s<sup>-1</sup>, under the hood. For transparency, this guide explains how this works.\n"
19
21
]
20
22
},
21
23
{
@@ -130,7 +132,7 @@
130
132
"cell_type": "markdown",
131
133
"metadata": {},
132
134
"source": [
133
-
"Indeed, if we multiply the value of the U field with 1852 \\* 60 \\* cos(lat) (the number of meters in 1 degree of longitude) and the value of the V field with 1852 \\* 60 (the number of meters in 1 degree of latitude), we get the expected 1 m s<sup>-1</sup> for `u` and `v`.\n"
135
+
"Indeed, if we multiply the value of `u` with 1852 \\* 60 \\* cos(lat) (the number of meters in 1 degree of longitude) and the value of `v` with 1852 \\* 60 (the number of meters in 1 degree of latitude), we get the expected 1 m s<sup>-1</sup> for `u` and `v`.\n"
134
136
]
135
137
},
136
138
{
@@ -149,31 +151,6 @@
149
151
"assert np.isclose(v, 1.0)"
150
152
]
151
153
},
152
-
{
153
-
"attachments": {},
154
-
"cell_type": "markdown",
155
-
"metadata": {},
156
-
"source": [
157
-
"You can also interpolate the Field to these values directly by using the `eval()` method and setting `applyConversion=False`, as below\n"
158
-
]
159
-
},
160
-
{
161
-
"cell_type": "code",
162
-
"execution_count": null,
163
-
"metadata": {},
164
-
"outputs": [],
165
-
"source": [
166
-
"print(\n",
167
-
" fieldset.UV.eval(\n",
168
-
" time,\n",
169
-
" z,\n",
170
-
" lat,\n",
171
-
" lon,\n",
172
-
" apply_conversion=False,\n",
173
-
" )\n",
174
-
")"
175
-
]
176
-
},
177
154
{
178
155
"cell_type": "markdown",
179
156
"metadata": {},
@@ -185,7 +162,7 @@
185
162
"cell_type": "markdown",
186
163
"metadata": {},
187
164
"source": [
188
-
"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"
165
+
"Sampling `U` and `V` separately will _not_ convert to degrees s<sup>-1</sup>, so these velocities _should not_ 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"
189
166
]
190
167
},
191
168
{
@@ -204,7 +181,7 @@
204
181
"source": [
205
182
"## Unit conversion for other fields such as diffusivity\n",
206
183
"\n",
207
-
"For other fields such as diffusivity, Parcels does not apply similar unit conversions when using a `spherical` mesh. For example, if we define a diffusivity field with value 10 m<sup>2</sup> s<sup>-1</sup>, Parcels will not convert this to degrees<sup>2</sup> s<sup>-1</sup> under the hood. \n",
184
+
"For other fields such as diffusivity, Parcels does not apply similar unit conversions when using a `spherical` mesh. For example, if we define a diffusivity field in m<sup>2</sup> s<sup>-1</sup>, Parcels will _not_ convert this to degrees<sup>2</sup> s<sup>-1</sup> under the hood. \n",
208
185
"\n",
209
186
"If you want to work with diffusivity in degrees<sup>2</sup> s<sup>-1</sup> (for example to move particles using a random walk), you will have to convert this yourself in your kernel. \n",
Copy file name to clipboardExpand all lines: docs/user_guide/v4-migration.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ Version 4 of Parcels is unreleased at the moment. The information in this migrat
40
40
-`Field.eval()` returns an array of floats instead of a single float (related to the vectorization)
41
41
-`Field.eval()` does not throw OutOfBounds or other errors
42
42
- The `NestedField` class has been removed. See the Nested Grids how-to guide for how to set up Nested Grids in v4.
43
-
-`applyConversion` has been renamed to `apply_conversion` and only works for VectorFields. Conversion of units should be handled in Kernels.
43
+
-`applyConversion` has been removed. Interpolation on VectorFields automatically converts from m/s to degrees/s for spherical meshes. Other conversion of units should be handled in Interpolators or Kernels.
0 commit comments