|
|
@ -69,8 +69,10 @@ Plotting a Two-dimensional Field |
|
|
|
ax.coastlines('50m', linewidth=0.8) |
|
|
|
ax.coastlines('50m', linewidth=0.8) |
|
|
|
|
|
|
|
|
|
|
|
# Make the contour outlines and filled contours for the smoothed sea level pressure. |
|
|
|
# Make the contour outlines and filled contours for the smoothed sea level pressure. |
|
|
|
plt.contour(to_np(lons), to_np(lats), to_np(smooth_slp), 10, colors="black", transform=crs.PlateCarree()) |
|
|
|
plt.contour(to_np(lons), to_np(lats), to_np(smooth_slp), 10, colors="black", |
|
|
|
plt.contourf(to_np(lons), to_np(lats), to_np(smooth_slp), 10, transform=crs.PlateCarree(), cmap=get_cmap("jet")) |
|
|
|
transform=crs.PlateCarree()) |
|
|
|
|
|
|
|
plt.contourf(to_np(lons), to_np(lats), to_np(smooth_slp), 10, transform=crs.PlateCarree(), |
|
|
|
|
|
|
|
cmap=get_cmap("jet")) |
|
|
|
|
|
|
|
|
|
|
|
# Add a color bar |
|
|
|
# Add a color bar |
|
|
|
plt.colorbar(ax=ax, shrink=.62) |
|
|
|
plt.colorbar(ax=ax, shrink=.62) |
|
|
@ -86,6 +88,7 @@ Plotting a Two-dimensional Field |
|
|
|
|
|
|
|
|
|
|
|
plt.show() |
|
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Horizontal Interpolation to a Pressure Level |
|
|
|
Horizontal Interpolation to a Pressure Level |
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
|
|
|
|
|
|
|
|
|
@ -194,8 +197,8 @@ plot, see :ref:`cross_example`. |
|
|
|
slp = getvar(ncfile, "slp") |
|
|
|
slp = getvar(ncfile, "slp") |
|
|
|
smooth_slp = smooth2d(slp, 3) |
|
|
|
smooth_slp = smooth2d(slp, 3) |
|
|
|
ctt = getvar(ncfile, "ctt") |
|
|
|
ctt = getvar(ncfile, "ctt") |
|
|
|
z = getvar(ncfile, "z", timeidx=0) |
|
|
|
z = getvar(ncfile, "z") |
|
|
|
dbz = getvar(ncfile, "dbz", timeidx=0) |
|
|
|
dbz = getvar(ncfile, "dbz") |
|
|
|
Z = 10**(dbz/10.) |
|
|
|
Z = 10**(dbz/10.) |
|
|
|
wspd = getvar(ncfile, "wspd_wdir", units="kt")[0,:] |
|
|
|
wspd = getvar(ncfile, "wspd_wdir", units="kt")[0,:] |
|
|
|
|
|
|
|
|
|
|
@ -203,10 +206,12 @@ plot, see :ref:`cross_example`. |
|
|
|
start_point = CoordPair(lat=26.76, lon=-80.0) |
|
|
|
start_point = CoordPair(lat=26.76, lon=-80.0) |
|
|
|
end_point = CoordPair(lat=26.76, lon=-77.8) |
|
|
|
end_point = CoordPair(lat=26.76, lon=-77.8) |
|
|
|
|
|
|
|
|
|
|
|
# Compute the vertical cross-section interpolation. Also, include the lat/lon points along the cross-section |
|
|
|
# Compute the vertical cross-section interpolation. Also, include the lat/lon |
|
|
|
# in the metadata by setting latlon to True. |
|
|
|
# points along the cross-section in the metadata by setting latlon to True. |
|
|
|
z_cross = vertcross(Z, z, wrfin=ncfile, start_point=start_point, end_point=end_point, latlon=True, meta=True) |
|
|
|
z_cross = vertcross(Z, z, wrfin=ncfile, start_point=start_point, end_point=end_point, |
|
|
|
wspd_cross = vertcross(wspd, z, wrfin=ncfile, start_point=start_point, end_point=end_point, latlon=True, meta=True) |
|
|
|
latlon=True, meta=True) |
|
|
|
|
|
|
|
wspd_cross = vertcross(wspd, z, wrfin=ncfile, start_point=start_point, end_point=end_point, |
|
|
|
|
|
|
|
latlon=True, meta=True) |
|
|
|
dbz_cross = 10.0 * np.log10(z_cross) |
|
|
|
dbz_cross = 10.0 * np.log10(z_cross) |
|
|
|
|
|
|
|
|
|
|
|
# Get the lat/lon points |
|
|
|
# Get the lat/lon points |
|
|
@ -236,11 +241,11 @@ plot, see :ref:`cross_example`. |
|
|
|
|
|
|
|
|
|
|
|
# Create the filled cloud top temperature contours |
|
|
|
# Create the filled cloud top temperature contours |
|
|
|
contour_levels = [-80.0, -70.0, -60, -50, -40, -30, -20, -10, 0, 10] |
|
|
|
contour_levels = [-80.0, -70.0, -60, -50, -40, -30, -20, -10, 0, 10] |
|
|
|
ctt_contours = ax_ctt.contourf(to_np(lons), to_np(lats), to_np(ctt), contour_levels, cmap=get_cmap("Greys"), |
|
|
|
ctt_contours = ax_ctt.contourf(to_np(lons), to_np(lats), to_np(ctt), contour_levels, |
|
|
|
transform=crs.PlateCarree(), zorder=2) |
|
|
|
cmap=get_cmap("Greys"), transform=crs.PlateCarree(), zorder=2) |
|
|
|
|
|
|
|
|
|
|
|
ax_ctt.plot([start_point.lon, end_point.lon], [start_point.lat, end_point.lat], color="yellow", |
|
|
|
ax_ctt.plot([start_point.lon, end_point.lon], [start_point.lat, end_point.lat], |
|
|
|
marker="o", transform=crs.PlateCarree(), zorder=3) |
|
|
|
color="yellow", marker="o", transform=crs.PlateCarree(), zorder=3) |
|
|
|
|
|
|
|
|
|
|
|
# Create the color bar for cloud top temperature |
|
|
|
# Create the color bar for cloud top temperature |
|
|
|
cb_ctt = fig.colorbar(ctt_contours, ax=ax_ctt, shrink=.60) |
|
|
|
cb_ctt = fig.colorbar(ctt_contours, ax=ax_ctt, shrink=.60) |
|
|
@ -299,6 +304,7 @@ plot, see :ref:`cross_example`. |
|
|
|
|
|
|
|
|
|
|
|
plt.show() |
|
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Matplotlib with Basemap |
|
|
|
Matplotlib with Basemap |
|
|
|
----------------------- |
|
|
|
----------------------- |
|
|
|
|
|
|
|
|
|
|
@ -306,8 +312,7 @@ Although basemap is in maintenance mode only and becoming deprecated, it is stil |
|
|
|
widely used by many programmers. Cartopy is becoming the preferred package for |
|
|
|
widely used by many programmers. Cartopy is becoming the preferred package for |
|
|
|
mapping, however it suffers from growing pains in some areas |
|
|
|
mapping, however it suffers from growing pains in some areas |
|
|
|
(can't use latitude/longitude labels for many map projections). If you |
|
|
|
(can't use latitude/longitude labels for many map projections). If you |
|
|
|
run in to these issues, basemap is likely to accomplish what you need, despite |
|
|
|
run in to these issues, basemap is likely to accomplish what you need. |
|
|
|
slower performance. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Plotting a Two-Dimensional Field |
|
|
|
Plotting a Two-Dimensional Field |
|
|
@ -462,8 +467,8 @@ plot, see :ref:`cross_example`. |
|
|
|
slp = getvar(ncfile, "slp") |
|
|
|
slp = getvar(ncfile, "slp") |
|
|
|
smooth_slp = smooth2d(slp, 3) |
|
|
|
smooth_slp = smooth2d(slp, 3) |
|
|
|
ctt = getvar(ncfile, "ctt") |
|
|
|
ctt = getvar(ncfile, "ctt") |
|
|
|
z = getvar(ncfile, "z", timeidx=0) |
|
|
|
z = getvar(ncfile, "z") |
|
|
|
dbz = getvar(ncfile, "dbz", timeidx=0) |
|
|
|
dbz = getvar(ncfile, "dbz") |
|
|
|
Z = 10**(dbz/10.) |
|
|
|
Z = 10**(dbz/10.) |
|
|
|
wspd = getvar(ncfile, "wspd_wdir", units="kt")[0,:] |
|
|
|
wspd = getvar(ncfile, "wspd_wdir", units="kt")[0,:] |
|
|
|
|
|
|
|
|
|
|
@ -471,10 +476,12 @@ plot, see :ref:`cross_example`. |
|
|
|
start_point = CoordPair(lat=26.76, lon=-80.0) |
|
|
|
start_point = CoordPair(lat=26.76, lon=-80.0) |
|
|
|
end_point = CoordPair(lat=26.76, lon=-77.8) |
|
|
|
end_point = CoordPair(lat=26.76, lon=-77.8) |
|
|
|
|
|
|
|
|
|
|
|
# Compute the vertical cross-section interpolation. Also, include the lat/lon points along the cross-section in |
|
|
|
# Compute the vertical cross-section interpolation. Also, include the lat/lon points |
|
|
|
# the metadata by setting latlon to True. |
|
|
|
# along the cross-section in the metadata by setting latlon to True. |
|
|
|
z_cross = vertcross(Z, z, wrfin=ncfile, start_point=start_point, end_point=end_point, latlon=True, meta=True) |
|
|
|
z_cross = vertcross(Z, z, wrfin=ncfile, start_point=start_point, end_point=end_point, |
|
|
|
wspd_cross = vertcross(wspd, z, wrfin=ncfile, start_point=start_point, end_point=end_point, latlon=True, meta=True) |
|
|
|
latlon=True, meta=True) |
|
|
|
|
|
|
|
wspd_cross = vertcross(wspd, z, wrfin=ncfile, start_point=start_point, end_point=end_point, |
|
|
|
|
|
|
|
latlon=True, meta=True) |
|
|
|
dbz_cross = 10.0 * np.log10(z_cross) |
|
|
|
dbz_cross = 10.0 * np.log10(z_cross) |
|
|
|
|
|
|
|
|
|
|
|
# Get the latitude and longitude points |
|
|
|
# Get the latitude and longitude points |
|
|
@ -609,8 +616,10 @@ plotted using the standard matplotlib API. |
|
|
|
start_point = CoordPair(lat=26.76, lon=-80.0) |
|
|
|
start_point = CoordPair(lat=26.76, lon=-80.0) |
|
|
|
end_point = CoordPair(lat=26.76, lon=-77.8) |
|
|
|
end_point = CoordPair(lat=26.76, lon=-77.8) |
|
|
|
|
|
|
|
|
|
|
|
# Compute the vertical cross-section interpolation. Also, include the lat/lon points along the cross-section. |
|
|
|
# Compute the vertical cross-section interpolation. Also, include the lat/lon |
|
|
|
wspd_cross = vertcross(wspd, z, wrfin=ncfile, start_point=start_point, end_point=end_point, latlon=True, meta=True) |
|
|
|
# points along the cross-section. |
|
|
|
|
|
|
|
wspd_cross = vertcross(wspd, z, wrfin=ncfile, start_point=start_point, end_point=end_point, |
|
|
|
|
|
|
|
latlon=True, meta=True) |
|
|
|
|
|
|
|
|
|
|
|
# Create the figure |
|
|
|
# Create the figure |
|
|
|
fig = plt.figure(figsize=(12,6)) |
|
|
|
fig = plt.figure(figsize=(12,6)) |
|
|
|