Skip to content

Commit 34905ee

Browse files
reint-fischerreint-fischer
authored andcommitted
fix wording
1 parent d367e4f commit 34905ee

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

docs/user_guide/examples/tutorial_unitconverters.ipynb

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"cell_type": "markdown",
66
"metadata": {},
77
"source": [
8-
"# Spherical grids and unit conversion\n"
8+
"# Spherical grids and unit converters\n"
99
]
1010
},
1111
{
@@ -67,7 +67,7 @@
6767
"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",
6868
"```\n",
6969
"\n",
70-
"Plotting the `U` field indeed shows a uniform 1m/s eastward flow.\n"
70+
"Plotting the `U` field indeed shows a uniform 1 m/s eastward flow.\n"
7171
]
7272
},
7373
{
@@ -113,9 +113,13 @@
113113
"metadata": {},
114114
"outputs": [],
115115
"source": [
116-
"print(fieldset.UV[np.array([0]), np.array([0]), np.array([40]), np.array([-5])])\n",
116+
"time = np.array([0])\n",
117+
"z = np.array([0])\n",
118+
"lat = np.array([40])\n",
119+
"lon = np.array([-5])\n",
120+
"print(fieldset.UV[time, z, lat, lon])\n",
117121
"print(\n",
118-
" fieldset.temperature[np.array([0]), np.array([0]), np.array([40]), np.array([-5])]\n",
122+
" fieldset.temperature[time, z, lat, lon]\n",
119123
")"
120124
]
121125
},
@@ -126,7 +130,7 @@
126130
"source": [
127131
"While the temperature field indeed is 20C, as we defined, these printed velocities are much smaller.\n",
128132
"\n",
129-
"This is because Parcels converts under the hood from m/s to degrees/s. This conversion is done with a `UnitConverter` object, which is stored in the `.units` attribute of each Field. Below, we print these\n"
133+
"This is because Parcels converts under the hood from m/s to degrees/s. This conversion is done with a `parcels.converters` object, which is stored in the `.units` attribute of each Field. Below, we print these\n"
130134
]
131135
},
132136
{
@@ -144,7 +148,7 @@
144148
"cell_type": "markdown",
145149
"metadata": {},
146150
"source": [
147-
"So the U field has a `GeographicPolar` UnitConverter object, the V field has a `Geographic` Unitconverter and the `temp` field has a `UnitConverter` object.\n",
151+
"So the U field has a `GeographicPolar` UnitConverter object, the V field has a `Geographic` UnitConverter and the `temp` field has a `UnitConverter` object.\n",
148152
"\n",
149153
"Indeed, if we multiply 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.\n"
150154
]
@@ -155,7 +159,7 @@
155159
"metadata": {},
156160
"outputs": [],
157161
"source": [
158-
"u, v = fieldset.UV[np.array([0]), np.array([0]), np.array([40]), np.array([-5])]\n",
162+
"u, v = fieldset.UV[time, z, lat, lon]\n",
159163
"print(v * 1852 * 60)"
160164
]
161165
},
@@ -175,10 +179,10 @@
175179
"source": [
176180
"print(\n",
177181
" fieldset.UV.eval(\n",
178-
" np.array([0]),\n",
179-
" np.array([0]),\n",
180-
" np.array([40]),\n",
181-
" np.array([-5]),\n",
182+
" time,\n",
183+
" z,\n",
184+
" lat,\n",
185+
" lon,\n",
182186
" applyConversion=False,\n",
183187
" )\n",
184188
")"
@@ -235,7 +239,7 @@
235239
"\n",
236240
"print(\n",
237241
" \"Velocities:\",\n",
238-
" fieldset_flat.UV[np.array([0]), np.array([0]), np.array([40]), np.array([-5])],\n",
242+
" fieldset_flat.UV[time, z, lat, lon],\n",
239243
")\n",
240244
"for fld in [fieldset_flat.U, fieldset_flat.V, fieldset_flat.temperature]:\n",
241245
" print(f\"{fld.name}: {fld.units}\")"
@@ -301,7 +305,7 @@
301305
"fieldset.add_field(kh_meridional_field)\n",
302306
"\n",
303307
"for fld in [fieldset.Kh_zonal, fieldset.Kh_meridional]:\n",
304-
" val = fld[np.array([0]), np.array([0]), np.array([40]), np.array([-5])]\n",
308+
" val = fld[time, z, lat, lon]\n",
305309
" print(f\"{fld.name}: {val} {fld.units}\")"
306310
]
307311
},
@@ -323,7 +327,7 @@
323327
"source": [
324328
"deg_to_m = 1852 * 60\n",
325329
"print(\n",
326-
" fieldset.Kh_meridional[np.array([0]), np.array([0]), np.array([40]), np.array([-5])]\n",
330+
" fieldset.Kh_meridional[time, z, lat, lon]\n",
327331
" * deg_to_m**2\n",
328332
")"
329333
]
@@ -374,7 +378,7 @@
374378
" interp_method=parcels.interpolators.XLinear,\n",
375379
" )\n",
376380
")\n",
377-
"print(fieldset.Ustokes[np.array([0]), np.array([0]), np.array([40]), np.array([-5])])"
381+
"print(fieldset.Ustokes[time, z, lat, lon])"
378382
]
379383
},
380384
{
@@ -392,9 +396,9 @@
392396
"outputs": [],
393397
"source": [
394398
"fieldset.Ustokes.units = parcels.GeographicPolar()\n",
395-
"print(fieldset.Ustokes[np.array([0]), np.array([0]), np.array([40]), np.array([-5])])\n",
399+
"print(fieldset.Ustokes[time, z, lat, lon])\n",
396400
"print(\n",
397-
" fieldset.Ustokes[np.array([0]), np.array([0]), np.array([40]), np.array([-5])]\n",
401+
" fieldset.Ustokes[time, z, lat, lon]\n",
398402
" * 1852\n",
399403
" * 60\n",
400404
" * np.cos(40 * np.pi / 180)\n",

0 commit comments

Comments
 (0)