示例#1
0
 def test_src_y_points_and_bounds(self):
     sy_points = np.arange(self.ny - 1)
     emsg = 'Invalid number of src y-coordinate bounds'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#2
0
 def test_grid_x_bounds(self):
     gx_bounds = self.gx_bounds.flatten()
     emsg = 'Expected 2d contiguous grid x-coordinate bounds'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, gx_bounds,
             self.gy_bounds)
示例#3
0
 def test_regrid_irregular_src_y_points(self):
     self.sy_points[0] = self.sy_points[0] * 1.01
     emsg = 'Expected src y-coordinate points to be regular'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#4
0
 def test_src_y_bounds(self):
     sy_bounds = self.sy_bounds.reshape(1, -1)
     emsg = 'Expected 1d contiguous src y-coordinate bounds'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
             sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#5
0
 def test_src_x_points(self):
     sx_points = self.sx_points.reshape(1, -1)
     emsg = 'Expected 1d src x-coordinate points'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#6
0
 def test_data(self):
     data = self.data.flatten()
     emsg = 'Expected at least 2d src data'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#7
0
 def test_src_y_points_and_bounds(self):
     sy_points = np.arange(self.ny - 1)
     emsg = 'Invalid number of src y-coordinate bounds'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#8
0
 def test_data(self):
     data = self.data.flatten()
     emsg = 'Expected at least 2d src data'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#9
0
 def test_src_y_bounds(self):
     sy_bounds = self.sy_bounds.reshape(1, -1)
     emsg = 'Expected 1d contiguous src y-coordinate bounds'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             self.sy_points, sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#10
0
 def test_src_x_points(self):
     sx_points = self.sx_points.reshape(1, -1)
     emsg = 'Expected 1d src x-coordinate points'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#11
0
 def test_regrid_irregular_src_y_points(self):
     self.sy_points[0] = self.sy_points[0] * 1.01
     emsg = 'Expected src y-coordinate points to be regular'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#12
0
 def test_src_x_dim(self):
     # Positive index beyond last dimension.
     sx_dim = self.data.ndim
     emsg = 'Invalid src x-coordinate dimension'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#13
0
 def test_src_y_dim(self):
     # Negative index before first dimension.
     sy_dim = -(self.data.ndim + 1)
     emsg = 'Invalid src y-coordinate dimension'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#14
0
 def test_grid_x_bounds_and_y_bounds(self):
     shape = np.array(self.gy_bounds.shape) + 1
     gy_bounds = np.empty(shape)
     emsg = 'Misaligned grid'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             gy_bounds)
示例#15
0
 def test_grid_y_bounds(self):
     gy_bounds = self.gy_bounds.flatten()
     emsg = 'Expected 2d contiguous grid y-coordinate bounds'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, gy_bounds)
示例#16
0
 def test_grid_x_bounds_and_y_bounds(self):
     shape = np.array(self.gy_bounds.shape) + 1
     gy_bounds = np.empty(shape)
     emsg = 'Misaligned grid'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, gy_bounds)
示例#17
0
 def test_src_y_dim(self):
     # Negative index before first dimension.
     sy_dim = -(self.data.ndim + 1)
     emsg = 'Invalid src y-coordinate dimension'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#18
