-
Notifications
You must be signed in to change notification settings - Fork 296
Public contiguity checking #3144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Public contiguity checking #3144
Conversation
lib/iris/plot.py
Outdated
'where the discontiguity occurs. The ' \ | ||
'mesh created for this plot may cause a ' \ | ||
'misrepresentation of the input data. ' \ | ||
'Please use iris.contiguity_check(coord) ' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (80 > 79 characters)
lib/iris/plot.py
Outdated
@@ -1496,3 +1502,4 @@ def citation(text, figure=None, axes=None): | |||
anchor.patch.set_boxstyle('round, pad=0, rounding_size=0.2') | |||
axes = axes if axes else figure.gca() | |||
axes.add_artist(anchor) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W391 blank line at end of file
returned = find_discontiguities(coord) | ||
self.assertEqual(expected, returned) | ||
|
||
# TODO Make sure everything works when there are multiple discontiguities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (81 > 79 characters)
I can already see that I could do with making these changes:
|
lib/iris/plot.py
Outdated
@@ -271,7 +273,7 @@ def _invert_yaxis(v_coord, axes=None): | |||
axes.invert_yaxis() | |||
|
|||
|
|||
def _check_contiguity_and_bounds(coord, data, abs_tol=1e-4, transpose=False): | |||
def _check_contiguity_and_mask(coord, data, abs_tol=1e-4, transpose=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the inclusion of mask
but by not mentioning bounds
it isn't clear that that's what it is referring to.
How about _check_bounds_contiguity_and_mask
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that'll do. It's a bit of a mouthful but it's private anyway so it shouldn't matter.
lib/iris/plot.py
Outdated
' Matplotlib'.format(coord.name())) | ||
discontiguity_warning = 'The bounds of the {} coordinate are ' \ | ||
'not contiguous and data is not masked ' \ | ||
'where the discontiguity occurs. The ' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a change you've made but now rereading through this intial sentence I see it doesn't make sense. We say discontiguous twice: "The bounds of the {} coordinate are not contiguous ... where the discontiguity occurs.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, this says "there is a discontiguity and the data is not masked where that discontiguity is (or are)"
@lbdreyer The changes I made for the last commit prompted numpy to give me this warning: I'm not exactly sure what it's referring to, I have a horrible feeling it's something to do with the zip output, and that's been a really horrible nightmare to put into a user-friendly return format. We will obviously have to address this at some point, but I could do with your help with it I think. |
lib/iris/util.py
Outdated
@@ -20,7 +20,8 @@ | |||
""" | |||
|
|||
from __future__ import (absolute_import, division, print_function) | |||
from six.moves import (filter, input, map, range, zip) # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using these two lines as boilerplate for all our modules to help with Python 3 compatibility. (you'll find them at the top of all files.)
I think it would be best to keep all of them (even if they aren't being used) as otherwise we may forget to include them.
In fact that is what the #noqa
tag is there for - to stop flake8 complaining about unused imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even realise it wasn't there. I'll pop it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea how I removed that...
lib/iris/util.py
Outdated
|
||
(b) the :attr:`standard_name`, :attr:`long_name`, or | ||
:attr:`var_name` of an instance of an instance of | ||
:class:`iris.coords.Coord`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are going to allow for a user to do this, you need to also add a line at the start that gets the coordinate.
This function starts by doing
_, diffs_x, diffs_y = iris.coords._discontiguity_in_2d_bounds(coord.bounds,
abs_tol)
so if that needs to be a coord instance by then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thing is, if we do allow that user to use a name instead of a coord object, then we have to pass the cube in as well so that we can get the coord. This seems a bit unnecessary, so it might make sense to only allow a coord object.
lib/iris/plot.py
Outdated
@@ -339,12 +347,12 @@ def _draw_2d_from_bounds(draw_method_name, cube, *args, **kwargs): | |||
if hasattr(coord, 'has_bounds'): | |||
if coord.ndim == 2 and coord.has_bounds(): | |||
try: | |||
_check_contiguity_and_bounds(coord, data=cube.data, | |||
abs_tol=twodim_contig_atol) | |||
_check_contiguity_and_mask(coord, data=cube.data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F821 undefined name '_check_contiguity_and_mask'
lib/iris/plot.py
Outdated
if _check_contiguity_and_bounds(coord, data=cube.data, | ||
abs_tol=twodim_contig_atol, | ||
transpose=True) is True: | ||
if _check_contiguity_and_mask(coord, data=cube.data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F821 undefined name '_check_contiguity_and_mask'
lib/iris/plot.py
Outdated
_check_contiguity_and_bounds(coord, data=cube.data, | ||
abs_tol=twodim_contig_atol) | ||
_check_bounds_contiguity_and_mask(coord, data=cube.data, | ||
abs_tol=twodim_contig_atol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
lib/iris/plot.py
Outdated
abs_tol=twodim_contig_atol, | ||
transpose=True) is True: | ||
if _check_bounds_contiguity_and_mask(coord, data=cube.data, | ||
abs_tol=twodim_contig_atol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
lib/iris/plot.py
Outdated
transpose=True) is True: | ||
if _check_bounds_contiguity_and_mask(coord, data=cube.data, | ||
abs_tol=twodim_contig_atol, | ||
transpose=True) is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
lib/iris/util.py
Outdated
absolute tolerance in degrees | ||
|
||
Returns: | ||
Dictionary of values representing data array indices where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit 👎 on this.
Would it not be much simpler to return an boolean array of ok/bad-point values ?
Likewise in the code, avoid use of np.where + just use boolean arrays
bad = (diffs_x > abs_tol) | (diffs_y > abs_tol)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Not simpler. You still have to move everything along by one point to the right for x-values and down for y-values because the bad point is after the discontiguity in the array. That's really where the complication arises.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I don't see how that's any more use to the user. If they have a particularly large dataset then they will have to search through it for places where it's True anyway, so what's the point?
And also, would we return the boolean array for the data or for the coord points? What are you expecting the user to do with a boolean array?
lib/iris/util.py
Outdated
return None | ||
|
||
|
||
def mask_discontiguities(coord, data, abs_tol=1e-4): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought if we did have a simple boolean array from the previous, this routine would not be needed..
Something like
badpts = find_discontiguities(coord)
points = ma.masked_array(coord.points)
points[badpts] = ma.masked
coord.points = points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A boolean array would be fine for this because we don't need anything to be human-readable; we are just doing operations. But I still disagree with creating a boolean array for the previous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also what do you mean by 'this routine would not be needed?'
This routine is pretty much as simple as it gets. The whole point of having the two separate routines is that one allows you to check which points are discontiguous (as a human) and look at them and think about them, and the other allows you to just mask them without thought. Those are both valid options and it seems stupid to just not offer one of them because that's simpler.
# Construct an array the size of the points array filled with 'False' | ||
# to represent an empty discontiguity array | ||
self.empty_bool = np.zeros((self.lons.points.shape), | ||
dtype=bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E127 continuation line over-indented for visual indent
Changes following last review:
|
@lbdreyer All tests passed. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I have a few comments, mostly renaming things more descriptive names.
The tests are in a bit of a jumble. Maybe keep the old tests where they are (as I have moved them in the PR I am working on, but feel free to do so in this PR instead), but the new tests that are introduced in this PR (e.g. for find_discontiguities and mask_discontiguities) should go in the appropriate places
lib/iris/plot.py
Outdated
@@ -311,14 +314,19 @@ def _check_contiguity_and_bounds(coord, data, abs_tol=1e-4, transpose=False): | |||
np.logical_and(mask_invert[:-1, ], diffs_along_y)) | |||
|
|||
# If discontinuity occurs but not masked, any grid will be created | |||
# incorrectly, so raise a warning | |||
# incorrectly, so raise a warning for the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't really need this clarification as all warnings are for the user
lib/iris/plot.py
Outdated
'Please use ' \ | ||
'iris.contiguity_check(coord) to find ' \ | ||
'and mask your data ' \ | ||
'appropriately'.format(coord.name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you mean iris.util.find_discontiguities
and iris.util.mask_discontiguities
instead of iris.contiguity_check
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is leftover from before the full implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to end up a bit long and rambly?
lib/iris/plot.py
Outdated
'iris.contiguity_check(coord) to find ' \ | ||
'and mask your data ' \ | ||
'appropriately'.format(coord.name()) | ||
warnings.warn(discontiguity_warning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have chosen to raise this as an error but I make that change in the next PR so we'll leave this as it is in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Good decision.
lib/iris/util.py
Outdated
try: | ||
return bad_points_boolean | ||
except ValueError: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you forgot to remove this? Otherwise it will catch all errors which would working out what is going wrong difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I did. I needed this for an earlier implementation but it will never return None now (unless it's broken), so you're quite right.
# awkward but supported cube. | ||
cube = self.latlon_2d | ||
result = iplt._draw_2d_from_bounds('pcolormesh', cube) | ||
self.assertTrue(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
draw_2d_from_bounds
is too complicated to unit test. I suggest you just remove this test.
I am in the process of adding an integration test that will test draw_2d_from_bounds
(which will at the same time check that it is not raising an error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was meant as a placeholder really, I think it was one of the first tests I put in, just to help me think. I'll take it out.
lib/iris/util.py
Outdated
Copy of the data array, masked at points where bounds are | ||
discontiguous. | ||
""" | ||
mask = find_discontiguities(coord, abs_tol=abs_tol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mask
isn't that clear what it means as it doesn't refer to the cube's original mask, it refers to the locations of the discontiguities and so the new places that should be masked.
How about something like discontiguous_locations
or discontiguous
or discontiguous_bounds_locations
... I can't really think of a good name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just new_mask
or extra_mask
|
||
with warnings.catch_warnings(): | ||
warnings.simplefilter("error") | ||
with self.assertRaises(UserWarning): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really needs a assertRaisesRegexp
to check it's getting the right warning`
self.empty_bool = np.zeros(self.lons.points.shape, | ||
dtype=bool) | ||
self.masked = self.empty_bool.copy() | ||
self.masked[3, 3] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use the mask of self.latlon_2d
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And unmask it first? I suppose so. Don't see that it makes a lot of difference but I'll pop it in anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no wait a minute, I'm not quite sure what I'm actually trying to achieve here, maybe I need to think about this a bit more and add some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will need the array of Falses that I construct here because that's the easiest way to do it, but there is no need to then mask the single point I have done here. I can just use the cube's mask instead of constructing self.masked.
def setUp(self): | ||
self.latlon_2d = full2d_global() | ||
make_bounds_discontiguous_at_point(self.latlon_2d, 3, 2) | ||
self.lons = self.latlon_2d.coord('longitude') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer more descriptive names, it would make reading the test easier, so:
self.latlon_2d_cube
and self.lons_coord
import numpy.ma as ma | ||
import warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'warnings' imported but unused
|
||
import iris.coords as coords | ||
import iris.util |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'iris.util' imported but unused
# # with warnings.catch_warnings(): | ||
# # warnings.simplefilter("error") | ||
# # with self.assertRaises(UserWarning): | ||
# # iris.plot._check_bounds_contiguity_and_mask(coord, cube.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (81 > 79 characters)
# Construct an array the size of the points array filled with 'False' | ||
# to represent a mask showing no discontiguities | ||
empty_mask = np.zeros(self.longitude_coord.points.shape, | ||
dtype=bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E127 continuation line over-indented for visual indent
lib/iris/util.py
Outdated
|
||
# Apply mask for x-direction discontiguities: | ||
bad_points_boolean[:, :-1] = np.logical_or(bad_points_boolean[:, :-1], | ||
gaps_x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
lib/iris/util.py
Outdated
|
||
# apply mask for y-direction discontiguities: | ||
bad_points_boolean[:-1, :] = np.logical_or(bad_points_boolean[:-1, :], | ||
gaps_y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
import iris.tests as tests | ||
|
||
import numpy as np |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'numpy as np' imported but unused
|
||
import iris.coords as coords | ||
import iris.util | ||
from iris.util import find_discontiguities_in_bounds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'iris.util.find_discontiguities_in_bounds' imported but unused
|
||
import iris.coords as coords | ||
import iris.util | ||
from iris.util import find_discontiguities_in_bounds | ||
from iris.util import mask_data_at_discontiguities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'iris.util.mask_data_at_discontiguities' imported but unused
from iris.tests.stock import simple_2d_w_multidim_coords as cube_2dcoords | ||
from iris.tests.stock import simple_3d_w_multidim_coords as cube3d_2dcoords | ||
from iris.tests.stock import simple_3d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'iris.tests.stock.simple_3d' imported but unused
from iris.tests.stock import sample_2d_latlons | ||
from iris.tests.stock import make_bounds_discontiguous_at_point | ||
from iris.tests.stock._stock_2d_latlons import grid_coords_2d_from_1d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'iris.tests.stock._stock_2d_latlons.grid_coords_2d_from_1d' imported but unused
# Construct an array the size of the points array filled with 'False' | ||
# to represent a mask showing no discontiguities | ||
empty_mask = np.zeros(self.longitude_coord.points.shape, | ||
dtype=bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E127 continuation line over-indented for visual indent
Had some trouble with I have been finding that many coordinate points from This is possibly a good test for a relative tolerance option though... |
@lbdreyer I'm slightly worried about bits still being a problem, particularly test data. But for now, I'm afraid this is the best you're gonna get. Thanks for all your help and good luck getting to the finish with this. |
Hi @corinnebosley @lbdreyer However, discussing today with @lbdreyer I'm still not very sure about the API. It also seems to me that this should absolutely be checking both x- and y-coords of a given cube, or every use will be calling it twice ?? Rather more seriously ... I'm wondering now where + why we need this ?? |
Forget that -- I found out why today ! |
... and consider #3105 while getting this fixed. |
…orking pylint corrections, small corrections to zip nightmare and return format corrections for Laura reinstated imports of six that pycharm keeps secretly changing some changes on Laura's suggestions, more to come pylint changes more stickler requested changes (not pylint at all) some fixes and tweaks
582c164
to
29d0e95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of trivial points !!
lib/iris/tests/unit/plot/test__check_bounds_contiguity_and_mask.py
Outdated
Show resolved
Hide resolved
lib/iris/tests/unit/plot/test__check_bounds_contiguity_and_mask.py
Outdated
Show resolved
Hide resolved
PR moved on since suggested changes (some changes made, others discarded)
lib/iris/coords.py
Outdated
rtol * cell_size) | ||
|
||
points_close_enough = (diffs_along_axis <= (atol + | ||
rtol * (lower_bounds - upper_bounds))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
@pp-mo Still have to remove all references to discontiguity from |
@pp-mo I have now removed all references to discontiguity in Thanks! |
Looks fine to me 😃 ! |
Test discontiguity checking for a y-direction mismatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been getting lots of notifications from this PR so I couldn't help but have a very very quick look, as I was interested in what the API would look like.
I have a couple quick comments about doc strings.
* Fix coord_comparison when coords are the same object * Added what's new items for SciTools#2730 and SciTools#2325. (SciTools#2852) * Added what's new items for SciTools#2730 and SciTools#2325. [skip ci] * Moved the bugfix docs to enhancement for the 3x speedup of area weights. [skip ci] * Add unit test * Add workaround * Add test of current dask behaviour * Ammended cube.var_name documentation. (SciTools#2874) Ammended cube.var_name documentation to refer to it as NetCDF. * Futures netcdf no unlimited (SciTools#2838) * switched boolean operator and altered docstring * raised error on future flag and tweaked functionality * small change to deprecation warning message * Code changes * remake cdl results * More CDL updates (cherry picked from commit 47272b3) * Review actions * Use default Dask scheduler settings (SciTools#2879) Disable dask.set_options call on _lazy_data import. * Fix doctest failing due to change in 'netcdf_promote' future behaviour (SciTools#2883) * Remove unneeded image repo url (SciTools#2885) * Updated 2.0 release notes. (SciTools#2884) * Add iris-grib as a testing dependency; Python 3 included. * Fix requirements for iris_grib>=0.12, assuming it will have eccodes + thus work with Python 3 * Made the iris extensions not install by default. * Reduced the number of processes used by default when testing. * Set the documentation build to use viridis as the default colormap (rather than Jet as we are using matplotlib 1 still). * Change behaviour of 'error' level (SciTools#2881) * Change behaviour of 'error' level * Change Future netcdf_no_unlimited tests * Fix tests testing the wrong thing * Dask processing options docs updates * Added some what's new information about SciTools#2435 and SciTools#2810. * Use the cube dimension order to determine the plot axes. * Small update to experimental-FF whatsnew statement (SciTools#2898) * Move some whatsnew items, remove spurious list * Move nc-no-unlim text to whatsnew * Fill value handling on save notes * Netcdf scalar cube loading bugfix Previously Iris used to simply ignore scalar cubes. * Corrected usage context in description of PointInCell regrid scheme. (SciTools#2735) * Re-worked setup.py to avoid the need for separate/non-standard build commands (SciTools#2891) Re-worked setup.py to avoid the need for separate/non-standard build commands. * Missing data whitepaper (SciTools#2906) * Ensure lon/lat return order is consistent throughout (SciTools#2238) * Updated to v46 of the CF standard-name table. (SciTools#2908) * Updated to v46 of the CF standard-name table. * Updated the area-type table to v6. * Use viridis cmap for doc images (SciTools#2909) * Stickler config (SciTools#2896) * Added a flake8 config. * Added a stickler-ci config. * Handled the recent update to conda-forge for testing, perhaps relating to GEOS update. (SciTools#2912) * Bumped master to the v2.1 stream. (SciTools#2910) * Stickler config (SciTools#2896) * Added a flake8 config. * Added a stickler-ci config. * Improved the way requirements are handled, ensuring that pip gets all the information it needs. (SciTools#2890) Improved the way requirements are handled, ensuring that pip gets all the information it needs. * Further docs refinement for v2.0.0 (SciTools#2916) Some minor documentation tweaks for v2.0.0 * Remove obsolete reference from Userguide. (SciTools#2915) * Reverse 2878 (SciTools#2926) * Remove dask issue workaround; wrap computed MaskedConstant as array * Reduce exception message for loading missing files. (SciTools#2925) * reduce error message * update file not found tests * clearer message * Allow missing value (SciTools#2892) * Allow missing_value as a user set attribute This allows the user to set missing_value as an attribute on a cube while ensuring that it is saved as local attribute in the netcdf file. * Added the what's new and updated the copyright years for SciTools#2892. * Fix some header dates. * Add note on using intersection (SciTools#2931) * CML changes for cf_units v1.2.0 (SciTools#2936) * CML changes for cf-units v1.2.0 * Add whatsnew entry * [DOC]: Update userguide note on intersection (SciTools#2933) * Update userguide note on intersection * Update with concrete boundary examples * Prepare master for v2.0.x branch (SciTools#2934) * Converted the contributions into the whatsnew. * Updated to a dev version string. * Tweaked what's new, bumped version string, and updated the MANIFEST for pypi. * Perserve dtype of source cube with area weighted regridder (SciTools#2203) Perserve dtype of source cube with area weighted regridder & add what's new * Update license headers to handle the merge of a PR from 2017 in 2018 (SciTools#2948) * DOC: lazy data docstring made clearer (SciTools#2947) * DOC: lazy data docstring made clearer * Clarify "view" * Remove gdal from 'all' to 'extensions' depedency group. * Remove gdal from 'all' to 'extensions' depedency group. * DOC: lazy data docstring made clearer (SciTools#2947) * DOC: lazy data docstring made clearer * Clarify "view" * No docs are better than wrong docs on dask * Add a general zenodo link to the readme. (SciTools#2955) * Improved the pip installability of scitools-iris. (SciTools#2956) * Release of iris v2.0.0 🎉 * Merge v2.0.x into master (SciTools#2957) * Tweaked what's new, bumped version string, and updated the MANIFEST for pypi. * Remove gdal from 'all' to 'extensions' depedency group. * DOC: lazy data docstring made clearer (SciTools#2947) * DOC: lazy data docstring made clearer * Clarify "view" * No docs are better than wrong docs on dask * Add a general zenodo link to the readme. (SciTools#2955) * Improved the pip installability of scitools-iris. (SciTools#2956) * Release of iris v2.0.0 🎉 * Move v2.0.x branch into development mode. * Fix the documentation building for latest version of sphinx. (SciTools#2958) * Remove FutureWarning from use of np.issubdtype(obj, np.str) (SciTools#2954) * Add cube co-realisation. (SciTools#2967) * Fix for changed API of cartopy.crs.Stereographic (SciTools#2971) * Fix for changed API of cartopy.crs.Stereographic; fixes tests.test_coordsystem. * License header fix. * remove site.cfg exclude from manifest.in (SciTools#2978) * Save calendar attribute for cube data (SciTools#2984) * Fix bug with aux coords with scalefactor/add_offset (SciTools#2975) Fix bug with aux coords with scalefactor/add_offset * Rename to correct package name * Fix imagehash hex_to_hash (SciTools#2989) * Fix imagehash hex_to_hash * expose hamming distance vector * fix idiff * update imagerepo * fix repo hashes (bjlittle) * fix repo hashed (scitools) * fix test_image_json * test_pearsonr: use compatible cubes for testing compatible cubes (SciTools#2960) Pearsonr test using compatible cubes * Use unittest.mock for Python 3 (SciTools#3003) * reflect new latitude guess_bounds behaviour (SciTools#3006) * Pin Dask to >=0.17.1 (SciTools#2965) * Fill a usability gap in iris.analysis.Trajectory (SciTools#2770) * Fill a usability hole in Trajectory * Remove iris.experimental.um module (SciTools#2781) * Remove iris.experimental.um module * Replace use of sphinx's status_iterator function, which has moved * Lazy unit conversions for cube and coord data. (SciTools#2964) * Gracefully handle long time intervals (SciTools#2354) Gracefully handle long time intervals (months & years) when plotting * Prevent creation of invalid CF variable names. (SciTools#3009) Prevent creation of invalid CF variable names. * Add stash check to name() (SciTools#2930) Try the STASH attribute when checking for possible names (as is already done in the summary method) * Attempts to fix docs-build error reporting. (SciTools#2983) Remove final semicolon to report docs-build error. * Phenomenon translation updates (SciTools#3011) * Netcdftime dep (SciTools#3017) Pin to netcdf4 1.3 or below while we await netdftime updates Correct deprecated pandas use in v0.23 * add 'axes' kwarg to _label when called from contourf * Replace iris.co_realise_cubes with CubeList.realise_data. (SciTools#3013) * Replace iris.co_realise_cubes with CubeList.realise_data. * Avoid exposing lazy-data functions in iris.cube and iris.coord modules. * Tidy lazy_data imports in cube + coords modules. * Amend var_name documentation (SciTools#3020) Amend documentation to be explicit that var_name is a netCDF quantity, not necessarily a CF one. * Updated tests for cf_units 2 (SciTools#3023) Updated tests for cf_units>=2 This change: * Removes the redundant ``iris/tests/test_unit.py`` tests. They are all migrated to cf_units. * Makes use of CALENDAR_GREGORIAN, rather than CALENDAR_STANDARD. These calendars are implemented as aliases in cf_units 2, and the "STANDARD" concept is not preserved/round-tripped. Added a what's new to help reduce possible impact for users. * Use ConfigParser for py>=3.2 (SciTools#3025) * WIP: Unpin mpl (SciTools#3019) * unpin mpl * Add _repr_html_ for Iris cubes (SciTools#2918) Add cube _repr_html_ functionality * Partial collapse of multi-dimensional coordinates (SciTools#3028) Adding support for partial collapse of multi-dimensional coordinates * Tidy up the root of the repository for v2.1 (SciTools#3034) A bunch of miscellaneous changes in preparation for the v2.1 release: * Move CONTRIBUTING.md to a .github/ folder. See also: https://help.github.com/articles/setting-guidelines-for-repository-contributors/ * Updated the .gitignore to reflect what gets produce in day-to-day iris development * Reduced the amount of redundancy in INSTALL. It now points to the requirements/ directory which is what we actually test. * Updated minimum dependencies in requirements (because that is all we test): * Numpy>=1.14 * Matplotlib>=2 * cf_units>=2 * Remove the CODING matrix item. (SciTools#3036) * Add Albers Equal Area Projection and some test as per SciTools#2496 (SciTools#2943) Add Albers Equal Area Projection and NetCDF rules to handle it * Improve the appeal of the landing pages (docs and README) (SciTools#3040) * Update the Iris README markdown to be consistent with other SciTools projects. * Gave the package a description (for pypi). * Minor spruce of the Iris docs layout to include the tagline and the forkme button * Use the correct pypi name for nc-time-axis. (SciTools#3039) * Use cftime instead of netcdftime (SciTools#3016) * use cftime instead of netcdftime * fix the docs too * fix license year * review actions * simplify test_pandas * what's new * remove cf_units check * Fixed the intermittent test in SciTools#3035. (SciTools#3037) * Fixed the intermittent test in SciTools#3035. The problem was that iris.util.format_array was stateful (via np.set_printoptions). * Fix stateful tests (SciTools#26) * Add dask-array as a requirement when pip installing. (SciTools#3033) * Unpin netcdf4 (SciTools#3031) * unpin netcdf4 * adapt for netcdf4 >=1.4 * fix userguide doctests * Metarelate updates in the UM 2 CF mapping (SciTools#3043) * Updated the README, and copied that over to the iris docs homepage. (SciTools#3045) * Added the what's new for iris 2.1 (SciTools#3044) Added the what's new for iris 2.1 * Updated the cf-standard names to v54. (SciTools#3046) Achieved with: $ wget http://cfconventions.org/Data/cf-standard-names/54/src/cf-standard-name-table.xml -O etc/cf-standard-name-table.xml ... --2018-06-02 06:32:17-- http://cfconventions.org/Data/cf-standard-names/54/src/cf-standard-name-table.xml ... * iris.quickplot: Ensure labels and plot use the same axes Allow iris.quickplot to accept an axes kwarg to which title and axes labels can be attached. This is done without using the matplotlib state machine. Closes SciTools#2946 * sticklering * Full-featured Mercator coord system (SciTools#3041) Add ``standard_parallel`` to the Mercator Coord System * Updated the branding and execution of Iris docs (SciTools#3050) * Updated the branding and execution of Iris This includes: * removing the "easy-to-use" statement in Iris' strapline. Let's let users be the judge of that. * improved the styling of the homepage, including re-instating the search bar. * Added a what's new for SciTools#3010. * Added a extlinks section for convenient linking to github issues with :issue:`number` and :pr:`number`. * Added a favicon for the docs. * Improve strapline style, content (SciTools#27) * Further improvements to Iris docs * Improved font (noto-sans) * Removed old CSS * Fixed a few what's new entries * [DOC] Iris Introduction updates (SciTools#3052) Update the introduction of Iris content. * Updated to v2.1.0. (SciTools#3051) * Move into development mode for v2.1.1 * Move into development mode for v2.2.0 * remove first 'and' from tagline to make it read easier * Notebook repr whatsnew update * remove first 'and' from tagline to make it read easier * minor requirements tidy * http -> https for copybutton.js (SciTools#3066) * Explain use of saver='string' in iris.save (SciTools#3062) * Fix reStructuredText warnings in documentation (SciTools#3069) * Add information about comparing STASH objects with strings (SciTools#3072) * Doc: Fallback to no syntax hightlighting without warning. (SciTools#3071) Fixes: iris/docs/iris/src/developers_guide/gitwash/development_workflow.rst:317: WARNING: Could not lex literal_block as "python". Highlighting skipped. http://www.sphinx-doc.org/en/stable/config.html#confval-highlight_language * Quick fix to get tests passing by pinning dask version (SciTools#3086) * ENH: Working zonal mean linear regridding for circular sources or with use of extrapolation (SciTools#3085) * Working zonal mean from circular/extrapolated source to target * MAINT: Refactor of zonal mean testing * MAINT: Documentation changes from review * Avoid pandas deprecation warning. (SciTools#3079) Avoid pandas deprecation warning. This also simplifies code by being explicit about usage of "base" and "values" for numpy and pandas objects, and removes legacy code that may no longer be valid. * Workaround for dask array copy bug (SciTools#3088) * add contact options to README * Add stash mapping changes to v2.1.0 changelog * Pin Dask for avoid 0.18.2 bug with masked arrays. * Tiny fix for dask, Python3 only? * Disable doctests for Python 2. * Ignore warnings and update array printouts. * Better way to disable Python2 doctests. * Support plotting 2D bounded coords * Add gridcell_angles and rotate_grid_vectors to iris.analysis.cartography, with tests: INCOMPLETE WIP * Roughly working, snapshotted with complex test plot code, to be reduced. * Small improvements. * First working quiver+streamplot. * Handle custom coords correctly * some words for docs, WIP probably * suggested tweaks and corrections * Update docs to included 2.2 versions (SciTools#3110) * Provide a test skipper for 2d coords WIP. (SciTools#3099) * Change version number (SciTools#3118) * re-added bounds definition for contiguity check, removed unnecessary test * Ensure Sphinx autodocs for grid_angles routines. * Codestyle fixes. * Whatsnew entries for 2d vector support. * Pin Dask to avoid 0.18.2 bug with masked arrays. (SciTools#3127) * Put orca_util routines in subpackage of iris.test.stock, to get existing iris.tests.unit.plot.test_2d_coords working. * Disable broken misused testcode in test_gridcell_angles. * Ditch test_gridcell_angles, none of it is functional. * Further style fixes. * Skip tests using iris-test-data, for Travis TEST_MINIMAL phases. * Codestyle fix (though this code obsolete anyway). * Fix unused imports. * Made-up test cube replaces use of iris-test-data. * Renamed keyword; improved docstring. * Change 'co' to 'coord' for clarity. * Review changes. * Update pp save rules to handle time means (SciTools#3132) * Vector plots 2 (SciTools#3120) * Small improvements; first sensible tests. * Enhanced testing; better checking and crs awareness in grid_angles routine. * Remove crud from test_gridcell_angles. * Use degree units for everything in _grid_angles. * Make assertArrayAllClose print details when it fails. * Rework and extend testing for gridcell_angles. * Fix assertArrayAllClose; remove debug code from test_gridcell_angles. * Remove obsolete assignments. * Remove obsolete code. * Small comment improvements. * Attempt to clarify docstrings of low-level routines. * More tests, and some functional fixes. * Codestyle fixes. * Review changes + fixes. * Avoid using sample data. * Temporary pin to avoid problems caused by Proj4 v5.1. (SciTools#3150) * Extending ORCA blockplotting (w/ tests) (SciTools#3135) * Tests for rotate_grid_vectors (SciTools#3148) * Tests for rotate_grid_vectors. * Small fix to assertArrayAllClose for values near 0. * Small tweaks. * Fix test method. * Fix 1 test for 'equal_nans' no longer the default. * Review changes. * Remove 'skip_2d' test decorator. (SciTools#3156) * Add integration graphics tests for pcolormesh with 2d coords (SciTools#3149) * Vector plots 4 (SciTools#3158) * Fix contig_ tolerance kwarg bug (SciTools#3162) * Add simple lazy aggregations * Lazy SUM and COUNT, tests improved * Add tests for MAX and MIN * Update tests for STD_DEV * Use NetCDF variable's chunks on load (SciTools#3131) Preserve NetCDF chunks on dataset load * Iteration and less duplication * Attempt to fix Matplotlib issue by resticting to 2.x * Non-test review actions * Make COUNT tests truer unit tests * Convert MAX and MIN tests to truer unit tests * Convert COUNT and SUM agg tests to truer unit tests * Tests for new _lazy_data function * Fix for netCDF4 1.4 behaviour change. (SciTools#3177) * Improve gracefully filling warning (SciTools#3171) * Realise that running the tests is simpler than I thought * Make Gracefully warning only appear when filling is required * Add tests of warnings * Get rid of install changes, they are in SciTools#3170 * Update after review * Add whatsnew entry * Minor clarification to entry via a little more punctuation * Revert nc vars masking fix (temporarily). (SciTools#3178) * fix for pandas column object bug (SciTools#3176) * turn columns object into pandas array, plus test included cml this time * made things the way pandas like it; bambooish * regenerated cml to match output * Update module headers and installation instructions (SciTools#3170) * Update module headers and installation instructions * Realise that running the tests is simpler than I thought * Update install instructions for developers * Update INSTALL to be consistent * Correct some failing tests * Update tests.rst (SciTools#3082) Added one line on how to test. This is mentioned in the Iris Check List in pulls.rst list, but would be good to have it here as well (useful for new contributors like me). * Add link to developer guide. (SciTools#3093) * Combine identical test routines for pcolor + pcolormesh. * Test 'contiguity_tolerance' use in iris.plot.pcolor and pcolormesh. * Unpin dask * Handle printing bounds of long time interval coords (SciTools#3140) * Handle printing time bounds * Whatsnew, whitespace fix for test result * iris.util.reverse on cubes (SciTools#3155) * make cube reversing official * review: test conventions, etc. * review: enable coord specification * add whatsnew * review: AssertRaises --> AssertRaisesRegexp * cube error handling * Improved Aux factory error handling: better message, delivered earlier (SciTools#3182) * Tests for expected behaviour * Raise error if aux factory relies on a coordinate external to cube * Include coordinate name in error message * Don't check whether dependencies that are "None" are in the coords. * Review changes: check cube name in error and variable rename * Truncated variable for flake8 * Correct cube collapse code * Provide info on pp-field indices in the file for structured um loads. (SciTools#2977) * Field locations for structured um loads. * Remove unused import. * Fix test for new implementation. * Added whatsnew. * Review changes. * simplify dev guide * Integration test for iris.plot.contour with 2d coords. (SciTools#3189) * Integration test for iris.plot.contour with 2d coords. * Review changes. * pinned numpy to not 1.15.2 in core requirements * Public contiguity checking (SciTools#3144) :champagne: :1st_place_medal: for sticking with it @corinnebosley * Populate whatsnew 2.2 (SciTools#3192) * started adding entries to whatsnew * more updates to whatsnew * first complete draft of 2.2 whatsnew * some small corrections * made corrections suggested in review * Update version str * Update CF standard name table to v59 * Fix docstring re structured text warnings (SciTools#3073) (SciTools#3197) * updated version string to 2.3.0dev0 * add contact options to README removed gitter from contact list * Add stash mapping changes to v2.1.0 changelog replaced list with link of stash mappings * expanded name of dev group * added an n for better flow * Fix broken link to dask docs (SciTools#3204)
🍾 🥇 for sticking with it @corinnebosley
This PR contains:
plot.py:
test_2d_coords.py:
util.py:
Enjoy!