Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
3 changes: 1 addition & 2 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
71 changes: 43 additions & 28 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",
"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,27 @@
"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)"
]
},
{
"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": [],
"source": [
"print(um_cube.mesh)"
]
},
{
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
18 changes: 13 additions & 5 deletions notebooks/Sec_03_Plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
"outputs": [],
"source": [
"import geovista as gv\n",
"from geovista.pantry import um_orca2\n",
"from geovista.pantry.data import nemo_orca2\n",
"from display_demo_routines import popup_2d_data_xx_yy\n",
"\n",
"example_data = um_orca2()\n",
"# This will suppress RuntimeWarning flags\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
"# This is needed to run in a Jupyter notebook\n",
"import pyvista\n",
"pyvista.set_jupyter_backend('trame') # make sure trame, trame-vtk, and trame-vuetify are installed in conda env\n",
"\n",
"example_data = nemo_orca2()\n",
"popup_2d_data_xx_yy(example_data, \"ORCA test data\")"
]
},
Expand Down Expand Up @@ -99,8 +107,8 @@
"from pv_conversions import pv_from_lfric_cube\n",
"\n",
"pv = pv_from_lfric_cube(lfric_rh)\n",
"#print(pv)\n",
"#pv"
"print(pv)\n",
"pv"
]
},
{
Expand Down Expand Up @@ -246,7 +254,7 @@
"outputs": [],
"source": [
"viewpoint = plotter.camera_position\n",
"#print(viewpoint)"
"print(viewpoint)"
]
},
{
Expand Down
Loading