-
Notifications
You must be signed in to change notification settings - Fork 447
Height Scale for SkewT #3853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Height Scale for SkewT #3853
Changes from 10 commits
d874c4d
4a745b0
4afaa8c
4c06fd6
c096ef6
5502645
bceeae9
84f4675
d57c0c0
45d9627
d80f260
af8c385
af449b1
699cfcc
904abb5
7c3c93a
35e2a50
2bbe602
4a05f55
8b7cd8a
7324860
6a2b441
c8b598b
76c0261
1c446fe
989e094
c7086da
9fb5b6e
3f8760f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,13 +17,15 @@ | |||||
| from matplotlib.patches import Circle | ||||||
| from matplotlib.projections import register_projection | ||||||
| import matplotlib.spines as mspines | ||||||
| from matplotlib.ticker import MultipleLocator, NullFormatter, ScalarFormatter | ||||||
| from matplotlib.ticker import (MultipleLocator, FixedLocator, NullFormatter, | ||||||
| ScalarFormatter, NullLocator) | ||||||
| import matplotlib.transforms as transforms | ||||||
|
Check failure on line 22 in src/metpy/plots/skewt.py
|
||||||
| import numpy as np | ||||||
|
|
||||||
| from ._util import colored_line | ||||||
| from ..calc import dewpoint, dry_lapse, el, lcl, moist_lapse, vapor_pressure | ||||||
| from ..calc import (dewpoint, dry_lapse, el, lcl, moist_lapse, vapor_pressure, | ||||||
| pressure_to_height_std, height_to_pressure_std) | ||||||
| from ..calc.tools import _delete_masked_points | ||||||
|
Check failure on line 28 in src/metpy/plots/skewt.py
|
||||||
| from ..interpolate import interpolate_1d | ||||||
| from ..package_tools import Exporter | ||||||
| from ..units import concatenate, is_quantity, units | ||||||
|
|
@@ -261,7 +263,8 @@ | |||||
|
|
||||||
| """ | ||||||
|
|
||||||
| def __init__(self, fig=None, rotation=30, subplot=None, rect=None, aspect=80.5): | ||||||
| def __init__(self, fig=None, rotation=30, subplot=None, rect=None, | ||||||
| aspect=80.5, show_heights=False): | ||||||
| r"""Create SkewT - logP plots. | ||||||
|
|
||||||
| Parameters | ||||||
|
|
@@ -286,6 +289,10 @@ | |||||
| Aspect ratio (i.e. ratio of y-scale to x-scale) to maintain in the plot. | ||||||
| Defaults to 80.5. Passing the string ``'auto'`` tells matplotlib to handle | ||||||
| the aspect ratio automatically (this is not recommended for SkewT). | ||||||
| show_heights : boolean, optional | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
if we keep this interface, this should fix the doc builds yelling at you! |
||||||
| Flag for showing heights as a secondary y axis. | ||||||
| Calculated from pressure_to_height_std. | ||||||
| (defaults to false) | ||||||
|
|
||||||
| """ | ||||||
| if fig is None: | ||||||
|
|
@@ -335,6 +342,28 @@ | |||||
| self.dry_adiabats = None | ||||||
| self.moist_adiabats = None | ||||||
|
|
||||||
| if (show_heights): | ||||||
| # Set a secondary axis with height from pressure_to_height_standard | ||||||
| # Requires direct and inverse fctns - pressure axis and height axis | ||||||
| def pressure_axis(p): | ||||||
| return pressure_to_height_std(units.Quantity(p, 'hPa')).m_as('km') | ||||||
|
|
||||||
| def height_axis(h): | ||||||
| return height_to_pressure_std(units.Quantity(h, 'km')).m | ||||||
| # Positions the axis .12 normalized units to the left of the pressure axis | ||||||
| self.heightax = self.ax.secondary_yaxis(-0.12, | ||||||
| functions=(pressure_axis, height_axis)) | ||||||
| # Set ylim based on pressure limits | ||||||
| self.heightax.set_ylim(pressure_to_height_std(units.Quantity | ||||||
| (self.ax.get_ylim(), 'hPa'))) | ||||||
| self.heightax.yaxis.set_units(units.km) | ||||||
| self.heightax.yaxis.set_minor_locator(NullLocator()) | ||||||
| self.heightax.yaxis.set_major_formatter(ScalarFormatter()) | ||||||
| # Create ticks on the height axis counting by 1 from min to max | ||||||
| ymin, ymax = self.heightax.get_ylim() | ||||||
| yticks = np.arange(ymin, ymax + 1, 1) | ||||||
| self.heightax.yaxis.set_major_locator(FixedLocator(yticks)) | ||||||
|
|
||||||
| # Maintain a reasonable ratio of data limits. | ||||||
| self.ax.set_aspect(aspect, adjustable='box') | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you feel about this interface,
vs
etc etc etc., or something like that? To me, a height axis almost exactly straddles the line of "plot config" vs "physical parameter", so I'm torn, personally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dopplershift Mentioned on the original issue:
Which to me points to a separate method like add_heightax(). I originally interpreted the issue this way because a height axis feels a bit more like a "plot config" but in theory it shouldn't be hard to switch it around; the issue will be making sure it can dynamically update. I'll bake this up (maybe in a separate branch for now) and see what it entails