diff --git a/sup3r/utilities/utilities.py b/sup3r/utilities/utilities.py index c79467fb3..ebfb07a50 100644 --- a/sup3r/utilities/utilities.py +++ b/sup3r/utilities/utilities.py @@ -22,7 +22,11 @@ def preprocess_datasets(dset): """Standardization preprocessing applied before datasets are concatenated by ``xr.open_mfdataset``""" if 'time' in dset and dset.time.size > 1: - ti = dset.time.astype(int) + if 'time' in dset.indexes and hasattr( + dset.indexes['time'], 'to_datetimeindex' + ): + dset['time'] = dset.indexes['time'].to_datetimeindex() + ti = dset['time'].astype(int) dset['time'] = ti if 'latitude' in dset.dims: dset = dset.swap_dims({'latitude': 'south_north'}) diff --git a/tests/utilities/test_era_downloader.py b/tests/utilities/test_era_downloader.py index 5b79109c1..2afbc137b 100644 --- a/tests/utilities/test_era_downloader.py +++ b/tests/utilities/test_era_downloader.py @@ -98,7 +98,11 @@ def test_era_dl_year(tmpdir_factory): yearly_file_pattern=yearly_file_pattern, max_workers=1, combine_all_files=True, - res_kwargs={'compat': 'override', 'engine': 'netcdf4'}, + res_kwargs={ + 'compat': 'override', + 'engine': 'netcdf4', + 'concat_dim': 'time', + }, ) combined_file = yearly_file_pattern.replace('_{var}_', '').format(