def test_skewt_shade_area_kwargs(test_profile): """Test shading areas on a SkewT plot with kwargs.""" p, t, tp = test_profile fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig) skew.plot(p, t, 'r') skew.plot(p, tp, 'k') skew.shade_area(p, t, tp, facecolor='m') return fig
def test_skewt_shade_area_invalid(test_profile): """Test shading areas on a SkewT plot.""" p, t, tp = test_profile fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig) skew.plot(p, t, 'r') skew.plot(p, tp, 'k') with pytest.raises(ValueError): skew.shade_area(p, t, tp, which='positve')
def test_skewt_shade_area(test_profile): """Test shading areas on a SkewT plot.""" p, t, tp = test_profile fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig) skew.plot(p, t, 'r') skew.plot(p, tp, 'k') skew.shade_area(p, t, tp) return fig
def test_skewt_shade_area(test_profile): """Test shading areas on a SkewT plot.""" p, t, tp = test_profile fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig) skew.plot(p, t, 'r') skew.plot(p, tp, 'k') skew.shade_area(p, t, tp) skew.ax.set_xlim(-50, 50) return fig
def test_skewt_shade_area_kwargs(test_profile): """Test shading areas on a SkewT plot with kwargs.""" p, t, tp = test_profile with matplotlib.rc_context({'axes.autolimit_mode': 'data'}): fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig) skew.plot(p, t, 'r') skew.plot(p, tp, 'k') skew.shade_area(p, t, tp, facecolor='m') skew.ax.set_xlim(-50, 50) return fig
def test_skewt_shade_area(test_profile): """Test shading areas on a SkewT plot.""" p, t, tp = test_profile with matplotlib.rc_context({'axes.autolimit_mode': 'data'}): fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig, aspect='auto') skew.plot(p, t, 'r') skew.plot(p, tp, 'k') skew.shade_area(p, t, tp) skew.ax.set_xlim(-50, 50) skew.ax.set_ylim(1000, 100) return fig
def test_skewt_shade_area_kwargs(test_profile): """Test shading areas on a SkewT plot with kwargs.""" p, t, _, tp = test_profile with matplotlib.rc_context({'axes.autolimit_mode': 'data'}): fig = plt.figure(figsize=(9, 9)) skew = SkewT(fig, aspect='auto') skew.plot(p, t, 'r') skew.plot(p, tp, 'k') skew.shade_area(p, t, tp, facecolor='m') skew.ax.set_xlim(-50, 50) skew.ax.set_ylim(1000, 100) # This works around the fact that newer pint versions default to degrees_Celsius skew.ax.set_xlabel('degC') return fig
# automatically added fig = plt.figure(figsize=(9, 9)) # The rotation keyword changes how skewed the temperature lines are. MetPy has # a default skew of 30 degrees skew = SkewT(fig, rotation=45) ax = skew.ax # Shade every other section between isotherms x1 = np.linspace(-100, 40, 8) # The starting x values for the shaded regions x2 = np.linspace(-90, 50, 8) # The ending x values for the shaded regions y = [1050, 100] # The range of y values that the shades regions should cover for i in range(0, 8): skew.shade_area(y=y, x1=x1[i], x2=x2[i], color='limegreen', alpha=0.25, zorder=1) # Choose starting temperatures in Kelvin for the dry adiabats t0 = units.K * np.arange(243.15, 444.15, 10) skew.plot_dry_adiabats(t0=t0, linestyles='solid', colors='tan', linewidths=1.5) # Choose starting temperatures in Kelvin for the moist adiabats t0 = units.K * np.arange(281.15, 306.15, 4) skew.plot_moist_adiabats(t0=t0, linestyles='solid', colors='lime', linewidth=1.5) # Choose mixing ratios
def core_ens(p, T, Td, u, v, p2, T2, Td2, **kwargs): #from IPython import embed; embed() T = T.to(units.K) Td = Td.to(units.K) Tmean = T.mean(axis=0) Tdmean = Td.mean(axis=0) pmean = p.mean(axis=0) umean, vmean = u.mean(axis=0), v.mean(axis=0) Tstd = np.std(T.data, axis=0) * units.K Tdstd = np.std(Td.data, axis=0) * units.K # Calculate the parcel profile. parcel_prof = mpcalc.parcel_profile(pmean, Tmean[0], Tdmean[0]).to('degC') # Create a new figure. The dimensions here give a good aspect ratio fig = plt.figure(figsize=(8, 8)) skew = SkewT(fig, rotation=45) # Plot a zero degree isotherm skew.ax.axvline(0, color='k', linestyle='--', linewidth=1) # Add the relevant special lines skew.plot_dry_adiabats(lw=.5) skew.plot_moist_adiabats(lw=.5) skew.plot_mixing_lines(lw=.5) # Plot the data using normal plotting functions, in this case using # log scaling in Y, as dictated by the typical meteorological plot skew.shade_area(pmean, Tmean - Tstd, Tmean + Tstd, color='r', label='std$_{ens}$ mean$_{dom}$ T$_{fc}$') skew.shade_area(pmean, Tdmean - Tdstd, Tdmean + Tdstd, color='g', label='std$_{ens}$ mean$_{dom}$ Td$_{fc}$') #skew.plot(p, Tmean+np.std(T), '-', color='grey', lw=1, label='p.999(T)') skew.plot(pmean, Tmean, 'r:', ms=3, lw=1, label='mean$_{ens, dom}$ T$_{fc}$') skew.plot(pmean, Tdmean, 'g:', ms=3, lw=1, label='mean$_{ens, dom}$ Td$_{fc}$') skew.plot_barbs(pmean, umean, vmean) # Plot the parcel profile as a black line skew.plot(pmean, parcel_prof, 'k', linewidth=.5) # Shade areas of CAPE and CIN skew.shade_cin(pmean, Tmean, parcel_prof, alpha=0.2) skew.shade_cape(pmean, Tmean, parcel_prof, alpha=0.2) # nature skew.plot(p2, T2, 'r.-', ms=5, lw=2, label='mean$_{ens, dom}$ T$_{nature}$') skew.plot(p2, Td2, 'g.-', ms=5, lw=2, label='mean$_{ens, dom}$ Td$_{nature}$') skew.ax.set_ylim(1000, 180) skew.ax.set_xlim(-20, 40) plt.legend(loc='lower left') plt.title(kwargs.get('title')) fname = kwargs.get('saveto', 'profile.png') fig.savefig(fname) print(fname, 'saved.') plt.close()