Esempio n. 1
0
    def setUp(self) -> None:
        rimraf(self.TEST_CUBE)
        cube = new_cube(time_periods=3,
                        variables=dict(precipitation=np.nan,
                                       temperature=np.nan)).chunk(
                                           dict(time=1, lat=90, lon=90))

        write_cube(cube, self.TEST_CUBE, "zarr", cube_asserted=True)
Esempio n. 2
0
 def setUpClass(cls) -> None:
     rimraf(S3_BUCKET)
     os.mkdir(S3_BUCKET)
     cube = new_cube(time_periods=3,
                     variables=dict(precipitation=0.9,
                                    temperature=278.3)).chunk(dict(time=1, lat=90, lon=90))
     write_cube(cube, TEST_CUBE_1, "zarr", cube_asserted=True)
     write_cube(cube, TEST_CUBE_2, "zarr", cube_asserted=True)
Esempio n. 3
0
    def setUp(self):
        rimraf(self.TEST_ZARR)
        cube = new_cube(variables=dict(A=0.5, B=-1.5))
        cube = chunk_dataset(cube,
                             chunk_sizes=dict(time=1, lat=90, lon=90),
                             format_name=FORMAT_NAME_ZARR)
        cube.to_zarr(self.TEST_ZARR)

        self.chunked_a_files = {
            '.zarray', '.zattrs', '0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.1.0',
            '0.1.1', '0.1.2', '0.1.3', '1.0.0', '1.0.1', '1.0.2', '1.0.3',
            '1.1.0', '1.1.1', '1.1.2', '1.1.3', '2.0.0', '2.0.1', '2.0.2',
            '2.0.3', '2.1.0', '2.1.1', '2.1.2', '2.1.3', '3.0.0', '3.0.1',
            '3.0.2', '3.0.3', '3.1.0', '3.1.1', '3.1.2', '3.1.3', '4.0.0',
            '4.0.1', '4.0.2', '4.0.3', '4.1.0', '4.1.1', '4.1.2', '4.1.3'
        }
        self.chunked_b_files = self.chunked_a_files
        self.chunked_time_files = {
            '.zarray', '.zattrs', '0', '1', '2', '3', '4'
        }
        self.chunked_lat_files = {'.zattrs', '.zarray', '0', '1'}
        self.chunked_lon_files = {'.zattrs', '.zarray', '0', '1', '2', '3'}
Esempio n. 4
0
    def _assert_io_ok(self, shape, tile_shape, expected_num_levels,
                      expected_shapes, expected_chunks):

        input_path = get_path("pyramid-input.nc")
        output_path = get_path("pyramid-output")

        rimraf(input_path)
        rimraf(output_path)

        try:
            dataset = self.create_test_dataset(shape, chunks=None)
            dataset.to_netcdf(input_path)

            t0 = time.perf_counter()

            levels = write_levels(output_path,
                                  dataset=dataset,
                                  spatial_tile_shape=tile_shape,
                                  input_path=input_path)

            print(f"write time total: ", time.perf_counter() - t0)

            self._assert_levels_ok(levels, expected_num_levels,
                                   expected_shapes, expected_chunks)

            t0 = time.perf_counter()

            levels = read_levels(output_path)

            print(f"read time total: ", time.perf_counter() - t0)

            self._assert_levels_ok(levels, expected_num_levels,
                                   expected_shapes, expected_chunks)

        finally:
            rimraf(input_path)
            rimraf(output_path)
Esempio n. 5
0
 def tearDown(self):
     rimraf(TEST_CUBE_ZARR)
Esempio n. 6
0
 def setUp(self):
     rimraf(TEST_CUBE_ZARR)
     TEST_CUBE.to_zarr(TEST_CUBE_ZARR)
Esempio n. 7
0
 def tearDown(self) -> None:
     rimraf(self.TEST_CUBE)
Esempio n. 8
0
 def setUp(self) -> None:
     rimraf(self.TEST_CUBE)
Esempio n. 9
0
 def tearDownClass(cls) -> None:
     rimraf(S3_BUCKET)
Esempio n. 10
0
 def tearDown(self):
     rimraf(self.TEST_ZARR)
Esempio n. 11
0
 def _clear_outputs(self):
     rimraf(TEST_CUBE_ZARR)
     rimraf(TEST_CUBE_ZARR_OPTIMIZED_DEFAULT)
     rimraf(TEST_CUBE_ZARR_OPTIMIZED_USER)
Esempio n. 12
0
 def tearDown(self) -> None:
     rimraf(self.CUBE_PATH)
     rimraf(self.CUBE_PATH_2)
Esempio n. 13
0
 def setUp(self) -> None:
     rimraf(self.CUBE_PATH)
Esempio n. 14
0
def clean_up():
    files = ['l2c-single.nc', 'l2c.nc', 'l2c.zarr', 'l2c-single.zarr']
    for file in files:
        rimraf(file)
        rimraf(file + '.temp.nc')  # May remain from Netcdf4DatasetIO.append()
    rimraf(get_inputdata_path("input.txt"))
Esempio n. 15
0
 def _rm_outputs(self):
     for path in [TEST_ZARR_DIR, TEST_NC_FILE] + self.outputs():
         rimraf(path)