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