Self-contained runnable sample code for basic mesh plotting.#5501
Self-contained runnable sample code for basic mesh plotting.#5501pp-mo wants to merge 1 commit intoSciTools:mainfrom
Conversation
|
@pp-mo Adding Although, if you do this here, you'd probably want to be consistent and also do this throughout all the Worth considering, but certainly not essential. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5501 +/- ##
=======================================
Coverage 89.37% 89.37%
=======================================
Files 89 89
Lines 22446 22446
Branches 5387 5387
=======================================
Hits 20061 20061
Misses 1639 1639
Partials 746 746 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
|
|
||
| # We'll re-use this to plot some real global data later. | ||
| >>> from geovista.common import to_cartesian as to_xyz |
There was a problem hiding this comment.
Really?
You should adopt the use of to_cartesian and not rebrand it. The reason why you're doing this is already lost in the mists of time, and it's not recommending a good pattern to adopt to the reader moving forwards 👎
| # Convert our mesh+data to a PolyData object. | ||
| # Just plotting a single height level. | ||
| >>> face_polydata = cube_faces_to_polydata(face_cube[:, 0]) | ||
| ... |
There was a problem hiding this comment.
@pp-mo You can now simplify the call to Transform.from_unstructured as follows:
mesh = Transform.from_unstructured(
lons.points,
lats.points,
connectivity=indices,
data=cube.data,
name=f"{cube.name()} / {cube.units}",
)There is now no need to provide the start_index as geovista will detect this, and it's better to name the indices with the connectivity kwarg for clarity.
This is just a suggestion, and not strictly necessary.
| >>> camera_pos = camera_region.mean(axis=0) | ||
| >>> my_plotter.camera.position = camera_pos | ||
|
|
||
| >>> my_plotter.background_color = "#502020ff" |
There was a problem hiding this comment.
If you use import geovista.theme there's need to set the background_color
| >>> _ = my_plotter.add_coastlines(color="white", radius=1.01) | ||
| >>> _ = my_plotter.add_mesh(face_polydata, radius=1.0) |
There was a problem hiding this comment.
There's no real need here to set the radius, it's not adding anything of great value to "basic" plotting... it's just a distraction.
If you're concern is that the mesh is so low resolution that it's markedly different from the spherical coastlines, then only specify the radius for the coastlines. Setting the radius=1.0 for the face_polydata is a nop.
|
From @SciTools/peloton: This was closed by mistake, we think this is still worth doing! |
|
I revived the branch, which I deleted by mistake ! |
|
Well, as @trexfeathers pointed out, we do now have this mini geovista example in Iris docs. It's not in the gallery, but maybe it doesn't need to be? If that's enough, we can close this? |
I would support a full-on gallery entry, but the existing documentation means I'd be comfortable leaving this too, if we'd rather focus on other priorities. |
Attempts to at least partially address #5500
The new sample code I believe works, and produces the provided plot.
The issue of how we stop this untested code going stale is still unresolved.