Skip to content

Commit

Permalink
suggested tweaks and corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
corinnebosley authored and pp-mo committed Aug 14, 2018
1 parent 0b8baf5 commit 759e357
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
21 changes: 10 additions & 11 deletions lib/iris/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ def _check_contiguity_and_bounds(coord, data, abs_tol=1e-4, transpose=False):
"""
if transpose:
bounds = coord.bounds.T
else:
bounds = coord.bounds
data = data.T

both_dirs_contiguous, diffs_along_x, diffs_along_y = \
iris.coords._discontiguity_in_2d_bounds(bounds, abs_tol=abs_tol)
Expand Down Expand Up @@ -333,19 +331,18 @@ def _draw_2d_from_bounds(draw_method_name, cube, *args, **kwargs):
else:
plot_defn = _get_plot_defn(cube, mode, ndims=2)

two_dim_contig_atol = kwargs.pop('two_dim_coord_contiguity_atol',
twodim_contig_atol = kwargs.pop('two_dim_coord_contiguity_atol',
1e-4)
for coord in plot_defn.coords:
if hasattr(coord, 'has_bounds'):
if coord.ndim == 2 and coord.has_bounds():
try:
_check_contiguity_and_bounds(coord, data=cube.data,
abs_tol=two_dim_contig_atol)
abs_tol=twodim_contig_atol)
except ValueError:
if _check_contiguity_and_bounds(
coord, data=cube.data,
abs_tol=two_dim_contig_atol, transpose=True) \
is True:
if _check_contiguity_and_bounds(coord, data=cube.data,
abs_tol=twodim_contig_atol,
transpose=True) is True:
plot_defn.transpose = True

if _can_draw_map(plot_defn.coords):
Expand Down Expand Up @@ -1103,7 +1100,8 @@ def pcolor(cube, *args, **kwargs):
Draws a pseudocolor plot based on the given 2-dimensional Cube.
The cube must have either two 1-dimensional coordinates or two
2-dimensional coordinates with contiguous bounds to plot against each other.
2-dimensional coordinates with contiguous bounds to plot against each
other.
Kwargs:
Expand Down Expand Up @@ -1137,7 +1135,8 @@ def pcolormesh(cube, *args, **kwargs):
Draws a pseudocolor plot based on the given 2-dimensional Cube.
The cube must have either two 1-dimensional coordinates or two
2-dimensional coordinates with contiguous bounds to plot against each other.
2-dimensional coordinates with contiguous bounds to plot against each
other.
Kwargs:
Expand Down
9 changes: 4 additions & 5 deletions lib/iris/tests/unit/plot/test_2d_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from iris.tests.stock import simple_3d_w_multidim_coords as cube3d_2dcoords
from iris.tests.stock import lat_lon_cube

from orca_utils.plot_testing import testdata_2d_coords
from orca_utils.plot_testing import testdata_2d_coords as testdata

if tests.MPL_AVAILABLE:
import iris.plot as iplt
Expand All @@ -43,16 +43,15 @@ def setUp(self):

# latlon_2d is a cube with 2d coords, 4 bounds per point,
# discontiguities in the bounds but masked data at the discontiguities.
self.latlon_2d = testdata_2d_coords.full2d_global()
testdata_2d_coords.make_bounds_discontiguous_at_point\
(self.latlon_2d, 2, 2)
self.latlon_2d = testdata.full2d_global()
testdata.make_bounds_discontiguous_at_point(self.latlon_2d, 2, 2)

# Take a latlon cube with 1D coords, broadcast the coords into 2D
# ones, then add ONE of them back into the cube in place of original:
single_dims = lat_lon_cube()
lon = single_dims.coord('longitude')
lat = single_dims.coord('latitude')
big_lon, big_lat = testdata_2d_coords.grid_coords_2d_from_1d(lon, lat)
big_lon, big_lat = testdata.grid_coords_2d_from_1d(lon, lat)
mixed_dims = single_dims.copy()
mixed_dims.remove_coord(lon)
# TODO Fix this coord addition:
Expand Down

0 comments on commit 759e357

Please sign in to comment.