Example #1
0
# Read zonal and meridional wind components from file using the xarray module.
# The components are in separate files.
ds = xr.open_mfdataset([example_data_path(f)
                        for f in ('uwnd_mean.nc', 'vwnd_mean.nc')])
uwnd = ds['uwnd']
vwnd = ds['vwnd']

# Create a VectorWind instance to handle the computations.
w = VectorWind(uwnd, vwnd)

# Compute components of rossby wave source: absolute vorticity, divergence,
# irrotational (divergent) wind components, gradients of absolute vorticity.
eta = w.absolutevorticity()
div = w.divergence()
uchi, vchi = w.irrotationalcomponent()
etax, etay = w.gradient(eta)
etax.attrs['units'] = 'm**-1 s**-1'
etay.attrs['units'] = 'm**-1 s**-1'

# Combine the components to form the Rossby wave source term.
S = eta * -1. * div - (uchi * etax + vchi * etay)

# Pick out the field for December at 200 hPa.
S_dec = S[S['time.month'] == 12]

# Plot Rossby wave source.
clevs = [-30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30]
ax = plt.subplot(111, projection=ccrs.PlateCarree(central_longitude=180))
S_dec *= 1e11
fill = S_dec[0].plot.contourf(ax=ax, levels=clevs, cmap=plt.cm.RdBu_r,
Example #2
0
# Read zonal and meridional wind components from file using the xarray module.
# The components are in separate files.
ds = xr.open_mfdataset(
    [example_data_path(f) for f in ('uwnd_mean.nc', 'vwnd_mean.nc')])
uwnd = ds['uwnd']
vwnd = ds['vwnd']

# Create a VectorWind instance to handle the computations.
w = VectorWind(uwnd, vwnd)

# Compute components of rossby wave source: absolute vorticity, divergence,
# irrotational (divergent) wind components, gradients of absolute vorticity.
eta = w.absolutevorticity()
div = w.divergence()
uchi, vchi = w.irrotationalcomponent()
etax, etay = w.gradient(eta)
etax.attrs['units'] = 'm**-1 s**-1'
etay.attrs['units'] = 'm**-1 s**-1'

# Combine the components to form the Rossby wave source term.
S = eta * -1. * div - (uchi * etax + vchi * etay)

# Pick out the field for December at 200 hPa.
S_dec = S[S['time.month'] == 12]

# Plot Rossby wave source.
clevs = [-30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30]
ax = plt.subplot(111, projection=ccrs.PlateCarree(central_longitude=180))
S_dec *= 1e11
fill = S_dec[0].plot.contourf(ax=ax,
Example #3
0
axs.coastlines()
axs.set_title('')
plt.savefig('tempfigs/divergence_mass.png', dpi=600, transparent=True)
plt.close()
from windspharm.xarray import VectorWind

typeofwind = 'full'
if typeofwind == 'nondivergent':
    w = VectorWind(u, v)
    u_nd, v_nd = w.nondivergentcomponent()
    u_nd.name = 'u'
    v_nd.name = 'v'
    ds = xr.merge([u_nd, v_nd])
elif typeofwind == 'irrotational':
    w = VectorWind(u, v)
    u_nd, v_nd = w.irrotationalcomponent()
    u_nd.name = 'u'
    v_nd.name = 'v'
    ds = xr.merge([u_nd, v_nd])
else:
    ds = xr.merge([u, v])
# ---- Running LCS ---- #
ntimes = 30 * 4
ftle_list = []

compute_and_save_ftle(ds)

# for dt in range(6, 33, 3):
#
import glob