Skip to content

Commit 1ea239b

Browse files
committed
rebase and update based on changes to numpy
1 parent 9e4d75d commit 1ea239b

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/metpy/plots/declarative.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,14 @@ class SkewtPanel(PanelTraits, Panel):
587587
ylimits = Tuple(Int(), Int(), default_value=(1000, 100), allow_none=True)
588588
ylimits.__doc__ = """A tuple of y-axis limits to plot the skew-T.
589589
590-
Order is in higher pressure to lower pressure."""
590+
Order is in higher pressure to lower pressure. Assumption is that y-limit values are
591+
hPa."""
591592

592593
xlimits = Tuple(Int(), Int(), default_value=(-40, 40), allow_none=True)
593594
xlimits.__doc__ = """A tuple of x-axis limits to plot the skew-T.
594595
595-
Order is lower temperature to higher temperature."""
596+
Order is lower temperature to higher temperature. Assumption is that x-limit values are
597+
Celsius."""
596598

597599
ylabel = Unicode(default_value='pressure [hPa]')
598600
ylabel.__doc__ = """A string to plot for the y-axis label.

src/metpy/plots/skewt.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,21 +622,23 @@ def plot_labeled_skewt_lines(self):
622622
r"""Plot common skewt lines and labels.
623623
624624
This function plots the three common SkewT lines, dry adiabats, moist adiabats,
625-
and mixing ratio lines with labels using a default coloring.
625+
and mixing ratio lines with labels using a default coloring. Function assumes
626+
that temperature value limits are in Celsius and pressure value limits are in
627+
hPa.
626628
"""
627629
from metpy.constants import Cp_d, Rd
628630

629631
# Get axes x, y limits
630632
xmin, xmax = self.ax.get_xlim()
631-
ymax, ymin = self.ax.get_ylim()
633+
ymax, _ = self.ax.get_ylim()
632634

633635
# Pressure for plotting mixing ratio lines
634636
pressure = units.Quantity(np.linspace(500, ymax, 25)[::-1], 'hPa')
635637

636638
# Set plotting certain mixing ratio values
637639
mixing_ratio = units.Quantity(np.array([0.1, 0.2, 0.4, 0.6, 1, 1.5, 2, 3,
638640
4, 6, 8, 10, 13, 16, 20, 25, 30, 36, 42
639-
]).reshape(-1, 1), 'g/kg')
641+
]).reshape(-1, 1)[:, 0], 'g/kg')
640642

641643
# Calculate the dewpoint at 500 hPa based on the mixing ratio (for plotting mixing
642644
# ratio values)
@@ -674,10 +676,7 @@ def plot_labeled_skewt_lines(self):
674676

675677
# Add saturation mixing ratio labels
676678
for i in range(mixing_ratio.m.size):
677-
if mixing_ratio.m[i, 0] % 1:
678-
val = str(mixing_ratio[i, 0].m)
679-
else:
680-
val = int(mixing_ratio[i, 0].m)
679+
val = str(mixing_ratio[i].m) if mixing_ratio.m[i] % 1 else int(mixing_ratio[i].m)
681680
_ = self.ax.text(plottd.m[i], 500, f'{val}', ha='center', va='bottom',
682681
weight='bold', size=8, color='dodgerblue', clip_on=True,
683682
rotation=30)

tests/plots/test_declarative.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,8 +2247,7 @@ def test_declarative_plot_geometry_points(ccrs):
22472247
return pc.figure
22482248

22492249

2250-
@pytest.mark.mpl_image_compare(remove_text=True,
2251-
tolerance=3.27 if MPL_VERSION.startswith('3.3') else 0.03)
2250+
@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.03)
22522251
def test_declarative_skewt_plot():
22532252
"""Test plotting of a simple skewT with declarative."""
22542253
date = datetime(2016, 5, 22, 0)
@@ -2276,8 +2275,7 @@ def test_declarative_skewt_plot():
22762275
return panel.figure
22772276

22782277

2279-
@pytest.mark.mpl_image_compare(remove_text=True,
2280-
tolerance=3.24 if MPL_VERSION.startswith('3.3') else 0.03)
2278+
@pytest.mark.mpl_image_compare(remove_text=True, tolerance = 0.03)
22812279
def test_declarative_skewt_plot_shade_cape():
22822280
"""Test plotting of a skewT with declarative and shading."""
22832281
from metpy.calc import parcel_profile

0 commit comments

Comments
 (0)