You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are as yet *no* facilities in Iris for plotting unstructed cubes.
145
124
We can do that using PyVista, but we need first to convert the data to a PyVista format.
146
125
147
126
So first,
148
-
**Ex: import the routine`pv_from_lfric_cube`from the package `pv_conversions`(provided here in the tutorial).**
149
-
<details><summary>Sample code solution : <b>click to reveal</b></summary>
127
+
**Import the routine**`pv_conversions.pv_from_lfric_cube`**(provided here in the tutorial).
128
+
And call that..**
150
129
151
-
```python
152
-
from pv_conversions import pv_from_lfric_cube
153
-
```
154
-
</details>
155
130
<!-- #endregion -->
156
131
157
132
```python
158
133
from pv_conversions import pv_from_lfric_cube
159
-
```
160
134
161
-
<!-- #region -->
162
-
**Ex: now call that function, passing it our 2D RH cube, to get a PyVista object.**
163
-
<details><summary>Sample code solution : <b>click to reveal</b></summary>
164
-
165
-
```python
166
135
pv = pv_from_lfric_cube(rh_t0)
167
136
```
168
-
</details>
169
-
<!-- #endregion -->
170
137
171
-
```python
172
-
pv = pv_from_lfric_cube(rh_t0)
173
-
```
174
-
175
-
<!-- #region -->
176
138
This produces a PyVista ["PolyData" object](https://docs.pyvista.org/api/core/_autosummary/pyvista.PolyData.html#pyvista-polydata).
177
-
Which is a thing we can plot.
178
-
179
-
**Now just print that + see what it looks like ...**
180
-
<details><summary>Sample code solution : <b>click to reveal</b></summary>
181
-
182
-
```python
183
-
pv
184
-
```
185
-
</details>
186
-
<!-- #endregion -->
187
-
188
-
```python
189
-
pv
190
-
```
191
-
192
-
***TODO:*** some notes here on what the detail means ?
193
-
194
-
195
-
( Note: like `Cube`s + `CubeList`s, these `PolyData` objects are provided with a specific visible within the Jupyter notebooks. This is displayed when you just enter the variable in a cell.
196
-
You can also use "print(x)" to display the standard string representation of the object, but usually the notebook-style output is a bit more useful. )
139
+
Which is a thing we can plot, by simply calling its `.plot()` method.
197
140
198
141
199
142
---
200
-
### Quick 3d plotting
201
-
202
-
For a really quick, basic plot, you can display a PolyData as a VTK view with PyVista, by simply calling its `.plot` method.
203
143
204
144
**Call the `plot` routine of the PolyData object. An output should appear.**
205
145
@@ -213,72 +153,13 @@ pv.plot()
213
153
* To ***remove*** a plot output, use "Clear Output" from the "Edit" menu (or from right-click on the cell)
214
154
* alternatively, set the keyword `jupyter_backend='static'` in the command, for output as a plain image
215
155
216
-
There are a lot more keywords available to [the `PolyData.plot()` method](https://docs.pyvista.org/api/core/_autosummary/pyvista.PolyData.plot.html), but it is not ideal to overcomplicate these calls. :
156
+
There are a lot more keywords available to [the `PolyData.plot()` method](https://docs.pyvista.org/api/core/_autosummary/pyvista.PolyData.plot.html), but it is not ideal to overcomplicate these calls.
217
157
Finer control is better achieved in a different ways : See more detail on plotting in [the Plotting section](./Sec_03_Plotting.ipynb).
218
158
219
159
220
-
<!-- #region tags=[] -->
221
-
### Create a plotter, and display 3D visualisation
222
-
223
-
Finally, we will plot the 'PolyData' object via PyVista.
224
-
This requires a few additional steps ...
225
-
226
-
First, we need a [PyVista "plotter"](https://docs.pyvista.org/api/plotting/_autosummary/pyvista.Plotter.html#pyvista.Plotter) object to display things in 3D.
227
-
Since our data is geo-located, we will use a special type of plotter from [GeoVista](https://github.com/bjlittle/geovista#philisophy) for this.
228
-
229
-
**Import the class `GeoPlotter` from the `geovista` package, and create one** (with no arguments)
230
-
<details><summary>Sample code solution : <b>click to reveal</b></summary>
160
+
## Next notebook
161
+
See the next section : [03 - Plotting and Visualisation](./Sec_03_Plotting.ipynb)
231
162
232
163
```python
233
-
from geovista import GeoPlotter
234
-
plotter = GeoPlotter()
235
-
```
236
-
</details>
237
-
<!-- #endregion -->
238
164
239
-
```python
240
-
from geovista import GeoPlotter
241
-
plotter = GeoPlotter()
242
165
```
243
-
244
-
<!-- #region -->
245
-
Call the plotter `add_mesh` function, passing in our PolyData object with the Rh cube data in it.
246
-
( **N.B.** don't worry about the object which this passes back -- just discard it ).
247
-
<details><summary>Sample code solution : <b>click to reveal</b></summary>
248
-
249
-
```python
250
-
_ = plotter.add_mesh(pv)
251
-
```
252
-
</details>
253
-
<!-- #endregion -->
254
-
255
-
```python
256
-
_ = plotter.add_mesh(pv)
257
-
```
258
-
259
-
<!-- #region -->
260
-
Now simply plot this, by calling the plotter function "show" (with no args).
261
-
<details><summary>Sample code solution : <b>click to reveal</b></summary>
262
-
263
-
```python
264
-
plotter.show()
265
-
```
266
-
</details>
267
-
<!-- #endregion -->
268
-
269
-
```python
270
-
plotter.show()
271
-
```
272
-
273
-
**Some odd notes:**
274
-
* By default, `plotter.show()` opens an interactive window : **you can rotate and zoom it with the mouse**.
275
-
* you can instead generate static output
276
-
* in a notebook, you do this with `jupyter_backend='static'`
277
-
* or in a Python session, try `interactive=False`
278
-
* VTK/PyVista doesn't use plot "types".
279
-
Instead, you add meshes to a plotter + can subsequently control the presentation.
280
-
* GeoVista can also produce more familiar 2D plots (see on ...)
281
-
282
-
283
-
284
-
***TODO:*** can suggest some of these as follow-on exercises
0 commit comments