Esempio n. 1
0
    def test_replace_time_slice(self):
        self.write_cube('2019-01-02', 10)

        replace_time_slice(self.CUBE_PATH, 5,
                           self.make_slice('2019-01-06T02:00'))
        replace_time_slice(self.CUBE_PATH, 9,
                           self.make_slice('2019-01-11T02:00'))
        replace_time_slice(self.CUBE_PATH, 0,
                           self.make_slice('2019-01-01T02:00'))

        cube = xr.open_zarr(self.CUBE_PATH)
        expected = np.array([
            '2019-01-01T14:00', '2019-01-03T12:00', '2019-01-04T12:00',
            '2019-01-05T12:00', '2019-01-06T12:00', '2019-01-06T14:00',
            '2019-01-08T12:00', '2019-01-09T12:00', '2019-01-10T12:00',
            '2019-01-11T14:00'
        ],
                            dtype=cube.time.dtype)
        self.assertEqual(10, cube.time.size)
        self.assertEqual(None, cube.time.chunks)
        np.testing.assert_equal(cube.time.values, expected)
Esempio n. 2
0
 def replace(self, dataset: xr.Dataset, index: int, output_path: str,
             **kwargs):
     replace_time_slice(output_path, index, dataset)