A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

7.4 KiB

In [ ]:
%matplotlib inline
import numpy as np
from netCDF4 import Dataset
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
import cartopy.crs as crs
from cartopy.feature import NaturalEarthFeature

from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords

# Open the NetCDF file
ncfile = Dataset("/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00")

# Get the sea level pressure
ctt = getvar(ncfile, "ctt", fill_nocloud=False)
slp = getvar(ncfile, "slp")


# Get the latitude and longitude points
lats, lons = latlon_coords(ctt)

# Get the cartopy mapping object
cart_proj = get_cartopy(ctt)

# Create a figure
fig = plt.figure(figsize=(12,9))
# Set the GeoAxes to the projection used by WRF
ax = plt.axes(projection=cart_proj)

# Download and add the states and coastlines
states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',
                             name='admin_1_states_provinces_shp')
ax.add_feature(states, linewidth=.5)
ax.coastlines('50m', linewidth=0.8)

# Make the contour outlines and filled contours for the smoothed sea level pressure.
levels = np.arange(-80, 20, 5)
plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors="black",
            transform=crs.PlateCarree())
plt.contourf(to_np(lons), to_np(lats), to_np(ctt), levels=levels, transform=crs.PlateCarree(),
             cmap=get_cmap("Greys"))

# Add a color bar
plt.colorbar(ax=ax, shrink=.88)

# Set the map limits.  Not really necessary, but used for demonstration.
ax.set_xlim(cartopy_xlim(ctt))
ax.set_ylim(cartopy_ylim(ctt))

# Add the gridlines
ax.gridlines(color="black", linestyle="dotted")

plt.title("Cloud Top Temperature (degC)")

plt.show()
In [ ]:
%matplotlib inline
import numpy as np
from netCDF4 import Dataset
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
import cartopy.crs as crs
from cartopy.feature import NaturalEarthFeature

from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords

# Open the NetCDF file
ncfile = Dataset("/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00")

# Get the sea level pressure
ctt = getvar(ncfile, "ctt", fill_nocloud=True, opt_thresh=1.0)
slp = getvar(ncfile, "slp")


# Get the latitude and longitude points
lats, lons = latlon_coords(ctt)

# Get the cartopy mapping object
cart_proj = get_cartopy(ctt)

# Create a figure
fig = plt.figure(figsize=(12,9))
# Set the GeoAxes to the projection used by WRF
ax = plt.axes(projection=cart_proj)

# Download and add the states and coastlines
states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',
                             name='admin_1_states_provinces_shp')
ax.add_feature(states, linewidth=.5)
ax.coastlines('50m', linewidth=0.8)

# Make the contour outlines and filled contours for the smoothed sea level pressure.
levels = np.arange(-80, 20, 5)
plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors="black",
            transform=crs.PlateCarree())
plt.contourf(to_np(lons), to_np(lats), to_np(ctt), levels=levels, transform=crs.PlateCarree(),
             cmap=get_cmap("Greys"))

# Add a color bar
plt.colorbar(ax=ax, shrink=.88)

# Set the map limits.  Not really necessary, but used for demonstration.
ax.set_xlim(cartopy_xlim(ctt))
ax.set_ylim(cartopy_ylim(ctt))

# Add the gridlines
ax.gridlines(color="black", linestyle="dotted")

plt.title("Cloud Top Temperature (degC)")

plt.show()
In [ ]:
%matplotlib inline
import numpy as np
from netCDF4 import Dataset
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
import cartopy.crs as crs
from cartopy.feature import NaturalEarthFeature

from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords

# Open the NetCDF file
ncfile = Dataset("/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00")

# Get the sea level pressure
cfrac = getvar(ncfile, "cfrac")[2, :]
slp = getvar(ncfile, "slp")


# Get the latitude and longitude points
lats, lons = latlon_coords(ctt)

# Get the cartopy mapping object
cart_proj = get_cartopy(ctt)

# Create a figure
fig = plt.figure(figsize=(12,9))
# Set the GeoAxes to the projection used by WRF
ax = plt.axes(projection=cart_proj)

# Download and add the states and coastlines
states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',
                             name='admin_1_states_provinces_shp')
ax.add_feature(states, linewidth=.5)
ax.coastlines('50m', linewidth=0.8)

# Make the contour outlines and filled contours for the smoothed sea level pressure.
levels = np.arange(0, 1.1, .1)
plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors="black",
            transform=crs.PlateCarree())
plt.contourf(to_np(lons), to_np(lats), to_np(cfrac), levels=levels, transform=crs.PlateCarree(),
             cmap=get_cmap("Greys_r"))

# Add a color bar
plt.colorbar(ax=ax, shrink=.88)

# Set the map limits.  Not really necessary, but used for demonstration.
ax.set_xlim(cartopy_xlim(ctt))
ax.set_ylim(cartopy_ylim(ctt))

# Add the gridlines
ax.gridlines(color="black", linestyle="dotted")

plt.title("Cloud Fraction")

plt.show()