-
Notifications
You must be signed in to change notification settings - Fork 388
Closed
Milestone
Description
Description
I'm trying use Nightshade to draw twilight lines (and sub solar point).
If I do Nightshade w/ refraction=-6.0, I get ValueError: GEOSGeom_createLinearRing_r returned a NULL pointer
Nightshade w/ refraction=-6.0001 works OK
Also, refraction=89 causes extraneous lines.
Code to reproduce
import matplotlib.pyplot as plt
fig = plt.figure()
import cartopy
ax = fig.add_subplot(projection=cartopy.crs.PlateCarree())
ax.coastlines()
import datetime
date = datetime.datetime(1999, 12, 31, 12)
from cartopy.feature.nightshade import Nightshade
ax.add_feature(Nightshade(date, color='none'))
ax.add_feature(Nightshade(date, refraction=-6.0, color='none')) # Civil Twilight
#ax.add_feature(Nightshade(date, refraction=-6.0001, color='none')) # Civil Twilight
ax.add_feature(Nightshade(date, refraction=-12, color='none')) # Nautical Twilight
ax.add_feature(Nightshade(date, refraction=89, color='none')) # sub solar circle ...
plt.show()
Traceback
python /tmp/nightshade-bug.py
/usr/lib64/python3.10/site-packages/cartopy/feature/nightshade.py:80: RuntimeWarning: invalid value encountered in arccos
omega0 = np.rad2deg(np.arccos(np.sin(np.deg2rad(refraction)) /
IllegalArgumentException: Points of LinearRing do not form a closed linestring
Traceback (most recent call last):
File "/tmp/nightshade-bug.py", line 15, in <module>
ax.add_feature(Nightshade(date, refraction=-6, color='none')) # Civil Twilight
File "/usr/lib64/python3.10/site-packages/cartopy/feature/nightshade.py", line 93, in __init__
geom = sgeom.Polygon(np.column_stack((x, y)))
File "/usr/lib64/python3.10/site-packages/shapely/geometry/polygon.py", line 243, in __init__
ret = geos_polygon_from_py(shell, holes)
File "/usr/lib64/python3.10/site-packages/shapely/geometry/polygon.py", line 509, in geos_polygon_from_py
ret = geos_linearring_from_py(shell)
File "shapely/speedups/_speedups.pyx", line 408, in shapely.speedups._speedups.geos_linearring_from_py
ValueError: GEOSGeom_createLinearRing_r returned a NULL pointer
Full environment definition
Operating system
Fedora 35
Cartopy version
python3-cartopy-0.20.1-1.fc35.x86_64
python3-shapely-1.7.1-12.fc35.x86_64
python3-matplotlib-3.5.1-3.fc35.x86_64
Thanks !
Metadata
Metadata
Assignees
Labels
No labels