Example #1
0
    def test_get_cubes_missing_time_step(self, fake_get_region):
        """Test get_cubes() when not supplying keys for all time steps in a 
        time range.
        """
        EXTENTS = [self.x_dim, self.y_dim, self.z_dim]
        FIRST_T_RNG = (0, 4)
        cube1 = Cube.create_cube(self.resource, EXTENTS, FIRST_T_RNG)
        cube1.random()
        cube1.morton_id = 70

        # Note, no data for time steps 4 and 5 provided.

        SECOND_T_RNG = (6, 9)
        cube2 = Cube.create_cube(self.resource, EXTENTS, SECOND_T_RNG)
        cube2.random()
        cube2.morton_id = 70

        TOTAL_T_RNG = (0, 9)
        exp_cube = Cube.create_cube(self.resource, EXTENTS, TOTAL_T_RNG)
        exp_cube.zeros()
        exp_cube.morton_id = 70
        exp_cube.overwrite(cube1.data, FIRST_T_RNG)
        exp_cube.overwrite(cube2.data, SECOND_T_RNG)
            

        db = SpatialDB(self.kvio_config, self.state_config, self.object_store_config)

        # populate dummy data
        keys = self.write_test_cube(db, self.resource, 0, cube1, cache=True, s3=False)
        keys.extend(self.write_test_cube(db, self.resource, 0, cube2, cache=True, s3=False))

        # Method under test.
        cube_read = db.get_cubes(self.resource, keys)

        np.testing.assert_array_equal(exp_cube.data, cube_read[0].data)
Example #2
0
    def test_get_cubes_no_time_multiple(self, fake_get_region):
        """Test the get_cubes method - no time - multiple cubes"""
        # Generate random data

        cube1 = Cube.create_cube(self.resource, [self.x_dim, self.y_dim, self.z_dim])
        cube1.random()
        cube1.morton_id = 32
        cube2 = Cube.create_cube(self.resource, [self.x_dim, self.y_dim, self.z_dim])
        cube2.random()
        cube2.morton_id = 33
        cube3 = Cube.create_cube(self.resource, [self.x_dim, self.y_dim, self.z_dim])
        cube3.random()
        cube3.morton_id = 36

        db = SpatialDB(self.kvio_config, self.state_config, self.object_store_config)

        # populate dummy data
        keys = self.write_test_cube(db, self.resource, 0, cube1, cache=True, s3=False)
        keys.extend(self.write_test_cube(db, self.resource, 0, cube2, cache=True, s3=False))
        keys.extend(self.write_test_cube(db, self.resource, 0, cube3, cache=True, s3=False))

        cube_read = db.get_cubes(self.resource, keys)

        np.testing.assert_array_equal(cube1.data, cube_read[0].data)
        np.testing.assert_array_equal(cube2.data, cube_read[1].data)
        np.testing.assert_array_equal(cube3.data, cube_read[2].data)
Example #3
0
    def test_get_cubes_no_time_single(self, fake_get_region):
        """Test the get_cubes method - no time - single"""
        # Generate random data
        cube1 = Cube.create_cube(self.resource, [self.x_dim, self.y_dim, self.z_dim])
        cube1.random()
        cube1.morton_id = 32

        db = SpatialDB(self.kvio_config, self.state_config, self.object_store_config)

        # populate dummy data
        keys = self.write_test_cube(db, self.resource, 0, cube1, cache=True, s3=False)

        cube2 = db.get_cubes(self.resource, keys)

        np.testing.assert_array_equal(cube1.data, cube2[0].data)