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 2 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
13 changes: 11 additions & 2 deletions lib/cartopy/feature/nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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.

Expand All @@ -29,6 +29,11 @@ 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
dsheward-astro marked this conversation as resolved.
Show resolved Hide resolved
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.

dsheward-astro marked this conversation as resolved.
Show resolved Hide resolved

Note
----
Expand All @@ -47,8 +52,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:
lat, lon = sub_solar_point #if specified, use given coordinates
pole_lon = lon

if lat > 0:
pole_lat = -90 + lat
central_lon = 180
Expand Down
Loading