Skip to content

Commit

Permalink
Add Stüve, Emagram plots
Browse files Browse the repository at this point in the history
Stüve and Emagram plots are enabled as child classes of SkewT parent class.
The child classes inherit plotting capabilities from SkewT (e.g. data, wind barbs, dry and saturated adiabats, and mixing ratio lines).
  • Loading branch information
cdholmes committed Sep 9, 2024
1 parent 058c0a2 commit 06ea4c6
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions src/metpy/plots/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,103 @@ def shade_cin(self, pressure, t, t_parcel, dewpoint=None, **kwargs):
**kwargs)


@exporter.export
class Stuve(SkewT):
r"""Make Stüve plots of data.
Stüve plots are are a thermodynamic diagram with temperature on the x-axis and
pressure scaled by p^(R/cp)=p^0.286 on the y-axis. This class is derived from the SkewT class and

Check failure on line 752 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (E501)

src/metpy/plots/skewt.py:752:96: E501 Line too long (101 > 95)
has the same capabilities for plotting data, wind barbs, dry and saturated

Check failure on line 753 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (W291)

src/metpy/plots/skewt.py:753:79: W291 Trailing whitespace
adiabats, and mixing ratio lines.
Attributes
----------
ax : `matplotlib.axes.Axes`
The underlying Axes instance, which can be used for calling additional
plot functions (e.g. `axvline`)
"""

Check failure on line 762 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (D204)

src/metpy/plots/skewt.py:749:5: D204 1 blank line required after class docstring
def __init__(self, *args, rotation=0, aspect='auto', **kwargs):
r"""Create Stüve plots.
Parameters
----------
fig : matplotlib.figure.Figure, optional
Source figure to use for plotting. If none is given, a new
:class:`matplotlib.figure.Figure` instance will be created.
rotation : float or int, optional
This value is ignored for Stüve plots (included only for compatibility with SkewT)

Check failure on line 772 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (W291)

src/metpy/plots/skewt.py:772:95: W291 Trailing whitespace
subplot : tuple[int, int, int] or `matplotlib.gridspec.SubplotSpec` instance, optional
Controls the size/position of the created subplot. This allows creating
the skewT as part of a collection of subplots. If subplot is a tuple, it
should conform to the specification used for
:meth:`matplotlib.figure.Figure.add_subplot`. The
:class:`matplotlib.gridspec.SubplotSpec`
can be created by using :class:`matplotlib.gridspec.GridSpec`.
rect : tuple[float, float, float, float], optional
Rectangle (left, bottom, width, height) in which to place the axes. This
allows the user to place the axes at an arbitrary point on the figure.
aspect : float, int, or Literal['auto'], optional
Aspect ratio (i.e. ratio of y-scale to x-scale) to maintain in the plot.
Defaults to ``'auto'`` which tells matplotlib to handle
the aspect ratio automatically.
"""
super().__init__(*args, **kwargs, rotation=0, aspect=aspect)

Check warning on line 789 in src/metpy/plots/skewt.py

View check run for this annotation

Codecov / codecov/patch

src/metpy/plots/skewt.py#L789

Added line #L789 was not covered by tests

# Forward and inverse functions for Stuve pressure coordinate scaling
f = lambda p: p**0.286

Check failure on line 792 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (E731)

src/metpy/plots/skewt.py:792:9: E731 Do not assign a `lambda` expression, use a `def`
g = lambda p: p**(1/0.286)

Check failure on line 793 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (E731)

src/metpy/plots/skewt.py:793:9: E731 Do not assign a `lambda` expression, use a `def`

Check failure on line 793 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (E226)

src/metpy/plots/skewt.py:793:28: E226 Missing whitespace around arithmetic operator

Check warning on line 793 in src/metpy/plots/skewt.py

View check run for this annotation

Codecov / codecov/patch

src/metpy/plots/skewt.py#L792-L793

Added lines #L792 - L793 were not covered by tests

# Set the yaxis as Stuve
self.ax.set_yscale('function',functions=(f, g))

Check warning on line 796 in src/metpy/plots/skewt.py

View check run for this annotation

Codecov / codecov/patch

src/metpy/plots/skewt.py#L796

Added line #L796 was not covered by tests


@exporter.export
class Emagram(SkewT):
r"""Make Emagram plots of data.
Emagram plots are T log-P thermodynamic diagrams. They differ from SkewT
in that the T axis is not skewed. This class is derived from the SkewT class and
has the same capabilities for plotting data, wind barbs, dry and saturated

Check failure on line 805 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (W291)

src/metpy/plots/skewt.py:805:79: W291 Trailing whitespace
adiabats, and mixing ratio lines.
Attributes
----------
ax : `matplotlib.axes.Axes`
The underlying Axes instance, which can be used for calling additional
plot functions (e.g. `axvline`)
"""

Check failure on line 814 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (D204)

src/metpy/plots/skewt.py:801:5: D204 1 blank line required after class docstring
def __init__(self, *args, rotation=0, **kwargs):
r"""Create Emagram plots.
Parameters
----------
fig : matplotlib.figure.Figure, optional
Source figure to use for plotting. If none is given, a new
:class:`matplotlib.figure.Figure` instance will be created.
rotation : float or int, optional
This value is ignored for Emagram plots (included only for compatibility with SkewT)

Check failure on line 824 in src/metpy/plots/skewt.py

View workflow job for this annotation

GitHub Actions / Run Lint Tools

Ruff (E501)

src/metpy/plots/skewt.py:824:96: E501 Line too long (97 > 95)
subplot : tuple[int, int, int] or `matplotlib.gridspec.SubplotSpec` instance, optional
Controls the size/position of the created subplot. This allows creating
the skewT as part of a collection of subplots. If subplot is a tuple, it
should conform to the specification used for
:meth:`matplotlib.figure.Figure.add_subplot`. The
:class:`matplotlib.gridspec.SubplotSpec`
can be created by using :class:`matplotlib.gridspec.GridSpec`.
rect : tuple[float, float, float, float], optional
Rectangle (left, bottom, width, height) in which to place the axes. This
allows the user to place the axes at an arbitrary point on the figure.
aspect : float, int, or Literal['auto'], optional
Aspect ratio (i.e. ratio of y-scale to x-scale) to maintain in the plot.
Defaults to ``'auto'`` tells matplotlib to handle
the aspect ratio automatically.
"""
super().__init__(*args, **kwargs, rotation=0)

Check warning on line 841 in src/metpy/plots/skewt.py

View check run for this annotation

Codecov / codecov/patch

src/metpy/plots/skewt.py#L841

Added line #L841 was not covered by tests


@exporter.export
class Hodograph:
r"""Make a hodograph of wind data.
Expand Down

0 comments on commit 06ea4c6

Please sign in to comment.