diff --git a/notebooks/Exercise_01.ipynb b/notebooks/Exercise_01.ipynb
index 3c38480..48d8eff 100644
--- a/notebooks/Exercise_01.ipynb
+++ b/notebooks/Exercise_01.ipynb
@@ -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"
]
},
diff --git a/notebooks/Sec_01_Load_and_Examine.ipynb b/notebooks/Sec_01_Load_and_Examine.ipynb
index 8279545..6c9a717 100644
--- a/notebooks/Sec_01_Load_and_Examine.ipynb
+++ b/notebooks/Sec_01_Load_and_Examine.ipynb
@@ -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."
]
},
{
@@ -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`."
]
},
{
@@ -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\")"
]
},
{
@@ -103,12 +95,14 @@
"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"
]
},
{
@@ -116,7 +110,10 @@
"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. Currently does not show any data, just empty table\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. "
]
},
{
@@ -151,14 +148,13 @@
},
"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"
]
},
{
@@ -166,7 +162,7 @@
"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\": "
]
},
{
@@ -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)"
]
},
{
diff --git a/notebooks/Sec_02_Meshes.ipynb b/notebooks/Sec_02_Meshes.ipynb
index 80bd7a7..d0d1639 100644
--- a/notebooks/Sec_02_Meshes.ipynb
+++ b/notebooks/Sec_02_Meshes.ipynb
@@ -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": {
diff --git a/notebooks/Sec_03_Plotting.ipynb b/notebooks/Sec_03_Plotting.ipynb
index 06499e8..dd347f0 100644
--- a/notebooks/Sec_03_Plotting.ipynb
+++ b/notebooks/Sec_03_Plotting.ipynb
@@ -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\")"
]
},
@@ -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"
]
},
{
@@ -246,7 +254,7 @@
"outputs": [],
"source": [
"viewpoint = plotter.camera_position\n",
- "#print(viewpoint)"
+ "print(viewpoint)"
]
},
{
diff --git a/notebooks/Sec_04_Regridding.ipynb b/notebooks/Sec_04_Regridding.ipynb
index 948810d..c504da4 100644
--- a/notebooks/Sec_04_Regridding.ipynb
+++ b/notebooks/Sec_04_Regridding.ipynb
@@ -19,7 +19,11 @@
"source": [
"from esmf_regrid.experimental.unstructured_scheme import MeshToGridESMFRegridder, GridToMeshESMFRegridder\n",
"from iris.coords import DimCoord\n",
- "from iris.cube import Cube"
+ "from iris.cube import Cube\n",
+ "\n",
+ "# This will suppress RuntimeWarning warning flags\n",
+ "import warnings\n",
+ "warnings.filterwarnings(\"ignore\")"
]
},
{
@@ -176,7 +180,9 @@
"id": "a6355ff5-805e-43dd-9937-93a6cabaf6e0",
"metadata": {},
"source": [
- "We can compare the regridded file to an equivalent file from the UM."
+ "We can compare the regridded file to an equivalent file from the UM.\n",
+ "\n",
+ "BELOW PLOTTING CODE WILL CRASH KERNEL: OLD STYLE REGRIDDER DEPRECATED? - COMMENTED OUT FOR NOW"
]
},
{
@@ -220,10 +226,10 @@
"temp_diff = regridded_temperature - grid_temp\n",
"temp_diff.long_name = \"Difference in temperature\"\n",
"\n",
- "# We choose a colormap that makes it clear where the differences are.\n",
- "iqplt.pcolormesh(temp_diff[0, 0], vmin=-4,vmax=4, cmap=\"seismic\")\n",
- "plt.gca().coastlines()\n",
- "plt.show()"
+ "# # We choose a colormap that makes it clear where the differences are.\n",
+ "# iqplt.pcolormesh(temp_diff[0, 0], vmin=-4,vmax=4, cmap=\"seismic\")\n",
+ "# plt.gca().coastlines()\n",
+ "# plt.show()"
]
},
{
@@ -304,7 +310,9 @@
"id": "5b07456d-bbc3-4e78-a3b0-031331e6e4b0",
"metadata": {},
"source": [
- "**Step 3:** Compare this result with the result from the default area weighted conservative regridder."
+ "**Step 3:** Compare this result with the result from the default area weighted conservative regridder.\n",
+ "\n",
+ "BELOW PLOTTING CODE WILL CRASH KERNEL - COMMENTED OUT FOR NOW"
]
},
{
@@ -314,7 +322,7 @@
"metadata": {},
"outputs": [],
"source": [
- "bilinear_diff = bilinear_regridded_orography - regridded_orography"
+ "# bilinear_diff = bilinear_regridded_orography - regridded_orography"
]
},
{
@@ -335,13 +343,13 @@
"import iris.quickplot as iqplt\n",
"import matplotlib.pyplot as plt\n",
"\n",
- "iqplt.pcolormesh(regridded_orography, cmap=\"terrain\")\n",
- "plt.show()\n",
- "iqplt.pcolormesh(bilinear_regridded_orography, cmap=\"terrain\")\n",
- "plt.show()\n",
- "bilinear_diff.long_name = \"Difference in altitude\"\n",
- "iqplt.pcolormesh(bilinear_diff, vmin=-400,vmax=400, cmap=\"seismic\")\n",
- "plt.show()"
+ "# iqplt.pcolormesh(regridded_orography, cmap=\"terrain\")\n",
+ "# plt.show()\n",
+ "# iqplt.pcolormesh(bilinear_regridded_orography, cmap=\"terrain\")\n",
+ "# plt.show()\n",
+ "# bilinear_diff.long_name = \"Difference in altitude\"\n",
+ "# iqplt.pcolormesh(bilinear_diff, vmin=-400,vmax=400, cmap=\"seismic\")\n",
+ "# plt.show()"
]
},
{
@@ -438,7 +446,7 @@
"\n",
"If we initialise a regridder with `MeshToGridESMFRegridder(src_mesh, tgt_grid, resolution=10)`, then the lines of latitude bounding each of the cells in `tgt_grid` will be *approximated* by 10 great circle sections.\n",
"\n",
- "Initialise a `MeshToGridESMFRegridder` with `mesh_cube` and your single celled cube as its arguments and with a `resolution=10` keyword."
+ "Initialise a `MeshToGridESMFRegridder` with `mesh_cube` and your single celled cube as its arguments and with a `tgt_resolution=10` keyword."
]
},
{
@@ -448,7 +456,7 @@
"metadata": {},
"outputs": [],
"source": [
- "lat_band_mean_calculator_10 = MeshToGridESMFRegridder(mesh_cube, lat_band_cube, resolution=10)"
+ "lat_band_mean_calculator_10 = MeshToGridESMFRegridder(mesh_cube, lat_band_cube, tgt_resolution=10)"
]
},
{
@@ -456,7 +464,9 @@
"id": "c66c9fe0-d75b-4402-bcc0-ab675beb2c74",
"metadata": {},
"source": [
- "**Step 5:** Apply this regridder to `mesh_cube` and print the data from this result (i.e. `print(result_cube.data)`) and plot with `iqplt.pcolormesh`."
+ "**Step 5:** Apply this regridder to `mesh_cube` and print the data from this result (i.e. `print(result_cube.data)`) and plot with `iqplt.pcolormesh`.\n",
+ "\n",
+ "BELOW PLOTTING CODE WILL CRASH KERNEL - COMMENTED OUT FOR NOW"
]
},
{
@@ -468,9 +478,9 @@
"source": [
"lat_band_mean_10 = lat_band_mean_calculator_10(mesh_cube)\n",
"print(lat_band_mean_10.data)\n",
- "iqplt.pcolormesh(lat_band_mean_10)\n",
- "plt.gca().coastlines()\n",
- "plt.show()"
+ "# iqplt.pcolormesh(lat_band_mean_10)\n",
+ "# plt.gca().coastlines()\n",
+ "# plt.show()"
]
},
{
@@ -478,9 +488,11 @@
"id": "402ee42e-a85c-46e8-be48-3f53d1f1ed12",
"metadata": {},
"source": [
- "**Step 6:** Repeat step 4 and 5 for `resolution=100`.\n",
+ "**Step 6:** Repeat step 4 and 5 for `tgt_resolution=100`.\n",
"\n",
- "Note the difference in value. Also note that it takes more time to initialise a regridder with higher resolution. Higher resolutions ought to be more accurate but there is a tradeoff between performance and accuracy."
+ "Note the difference in value. Also note that it takes more time to initialise a regridder with higher resolution. Higher resolutions ought to be more accurate but there is a tradeoff between performance and accuracy.\n",
+ "\n",
+ "BELOW PLOTTING CODE WILL CRASH KERNEL - COMMENTED OUT FOR NOW"
]
},
{
@@ -490,13 +502,13 @@
"metadata": {},
"outputs": [],
"source": [
- "lat_band_mean_calculator_100 = MeshToGridESMFRegridder(mesh_cube, lat_band_cube, resolution=100)\n",
+ "lat_band_mean_calculator_100 = MeshToGridESMFRegridder(mesh_cube, lat_band_cube, tgt_resolution=100)\n",
"lat_band_mean_100 = lat_band_mean_calculator_100(mesh_cube)\n",
"print(lat_band_mean_100.data)\n",
"\n",
- "iqplt.pcolormesh(lat_band_mean_100)\n",
- "plt.gca().coastlines()\n",
- "plt.show()"
+ "# iqplt.pcolormesh(lat_band_mean_100)\n",
+ "# plt.gca().coastlines()\n",
+ "# plt.show()"
]
},
{
@@ -506,7 +518,7 @@
"source": [
"**Step 7:** Repeat steps 1 - 6 for latitude bounds `[[-90, 90]]`, longitude bounds `[[-40, 40]]` and resolutions 2 and 10.\n",
"\n",
- "*Note:* Unlike lines of constant latitude, lines of constant longitude are already great circle arcs.This might suggest that the `resolution` argument is unnnecessary, however these arcs are 180 degrees which ESMF is unable to represent so we still need a `resolution` of at least 2. In this case, an increase in resolution will not affect the accuracy since a resolution of 2 will already have maximum accuracy. Note how the results are the equal."
+ "*Note:* Unlike lines of constant latitude, lines of constant longitude are already great circle arcs.This might suggest that the `tgt_resolution` argument is unnnecessary, however these arcs are 180 degrees which ESMF is unable to represent so we still need a `tgt_resolution` of at least 2. In this case, an increase in resolution will not affect the accuracy since a resolution of 2 will already have maximum accuracy. Note how the results are the equal."
]
},
{
@@ -523,11 +535,11 @@
"lon_band_cube.add_dim_coord(lat_full, 0)\n",
"lon_band_cube.add_dim_coord(lon_band, 1)\n",
"\n",
- "lon_band_mean_calculator_2 = MeshToGridESMFRegridder(mesh_cube, lon_band_cube, resolution=2)\n",
+ "lon_band_mean_calculator_2 = MeshToGridESMFRegridder(mesh_cube, lon_band_cube, tgt_resolution=2)\n",
"lon_band_mean_2 = lon_band_mean_calculator_2(mesh_cube)\n",
"print(lon_band_mean_2.data)\n",
"\n",
- "lon_band_mean_calculator_10 = MeshToGridESMFRegridder(mesh_cube, lon_band_cube, resolution=10)\n",
+ "lon_band_mean_calculator_10 = MeshToGridESMFRegridder(mesh_cube, lon_band_cube, tgt_resolution=10)\n",
"lon_band_mean_10 = lon_band_mean_calculator_10(mesh_cube)\n",
"print(lon_band_mean_10.data)"
]
@@ -578,6 +590,14 @@
"target_cube_lats"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "34bcb351",
+ "metadata": {},
+ "source": [
+ "We also can do the same thing for bands of constant longitude."
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
@@ -585,12 +605,10 @@
"metadata": {},
"outputs": [],
"source": [
- "# We also can do the same thing for bands of constant longitude.\n",
- "\n",
- "# target_cube_lons = grid_cube[:1]\n",
- "# target_cube_lons.remove_coord(\"latitude\")\n",
- "# target_cube_lons.add_dim_coord(lat_full, 0)\n",
- "# target_cube_lons"
+ "target_cube_lons = grid_cube[:1]\n",
+ "target_cube_lons.remove_coord(\"latitude\")\n",
+ "target_cube_lons.add_dim_coord(lat_full, 0)\n",
+ "target_cube_lons"
]
},
{
@@ -608,11 +626,19 @@
"metadata": {},
"outputs": [],
"source": [
- "um_lat_band_mean_calculator = MeshToGridESMFRegridder(humidity_cube, target_cube_lats, resolution=500)\n",
+ "um_lat_band_mean_calculator = MeshToGridESMFRegridder(humidity_cube, target_cube_lats, tgt_resolution=500)\n",
"um_lat_band_means = um_lat_band_mean_calculator(humidity_cube)\n",
"um_lat_band_means"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "5f079cd4",
+ "metadata": {},
+ "source": [
+ "Continuing for bands of constant longitude."
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
@@ -620,13 +646,9 @@
"metadata": {},
"outputs": [],
"source": [
- "# Continuing for bands of constant longitude.\n",
- "# Note: this code takes about 2 minutes to run. I think this is due to with the way ESMF handles cells\n",
- "# with unusual shapes. See https://github.com/SciTools-incubator/iris-esmf-regrid/issues/234.\n",
- "\n",
- "# um_lon_band_mean_calculator = MeshToGridESMFRegridder(humidity_cube, target_cube_lons, resolution=2)\n",
- "# um_lon_band_means = um_lon_band_mean_calculator(humidity_cube)\n",
- "# um_lon_band_means"
+ "um_lon_band_mean_calculator = MeshToGridESMFRegridder(humidity_cube, target_cube_lons, tgt_resolution=2)\n",
+ "um_lon_band_means = um_lon_band_mean_calculator(humidity_cube)\n",
+ "um_lon_band_means"
]
},
{
@@ -651,6 +673,14 @@
"plt.show()"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "fd4b6749",
+ "metadata": {},
+ "source": [
+ "Continuing for bands of constant longitude."
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
@@ -658,11 +688,9 @@
"metadata": {},
"outputs": [],
"source": [
- "# Continuing for bands of constant longitude.\n",
- "\n",
- "# iqplt.pcolormesh(um_lon_band_means[:, 0])\n",
- "# plt.gca().yaxis.set_major_formatter(mdates.DateFormatter(\"%D\"))\n",
- "# plt.show()"
+ "iqplt.pcolormesh(um_lon_band_means[:, 0])\n",
+ "plt.gca().yaxis.set_major_formatter(mdates.DateFormatter(\"%D\"))\n",
+ "plt.show()"
]
},
{
diff --git a/notebooks/Sec_05_RegionExtraction.ipynb b/notebooks/Sec_05_RegionExtraction.ipynb
index ba51cb9..87da61f 100644
--- a/notebooks/Sec_05_RegionExtraction.ipynb
+++ b/notebooks/Sec_05_RegionExtraction.ipynb
@@ -31,9 +31,13 @@
},
"outputs": [],
"source": [
+ "# This will suppress RuntimeWarning warning flags\n",
+ "import warnings\n",
+ "warnings.filterwarnings(\"ignore\")\n",
+ "\n",
"from testdata_fetching import lfric_rh_singletime_2d\n",
"lfric_rh = lfric_rh_singletime_2d()\n",
- "#lfric_rh"
+ "lfric_rh"
]
},
{
@@ -56,7 +60,7 @@
"source": [
"from pv_conversions import pv_from_lfric_cube\n",
"pv_global_rh = pv_from_lfric_cube(lfric_rh)\n",
- "#pv_global_rh"
+ "pv_global_rh"
]
},
{
diff --git a/notebooks/testdata_fetching.py b/notebooks/testdata_fetching.py
index a8afd34..bc860eb 100644
--- a/notebooks/testdata_fetching.py
+++ b/notebooks/testdata_fetching.py
@@ -3,10 +3,8 @@
from pathlib import Path
import iris
-iris.FUTURE.datum_support = True # avoids some irritating warnings
-
-from iris.experimental.ugrid.load import PARSE_UGRID_ON_LOAD
+iris.FUTURE.datum_support = True # avoids some irritating warnings
# Useful public variables
data_path = None
@@ -40,23 +38,19 @@ def um_rh_singletime_2d():
return cube[0]
def lfric_all_datacubes():
- with PARSE_UGRID_ON_LOAD.context():
- cubes = iris.load(lfric_filepth)
+ cubes = iris.load(lfric_filepth)
return cubes
def lfric_orography():
- with PARSE_UGRID_ON_LOAD.context():
- cube = iris.load_cube(lfric_filepth, 'surface_altitude')
+ cube = iris.load_cube(lfric_filepth, 'surface_altitude')
return cube[0]
def lfric_temp():
- with PARSE_UGRID_ON_LOAD.context():
- cube = iris.load_cube(lfric_filepth, 'air_temperature')
+ cube = iris.load_cube(lfric_filepth, 'air_temperature')
return cube
def lfric_rh_alltimes_3d():
- with PARSE_UGRID_ON_LOAD.context():
- rh_cube = iris.load_cube(lfric_filepth, 'relative_humidity_at_screen_level')
+ rh_cube = iris.load_cube(lfric_filepth, 'relative_humidity_at_screen_level')
return rh_cube
def lfric_rh_singletime_2d():