0
 def test_src_x_dim(self):
     # Positive index beyond last dimension.
     sx_dim = self.data.ndim
     emsg = 'Invalid src x-coordinate dimension'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(self.data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#19
0
 def test_src_y_points_and_data(self):
     shape = list(self.shape)
     shape[self.sy_dim] = self.ny - 1
     data = np.empty(shape)
     emsg = 'src y-coordinate points .* do not align'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(data, self.sx_points, self.sx_bounds, self.sy_points,
             self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
             self.gy_bounds)
示例#20
0
 def test_src_y_points_and_data(self):
     shape = list(self.shape)
     shape[self.sy_dim] = self.ny - 1
     data = np.empty(shape)
     emsg = 'src y-coordinate points .* do not align'
     with self.assertRaisesRegexp(ValueError, emsg):
         agg(data, self.sx_points, self.sx_bounds,
             self.sy_points, self.sy_bounds,
             self.sx_dim, self.sy_dim,
             self.gx_bounds, self.gy_bounds)
示例#21
0
 def test_regrid_ok_negative_sy_dim(self):
     self.sy_dim = -(self.data.ndim - self.sy_dim)
     result = agg(self.data, self.sx_points, self.sx_bounds,
                  self.sy_points, self.sy_bounds,
                  self.sx_dim, self.sy_dim,
                  self.gx_bounds, self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#22
0
 def test_regrid_ok_src_y_points_cast(self):
     self.sy_points = np.asarray(self.sy_points, dtype=np.float32)
     result = agg(self.data, self.sx_points, self.sx_bounds,
                  self.sy_points, self.sy_bounds,
                  self.sx_dim, self.sy_dim,
                  self.gx_bounds, self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#23
0
 def test_regrid_ok_grid_brhc_out_of_bounds(self):
     self.gy_bounds[-1, -1] = self.gy_bounds[-1, -1] * 2
     result = agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
                  self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
                  self.gy_bounds)
     expected = self._expected()
     expected[1, 1] = ma.masked
     assert_array_equal(result, self._expected())
示例#24
0
 def test_regrid_ok_transpose(self):
     self.data = self.data.T
     sy_dim, sx_dim = self.sx_dim, self.sy_dim
     result = agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
                  self.sy_bounds, sx_dim, sy_dim, self.gx_bounds,
                  self.gy_bounds)
     expected = self._expected(transpose=True)
     assert_array_equal(result, expected)
示例#25
0
 def test_regrid_ok_transpose(self):
     self.data = self.data.T
     sy_dim, sx_dim = self.sx_dim, self.sy_dim
     result = agg(self.data, self.sx_points, self.sx_bounds,
                  self.sy_points, self.sy_bounds,
                  sx_dim, sy_dim,
                  self.gx_bounds, self.gy_bounds)
     expected = self._expected(transpose=True)
     assert_array_equal(result, expected)
示例#26
0
 def test_regrid_ok_grid_brhc_out_of_bounds(self):
     self.gy_bounds[-1, -1] = self.gy_bounds[-1, -1] * 2
     result = agg(self.data, self.sx_points, self.sx_bounds,
                  self.sy_points, self.sy_bounds,
                  self.sx_dim, self.sy_dim,
                  self.gx_bounds, self.gy_bounds)
     expected = self._expected()
     expected[1, 1] = ma.masked
     assert_array_equal(result, self._expected())
示例#27
0
 def test_regrid_ok_src_masked(self):
     self.data = ma.asarray(self.data)
     self.data[2, 3] = ma.masked  # tlhc 1x masked of 6x src cells
     self.data[2, 4] = ma.masked  # trhc 2x masked of 6x src cells
     self.data[2, 5] = ma.masked
     self.data[3, 2] = ma.masked  # blhc 3x masked of 6x src cells
     self.data[3, 3] = ma.masked
     self.data[4, 3] = ma.masked
     self.data[3, 4] = ma.masked  # brhc 4x masked of 6x src cells
     self.data[3, 5] = ma.masked
     self.data[4, 4] = ma.masked
     self.data[4, 5] = ma.masked
     result = agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
                  self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
                  self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#28
0
 def test_regrid_ok_src_masked(self):
     self.data = ma.asarray(self.data)
     self.data[2, 3] = ma.masked # tlhc 1x masked of 6x src cells
     self.data[2, 4] = ma.masked # trhc 2x masked of 6x src cells
     self.data[2, 5] = ma.masked
     self.data[3, 2] = ma.masked # blhc 3x masked of 6x src cells
     self.data[3, 3] = ma.masked
     self.data[4, 3] = ma.masked
     self.data[3, 4] = ma.masked # brhc 4x masked of 6x src cells
     self.data[3, 5] = ma.masked
     self.data[4, 4] = ma.masked
     self.data[4, 5] = ma.masked
     result = agg(self.data, self.sx_points, self.sx_bounds,
                  self.sy_points, self.sy_bounds,
                  self.sx_dim, self.sy_dim,
                  self.gx_bounds, self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#29
0
 def test_regrid_ok(self):
     result = agg(self.data, self.sx_points, self.sx_bounds,
                  self.sy_points, self.sy_bounds,
                  self.sx_dim, self.sy_dim,
                  self.gx_bounds, self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#30
0
 def test_regrid_ok_negative_sy_dim(self):
     self.sy_dim = -(self.data.ndim - self.sy_dim)
     result = agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
                  self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
                  self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#31
0
 def test_regrid_ok_src_y_points_cast(self):
     self.sy_points = np.asarray(self.sy_points, dtype=np.float32)
     result = agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
                  self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
                  self.gy_bounds)
     assert_array_equal(result, self._expected())
示例#32
0
 def test_regrid_ok(self):
     result = agg(self.data, self.sx_points, self.sx_bounds, self.sy_points,
                  self.sy_bounds, self.sx_dim, self.sy_dim, self.gx_bounds,
                  self.gy_bounds)
     assert_array_equal(result, self._expected())