def test_streamfunc(): """Test of Montgomery Streamfunction calculation.""" t = 287. * units.kelvin hgt = 5000. * units.meter msf = montgomery_streamfunction(hgt, t) assert_almost_equal(msf, 337468.2500 * units('m^2 s^-2'), 4)
# Make some titles ax.set_title('{:.0f} K Isentropic Pressure (hPa), Wind (kt), Relative Humidity (percent)' .format(isentlevs[level].m), loc='left') add_timestamp(ax, times[0].dt, y=0.02, high_contrast=True) fig.tight_layout() ###################################### # **Montgomery Streamfunction** # # The Montgomery Streamfunction, :math:`{\psi} = gdz + CpT`, is often desired because its # gradient is proportional to the geostrophic wind in isentropic space. This can be easily # calculated with `mpcalc.montgomery_streamfunction`. # Calculate Montgomery Streamfunction and scale by 10^-2 for plotting msf = mpcalc.montgomery_streamfunction(isenthgt, isenttmp) / 100. # Choose a level to plot, in this case 296 K level = 0 fig = plt.figure(figsize=(17., 12.)) add_metpy_logo(fig, 120, 250, size='large') ax = plt.subplot(111, projection=crs) ax.set_extent(*bounds, crs=ccrs.PlateCarree()) ax.add_feature(cfeature.COASTLINE.with_scale('50m'), linewidth=0.75) ax.add_feature(cfeature.STATES.with_scale('50m'), linewidth=0.5) # Plot the surface clevmsf = np.arange(0, 4000, 5) cs = ax.contour(lon, lat, msf[level, :, :], clevmsf, colors='k', linewidths=1.0, linestyles='solid', transform=ccrs.PlateCarree())
plt.title( '{:.0f} K Isentropic Pressure (hPa), Wind (kt), Relative Humidity (percent)' .format(isentlevs[level].m), loc='left') plt.title('VALID: {:s}'.format(str(vtimes[0])), loc='right') plt.tight_layout() ###################################### # **Montgomery Streamfunction** # # The Montgomery Streamfunction, :math:`{\psi} = gdz + CpT`, is often desired because its # gradient is proportional to the geostrophic wind in isentropic space. This can be easily # calculated with `mcalc.montgomery_streamfunction`. # Calculate Montgomery Streamfunction and scale by 10^-2 for plotting msf = mcalc.montgomery_streamfunction(isenthgt, isenttmp) / 100. # Choose a level to plot, in this case 296 K level = 0 fig = plt.figure(1, figsize=(17., 12.)) ax = plt.subplot(111, projection=crs) ax.set_extent(*bounds, crs=ccrs.PlateCarree()) ax.coastlines('50m', edgecolor='black', linewidth=0.75) ax.add_feature(states_provinces, edgecolor='black', linewidth=0.5) # Plot the surface clevmsf = np.arange(0, 4000, 5) cs = ax.contour(tlons, tlats, msf[level, :, :],
loc='left') add_timestamp(ax, isent_data['time'].values.astype('datetime64[ms]').astype('O'), y=0.02, high_contrast=True) fig.tight_layout() ###################################### # **Montgomery Streamfunction** # # The Montgomery Streamfunction, :math:`{\psi} = gdz + CpT`, is often desired because its # gradient is proportional to the geostrophic wind in isentropic space. This can be easily # calculated with `mpcalc.montgomery_streamfunction`. # Calculate Montgomery Streamfunction and scale by 10^-2 for plotting msf = mpcalc.montgomery_streamfunction(isent_data['Geopotential_height'], isent_data['temperature']).values / 100. # Choose a level to plot, in this case 296 K level = 0 fig = plt.figure(figsize=(17., 12.)) add_metpy_logo(fig, 120, 250, size='large') ax = plt.subplot(111, projection=crs) ax.set_extent(*bounds, crs=ccrs.PlateCarree()) ax.add_feature(cfeature.COASTLINE.with_scale('50m'), linewidth=0.75) ax.add_feature(cfeature.STATES.with_scale('50m'), linewidth=0.5) # Plot the surface clevmsf = np.arange(0, 4000, 5) cs = ax.contour(lon, lat,