Esempio n. 1
0
 def test_desc_bounds_all_singleton(self):
     top = self._make_cube([5], [10, 0])
     bottom = self._make_cube([15], [20, 10])
     result1 = concatenate([top, bottom])
     result2 = concatenate([bottom, top])
     self.assertEqual(len(result1), 1)
     self.assertEqual(len(result2), 1)
     self.assertEqual(result1, result2)
Esempio n. 2
0
 def test_points_all_singleton(self):
     top = self._make_cube([5])
     bottom = self._make_cube([15])
     result1 = concatenate([top, bottom])
     result2 = concatenate([bottom, top])
     self.assertEqual(len(result1), 1)
     self.assertEqual(len(result2), 1)
     self.assertEqual(result1, result2)
Esempio n. 3
0
 def test_points_all_singleton(self):
     top = self._make_cube([5])
     bottom = self._make_cube([15])
     result1 = concatenate([top, bottom])
     result2 = concatenate([bottom, top])
     self.assertEqual(len(result1), 1)
     self.assertEqual(len(result2), 1)
     self.assertEqual(result1, result2)
Esempio n. 4
0
 def test_desc_bounds_all_singleton(self):
     top = self._make_cube([5], [10, 0])
     bottom = self._make_cube([15], [20, 10])
     result1 = concatenate([top, bottom])
     result2 = concatenate([bottom, top])
     self.assertEqual(len(result1), 1)
     self.assertEqual(len(result2), 1)
     self.assertEqual(result1, result2)
Esempio n. 5
0
 def test_definition_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.units = '1'
     exc_regexp = 'Cube metadata differs for phenomenon: *'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 6
0
 def test_anonymous_coord_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord('latitude')
     exc_regexp = 'one or both cubes have anonymous dimensions'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 7
0
 def test_dimensions_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord('latitude').long_name = 'bob'
     exc_regexp = 'Dimension coordinates metadata differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 8
0
 def test_aux_coords_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord('foo').units = 'm'
     exc_regexp = 'Auxiliary coordinates metadata differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 9
0
 def test_dimensions_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord('latitude')
     exc_regexp = 'Dimension coordinates differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 10
0
 def test_scalar_coords_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord('height')
     exc_regexp = 'Scalar coordinates differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 11
0
 def test_dimensions_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord('latitude')
     exc_regexp = 'Dimension coordinates differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 12
0
 def test_definition_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.units = '1'
     exc_regexp = 'Cube metadata differs for phenomenon: *'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 13
0
 def test_aux_coords_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord("foo").units = "m"
     exc_regexp = "Auxiliary coordinates metadata differ: .* != .*"
     with self.assertRaisesRegex(ConcatenateError, exc_regexp):
         _ = concatenate([cube_1, cube_2], True)
Esempio n. 14
0
 def test_scalar_coords_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord('height')
     exc_regexp = 'Scalar coordinates differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 15
0
 def test_scalar_coords_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord('height').long_name = 'alice'
     exc_regexp = 'Scalar coordinates metadata differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 16
0
 def test_dimensions_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord('latitude').long_name = 'bob'
     exc_regexp = 'Dimension coordinates metadata differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 17
0
 def test_dimensions_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord("latitude").long_name = "bob"
     exc_regexp = "Dimension coordinates metadata differ: .* != .*"
     with self.assertRaisesRegex(ConcatenateError, exc_regexp):
         _ = concatenate([cube_1, cube_2], True)
Esempio n. 18
0
 def test_aux_coords_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord('foo').units = 'm'
     exc_regexp = 'Auxiliary coordinates metadata differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 19
0
 def test_concat_1d_with_same_time_units(self):
     reftimes = ["hours since 1970-01-01 00:00:00", "hours since 1970-01-01 00:00:00"]
     coords_points = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]
     cubes = self.simple_1d_time_cubes(reftimes, coords_points)
     result = concatenate(cubes)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].shape, (10,))
Esempio n. 20
0
 def test_lazy_concatenate_masked_array_mixed_deferred(self):
     c1 = self.build_lazy_cube([1, 2])
     c2 = self.build_lazy_cube([3, 4, 5])
     c2.data = np.ma.masked_greater(c2.data, 3)
     cube, = concatenate([c1, c2])
     self.assertTrue(cube.has_lazy_data())
     self.assertTrue(ma.isMaskedArray(cube.data))
