Ejemplo n.º 1
0
def test_vorticity_asym():
    """Test vorticity calculation with a complicated field."""
    u = np.array([[2, 4, 8], [0, 2, 2], [4, 6, 8]]) * units('m/s')
    v = np.array([[6, 4, 8], [2, 6, 0], [2, 2, 6]]) * units('m/s')
    vort = v_vorticity(u, v, 1 * units.meters, 2 * units.meters, dim_order='yx')
    true_vort = np.array([[-1., 2., 7.], [3.5, -1.5, -6.], [-2., 0., 1.]]) / units.sec
    assert_array_equal(vort, true_vort)

    # Now try for xy ordered
    vort = v_vorticity(u.T, v.T, 1 * units.meters, 2 * units.meters, dim_order='xy')
    assert_array_equal(vort, true_vort.T)
Ejemplo n.º 2
0
def test_zero_vorticity():
    """Test vorticity calculation when zeros should be returned."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    v = v_vorticity(u, u.T, 1 * units.meter, 1 * units.meter, dim_order='xy')
    true_v = np.zeros_like(u) / units.sec
    assert_array_equal(v, true_v)
Ejemplo n.º 3
0
def test_vorticity():
    """Test vorticity for simple case."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    v = v_vorticity(u, u, 1 * units.meter, 1 * units.meter, dim_order='xy')
    true_v = np.ones_like(u) / units.sec
    assert_array_equal(v, true_v)
Ejemplo n.º 4
0
def test_vorticity():
    """Test vorticity for simple case."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    v = v_vorticity(u, u, 1 * units.meter, 1 * units.meter)
    true_v = np.ones_like(u) / units.sec
    assert_array_equal(v, true_v)
Ejemplo n.º 5
0
def test_zero_vorticity():
    """Test vorticity calculation when zeros should be returned."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    v = v_vorticity(u, u.T, 1 * units.meter, 1 * units.meter)
    true_v = np.zeros_like(u) / units.sec
    assert_array_equal(v, true_v)
Ejemplo n.º 6
0
def test_v_vorticity():
    """Test that v_vorticity wrapper works (deprecated in 0.7)."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    v = v_vorticity(u, u, 1 * units.meter, 1 * units.meter, dim_order='xy')
    true_v = np.ones_like(u) / units.sec
    assert_array_equal(v, true_v)
Ejemplo n.º 7
0
hght_500 = ds.variables['Geopotential_height'][0, lev_500, :, :]
hght_500 = ndimage.gaussian_filter(hght_500, sigma=3, order=0) * units.meter

uwnd_500 = ds.variables['u_wind'][0, lev_500, :, :] * units('m/s')
vwnd_500 = ds.variables['v_wind'][0, lev_500, :, :] * units('m/s')

#######################################
# Begin Data Calculations
# -----------------------

dx, dy = calc_dx_dy(lon, lat)

f = coriolis_parameter(np.deg2rad(lat)).to(units('1/sec'))

avor = v_vorticity(uwnd_500.T, vwnd_500.T, dx.T, dy.T).T + f

avor = ndimage.gaussian_filter(avor, sigma=3, order=0) * units('1/s')

vort_adv = advection(avor.T, [uwnd_500.T, vwnd_500.T], (dx.T, dy.T)).T * 1e9

#######################################
# Map Creation
# ------------

# Set up Coordinate System for Plot and Transforms
dproj = ds.variables['Lambert_Conformal']
globe = ccrs.Globe(ellipse='sphere',
                   semimajor_axis=dproj.earth_radius,
                   semiminor_axis=dproj.earth_radius)
datacrs = ccrs.LambertConformal(