You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Area: PlotsPertains to producing plotsType: EnhancementEnhancement to existing functionalitygood first issueStraightforward issues suitable for new and inexperienced contributors to the project
Should be a standalone graphical element, secondary scale that pulls from the standard atmosphere conversion function we have. Should be do-able modelling off of some of matplotlib's examples with multiple scales.
Borrowing liberally from SkewT python 3 port, I added a height scale to a plot with the code below (the class is just a holder). Most would be easy to port into Metpy.SkewT with some finagling.
Two obvious problems would need to be worked out:
The axis for height doesn't show up. I've tried a number of settings with no luck.
Better(smart?) positioning of the axes and wind barbs.
I'd really like to have it separated from the plotting call
In an ideal world, it'd be dynamically updated from the y-axis in pressure coords. I'm not sure if a
matplotlib spine is enough, or if maybe we do need the separate Axes, but we use matplotlib's event
handling to update the range on the height scale
I don't think the scaling for heights is correct. Pressure is plotted with log scaling, but I don't see any
log scaling associated with the heights.
I may misunderstand, but I just want to note that the plot in the class above is not equivalent to the plot in Metpy.SkewT, but is a handler that basically does most things from the individual examples. I'm sure matplotlib event handling could be used for dynamic updates, but I'd have to look into that, since the values for the heights are computed from the limits of the plot maybe this would be easier. (?)
I'm open to another method. Just went the "easy" route of least resistance (development).
The scaline for the heights is a linear scale. I made no attempt to have a logarithmic axis as we often don't think of altitude the same way we do atmospheric pressure.
So what I'd want to merge is a patch that adds a method to the SkewT class that allows the user to turn on the height scale bar.
As far as the scaling is concerned, I think there's some confusion. You start by taking the pressure values and converting them to heights--no problem here. When we make the skewT, pressure is logarithmically spaced (not changing the values) along the y-axis. If you want the heights to properly align with the pressure values, the height axis has to be logarithmically scaled as well.
Hey @dopplershift, this may be a stupid question but...what if I already have the height values in the original sounding?
Using standard atmosphere can cause some large discrepancies sometimes, but I cannot find a way to use an array for the values of the secondary y axis instead than a function.
If you have the data, then you could just go ahead and manually annotate the plot with that using matplotlib's text()/annotate() methods. You could also use the code above and do some kind of linear/nearest neighbor interpolation as the functions.
One simple approach is, given that you have pairs of height/pressure, you could use the minor ticks with fixed labels for these like this:
If you have the data, then you could just go ahead and manually annotate the plot with that using matplotlib's text()/annotate() methods. You could also use the code above and do some kind of linear/nearest neighbor interpolation as the functions.
One simple approach is, given that you have pairs of height/pressure, you could use the minor ticks with fixed labels for these like this:
Note that with this approach, if you have a minor tick that duplicates a major tick, the minor tick won't show.
Ah ok, I was hoping for a more clean way of doing it directly into metpy api without using direct text annotations :)
I will maintain the secondary_y_axis approach for now, thanks!
I tried to create a function that just returns the array of height no matter the input but that doesn't seem to work because I don't really know when and with which arguments those transforming functions are called. Also a function that returns just the nearest value does not work... The doc says the function should expect numpy arrays as input but to me it is not clear what is passed.
Area: PlotsPertains to producing plotsType: EnhancementEnhancement to existing functionalitygood first issueStraightforward issues suitable for new and inexperienced contributors to the project
Activity
guytcc commentedon May 17, 2017
Borrowing liberally from SkewT python 3 port, I added a height scale to a plot with the code below (the class is just a holder). Most would be easy to port into Metpy.SkewT with some finagling.
Two obvious problems would need to be worked out:
dopplershift commentedon May 17, 2017
Thanks for digging that up! A few comments:
matplotlib spine is enough, or if maybe we do need the separate Axes, but we use matplotlib's event
handling to update the range on the height scale
log scaling associated with the heights.
guytcc commentedon May 17, 2017
I may misunderstand, but I just want to note that the plot in the class above is not equivalent to the plot in Metpy.SkewT, but is a handler that basically does most things from the individual examples. I'm sure matplotlib event handling could be used for dynamic updates, but I'd have to look into that, since the values for the heights are computed from the limits of the plot maybe this would be easier. (?)
I'm open to another method. Just went the "easy" route of least resistance (development).
The scaline for the heights is a linear scale. I made no attempt to have a logarithmic axis as we often don't think of altitude the same way we do atmospheric pressure.
dopplershift commentedon May 17, 2017
So what I'd want to merge is a patch that adds a method to the
SkewTclass that allows the user to turn on the height scale bar.As far as the scaling is concerned, I think there's some confusion. You start by taking the pressure values and converting them to heights--no problem here. When we make the skewT, pressure is logarithmically spaced (not changing the values) along the y-axis. If you want the heights to properly align with the pressure values, the height axis has to be logarithmically scaled as well.
dopplershift commentedon May 17, 2017
Nevermind, I mis-read the code before. I see what's going on and everything is aligned just fine.
12 remaining items
guidocioni commentedon Aug 21, 2023
Hey @dopplershift, this may be a stupid question but...what if I already have the height values in the original sounding?
Using standard atmosphere can cause some large discrepancies sometimes, but I cannot find a way to use an array for the values of the secondary y axis instead than a function.
dopplershift commentedon Aug 21, 2023
If you have the data, then you could just go ahead and manually annotate the plot with that using matplotlib's
text()/annotate()methods. You could also use the code above and do some kind of linear/nearest neighbor interpolation as the functions.One simple approach is, given that you have pairs of height/pressure, you could use the minor ticks with fixed labels for these like this:
This gives:
Note that with this approach, if you have a minor tick that duplicates a major tick, the minor tick won't show.
guidocioni commentedon Aug 22, 2023
Ah ok, I was hoping for a more clean way of doing it directly into metpy api without using direct text annotations :)
I will maintain the
secondary_y_axisapproach for now, thanks!I tried to create a function that just returns the array of height no matter the input but that doesn't seem to work because I don't really know when and with which arguments those transforming functions are called. Also a function that returns just the nearest value does not work... The doc says the function should expect numpy arrays as input but to me it is not clear what is passed.