Esempio n. 21
0
 def test_aux_coords_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord("foo")
     exc_regexp = "Auxiliary coordinates differ: .* != .*"
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 22
0
 def test_cell_measure_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.cell_measure("bar").units = "m"
     exc_regexp = "Cell measures metadata differ: .* != .*"
     with self.assertRaisesRegex(ConcatenateError, exc_regexp):
         _ = concatenate([cube_1, cube_2], True)
Esempio n. 23
0
 def test_datatype_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.data.dtype = np.float64
     exc_regexp = 'Datatypes differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 24
0
 def test_scalar_coords_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord("height").long_name = "alice"
     exc_regexp = "Scalar coordinates metadata differ: .* != .*"
     with self.assertRaisesRegex(ConcatenateError, exc_regexp):
         _ = concatenate([cube_1, cube_2], True)
Esempio n. 25
0
 def test_ancillary_variable_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.ancillary_variable("baz").units = "m"
     exc_regexp = "Ancillary variables metadata differ: .* != .*"
     with self.assertRaisesRegex(ConcatenateError, exc_regexp):
         _ = concatenate([cube_1, cube_2], True)
Esempio n. 26
0
 def test_lazy_concatenate_masked_array_mixed_deferred(self):
     c1 = self.build_lazy_cube([1, 2])
     c2 = self.build_lazy_cube([3, 4, 5])
     c2.data = np.ma.masked_greater(c2.data, 3)
     (cube, ) = concatenate([c1, c2])
     self.assertTrue(cube.has_lazy_data())
     self.assertTrue(ma.isMaskedArray(cube.data))
Esempio n. 27
0
 def test_datatype_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.data.dtype = np.float64
     exc_regexp = 'Datatypes differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 28
0
 def test_anonymous_coord_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.remove_coord('latitude')
     exc_regexp = 'one or both cubes have anonymous dimensions'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 29
0
 def test_scalar_coords_metadata_difference_message(self):
     cube_1 = self.cube
     cube_2 = cube_1.copy()
     cube_2.coord('height').long_name = 'alice'
     exc_regexp = 'Scalar coordinates metadata differ: .* != .*'
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 30
0
 def test_concat_1d_with_same_time_units(self):
     reftimes = ['hours since 1970-01-01 00:00:00',
                 'hours since 1970-01-01 00:00:00']
     coords_points = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]
     cubes = self.simple_1d_time_cubes(reftimes, coords_points)
     result = concatenate(cubes)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].shape, (10,))
Esempio n. 31
0
    def test_diff_aux_coord(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord('time').points = [12, 18]
        cube_b.coord('longitude').points = [120, 150]

        result = concatenate([cube_a, cube_b])
        self.assertEqual(len(result), 2)
Esempio n. 32
0
 def test_lazy_biggus_concatenate_masked_array_mixed_deffered(self):
     c1 = self.build_lazy_cube([1, 2])
     c2 = self.build_lazy_cube([3, 4, 5])
     c2.data = np.ma.masked_greater(c2.data, 3)
     self.assertFalse(c2.has_lazy_data())
     cube, = concatenate([c1, c2])
     self.assertTrue(cube.has_lazy_data())
     self.assertIsInstance(cube.data, np.ma.MaskedArray)
Esempio n. 33
0
    def test_diff_ancillary_variables(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord("time").points = [12, 18]
        cube_b.ancillary_variable("quality").data = [120, 150]

        result = concatenate([cube_a, cube_b])
        self.assertEqual(len(result), 2)
Esempio n. 34
0
    def test_diff_aux_coord(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord("time").points = [12, 18]
        cube_b.coord("longitude").points = [120, 150]

        result = concatenate([cube_a, cube_b])
        self.assertEqual(len(result), 2)
Esempio n. 35
0
    def test_diff_cell_measure(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord("time").points = [12, 18]
        cube_b.cell_measure("volume").data = [120, 150]

        result = concatenate([cube_a, cube_b])
        self.assertEqual(len(result), 2)
Esempio n. 36
0
 def test_lazy_biggus_concatenate_masked_array_mixed_deffered(self):
     c1 = self.build_lazy_cube([1, 2])
     c2 = self.build_lazy_cube([3, 4, 5])
     c2.data = np.ma.masked_greater(c2.data, 3)
     self.assertFalse(c2.has_lazy_data())
     cube, = concatenate([c1, c2])
     self.assertTrue(cube.has_lazy_data())
     self.assertIsInstance(cube.data, np.ma.MaskedArray)
Esempio n. 37
0
    def test_ignore_diff_aux_coord(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord("time").points = [12, 18]
        cube_b.coord("longitude").points = [120, 150]

        result = concatenate([cube_a, cube_b], check_aux_coords=False)
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].shape, (4, 2))
Esempio n. 38
0
    def test_ignore_diff_ancillary_variables(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord("time").points = [12, 18]
        cube_b.ancillary_variable("quality").data = [120, 150]

        result = concatenate([cube_a, cube_b], check_ancils=False)
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].shape, (4, 2))
Esempio n. 39
0
    def test_ignore_diff_cell_measure(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord("time").points = [12, 18]
        cube_b.cell_measure("volume").data = [120, 150]

        result = concatenate([cube_a, cube_b], check_cell_measures=False)
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].shape, (4, 2))
Esempio n. 40
0
    def test_matching_2d_longitudes(self):
        cube1 = self.cube
        cube1.add_dim_coord(self.y_coord, 1)
        cube1.add_aux_coord(self.x_coord_2D, (1, 2))

        cube2 = cube1.copy()
        cube2.coord("time").points = [12, 18]
        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 1)
Esempio n. 41
0
    def test_matching_2d_longitudes(self):
        cube1 = self.cube
        cube1.add_dim_coord(self.y_coord, 1)
        cube1.add_aux_coord(self.x_coord_2D, (1, 2))

        cube2 = cube1.copy()
        cube2.coord('time').points = [12, 18]
        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 1)
Esempio n. 42
0
 def test_concat_1d_with_differing_time_units(self):
     reftimes = ['hours since 1970-01-01 00:00:00',
                 'hours since 1970-01-02 00:00:00']
     coords_points = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
     cubes = self.simple_1d_time_cubes(reftimes, coords_points)
     unify_time_units(cubes)
     result = concatenate(cubes)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].shape, (10,))
Esempio n. 43
0
    def test_ignore_diff_aux_coord(self):
        cube_a = self.create_cube()
        cube_b = cube_a.copy()
        cube_b.coord('time').points = [12, 18]
        cube_b.coord('longitude').points = [120, 150]

        result = concatenate([cube_a, cube_b], check_aux_coords=False)
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].shape, (4, 2))
Esempio n. 44
0
    def test_concatenate_along_anon_dim(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord_non_monotonic, 1)
        cube1.add_aux_coord(self.x_coord, 2)

        cube2 = cube1.copy()
        cube2.coord('latitude').points = [30, 0, 15]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 2)
Esempio n. 45
0
 def test_anonymous_coord_message(self):
     cube_1 = self.cube
     cube_1.remove_coord('latitude')
     cube_2 = cube_1.copy()
     with warnings.catch_warnings(record=True) as warn:
         warnings.simplefilter("always")
         result = concatenate([cube_1, cube_2], True)
     self.assertEqual(len(warn), 1)
     msg = 'One or both cubes have anonymous dimensions'
     six.assertRegex(self, str(warn[0].message), msg)
Esempio n. 46
0
    def test_matching_non_monotonic_latitudes(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord_non_monotonic, 1)
        cube1.add_aux_coord(self.x_coord, 2)

        cube2 = cube1.copy()
        cube2.coord("time").points = [12, 18]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 1)
Esempio n. 47
0
    def test_matching_non_monotonic_latitudes(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord_non_monotonic, 1)
        cube1.add_aux_coord(self.x_coord, 2)

        cube2 = cube1.copy()
        cube2.coord('time').points = [12, 18]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 1)
Esempio n. 48
0
    def test_concatenate_along_anon_dim(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord_non_monotonic, 1)
        cube1.add_aux_coord(self.x_coord, 2)

        cube2 = cube1.copy()
        cube2.coord("latitude").points = [30, 0, 15]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 2)
Esempio n. 49
0
 def test_concatenate_anom_1st_dim(self):
     # Check that concatenation along a non anonymous dimension is
     # insensitive to the dimension which is anonymous.
     # Concatenate along longitude.
     # DIM: cube(--, lat, lon)   & cube(--, lat, lon')
     # AUX: cube(wibble, --, --) & cube(wibble, --, --)
     cube1 = self.cube[..., :2]
     cube2 = self.cube[..., 2:]
     result = concatenate([cube1, cube2])
     self.assertEqual(len(result), 1)
Esempio n. 50
0
 def test_ndim_difference_message(self):
     cube_1 = self.cube
     cube_2 = iris.cube.Cube(np.arange(5, dtype=np.float32), standard_name="air_temperature", units="K")
     x_coord = iris.coords.DimCoord(
         points=np.arange(5, dtype=np.float32), standard_name="longitude", units="degrees"
     )
     cube_2.add_dim_coord(x_coord, 0)
     exc_regexp = "Data dimensions differ: [0-9] != [0-9]"
     with self.assertRaisesRegexp(ConcatenateError, exc_regexp):
         result = concatenate([cube_1, cube_2], True)
Esempio n. 51
0
 def test_concatenate_anom_1st_dim(self):
     # Check that concatenation along a non anonymous dimension is
     # insensitive to the dimension which is anonymous.
     # Concatenate along longitude.
     # DIM: cube(--, lat, lon)   & cube(--, lat, lon')
     # AUX: cube(wibble, --, --) & cube(wibble, --, --)
     cube1 = self.cube[..., :2]
     cube2 = self.cube[..., 2:]
     result = concatenate([cube1, cube2])
     self.assertEqual(len(result), 1)
Esempio n. 52
0
    def test_differing_2d_longitudes(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord, 1)
        cube1.add_aux_coord(self.x_coord_2D, (1, 2))

        cube2 = cube1.copy()
        cube2.coord("time").points = [12, 18]
        cube2.coord("longitude").points = [[-30, -15], [0, 15], [30, 45]]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 2)
Esempio n. 53
0
    def test_differing_2d_longitudes(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord, 1)
        cube1.add_aux_coord(self.x_coord_2D, (1, 2))

        cube2 = cube1.copy()
        cube2.coord('time').points = [12, 18]
        cube2.coord('longitude').points = [[-30, -15], [0, 15], [30, 45]]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 2)
Esempio n. 54
0
 def test_concat_1d_with_differing_time_units(self):
     reftimes = [
         "hours since 1970-01-01 00:00:00",
         "hours since 1970-01-02 00:00:00",
     ]
     coords_points = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
     cubes = self.simple_1d_time_cubes(reftimes, coords_points)
     unify_time_units(cubes)
     result = concatenate(cubes)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].shape, (10, ))
Esempio n. 55
0
    def test_differing_non_monotonic_latitudes(self):
        cube1 = self.cube
        cube1.add_aux_coord(self.y_coord_non_monotonic, 1)
        cube1.add_aux_coord(self.x_coord, 2)

        cube2 = cube1.copy()
        cube2.coord("time").points = [12, 18]
        cube2.coord("latitude").points = [30, 0, 15]

        result = concatenate([cube1, cube2])
        self.assertEqual(len(result), 2)
Esempio n. 56
0
 def test_concatenate_anom_3rd_dim(self):
     # Check that concatenation along a non anonymous dimension is
     # insensitive to the dimension which is anonymous.
     # Concatenate along longitude.
     # DIM: cube(lat, lon, --)   & cube(lat, lon', --)
     # AUX: cube(--, --, wibble) & cube(--, --, wibble)
     cube1 = self.cube[..., :2]
     cube2 = self.cube[..., 2:]
     cube1.transpose((1, 2, 0))
     cube2.transpose((1, 2, 0))
     result = concatenate([cube1, cube2])
     self.assertEqual(len(result), 1)
Esempio n. 57
0
 def test_lazy_concatenate(self):
     c1 = self.build_lazy_cube([1, 2])
     c2 = self.build_lazy_cube([3, 4, 5])
     cube, = concatenate([c1, c2])
     self.assertTrue(cube.has_lazy_data())
     self.assertFalse(ma.isMaskedArray(cube.data))
Esempio n. 58
0
 def test_desc_bounds(self):
     top = self._make_cube([67.5, 22.5], [[90, 45], [45, 0]])
     bottom = self._make_cube([-22.5, -67.5], [[0, -45], [-45, -90]])
     result = concatenate([top, bottom])
     self.assertEqual(len(result), 1)
Esempio n. 59
0
 def test_desc_points(self):
     top = self._make_cube([90, 70, 50, 30, 10])
     bottom = self._make_cube([-10, -30, -50, -70, -90])
     result = concatenate([top, bottom])
     self.assertEqual(len(result), 1)
Esempio n. 60
0
 def test_lazy_biggus_concatenate(self):
     c1 = self.build_lazy_cube([1, 2])
     c2 = self.build_lazy_cube([3, 4, 5])
     cube, = concatenate([c1, c2])
     self.assertTrue(cube.has_lazy_data())
     self.assertNotIsInstance(cube.data, np.ma.MaskedArray)