Skip to content

Commit

Permalink
Added test and requested alterations
Browse files Browse the repository at this point in the history
Reset pmin to be 600 hPa instead of 60pct of max pressure
Added test to hit edge case where user specifies kelvin t0
  • Loading branch information
jibbals committed Oct 29, 2019
1 parent 0d05983 commit 24c0590
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/metpy/plots/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,13 @@ def plot_mixing_lines(self, w=None, p=None, **kwargs):

# Set pressure range if necessary
if p is None:
# from highest pressure to 60% of highest pressure
# from highest pressure to 600 hPa
pmax = max(self.ax.get_ylim())
p = np.linspace(0.6 * pmax, pmax) * self.ax.yaxis.units
pmin = units.Quantity(600, 'hPa').to(self.ax.yaxis.units)
p = np.linspace(pmin, pmax) * self.ax.yaxis.units

# Dewpoint contours calculated and converted to xaxis units
td = dewpoint(vapor_pressure(p, w)).to(self.ax.xaxis.units)
# Dewpoint temperature profiles
td = dewpoint(vapor_pressure(p, w))

# Assemble data for plotting
linedata = [np.vstack((t.m, p.m)).T for t in td]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plots/baseline/test_skewt_adiabat_units.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plots/baseline/test_skewt_api_units.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions tests/plots/test_skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ def test_skewt_adiabat_units():
return fig


@pytest.mark.mpl_image_compare(tolerance=.027, remove_text=False, style='default')
def test_skewt_adiabat_kelvin_base():
"""Test adiabats and mixing lines can handle different units."""
with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig, rotation=45)
p = np.linspace(950, 100, 10) * units.hPa
t = (np.linspace(18, -30, 10) * units.degC).to(units.degK)

skew.plot(p, t, 'r')

# At this point the xaxis is actually degC
# Add lines using kelvin base
t0 = (np.linspace(-20, 40, 5) * units.degC).to(units.degK)
skew.plot_dry_adiabats(t0=t0)
# add lines with no units (but using kelvin)
t0 = np.linspace(253.15, 313.15, 5)
skew.plot_moist_adiabats(t0=t0)
skew.plot_mixing_lines()

return fig

@pytest.mark.mpl_image_compare(tolerance=0. if matplotlib.__version__ >= '3.2' else 30.,
remove_text=True, style='default')
def test_skewt_default_aspect_empty():
Expand Down

0 comments on commit 24c0590

Please sign in to comment.