bjlittle / geovista

Cartographic rendering and mesh analytics powered by PyVista

Home Page:https://geovista.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Projected LFRic cubesphere C12 produces invalid arcsin error

trexfeathers opened this issue Β· comments

πŸ› Bug Report

Plotting a C12 LFRic cubesphere on a planar projection produces the error:

...geovista/common.py:299: RuntimeWarning: invalid value encountered in arcsin
  lats = np.degrees(np.arcsin(xyz[:, 2] / radius))

This is accompanied by an invalid looking plot with Mollweide, although not with Plate Carree.

I have not seen this behaviour with C72 cubespheres. Might be worth some experiments at other resolutions.

How To Reproduce

Expand for code
import geovista
from geovista import Transform
from geovista.geoplotter import GeoPlotter
from iris import load_cube
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
from iris.tests import get_data_path

print(geovista.__version__)

file_path = get_data_path(
    [
        "NetCDF",
        "unstructured_grid",
        "lfric_ngvat_2D_1t_face_half_levels_main_conv_rain.nc",
    ]
)

with PARSE_UGRID_ON_LOAD.context():
    my_cube = load_cube(file_path, "conv_rain")

face_node = my_cube.mesh.face_node_connectivity
lons, lats = my_cube.mesh.node_coords
indices = face_node.indices_by_location()
my_polydata = Transform.from_unstructured(
    lons.points, lats.points, indices, start_index=face_node.start_index,
)

for proj in ("moll", "eqc"):
    my_plotter = GeoPlotter(crs=f"+proj={proj}")
    my_plotter.add_mesh(my_polydata, show_edges=True)
    my_plotter.camera_position = "xy"
    my_plotter.show(screenshot=f"{proj}.png")

Expected behaviour

No error raised, and valid plots produced, given this will become a widely used format.

Screenshots

Expand for screenshots

moll
eqc

Environment

  • OS & Version - Linux RHEL7
  • GeoVista Version - 0.1a1.dev313

This is a rounding issue, which I've seen before πŸ‘

@trexfeathers This issue has been resolved by b415e50.

Additionally, note that pole cell management is more stable (and correct). This is more obvious in the Equidistant Cylindrical (Plate CarrΓ©e) projection for your C12 cube-sphere example (see below).

Thanks again for providing the code to replicate this issue, it really helped πŸ’― πŸ₯‡

moll

eqc

I'm going to close this issue, but please re-open it if you don't believe it's resolved.

🍻

@all-contributors please add @trexfeathers for question

@bjlittle

I've put up a pull request to add @trexfeathers! πŸŽ‰