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)
 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)
 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)
 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)
 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)
 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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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())
Exemple #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())
Exemple #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())
Exemple #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)
Exemple #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)
Exemple #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())
Exemple #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())
Exemple #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())
Exemple #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())
Exemple #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())
Exemple #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())
Exemple #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())