-
Notifications
You must be signed in to change notification settings - Fork 421
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
ImagePlot fails on some [0, 360] data #1915
Comments
Of course it's not as simple as removing that bogus wrapping code, as that breaks a the from datetime import datetime
from metpy.cbook import get_test_data
from metpy.plots import ContourPlot, ImagePlot, MapPanel, PanelContainer
from metpy.units import units
import xarray as xr
data = xr.open_dataset(get_test_data('irma_gfs_example.nc', as_file_obj=False))
img = ImagePlot()
img.data = data
img.field = 'Temperature_isobaric'
img.level = 500 * units.hPa
img.time = datetime(2017, 9, 5, 15, 0, 0)
#img.colorbar = None
contour = ContourPlot()
contour.data = data
contour.field = 'Geopotential_height_isobaric'
contour.level = img.level
contour.time = img.time
panel = MapPanel()
#panel.projection = 'lcc'
panel.area = 'global'
panel.plots = [img, contour]
pc = PanelContainer(size=(8,5))
pc.panel = panel
pc.draw() so that's lovely. |
Everything works fine if I change the extent of the image data (either with I've so far traced this into CartoPy's image warping code. It seems to be an issue where we're using the fact that In the meanwhile, though, we need to unbreak the original example with MetPy, but also keep the test case working. This probably means writing some code to properly "roll" an image from [0, 360] to [-180, 180]. |
I had to face this issue in the past where I had to wrestle with plotting with longitudes from -180 to 180 degrees. When plotting on a map with this set of longitudes it would warp the lines and wrap around the globe when taken from platecarree. The only solution that I found that prevented these problems was to convert the longitudes to 0 to 360 degrees and it works over the poles too. I tried both ways and looked at the results. It was quite convincing. |
Jotting down a thought here:
|
This example:
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
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 andx[-1]
is -0.25, since this full dataset has a longitude range of [0, 360].The text was updated successfully, but these errors were encountered: