Esempio n. 1
0
 def test_multi_dimensional(self):
     time = AuxCoord(np.arange(12).reshape(3, 4), 'time',
                     units='hours since 2013-10-29 18:00:00')
     cube = Cube(np.arange(12).reshape(3, 4))
     cube.add_aux_coord(time, (0, 1))
     constraint = TimeConstraint(hour=12)
     with self.assertRaises(CoordinateMultiDimError):
         sub_cube = constraint.extract(cube)
Esempio n. 2
0
 def test_3d_data(self):
     time = DimCoord(np.arange(12) * 6, 'time',
                     units='hours since 2013-10-29 18:00:00')
     cube = Cube(np.arange(12 * 5 * 6).reshape(12, 5, 6))
     cube.add_dim_coord(time, 0)
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertArrayEqual(sub_cube.coord('time').points, [18, 42, 66])
Esempio n. 3
0
 def test_3d_data(self):
     time = DimCoord(np.arange(12) * 6,
                     'time',
                     units='hours since 2013-10-29 18:00:00')
     cube = Cube(np.arange(12 * 5 * 6).reshape(12, 5, 6))
     cube.add_dim_coord(time, 0)
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertArrayEqual(sub_cube.coord('time').points, [18, 42, 66])
Esempio n. 4
0
 def test_multi_dimensional(self):
     time = AuxCoord(np.arange(12).reshape(3, 4),
                     'time',
                     units='hours since 2013-10-29 18:00:00')
     cube = Cube(np.arange(12).reshape(3, 4))
     cube.add_aux_coord(time, (0, 1))
     constraint = TimeConstraint(hour=12)
     with self.assertRaises(CoordinateMultiDimError):
         sub_cube = constraint.extract(cube)
Esempio n. 5
0
 def test_1d_data(self):
     cube = self._1d_cube()
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertArrayEqual(sub_cube.coord('time').points, [18, 42, 66])
Esempio n. 6
0
 def test_scalar_time_coord_no_match(self):
     cube = self._cube(0)
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertIsNone(sub_cube)
Esempio n. 7
0
 def test_no_coord_match(self):
     cube = self._1d_cube()
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertIsNone(sub_cube)
Esempio n. 8
0
 def test_none(self):
     cube = self._1d_cube()
     constraint = TimeConstraint(hour=None)
     sub_cube = constraint.extract(cube)
     self.assertIs(sub_cube, cube)
Esempio n. 9
0
 def test_default(self):
     cube = self._1d_cube()
     constraint = TimeConstraint()
     sub_cube = constraint.extract(cube)
     self.assertIs(sub_cube, cube)
Esempio n. 10
0
 def test_1d_data(self):
     cube = self._1d_cube()
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertArrayEqual(sub_cube.coord('time').points, [18, 42, 66])
Esempio n. 11
0
 def test_scalar_time_coord_no_match(self):
     cube = self._cube(0)
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertIsNone(sub_cube)
Esempio n. 12
0
 def test_no_coord_match(self):
     cube = self._1d_cube()
     constraint = TimeConstraint(hour=12)
     sub_cube = constraint.extract(cube)
     self.assertIsNone(sub_cube)
Esempio n. 13
0
 def test_none(self):
     cube = self._1d_cube()
     constraint = TimeConstraint(hour=None)
     sub_cube = constraint.extract(cube)
     self.assertIs(sub_cube, cube)
Esempio n. 14
0
 def test_default(self):
     cube = self._1d_cube()
     constraint = TimeConstraint()
     sub_cube = constraint.extract(cube)
     self.assertIs(sub_cube, cube)