Skip to content

Commit 2bb431d

Browse files
address additional comments
1 parent 907bb50 commit 2bb431d

File tree

2 files changed

+69
-65
lines changed

2 files changed

+69
-65
lines changed

notebooks/.notebook_shadow_copies/Sec_05_Regridding.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ regridder = MeshToGridESMFRegridder(mesh_cube, grid_cube)
5353

5454
```python
5555
# Regrid the mesh cube.
56-
result = regridder(mesh_cube)
57-
result
56+
regridded_orography = regridder(mesh_cube)
57+
regridded_orography
5858
```
5959

6060
The reason this is done in two steps is because initialising a regridder is potentially quite expensive if the grids or meshes involved are large. Once initialised, a regridder can regrid many source cubes (defined on the same source grid/mesh) onto the same target. We can demonstrate this by regridding a different cube using the same regridder.
@@ -73,8 +73,8 @@ mesh_temp
7373
```python
7474
# Regrid the new mesh cube using the same regridder.
7575
# Note how the time coordinate is also transposed in the result.
76-
result_2 = regridder(mesh_temp)
77-
result_2
76+
regridded_temperature = regridder(mesh_temp)
77+
regridded_temperature
7878
```
7979

8080
We can save time in future runs by saving and loading a regridder with `save_regridder` and `load_regridder`.
@@ -104,15 +104,16 @@ iqplt.pcolormesh(grid_temp[0, 0])
104104
plt.gca().coastlines()
105105
plt.show()
106106

107-
iqplt.pcolormesh(result_2[0, 0])
107+
iqplt.pcolormesh(regridded_temperature[0, 0])
108108
plt.gca().coastlines()
109109
plt.show()
110110
```
111111

112112
We can then plot the difference between the UM data and the data regridded from LFRic. Since all our data is now on a latlon grid we can subtract to find the difference between the regridded LFRic data and equivalent UM data and plot this with matplotlib as normal.
113113

114114
```python
115-
temp_diff = result_2 - grid_temp
115+
temp_diff = regridded_temperature - grid_temp
116+
temp_diff.long_name = "Difference in temperature"
116117

117118
# We choose a colormap that makes it clear where the differences are.
118119
iqplt.pcolormesh(temp_diff[0, 0], vmin=-4,vmax=4, cmap="seismic")
@@ -126,8 +127,8 @@ We can also regrid from latlon grids to LFRic style meshes using `GridToMeshESMF
126127
# Initialise the regridder.
127128
g2m_regridder = GridToMeshESMFRegridder(grid_cube, mesh_cube)
128129
# Regrid the grid cube.
129-
result_3 = g2m_regridder(grid_cube)
130-
result_3
130+
orography_on_mesh = g2m_regridder(grid_cube)
131+
orography_on_mesh
131132
```
132133

133134
```python
@@ -148,13 +149,13 @@ bilinear_regridder = MeshToGridESMFRegridder(mesh_cube, grid_cube, method="bilin
148149
**Step 2:** Use this regridder to regrid `mesh_cube`.
149150

150151
```python
151-
bilinear_result = bilinear_regridder(mesh_cube)
152+
bilinear_regridded_orography = bilinear_regridder(mesh_cube)
152153
```
153154

154155
**Step 3:** Compare this result with the result from the default area weighted conservative regridder.
155156

156157
```python
157-
bilinear_diff = bilinear_result - result
158+
bilinear_diff = bilinear_regridded_orography - regridded_orography
158159
```
159160

160161
**Step 4:** Plot the results and the difference using `iris.quickplot` and `matplotlib`.
@@ -163,10 +164,11 @@ bilinear_diff = bilinear_result - result
163164
import iris.quickplot as iqplt
164165
import matplotlib.pyplot as plt
165166

166-
iqplt.pcolormesh(result, cmap="terrain")
167+
iqplt.pcolormesh(regridded_orography, cmap="terrain")
167168
plt.show()
168-
iqplt.pcolormesh(bilinear_result, cmap="terrain")
169+
iqplt.pcolormesh(bilinear_regridded_orography, cmap="terrain")
169170
plt.show()
171+
bilinear_diff.long_name = "Difference in altitude"
170172
iqplt.pcolormesh(bilinear_diff, vmin=-400,vmax=400, cmap="seismic")
171173
plt.show()
172174
```

notebooks/Sec_05_Regridding.ipynb

Lines changed: 55 additions & 53 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)