-
Notifications
You must be signed in to change notification settings - Fork 422
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
skewT subplots assume celcius without a warning #1155
Comments
I would be happy to attempt a fix, for instance changing the plot_dry_adiabats as follows? def plot_dry_adiabats(self, t0=None, p=None, **kwargs):
""" ... """
# Determine set of starting temps if necessary
xmin, xmax = self.ax.get_xlim() # MOVED THIS LINE OUT OF IF
kelvin=xmin>150 # is there a better way for this to be flagged?
if t0 is None:
t0 = np.arange(xmin, xmax + 1, 10) * units.degC
if kelvin: # ADDED THIS LINE
t0 = np.arange(xmin, xmax + 1, 10) * units.degK
# Get pressure levels based on ylims if necessary
if p is None:
p = np.linspace(*self.ax.get_ylim()) * units.mbar
# Assemble into data for plotting
t = dry_lapse(p, t0[:, np.newaxis].to(units.degC), 1000. * units.mbar).to(units.degC)
if kelvin: # ADDED
t = t.to(units.degK) # ADDED
linedata = [np.vstack((ti, p)).T for ti in t]
# Add to plot
kwargs.setdefault('colors', 'r')
kwargs.setdefault('linestyles', 'dashed')
kwargs.setdefault('alpha', 0.5)
return self.ax.add_collection(LineCollection(linedata, **kwargs)) |
This bug is definitely worrisome, but it isn't surprising given the current absence of proper unit handling in SkewT plotting. In relation to @zbruick's recent side question in #1149, I think this is a good demonstration of how the current approach is problematic and why units for SkewT should be required. |
Yeah I've seen this before (way before I got to Unidata) when I forgot to convert to Celsius. I hadn't actually looked at these methods before to see that Celsius was hardcoded in. Definitely worrisome as we should handle this easily, as a lot of research SkewTs use Kelvin. Thanks @jibbals for documenting and reporting this bug. As to fixing it, setting a flag to catch when the minimum is above a certain number is a good idea, but I see that solution running into the problem identified in #195 (which might as well be solved at the same time as this bug if possible). I don't know if patching this bug in this manner, but leaving #195, is a good option at this point. Seems like we should somehow default to a normal Celsius range (most common scale IMO) when |
After investigating this a bit, here are my conclusions:
@jibbals do you want to tackle this? @dopplershift, any other thoughts or better way? |
This patch got a thumbs up from @dopplershift. We're going to open an issue with matplotlib to gain unit support for |
So to capture the conversation I had with @zbruick:
|
Actually, here's another option to get the proper xunits that's not a hack: self.ax.xaxis.get_xunits() |
I’ll have a go at this, thanks for all the feedback and I’ll try to use that get_xunits too |
Wet and dry adiabats, along with mixing lines, do not correctly plot unless everything is in degrees celcius. This is especially a problem when the plots show the wrong values without giving any sort of warning. This fix makes the subroutines plot onto units matching the xaxis or input temperature. Checklist Closes Unidata#1155 test added
Wet and dry adiabats, along with mixing lines, do not correctly plot unless everything is in degrees celcius. This is especially a problem when the plots show the wrong values without giving any sort of warning. This fix makes the subroutines plot onto units matching the xaxis or input temperature. Checklist Closes #1155 test added
Wet and dry adiabats, along with mixing lines, do not correctly plot unless everything is in degrees celcius. This is especially a problem when the plots show the wrong values without giving any sort of warning. This fix makes the subroutines plot onto units matching the xaxis or input temperature. Checklist Closes Unidata#1155 test added
Though we should potentially hold on to #1216 for some of its other additions, this no longer occurs on newer versions! |
Problem:
If using degrees Kelvin for the SkewT plot, the axis is updated to 'kelvin' but the plot_dry_adiabats() plot_moist_adiabats() and plot_mixing_lines() assume the units are in degrees Celcius. This means that the adiabats are plotted wrongly, and the mixing rate lines are 273.15 degrees to the left of where they should be.
Expected output:
Either a warning that Celcius is required, or correct conversion of the x-axis to degrees Kelvin.
Run environment:
Anaconda on windows:
python --version
Python 3.7.4The text was updated successfully, but these errors were encountered: