Skip to content
Open
Show file tree
Hide file tree
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: 9 additions & 2 deletions lib/iris/coords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2016, Met Office
# (C) British Crown Copyright 2010 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -492,7 +492,14 @@ def is_full_slice(s):
raise IndexError('Cannot index with zero length '
'slice.')
if bounds is not None:
bounds = bounds[keys + (Ellipsis, )]
# Bounds will generally have an extra dimension compared
# to points, so add an Ellipsis at the end, unless there
# is already on, as numpy does not support double Ellipsis.
if (not isinstance(keys[-1], np.ndarray) and
keys[-1] == Ellipsis):
bounds = bounds[keys]
else:
bounds = bounds[keys + (Ellipsis, )]

new_coord = self.copy(points=points, bounds=bounds)
return new_coord
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/plot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2016, Met Office
# (C) British Crown Copyright 2010 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down
18 changes: 12 additions & 6 deletions lib/iris/tests/integration/plot/test_netcdftime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2016, Met Office
# (C) British Crown Copyright 2016 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -26,12 +26,15 @@
# importing anything else
import iris.tests as tests

import numpy as np
import netcdftime

from iris.coords import AuxCoord

from cf_units import Unit
if tests.NC_TIME_AXIS_AVAILABLE:
from nc_time_axis import CalendarDateTime
import numpy as np

from iris.coords import AuxCoord

# Run tests in no graphics mode if matplotlib is not available.
if tests.MPL_AVAILABLE:
Expand All @@ -47,9 +50,12 @@ def test_360_day_calendar(self):
calendar = '360_day'
time_unit = Unit('days since 1970-01-01 00:00', calendar=calendar)
time_coord = AuxCoord(np.arange(n), 'time', units=time_unit)
expected_ydata = np.array([CalendarDateTime(time_unit.num2date(point),
calendar)
for point in time_coord.points])
times = [time_unit.num2date(point) for point in time_coord.points]
times = [netcdftime.datetime(atime.year, atime.month, atime.day,
atime.hour, atime.minute, atime.second)
for atime in times]
expected_ydata = np.array([CalendarDateTime(time, calendar)
for time in times])
line1, = iplt.plot(time_coord)
result_ydata = line1.get_ydata()
self.assertArrayEqual(expected_ydata, result_ydata)
Expand Down
5 changes: 3 additions & 2 deletions lib/iris/tests/results/imagerepo.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,12 @@
"iris.tests.test_quickplot.TestTimeReferenceUnitsLabels.test_not_reference_time_units.0": [
"https://scitools.github.io/test-iris-imagehash/images/415f85e9fefb91e94600bb6f07009be7effa1966ab065b273b009b663b007a04.png",
"https://scitools.github.io/test-iris-imagehash/images/411d85e9fefb91e14600bb6707009be7effe1966ab06fb273b009b663f007a04.png",
"https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6f07009be7effe1966ab067b273b009b663b007a04.png"
"https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6f07009be7effe1966ab067b273b009b663b007a04.png",
"https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6707009be7effe1966ab06fb273b00bb263b007a04.png"
],
"iris.tests.test_quickplot.TestTimeReferenceUnitsLabels.test_reference_time_units.0": [
"https://scitools.github.io/test-iris-imagehash/images/417f8119feebeeff070054bb2b0014a0bb157ba6bb972b46dabf3b0419827b04.png",
"https://scitools.github.io/test-iris-imagehash/images/417f8119fefbeeff070054b92b0014a0bb557ba69b95ab46dabf3b0419827b04.png",
"https://scitools.github.io/test-iris-imagehash/images/417f8119fefbeeff070054bb2b0014a0bb14fbe69b952b46dabf3b0419827b04.png"
]
}
}
28 changes: 20 additions & 8 deletions lib/iris/tests/test_pandas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2016, Met Office
# (C) British Crown Copyright 2013 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -28,6 +28,7 @@

import cf_units
import matplotlib.units
import netCDF4
import netcdftime
import numpy as np

Expand Down Expand Up @@ -100,11 +101,18 @@ def test_time_360(self):
time_coord = DimCoord([0, 100.1, 200.2, 300.3, 400.4],
long_name="time", units=time_unit)
cube.add_dim_coord(time_coord, 0)
expected_index = [netcdftime.datetime(2000, 1, 1, 0, 0),
netcdftime.datetime(2000, 4, 11, 2, 24),
netcdftime.datetime(2000, 7, 21, 4, 48),
netcdftime.datetime(2000, 11, 1, 7, 12),
netcdftime.datetime(2001, 2, 11, 9, 36)]
if netCDF4.__version__ > '1.2.4':
expected_index = [netcdftime.Datetime360Day(2000, 1, 1, 0, 0),
netcdftime.Datetime360Day(2000, 4, 11, 2, 24),
netcdftime.Datetime360Day(2000, 7, 21, 4, 48),
netcdftime.Datetime360Day(2000, 11, 1, 7, 12),
netcdftime.Datetime360Day(2001, 2, 11, 9, 36)]
else:
expected_index = [netcdftime.datetime(2000, 1, 1, 0, 0),
netcdftime.datetime(2000, 4, 11, 2, 24),
netcdftime.datetime(2000, 7, 21, 4, 48),
netcdftime.datetime(2000, 11, 1, 7, 12),
netcdftime.datetime(2001, 2, 11, 9, 36)]
series = iris.pandas.as_series(cube)
self.assertArrayEqual(series, cube.data)
self.assertArrayEqual(series.index, expected_index)
Expand Down Expand Up @@ -236,8 +244,12 @@ def test_time_360(self):
time_coord = DimCoord([100.1, 200.2], long_name="time",
units=time_unit)
cube.add_dim_coord(time_coord, 0)
expected_index = [netcdftime.datetime(2000, 4, 11, 2, 24),
netcdftime.datetime(2000, 7, 21, 4, 48)]
if netCDF4.__version__ > '1.2.4':
expected_index = [netcdftime.Datetime360Day(2000, 4, 11, 2, 24),
netcdftime.Datetime360Day(2000, 7, 21, 4, 48)]
else:
expected_index = [netcdftime.datetime(2000, 4, 11, 2, 24),
netcdftime.datetime(2000, 7, 21, 4, 48)]
expected_columns = [0, 1, 2, 3, 4]
data_frame = iris.pandas.as_data_frame(cube)
self.assertArrayEqual(data_frame, cube.data)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2016, Met Office
# (C) British Crown Copyright 2013 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -99,7 +99,6 @@ def setUp(self):
'proleptic_gregorian': np.array(list(range(360, 367)) +
list(range(1, 4))),
'noleap': np.array(list(range(359, 366)) + list(range(1, 4))),
'julian': np.array(list(range(360, 367)) + list(range(1, 4))),
'all_leap': np.array(list(range(360, 367)) + list(range(1, 4))),
'365_day': np.array(list(range(359, 366)) + list(range(1, 4))),
'366_day': np.array(list(range(360, 367)) + list(range(1, 4))),
Expand All @@ -115,7 +114,7 @@ def make_cube(self, calendar):
return cube

def test_calendars(self):
for calendar in calendars:
for calendar in self.expected:
cube = self.make_cube(calendar)
add_day_of_year(cube, 'time')
points = cube.coord('day_of_year').points
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2014 - 2015, Met Office
# (C) British Crown Copyright 2014 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -52,8 +52,12 @@ def _make_field(lbyr=None, lbyrd=None, lbft=None,
header = [0] * 64
if lbyr is not None:
header[0] = lbyr
header[1] = 1
header[2] = 1
if lbyrd is not None:
header[6] = lbyrd
header[7] = 1
header[8] = 1
if lbft is not None:
header[13] = lbft
if blev is not None:
Expand Down