Uh oh!
There was an error while loading. Please reload this page.
Quick patch to bypass scale validation in new Cartopy - #1371
Conversation
This pull request introduces 1 alert when merging a4aeb54 into c3df3bc - view on LGTM.com new alerts:
|
kgoebber
commented
May 7, 2020
Investigating the test failures has led to the following:
|
kgoebber
commented
May 7, 2020
Okay, as best as I can figure out at this point, it seems to be something with the Cartopy 0.18 update related to I also drafted some test code and if you don't set a projection, the clip_on setting works, once you add a projection then it no longer clips. Testing this same code on Cartopy 0.17 works for both instances. So it appears to be Cartopy, but not absolutely sure what or where this is being caused. importcartopy.crsasccrsimportmatplotlib.pyplotaspltfrommetpy.plotsimportStationPlotimportnumpyasnplat=np.linspace(40, 30, 11)
lon=np.linspace(-90, -80, 11)
lon, lat=np.meshgrid(lon, lat)
T=np.ones(lon.shape)*25# Create the figure and an axes set to the projection.fig=plt.figure(figsize=(8, 8))
ax=fig.add_subplot(1, 1, 1)
#ax.set_extent([-88, -86, 32, 38])ax.set_xlim(-88, -84)
stationplot=StationPlot(ax, lon.ravel(), lat.ravel(), fontsize=10, clip_on=True)
stationplot.plot_parameter('C', T.ravel())And now adding a projection and making it a GeoAxes... # Create the figure and an axes set to the projection.fig=plt.figure(figsize=(8, 8))
ax=fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
#ax.set_extent([-88, -86, 32, 38])ax.set_xlim(-88, -84)
stationplot=StationPlot(ax, lon.ravel(), lat.ravel(), fontsize=10, clip_on=True)
stationplot.plot_parameter('C', T.ravel()) |
kgoebber
commented
May 11, 2020
Okay, I've continued digging and not found much, but here is a summary of what I have found/tried... Clearly we are able to clip appropriately when not using a Geo-referenced Axes, so MetPy and Matplotlib are working okay together. It also seems like clipping happens okay with geo-referenced axes when there is a wrapped Matplotlib function in Cartopy (read: contour, contourf, barbs, etc.), but not for the |
jthielen
commented
May 11, 2020
@kgoebber Thank you for digging into this and investigating! It's a lot more than I've been able to do. At this point, does the "fix" have to come down to pinning v0.12.2 to Cartopy <=0.17? I've had this issue come up a few times with supporting people, so it would be great to have at least some form of a resolution ASAP. |
kgoebber
commented
May 11, 2020
This fix will allow things to work with Cartopy 0.18 - the only user issue would be if they are wanting to plot surface observations - they won't clip properly, which is really a different issue from this one. So if we are okay committing over CI failures (which are all just image issues within this PR; some resulting from this change, others unrelated (e.g., clipping issues)), then this works just fine with Cartopy 0.18. |
kgoebber
left a comment
There was a problem hiding this comment.
Overcomes import hurdles when using Cartopy 0.18. This quick fix gets the job done for that. There are still other Cartopy 0.18 issues. We should update the test images for the ones that change as the result of the updated adaptive scaler and gridline issues.
kgoebber
commented
May 11, 2020
I found a work around for the clipping! The clipbox attribute was not being set correctly (or unset?), but the bbox that was created in Adding the following code at line 105 in # Update the clipbox based on bboxtext_obj.clipbox=self.bbox |
dopplershift
commented
May 13, 2020
Good find @kgoebber. So the chain is that, as noted in SciTools/cartopy#1526, after SciTools/cartopy#1422 the default patch is a bit more complicated; most importantly it is not an instance of breathes So I think the clipping issue is actually a bug in matplotlib that has been made a problem for us by changes in CartoPy. I think we can do something like @kgoebber notes above until the bug is fixed in matplotlib. |
jthielen
commented
May 29, 2020
Closing in favor of @dopplershift's #1372. |


Description Of Changes
Quick patch of the
__init__method ofMetPyMapFeatureto fix the breakage caused by the scale validation added in Cartopy 0.18 toNaturalEarthFeature. Not a long term fix, since it assumes an exact set of attributes forNaturalEarthFeatureand particular behavior ofNaturalEarthFeature's parent classFeature. A more robust fix will be discussed for 1.0 in #1368 / #1370.