E3SM-Project / polaris

Testing and analysis for OMEGA, MPAS-Ocean, MALI and MPAS-Seaice
BSD 3-Clause "New" or "Revised" License
6 stars 13 forks source link

Switch spherical viz to use `uxarray` and `holoviews` #140

Closed xylar closed 11 months ago

xylar commented 1 year ago

This merge introduces several new dependencies used for plotting:

The approach used here is loosely based on the tutorials from uxarray provided here: https://uxarray.readthedocs.io/en/latest/examples/005-to-geodataframe-for-holoviz.html and here: https://uxarray.readthedocs.io/en/latest/examples/004-working-with-mpas-grids.html

The MPAS mesh and an associated data array are converted to a SpatialPandas GeoDataFrame for visualization in holoviews using its matplotlib backend. (The alternative bokeh backend is nice for working in Jupyter notebooks within a web browser but I did not find it useful for exporting images to files.)

At least for the mesh sizes and types of visualization we are currently doing on the sphere in Polaris, this new approach is much faster than generating mapping files, remapping the data to a regular grid, and then visualizing.

The to_geodataframe() method from uxarray currently only works reliably for DataArrays on cells, not on edges or vertices. Because of this, I have dropped plots of the normal velocity on edges from the geostrophic tasks. We can re-introduce this later if desired but it seems like a lot of work for some pretty noisy viz.

Checklist

xylar commented 1 year ago

@cbegeman and @sbrus89, I could use your eyes on this when you have a chance. I am currently testing all the affected tasks on Chrysalis and can point you to a tarball with all the images once my testing is done.

So far, the approach seems better. It's faster, though not lightning fast. It has a few quirks like when it decides have a flat vs. pointy end on the colorbar. I'm sure we can manually interfere but I didn't want to take the trouble for now.

xylar commented 1 year ago

Testing

I was able to run all with_viz test cases on Chrysalis. The images that result are tarred up in:

/lcrc/group/e3sm/ac.xylar/polaris_0.2/chrysalis/test_20231020/spherical-convergence-uxarray-viz/images.tar.gz
xylar commented 1 year ago

I'm seeing some glitches along the antimeridian that I may need to work with the uxarray folks on fixing: init

xylar commented 12 months ago

I seem to have fixed the last 2 aesthetic issues with the colorbar:

final

xylar commented 11 months ago

@sbrus89, could you let me know if you are happy with the handling of edge plotting, given the limitations I listed above? Is there anything else you'd like to see here?

xylar commented 11 months ago

@sbrus89 and @cbegeman, thank so much for you reviews! I really appreciate them!