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
I'm trying to implement something similar to the Nightshade feature on a Moon map. Providing the subearth and subsolar coordinates (se and ss, respectively), the code below seems to work as expected, but it seems that if se and ss latitudes are equal, rendering fails.
Code to reproduce
import cartopy.crs as ccrs
import shapely.geometry as sgeom
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from urllib.request import urlopen
import numpy as np
raster_url = "https://svs.gsfc.nasa.gov/vis/a000000/a004700/a004720/lroc_color_poles_1k.jpg"
raster = mpimg.imread(urlopen(raster_url), format="jpg")
def draw(se, ss):
lon_se, lat_se = se
lon_ss, lat_ss = ss
fig = plt.figure(figsize=(4, 4))
projection = ccrs.Orthographic(lon_se, lat_se)
transform = ccrs.PlateCarree()
ax = plt.axes(projection=projection)
# Moon map
ax.imshow(raster, cmap="gray", transform=transform)
# Shadow
rotated_pole = ccrs.RotatedPole(pole_latitude=lat_ss, pole_longitude=lon_ss)
rotated_lon = np.linspace(-180., 180., 40)
rotated_lat = np.zeros_like(rotated_lon)
geom = sgeom.Polygon(np.column_stack((rotated_lon, rotated_lat)))
ax.add_geometries(geom, rotated_pole, facecolors='k', edgecolors='none', alpha=0.6)
# This works as expected
draw(se=(0., 0.), ss=(50., 0.))
# But increasing subsolar longitude, it starts failing
draw(se=(0., 0.), ss=(100., 0.))
# ... but this is ok (making subsolar and subearth latitudes a bit different)
draw(se=(0., 0.), ss=(100., 1e-2)) # or: draw(se=(0., 1e-2), ss=(100., 0.))
Description
I'm trying to implement something similar to the Nightshade feature on a Moon map. Providing the subearth and subsolar coordinates (se and ss, respectively), the code below seems to work as expected, but it seems that if se and ss latitudes are equal, rendering fails.
Code to reproduce
Full environment definition
Operating system
Windows 11 22H2
Cartopy version
0.22.0 (same result also with 0.21.1)
conda list
pip list
The text was updated successfully, but these errors were encountered: