Skip to content

Fix legacy code, typos, suppress run_time warnings, added further support for PyVista visualisations, flagged all kernel killing code raised in Issue #46 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions notebooks/Exercise_01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"import iris\n",
"from geovista import GeoPlotter\n",
"from esmf_regrid.experimental.unstructured_scheme import MeshToGridESMFRegridder, GridToMeshESMFRegridder\n",
"from iris.experimental.ugrid.load import PARSE_UGRID_ON_LOAD\n",
"pv.rcParams[\"use_ipyvtk\"] = True\n",
"# pv.rcParams[\"use_ipyvtk\"] = True\n",
"iris.FUTURE.datum_support = True # avoids some warnings"
]
},
Expand Down Expand Up @@ -289,7 +288,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.13.2"
},
"toc-autonumbering": true,
"toc-showtags": false
Expand Down
83 changes: 53 additions & 30 deletions notebooks/Sec_01_Load_and_Examine.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@
"source": [
"## Iris unstructured loading\n",
"\n",
"\"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",
"\n",
"```python\n",
"with PARSE_UGRID_ON_LOAD.context():\n",
" cube_list = iris.load(path [, constraints])\n",
" # ..and/or..\n",
" single_cube = iris.load_cube(path [, constraints])\n",
" # ..and/or..\n",
" selected_cubes = iris.load_cubes(path, cube_constraints)\n",
"\n",
"```"
"\"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."
]
},
{
Expand All @@ -40,7 +30,7 @@
"source": [
"### Enable UGRID loading\n",
"\n",
"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"
"To test loading of UGRID files, like demonstrated above, we need to import `iris`."
]
},
{
Expand All @@ -52,9 +42,11 @@
},
"outputs": [],
"source": [
"import iris \n",
"import iris\n",
"\n",
"from iris.experimental.ugrid.load import PARSE_UGRID_ON_LOAD"
"# This will suppress RuntimeWarning flags\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")"
]
},
{
Expand Down Expand Up @@ -103,20 +95,25 @@
"outputs": [],
"source": [
"print('loading...')\n",
"with PARSE_UGRID_ON_LOAD.context():\n",
" cubes = iris.load(lfric_filepth)\n",
"\n",
"iris.FUTURE.date_microseconds = True\n",
"\n",
Comment on lines +99 to +100
Copy link

@ESadek-MO ESadek-MO Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in iris v3.11.1, you should add a minimum pin to the requirements and lock.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still needed!

"cubes = iris.load(lfric_filepth)\n",
"\n",
"print(f'\\n... Loaded {len(cubes)} cubes.')\n",
"print('Showing first 6:')\n",
"cubes[:6]"
"print('Showing them all:')\n",
"cubes"
]
},
{
"cell_type": "markdown",
"id": "604a48f9-8275-40e9-9d97-9294ce4e8ad7",
"metadata": {},
"source": [
"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. "
"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",
"\n",
"\n",
"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. "
]
},
{
Expand Down Expand Up @@ -151,22 +148,21 @@
},
"outputs": [],
"source": [
"with PARSE_UGRID_ON_LOAD.context():\n",
" lfric_rh = iris.load_cube(lfric_filepth,'relative_humidity_wrt_water')\n",
"lfric_rh = iris.load_cube(lfric_filepth,'relative_humidity_wrt_water')\n",
"\n",
"# just uncomment to explore: \n",
"#print(lfric_rh)\n",
"#print(lfric_rh.mesh)\n",
"#print(lfric_rh.location)\n",
"#print(lfric_rh.mesh_dim)\n"
"# print(lfric_rh)\n",
"# print(lfric_rh.mesh)\n",
"# print(lfric_rh.location)\n",
"# print(lfric_rh.mesh_dim)\n"
]
},
{
"cell_type": "markdown",
"id": "ee291cd1-7009-43e1-b62a-2ab615d458f0",
"metadata": {},
"source": [
"If the cube is not a mesh cube these propertise are `None`, which we can demonstrate with a cube from the \"UM file\": "
"If the cube is not a mesh cube these properties are `None`, which we can demonstrate with a cube from the \"UM file\": "
]
},
{
Expand All @@ -179,8 +175,35 @@
"outputs": [],
"source": [
"um_cube = iris.load_cube(um_filepth,'air_temperature')\n",
"#print(um_cube)\n",
"print(um_cube.mesh)\n"
"print('You can see the data here: \\n \\n', um_cube)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"print('You can see the data here: \\n \\n', um_cube)"
"print('You can see the data here: \n \n', um_cube)"

]
},
{
"cell_type": "markdown",
"id": "3b558541",
"metadata": {},
"source": [
"It is clearly not a mesh.\n",
"\n",
"If we try to print the mesh property, then the output is as follows:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9cdbd267",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"None\n"
]
}
],
"source": [
"print(um_cube.mesh)"
]
},
{
Expand All @@ -195,7 +218,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "everyday",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"display_name": "everyday",
"display_name": "Python 3 (ipykernel)",

"language": "python",
"name": "python3"
},
Expand All @@ -209,7 +232,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.13.2"
}
},
"nbformat": 4,
Expand Down
8 changes: 0 additions & 8 deletions notebooks/Sec_02_Meshes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@
"## Next notebook\n",
"See the next section: [03 - Plotting and Visualisation](./Sec_03_Plotting.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12005e21-9a61-44a2-85c1-01d11da5ade3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading