MPAS-Dev/MPAS-Analysis

Contour plots on projection grids

Closed this issue · 0 comments

xylar commented

The code for plotting contours on projection grids is not handling the fact that we are supplying the corners, rather than the centers, of grid cells. This needs to be fixed to allow for plots on projection grids that include contours (currently climatologyMapSSH).

Plotting 2-d maps of Zero-mean SSH climatologies for JFM on the north_atlantic grid...
analysis task climatologyMapSSH_plotJFM_north_atlantic failed during run
Traceback (most recent call last):
  File "/gpfs/fs1/home/ac.xylar/mpas-work/analysis/add_north_atlantic_pacific_comparison_grids/mpas_analysis/shared/analysis_task.py", line 330, in run
    self.run_task()
  File "/gpfs/fs1/home/ac.xylar/mpas-work/analysis/add_north_atlantic_pacific_comparison_grids/mpas_analysis/ocean/plot_climatology_map_subtask.py", line 446, in run_task
    self._plot_projection(remappedModelClimatology,
  File "/gpfs/fs1/home/ac.xylar/mpas-work/analysis/add_north_atlantic_pacific_comparison_grids/mpas_analysis/ocean/plot_climatology_map_subtask.py", line 583, in _plot_projection
    plot_projection_comparison(
  File "/gpfs/fs1/home/ac.xylar/mpas-work/analysis/add_north_atlantic_pacific_comparison_grids/mpas_analysis/shared/plot/climatology_map.py", line 652, in plot_projection_comparison
    plot_panel(ax, modelTitle, modelArray, **dictModelRef)
  File "/gpfs/fs1/home/ac.xylar/mpas-work/analysis/add_north_atlantic_pacific_comparison_grids/mpas_analysis/shared/plot/climatology_map.py", line 578, in plot_panel
    ax.contour(x, y, array, levels=contours, colors=lineColor,
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 318, in wrapper
    return func(self, *args, **kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 362, in wrapper
    return func(self, *args, **kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 1666, in contour
    result = matplotlib.axes.Axes.contour(self, *args, **kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 6301, in contour
    contours = mcontour.QuadContourSet(self, *args, **kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/matplotlib/contour.py", line 812, in __init__
    kwargs = self._process_args(*args, **kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/matplotlib/contour.py", line 1441, in _process_args
    x, y, z = self._contour_args(args, kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/matplotlib/contour.py", line 1480, in _contour_args
    x, y, z = self._check_xyz(args[:3], kwargs)
  File "/home/ac.xylar/anvil/miniconda3/envs/mpas_dev/lib/python3.10/site-packages/matplotlib/contour.py", line 1521, in _check_xyz
    raise TypeError(f"Length of x ({nx}) must match number of "
TypeError: Length of x (427) must match number of columns in z (426)