Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/iris/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ def _draw_2d_from_bounds(draw_method_name, cube, *args, **kwargs):
values = np.arange(data.shape[data_dim] + 1) - 0.5
else:
values = coord.contiguous_bounds()
values = _fixup_dates(coord, values)
if (isinstance(values.ravel()[0], datetime.datetime)):
values = mpl_dates.date2num(values)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.


plot_arrays.append(values)

Expand Down Expand Up @@ -402,11 +405,11 @@ def _draw_2d_from_points(draw_method_name, arg_func, cube, *args, **kwargs):


def _fixup_dates(coord, values):
if coord.units.calendar is not None and values.ndim == 1:
if coord.units.calendar is not None:
# Convert coordinate values into tuples of
# (year, month, day, hour, min, sec)
dates = [coord.units.num2date(val).timetuple()[0:6]
for val in values]
for val in values.flat]
if coord.units.calendar == 'gregorian':
r = [datetime.datetime(*date) for date in dates]
else:
Expand All @@ -423,8 +426,8 @@ def _fixup_dates(coord, values):
r = [nc_time_axis.CalendarDateTime(
netcdftime.datetime(*date), coord.units.calendar)
for date in dates]
values = np.empty(len(r), dtype=object)
values[:] = r
values = np.empty_like(values, dtype=object)
values.flat = r
return values


Expand Down