-
Notifications
You must be signed in to change notification settings - Fork 445
Open
Labels
Area: PlotsPertains to producing plotsPertains to producing plotsType: BugSomething is not working like it shouldSomething is not working like it should
Milestone
Description
This example:
from metpy.plots import ImagePlot, MapPanel, PanelContainer
from metpy.units import units
import xarray as xr
ds_z500 = xr.open_dataset('/Users/rmay/Downloads/gfs.t00z.pgrb2.0p25.f024', engine='cfgrib', filter_by_keys={'typeOfLevel': 'isobaricInhPa', 'level': 500})
img = ImagePlot()
img.data = ds_z500
img.field = 't'
img.colormap = 'plasma'
panel = MapPanel()
panel.area = 'us'
panel.title = 'GFS 500mb Temp Forecast Example'
panel.plots = [img]
pc = PanelContainer()
pc.size = (10,8)
pc.panels = [panel]
pc.show()produces the following with 1.0 and main:

Taken from a Stack Overflow question. This pretty clearly relates to this code that wraps longitude:
MetPy/src/metpy/plots/declarative.py
Lines 1087 to 1102 in 6944e23
| @property | |
| def plotdata(self): | |
| """Return the data for plotting. | |
| The data array, x coordinates, and y coordinates. | |
| """ | |
| x = self.griddata.metpy.x | |
| y = self.griddata.metpy.y | |
| # At least currently imshow with cartopy does not like this | |
| if 'degree' in x.units: | |
| x = x.data | |
| x[x > 180] -= 360 | |
| return x, y, self.griddata |
because without it the same code gives:
The code is pretty clearly incorrect because it results in an x array where x[0] is 0 and x[-1] is -0.25, since this full dataset has a longitude range of [0, 360].
Metadata
Metadata
Assignees
Labels
Area: PlotsPertains to producing plotsPertains to producing plotsType: BugSomething is not working like it shouldSomething is not working like it should
Type
Projects
Status
No status