Skip to content

Commit faf27fe

Browse files
authored
Fix read_ecmwf_macc test failure for cftime>=1.6.0 (#1656)
* use 'nearest' instead of 'before' and 'after' * whatsnew
1 parent a19b528 commit faf27fe

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/sphinx/source/whatsnew/v0.9.5.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Bug fixes
2525
* Fixed incorrect mapping of requested parameters names when using the ``get_psm3``
2626
function. Also fixed the random reordering of the dataframe columns.
2727
(:issue:`1629`, :issue:`1647`, :pull:`1648`)
28+
* When using ``utc_time_range`` with :py:func:`pvlib.iotools.read_ecmwf_macc`,
29+
the time index subset is now selected with ``nearest`` instead of ``before``
30+
and ``after`` for consistency with ``cftime>=1.6.0``. (:issue:`1609`, :pull:`1656`)
2831

2932

3033
Testing
@@ -56,3 +59,4 @@ Contributors
5659
* Mark Mikofski (:ghuser:`mikofski`)
5760
* Anton Driesse (:ghuser:`adriesse`)
5861
* Adam R. Jensen (:ghuser:`AdamRJensen`)
62+
* Michael Deceglie (:ghuser:`mdeceglie`)

pvlib/iotools/ecmwf_macc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ def read_ecmwf_macc(filename, latitude, longitude, utc_time_range=None):
294294
nctime = ecmwf_macc.data['time']
295295
if utc_time_range:
296296
start_idx = netCDF4.date2index(
297-
utc_time_range[0], nctime, select='before')
297+
utc_time_range[0], nctime, select='nearest')
298298
end_idx = netCDF4.date2index(
299-
utc_time_range[-1], nctime, select='after')
299+
utc_time_range[-1], nctime, select='nearest')
300300
time_slice = slice(start_idx, end_idx + 1)
301301
else:
302302
time_slice = slice(0, ecmwf_macc.time_size)

0 commit comments

Comments
 (0)