예제 #1
0
 def test_positive(self):
     # Check we can interpolate from a Cube defined over [0, 360).
     cube = self._create_cube([0, 90, 180, 270])
     samples = [('longitude', range(-360, 720, 45))]
     result = interpolate.linear(cube, samples)
     normalise_order(result)
     self.assertCMLApproxData(result,
                              ('analysis', 'interpolation', 'linear',
                               'circular_wrapping', 'positive'))
예제 #2
0
 def test_positive(self):
     # Check we can interpolate from a Cube defined over [0, 360).
     cube = self._create_cube([0, 90, 180, 270])
     samples = [('longitude', range(-360, 720, 45))]
     result = interpolate.linear(cube, samples)
     normalise_order(result)
     self.assertCMLApproxData(result, ('analysis', 'interpolation',
                                       'linear', 'circular_wrapping',
                                       'positive'))
예제 #3
0
 def test_symmetric(self):
     # Check we can interpolate from a Cube defined over [-180, 180).
     cube = self._create_cube([-180, -90, 0, 90])
     samples = [('longitude', np.arange(-360, 720, 45))]
     result = interpolate.linear(cube, samples, extrapolation_mode='nan')
     normalise_order(result)
     self.assertCMLApproxData(result, ('analysis', 'interpolation',
                                       'linear', 'circular_wrapping',
                                       'symmetric'))
예제 #4
0
 def test_symmetric(self):
     # Check we can interpolate from a Cube defined over [-180, 180).
     cube = self._create_cube([-180, -90, 0, 90])
     samples = [('longitude', np.arange(-360, 720, 45))]
     result = interpolate.linear(cube, samples, extrapolation_mode='nan')
     normalise_order(result)
     self.assertCMLApproxData(result,
                              ('analysis', 'interpolation', 'linear',
                               'circular_wrapping', 'symmetric'))
예제 #5
0
    def test_contrived_non_spherical_curl2(self):
        # testing :
        # F(x, y, z) = (z^3, x+2, y^2)
        # curl( F(x, y, z) ) = (2y, 3z^2, 1)

        cube = build_cube(np.empty((10, 25, 50)), spherical=False)

        x_pts, x_ones, y_pts, y_ones, z_pts, z_ones = self.get_coord_pts(cube)

        u = cube.copy(data=pow(z_pts, 3) * x_ones * y_ones)
        v = cube.copy(data=z_ones * (x_pts + 2.) * y_ones)
        w = cube.copy(data=z_ones * x_ones * pow(y_pts, 2.))
        u.rename('u_wind')
        v.rename('v_wind')
        w.rename('w_wind')

        r = iris.analysis.calculus.curl(u, v, w)

        # TODO #235 When regridding is not nearest neighbour: the commented out code could be made to work
        # r[0].data should now be tending towards result.data as the resolution of the grid gets higher.
        #        result = r[0].copy(data=True)
        #        x_pts, x_ones, y_pts, y_ones, z_pts, z_ones = self.get_coord_pts(result)
        #        result.data = y_pts * 2. * x_ones * z_ones
        #        print(repr(r[0].data[0:1, 0:5, 0:25:5]))
        #        print(repr(result.data[0:1, 0:5, 0:25:5]))
        #        np.testing.assert_array_almost_equal(result.data, r[0].data, decimal=2)
        #
        #        result = r[1].copy(data=True)
        #        x_pts, x_ones, y_pts, y_ones, z_pts, z_ones = self.get_coord_pts(result)
        #        result.data = pow(z_pts, 2) * x_ones * y_ones
        #        np.testing.assert_array_almost_equal(result.data, r[1].data, decimal=6)

        result = r[2].copy()
        result.data = result.data * 0 + 1
        np.testing.assert_array_almost_equal(result.data, r[2].data, decimal=4)

        normalise_order(r[1])
        self.assertCML(
            r, ('analysis', 'calculus', 'curl_contrived_cartesian2.cml'),
            checksum=False)
    def test_contrived_non_spherical_curl2(self):
        # testing :
        # F(x, y, z) = (z^3, x+2, y^2)
        # curl( F(x, y, z) ) = (2y, 3z^2, 1)

        cube = build_cube(np.empty((10, 25, 50)), spherical=False)

        x_pts, x_ones, y_pts, y_ones, z_pts, z_ones = self.get_coord_pts(cube)

        u = cube.copy(data=pow(z_pts, 3) * x_ones * y_ones)
        v = cube.copy(data=z_ones * (x_pts + 2.) * y_ones)
        w = cube.copy(data=z_ones * x_ones * pow(y_pts, 2.))
        u.rename('u_wind')
        v.rename('v_wind')
        w.rename('w_wind')

        r = iris.analysis.calculus.curl(u, v, w)


        # TODO #235 When regridding is not nearest neighbour: the commented out code could be made to work
        # r[0].data should now be tending towards result.data as the resolution of the grid gets higher.
#        result = r[0].copy(data=True)
#        x_pts, x_ones, y_pts, y_ones, z_pts, z_ones = self.get_coord_pts(result)
#        result.data = y_pts * 2. * x_ones * z_ones
#        print repr(r[0].data[0:1, 0:5, 0:25:5])
#        print repr(result.data[0:1, 0:5, 0:25:5])
#        np.testing.assert_array_almost_equal(result.data, r[0].data, decimal=2)
#
#        result = r[1].copy(data=True)
#        x_pts, x_ones, y_pts, y_ones, z_pts, z_ones = self.get_coord_pts(result)
#        result.data = pow(z_pts, 2) * x_ones * y_ones
#        np.testing.assert_array_almost_equal(result.data, r[1].data, decimal=6)

        result = r[2].copy()
        result.data = result.data * 0  + 1
        np.testing.assert_array_almost_equal(result.data, r[2].data, decimal=4)

        normalise_order(r[1])
        self.assertCML(r, ('analysis', 'calculus', 'curl_contrived_cartesian2.cml'), checksum=False)