|
20 | 20 | "source": [
|
21 | 21 | "## Iris unstructured loading\n",
|
22 | 22 | "\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." |
34 | 24 | ]
|
35 | 25 | },
|
36 | 26 | {
|
|
40 | 30 | "source": [
|
41 | 31 | "### Enable UGRID loading\n",
|
42 | 32 | "\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`." |
44 | 34 | ]
|
45 | 35 | },
|
46 | 36 | {
|
|
52 | 42 | },
|
53 | 43 | "outputs": [],
|
54 | 44 | "source": [
|
55 |
| - "import iris \n", |
| 45 | + "import iris\n", |
56 | 46 | "\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\")" |
58 | 50 | ]
|
59 | 51 | },
|
60 | 52 | {
|
|
103 | 95 | "outputs": [],
|
104 | 96 | "source": [
|
105 | 97 | "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", |
108 | 102 | "\n",
|
109 | 103 | "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" |
112 | 106 | ]
|
113 | 107 | },
|
114 | 108 | {
|
115 | 109 | "cell_type": "markdown",
|
116 | 110 | "id": "604a48f9-8275-40e9-9d97-9294ce4e8ad7",
|
117 | 111 | "metadata": {},
|
118 | 112 | "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. " |
120 | 117 | ]
|
121 | 118 | },
|
122 | 119 | {
|
|
151 | 148 | },
|
152 | 149 | "outputs": [],
|
153 | 150 | "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", |
156 | 152 | "\n",
|
157 | 153 | "# 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" |
162 | 158 | ]
|
163 | 159 | },
|
164 | 160 | {
|
165 | 161 | "cell_type": "markdown",
|
166 | 162 | "id": "ee291cd1-7009-43e1-b62a-2ab615d458f0",
|
167 | 163 | "metadata": {},
|
168 | 164 | "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\": " |
170 | 166 | ]
|
171 | 167 | },
|
172 | 168 | {
|
|
179 | 175 | "outputs": [],
|
180 | 176 | "source": [
|
181 | 177 | "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)" |
184 | 207 | ]
|
185 | 208 | },
|
186 | 209 | {
|
|
195 | 218 | ],
|
196 | 219 | "metadata": {
|
197 | 220 | "kernelspec": {
|
198 |
| - "display_name": "Python 3 (ipykernel)", |
| 221 | + "display_name": "everyday", |
199 | 222 | "language": "python",
|
200 | 223 | "name": "python3"
|
201 | 224 | },
|
|
209 | 232 | "name": "python",
|
210 | 233 | "nbconvert_exporter": "python",
|
211 | 234 | "pygments_lexer": "ipython3",
|
212 |
| - "version": "3.9.16" |
| 235 | + "version": "3.13.2" |
213 | 236 | }
|
214 | 237 | },
|
215 | 238 | "nbformat": 4,
|
|
0 commit comments