Skip to content
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

Update nightshade.py to allow user-defined sub-solar coordinates #2375

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/cartopy/feature/nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

class Nightshade(ShapelyFeature):
def __init__(self, date=None, delta=0.1, refraction=-0.83,
color="k", alpha=0.5, **kwargs):
color="k", alpha=0.5, sub_solar_point=None, **kwargs):
"""
Shade the darkside of the Earth, accounting for refraction.
Shade the darkside of a body, accounting for refraction.

Parameters
----------
Expand All @@ -29,6 +29,10 @@ def __init__(self, date=None, delta=0.1, refraction=-0.83,
refraction : float
The adjustment in degrees due to refraction,
thickness of the solar disc, elevation etc...
sub_solar_point : tuple of latitude, longitude, optional
The coordinates in degrees of the point at which the sun is directly
overhead. If both sub_solar_point and date are provided, sub_solar_point
takes precedence.

Note
----
Expand All @@ -47,7 +51,12 @@ def __init__(self, date=None, delta=0.1, refraction=-0.83,

# Returns the Greenwich hour angle,
# need longitude (opposite direction)
lat, lon = _solar_position(date)
if sub_solar_point is None:
#If not specified proceed as usual
lat, lon = _solar_position(date)
else:
#If specified, use given coordinates
lat, lon = sub_solar_point
pole_lon = lon
if lat > 0:
pole_lat = -90 + lat
Expand Down
Loading