-
Notifications
You must be signed in to change notification settings - Fork 300
Add date conversion to bounds plots #2260
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
Conversation
|
Is there some hope of showing us what difference this makes ? |
|
I've just read my initial description and see how horrible it is. I've updated it, but I'll provide extra info here. When a 2D cube is plotted with an For plotting functions which use the coordinate bounds values, such as pcolormesh, no such conversion is done, so you get the wrong dates on the axis if you use a date formatter. This PR fixes that. Here is some example code which demonstrates the difference. Run it with current Iris code and note the difference in dates on the y axis for the two plots: |
a7a102d to
e43837b
Compare
e43837b to
0b9241c
Compare
|
I need to update the image hash value for the two failing tests (i've verified them visually). Can someone give me some pointers on how to do that? |
|
Your image test failure is also exposing a bug in the idiff.py code : The global I think 'idiff' ought to be the easy way in to adding a new image-hash + its reference image, but we are behind in getting this working and/or documenting it. #2185 was a start on that, but that now needs updating with the consequences of the move from exact image hashes to imagehash-es. |
| values = coord.contiguous_bounds() | ||
| values = _fixup_dates(coord, values) | ||
| if (isinstance(values.ravel()[0], datetime.datetime)): | ||
| values = mpl_dates.date2num(values) |
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 have you removed this bit? Does it still work without this? What happens when the values are datetimes?
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 is code I've added.
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 of course it is, sorry, it's green.
In which case, I approve, just need to work out where we are with the image hashing stuff now.
|
@djkirkham Are these the same steps you followed last time you looked at this ticket: http://scitools.org.uk/iris/docs/latest/developers_guide/graphics_tests.html#developer-graphics-tests |
|
@corinnebosley No, I wasn't aware of that document before. I'll take a look, thanks. |
|
There's a problem here, and it's one which already exists when plotting dates based on the points. As I said, when Iris plots dates based on points on an axis, it converts the numeric data to datetime objects and back to numbers again. But the new numbers have a different unit to the original. So if a user has added an axis label like 'Hours since 1st January 2000', the numbers won't match. In fact, if it's plotted using quickplot, an axis label based on the original units will automatically be added. |
|
@djkirkham Once again, taking this on unless you say otherwise. |
Plotting functions which use a
cube'scoordinate's points for the axis values (e.g. contour) convert time coordinate dates into the units used by matplotlib where possible, allowing them to be interpreted correctly by, for example,matplolib.dates.DateFormatters. This PR extends that functionality to plotting functions which use bounds.