Skip to content

Commit 37bd966

Browse files
authored
Merge pull request #47 from harley-kelly/main
Fix legacy code, typos, suppress run_time warnings, added further support for PyVista visualisations, flagged all kernel killing code raised in Issue #46
2 parents 6467165 + 2da09be commit 37bd966

7 files changed

+365
-139
lines changed

notebooks/Exercise_01.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"import iris\n",
5050
"from geovista import GeoPlotter\n",
5151
"from esmf_regrid.experimental.unstructured_scheme import MeshToGridESMFRegridder, GridToMeshESMFRegridder\n",
52-
"from iris.experimental.ugrid.load import PARSE_UGRID_ON_LOAD\n",
53-
"pv.rcParams[\"use_ipyvtk\"] = True\n",
52+
"# pv.rcParams[\"use_ipyvtk\"] = True\n",
5453
"iris.FUTURE.datum_support = True # avoids some warnings"
5554
]
5655
},
@@ -289,7 +288,7 @@
289288
"name": "python",
290289
"nbconvert_exporter": "python",
291290
"pygments_lexer": "ipython3",
292-
"version": "3.9.16"
291+
"version": "3.13.2"
293292
},
294293
"toc-autonumbering": true,
295294
"toc-showtags": false

notebooks/Sec_01_Load_and_Examine.ipynb

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,7 @@
2020
"source": [
2121
"## Iris unstructured loading\n",
2222
"\n",
23-
"\"Unstructured\" data can be loaded from UGRID files (i.e. netCDF files containing a UGRID-style mesh). This is just like normal [Iris](https://scitools-iris.readthedocs.io/en/latest) loading, except that we must *enable* the interpretion of UGRID content like this:\n",
24-
"\n",
25-
"```python\n",
26-
"with PARSE_UGRID_ON_LOAD.context():\n",
27-
" cube_list = iris.load(path [, constraints])\n",
28-
" # ..and/or..\n",
29-
" single_cube = iris.load_cube(path [, constraints])\n",
30-
" # ..and/or..\n",
31-
" selected_cubes = iris.load_cubes(path, cube_constraints)\n",
32-
"\n",
33-
"```"
23+
"\"Unstructured\" data can be loaded from UGRID files (i.e. netCDF files containing a UGRID-style mesh). This is just like normal [Iris](https://scitools-iris.readthedocs.io/en/latest) loading."
3424
]
3525
},
3626
{
@@ -40,7 +30,7 @@
4030
"source": [
4131
"### Enable UGRID loading\n",
4232
"\n",
43-
"To test loading of UGRID files, like demonstrated above, we need to import `iris`, and the `PARSE_UGRID_ON_LOAD` object from [iris.experimental.ugrid.load](https://scitools-iris.readthedocs.io/en/latest/generated/api/iris/experimental/ugrid/load.html#)\n"
33+
"To test loading of UGRID files, like demonstrated above, we need to import `iris`."
4434
]
4535
},
4636
{
@@ -52,9 +42,11 @@
5242
},
5343
"outputs": [],
5444
"source": [
55-
"import iris \n",
45+
"import iris\n",
5646
"\n",
57-
"from iris.experimental.ugrid.load import PARSE_UGRID_ON_LOAD"
47+
"# This will suppress RuntimeWarning flags\n",
48+
"import warnings\n",
49+
"warnings.filterwarnings(\"ignore\")"
5850
]
5951
},
6052
{
@@ -103,20 +95,25 @@
10395
"outputs": [],
10496
"source": [
10597
"print('loading...')\n",
106-
"with PARSE_UGRID_ON_LOAD.context():\n",
107-
" cubes = iris.load(lfric_filepth)\n",
98+
"\n",
99+
"iris.FUTURE.date_microseconds = True\n",
100+
"\n",
101+
"cubes = iris.load(lfric_filepth)\n",
108102
"\n",
109103
"print(f'\\n... Loaded {len(cubes)} cubes.')\n",
110-
"print('Showing first 6:')\n",
111-
"cubes[:6]"
104+
"print('Showing them all:')\n",
105+
"cubes"
112106
]
113107
},
114108
{
115109
"cell_type": "markdown",
116110
"id": "604a48f9-8275-40e9-9d97-9294ce4e8ad7",
117111
"metadata": {},
118112
"source": [
119-
"Putting just `cubes` at the end of the code above triggers noteboook printing output. You can click on each cube to expand it into detail view. Try this. Try also to use `print(cubes)` instead. To spot some structual differences between LFRic and UM data also load some cubes from `um_filepath` above. "
113+
"Putting just `cubes` at the end of the code above triggers notebook printing output. You can click on each cube to expand it into detail view. Try this. <span style=\"color:red; font-weight:bold;\">Currently does not show any data, just empty table</span>\n",
114+
"\n",
115+
"\n",
116+
"Try also to use `print(cubes)` instead. To spot some structual differences between LFRic and UM data also load some cubes from `um_filepath` above. "
120117
]
121118
},
122119
{
@@ -151,22 +148,21 @@
151148
},
152149
"outputs": [],
153150
"source": [
154-
"with PARSE_UGRID_ON_LOAD.context():\n",
155-
" lfric_rh = iris.load_cube(lfric_filepth,'relative_humidity_wrt_water')\n",
151+
"lfric_rh = iris.load_cube(lfric_filepth,'relative_humidity_wrt_water')\n",
156152
"\n",
157153
"# just uncomment to explore: \n",
158-
"#print(lfric_rh)\n",
159-
"#print(lfric_rh.mesh)\n",
160-
"#print(lfric_rh.location)\n",
161-
"#print(lfric_rh.mesh_dim)\n"
154+
"# print(lfric_rh)\n",
155+
"# print(lfric_rh.mesh)\n",
156+
"# print(lfric_rh.location)\n",
157+
"# print(lfric_rh.mesh_dim)\n"
162158
]
163159
},
164160
{
165161
"cell_type": "markdown",
166162
"id": "ee291cd1-7009-43e1-b62a-2ab615d458f0",
167163
"metadata": {},
168164
"source": [
169-
"If the cube is not a mesh cube these propertise are `None`, which we can demonstrate with a cube from the \"UM file\": "
165+
"If the cube is not a mesh cube these properties are `None`, which we can demonstrate with a cube from the \"UM file\": "
170166
]
171167
},
172168
{
@@ -179,8 +175,35 @@
179175
"outputs": [],
180176
"source": [
181177
"um_cube = iris.load_cube(um_filepth,'air_temperature')\n",
182-
"#print(um_cube)\n",
183-
"print(um_cube.mesh)\n"
178+
"print('You can see the data here: \\n \\n', um_cube)"
179+
]
180+
},
181+
{
182+
"cell_type": "markdown",
183+
"id": "3b558541",
184+
"metadata": {},
185+
"source": [
186+
"It is clearly not a mesh.\n",
187+
"\n",
188+
"If we try to print the mesh property, then the output is as follows:"
189+
]
190+
},
191+
{
192+
"cell_type": "code",
193+
"execution_count": null,
194+
"id": "9cdbd267",
195+
"metadata": {},
196+
"outputs": [
197+
{
198+
"name": "stdout",
199+
"output_type": "stream",
200+
"text": [
201+
"None\n"
202+
]
203+
}
204+
],
205+
"source": [
206+
"print(um_cube.mesh)"
184207
]
185208
},
186209
{
@@ -195,7 +218,7 @@
195218
],
196219
"metadata": {
197220
"kernelspec": {
198-
"display_name": "Python 3 (ipykernel)",
221+
"display_name": "everyday",
199222
"language": "python",
200223
"name": "python3"
201224
},
@@ -209,7 +232,7 @@
209232
"name": "python",
210233
"nbconvert_exporter": "python",
211234
"pygments_lexer": "ipython3",
212-
"version": "3.9.16"
235+
"version": "3.13.2"
213236
}
214237
},
215238
"nbformat": 4,

notebooks/Sec_02_Meshes.ipynb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@
100100
"## Next notebook\n",
101101
"See the next section: [03 - Plotting and Visualisation](./Sec_03_Plotting.ipynb)"
102102
]
103-
},
104-
{
105-
"cell_type": "code",
106-
"execution_count": null,
107-
"id": "12005e21-9a61-44a2-85c1-01d11da5ade3",
108-
"metadata": {},
109-
"outputs": [],
110-
"source": []
111103
}
112104
],
113105
"metadata": {

0 commit comments

Comments
 (0)