I’m trying to plot a potential temperature line that passes through the point located by the temperature and pressure of an air parcel on a “skew T - lnp” chart.
As far as I understood, metpy provides two possibilities. metpy.plots.plot_dry_adiabats and metpy.calc.dry_lapse.
The former directly plots the potential temperature line, the latter provides the array of values that can be plotted by metpy.plots.SkewT.ax.plot.
I’m trying to understand why the two methods give different results (at least with my code) as in the example below. The second one seems the correct one.
Both methods require the starting point of the line. Starting point that I have to place on the border of the chart. To find the value of (T,p) I used sequentially metpy.calc.potential_temperature and metpy.calc.temperature_from_potential_temperature.
My code to draw the lines is the following:
import matplotlib.pyplot as plt
import metpy.calc as mpcalc
from metpy.units import units
from metpy.plots import SkewT
import numpy as np
# coordinate of the target point
p_trg=900*units.hPa
T_trg=15*units.degC
fig = plt.figure(figsize=(9, 5))
skew = SkewT(fig, rotation=30)
skew.ax.set_xticks(range(-15,26,5))
skew.ax.set_yticks(range(600,1010,50))
skew.ax.set_ylim(1020, 600)
skew.ax.set_xlim(-10,27)
# potential temperature of the line
theta=mpcalc.potential_temperature(p_trg, T_trg)
# point on the border of the chart and on the potential temperature line
p_bord=skew.ax.get_ylim()[0]*units.hPa
T_bord=mpcalc.temperature_from_potential_temperature(p_bord,potential_temperature=theta)
# pressure values to be included in the line (first value on the border)
pressure_levels=np.append(p_bord.magnitude, np.array([1010,900,800,700,600]))*units.hPa
# plot the dry adiabat line
skew.plot_dry_adiabats(t0=[T_bord.magnitude]*T_bord.units,pressure=pressure_levels)
# privide the value of T at each pressur level and plot them
dry_lapse_T=mpcalc.dry_lapse(pressure=pressure_levels, temperature=T_bord,reference_pressure=p_bord)
skew.ax.plot(dry_lapse_T,pressure_levels)
Thanks for any help.
If you look at the code for SkewT.plot_dry_adiabats()
, you can see that when calculating the dry adiabats the reference pressure is set to 1000 hPa. If you use that when doing your own calculation, the results then completely line up.
This could definitely be better documented. If being able to control that on the call to plot_dry_adiabats
is important to you, feel free to open a feature request (or even better, contribute the enhancement yourself!).