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
This is a bug with the plot range that is shown in cartopy. With a Geostationary projection if you use the bounds given in the projection_object.boundary.bounds to set your extent then the plot will show only a small rectangle of the middle of the globe. If you remove a very small amount from each side of the bounds, suddenly it shows the whole globe again.
There is no crash or traceback message, the program simply creates incorrect plots.
Code to reproduce
importmatplotlibmatplotlib.use('Agg')
importmatplotlib.pyplotaspltimportcartopy.crsascrsimportcartopy# This geostationary projection matches that of GOES 16.proj_object=crs.Geostationary(central_longitude=-75.0, satellite_height=35786023.0, sweep_axis='x', )
bounding_axes=proj_object.boundary.bounds# note, the bounds are in the wrong order, so reorder thembounding_axes= (bounding_axes[0], bounding_axes[2], bounding_axes[1], bounding_axes[3])
# plot a figure that shows the broken bounds behaviorfig=plt.figure( )
axes=fig.add_subplot(111, projection=proj_object)
axes.set_extent(bounding_axes, crs=proj_object)
axes.add_feature(cartopy.feature.LAND, facecolor="green", ) # not nessicary, but makes it clearer where we arefig.savefig("./fdtest1.png", )
plt.close(fig)
# plot a figure that works around the bugbounds_offset=1.0new_bounds= (bounding_axes[0] +bounds_offset, bounding_axes[1] -bounds_offset,
bounding_axes[2] +bounds_offset, bounding_axes[3] -bounds_offset,)
fig=plt.figure( )
axes=fig.add_subplot(111, projection=proj_object)
axes.set_extent(new_bounds, crs=proj_object)
axes.add_feature(cartopy.feature.LAND, facecolor="green", ) # not nessicary, but makes it clearer where we arefig.savefig("./fdtest2.png", )
plt.close(fig)
I think there's something wrong (maybe some precision issue) with the interpolator going on here. If i increase the number of points in the boundary for Geostationary (to say 1001 from 91), I can actually trigger a ValueError: Axis limits cannot be NaN or Inf. The points in that boundary itself, though, all seem to be valid since (using pyproj.Transform directly) they all transform fine to PlateCarre/Geodetic--no nans. Not sure why adding points produced worse results here.
In the meantime, there are a couple easy enough work-arounds. If all you want is to just have the limits show the entire valid range of the projection, just use axes.set_global(). Alternatively, since you directly have x/y ranges in projected space, you can use set_xlim/set_ylim with those:
I would bet a substantial amount of money that this is because the extent is represented as a LineString and what the interpolator needs to sample over is a Polygon:
Description
This is a bug with the plot range that is shown in cartopy. With a Geostationary projection if you use the bounds given in the
projection_object.boundary.bounds
to set your extent then the plot will show only a small rectangle of the middle of the globe. If you remove a very small amount from each side of the bounds, suddenly it shows the whole globe again.There is no crash or traceback message, the program simply creates incorrect plots.
Code to reproduce
Here are the plots I get:
Traceback
(No traceback is created.)
Full environment definition
Operating system
MacBook Pro with MacOS 12.6.7
Cartopy version
cartopy 0.21.1
conda list
pip list
The text was updated successfully, but these errors were encountered: