def test_series_locator_initial_times(self): paths = [ "/some/file_20190101T0000Z_000.nc", "/some/file_20190101T0000Z_006.nc", "/some/file_20190101T0000Z_012.nc", "/some/file_20190101T1200Z_000.nc", "/some/file_20190101T1200Z_006.nc", "/some/file_20190101T1200Z_012.nc", ] locator = series.SeriesLocator(paths) result = locator.initial_times() expect = np.array(['2019-01-01 00:00', '2019-01-01 12:00'], dtype='datetime64[s]') npt.assert_array_equal(expect, result)
def test_series_locator_getitem_given_datetime64(self): paths = [ "/some/file_20190101T0000Z_000.nc", "/some/file_20190101T0000Z_006.nc", "/some/file_20190101T0000Z_012.nc", "/some/file_20190101T1200Z_000.nc", "/some/file_20190101T1200Z_006.nc", "/some/file_20190101T1200Z_012.nc", ] reference_time = np.datetime64('2019-01-01T12:00:00', 's') locator = series.SeriesLocator(paths) result = locator[reference_time] expect = [ "/some/file_20190101T1200Z_000.nc", "/some/file_20190101T1200Z_006.nc", "/some/file_20190101T1200Z_012.nc", ] self.assertEqual(expect, result)
def test_series_locator(self): paths = [ "/some/file_20190101T0000Z_000.nc", "/some/file_20190101T0000Z_006.nc", "/some/file_20190101T0000Z_012.nc", "/some/file_20190101T1200Z_000.nc", "/some/file_20190101T1200Z_006.nc", "/some/file_20190101T1200Z_012.nc", ] reference_time = dt.datetime(2019, 1, 1, 12) locator = series.SeriesLocator(paths) result = locator[reference_time] expect = [ "/some/file_20190101T1200Z_000.nc", "/some/file_20190101T1200Z_006.nc", "/some/file_20190101T1200Z_012.nc", ] self.assertEqual(expect, result)