Using cartopy projections sometimes results in garbled plots
dennissergeev opened this issue Β· comments
π Bug Report
I'm very grateful for geovista
supporting cartopy
projections, but the interface seems to contain a few bugs π
One bug leads to the data not displayed correctly for some values of the central_longitude
parameter in the Plate Carree projection. For example, the plot looks OK for central_longitude=0
or 90
or 180
, but not for 45
, 135
, etc. (see screenshots below). This is likely related to the arcsin issue, because I sometimes see that error too.
I also noticed that some of the projections are not displayed correctly, such as Mercator.
How to Reproduce
Click to expand this section...
Data source: LFRic C48 simulation.import cartopy.crs as ccrs
import geovista as gv
import iris
from geovista.pantry import capitalise
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
fname = "lfric_diag.nc"
with PARSE_UGRID_ON_LOAD.context():
my_cube = iris.util.squeeze(iris.load_cube(fname, "toa_upward_longwave_flux"))
face_node = my_cube.mesh.face_node_connectivity
lons, lats = my_cube.mesh.node_coords
indices = face_node.indices_by_location()
mesh0 = gv.Transform.from_unstructured(
lons.points,
lats.points,
indices,
data=my_cube.data,
start_index=face_node.start_index,
)
file_prefix = __file__.lower().replace(".py", "")
# Point no. 1: central longitude causes the mesh to display incorrectly
for cen_lon in [0, 45, 90, 135, 180]:
mesh = mesh0.copy()
plotter = gv.GeoPlotter(
off_screen=True, crs=ccrs.PlateCarree(central_longitude=cen_lon), border=True
)
sargs = dict(title=f"{capitalise(my_cube.name())} / {my_cube.units}")
plotter.add_title(f"LFRic C48\nPlateCarree(central_longitude={cen_lon})")
plotter.add_mesh(
mesh, cmap="thermal", show_edges=True, edge_color="grey", scalar_bar_args=sargs
)
# plotter.add_base_layer(texture=gv.natural_earth_1())
# plotter.add_coastlines(resolution="10m", color="white")
plotter.view_xy()
# plotter.add_axes()
plotter.camera.zoom(1.5)
plotter.show(screenshot=f"{file_prefix}__platecarree_cen_lon{cen_lon}.png")
Expected Behaviour
Robust and valid plots.
Screenshots
Point no. 1: central longitude causes the mesh to display incorrectly
Environment
- OS & Version: Ubuntu 22.04.1 LTS 64-bit
- GeoVista Version: 0.1a1.dev460
@dennissergeev Thanks for raising this π
There's some technical debt that I need to service which I think is related to this issue (and a few others) i.e., basically for geovista
to take a more robust approach prior to projecting when ripping the unstructured mesh.
@dennissergeev Just to let you know that I've been making good progress on this issue and essentially resolved the problem of cells smearing across the projection when ripping the mesh...
I've been stress testing the basic geovista
projection support with more complex mesh geometries and uncovered a few other interesting cases where this can occur. So I'm going to tackle those also, then I'll update you here went you can pick up the changes from main
and test at your end i.e., this fix isn't available just yet.
Additionally, I want to revisit pole singularity handling as there is obvious incorrect behaviour that requires to be flushed out... but once that's done, this would be a reasonable first stable step forwards.
Noted about Mercator
support π I'll create a separate issue for that. Over time the projection support will become more mature (gotta start somewhere π)... but in this particular case for Mercator
I specifically require to honour max_latitude
and min_latitude
.
BTW It would be really great to know the basic projections that you tend to use for your workflow. This'll help me prioritise effort on those projections first, ensuring that they're feature complete and with most wrinkles ironed-out - flushing these out just needs mileage, so keep reporting issues to me when you find them.
Much appreciated π€©π»
BTW It would be really great to know the basic projections that you tend to use for your workflow.
Everyone uses the Waterman butterfly, right? π
... more like Spilhaus World Ocean, no? π€
Thanks for the update, much appreciated @bjlittle!
Hey @dennissergeev,
I've pushed up c90b2ba which should address your issue.
So any dev version of geovista
north of 0.1a1.dev518+dirty
should have more stable behaviour.
Give it a try on your side and let me know. Once you're happy I'll close this issue π
Hey @bjlittle,
Thanks very much, it now works for me too! π
@dennissergeev Awesome, thanks for confirming! π»
@all-contributors please add @dennissergeev for bug
I've put up a pull request to add @dennissergeev! π
Much appreciated @bjlittle !!