Skip to content

Commit

Permalink
Merge pull request #109 from michealroberts/refactor/night/get_solar_…
Browse files Browse the repository at this point in the history
…transit

refactor: amend get_solar_transit() internal usage in celerity/night.
  • Loading branch information
michealroberts authored Apr 28, 2024
2 parents a33189a + 6d16f76 commit 364e700
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/celerity/night.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ def get_solar_transit(
eq = get_equatorial_coordinate(date)

# Convert the equatorial coordinate to a horizontal coordinate:
hor = convert_equatorial_to_horizontal(date, observer, eq)
hz = convert_equatorial_to_horizontal(date, observer, eq)

# Correct the horizontal coordinate for atmospheric refraction:
hor = get_correction_to_horizontal_for_refraction(hor, 288.15, 101325)
hz = get_correction_to_horizontal_for_refraction(hz, 288.15, 101325)

# Find the altitude of the Sun where it crosses over the horizon:
if hor["alt"] > horizon and rise is None:
if hz["alt"] > horizon and rise is None:
rise = i

# Find the altitude of the Sun where it crosses back under the horizon:
if hor["alt"] < horizon and set is None and rise is not None:
if hz["alt"] < horizon and set is None and rise is not None:
set = i

sun.append(hor)
sun.append(hz)

# Increment the date by 1 second:
date += timedelta(minutes=1)
Expand Down Expand Up @@ -116,7 +116,8 @@ def get_night(
# Get the time of the sunrise for the following date:
sunrise, _, _ = get_solar_transit(date + timedelta(days=1), observer, horizon)

# The observer could be in perpetual daylight or perpetual night, e.g., the North Pole or South Pole:
# The observer could be in perpetual daylight or perpetual night, e.g., the
# North Pole or South Pole:
if sunset is None or sunrise is None:
return None

Expand Down

0 comments on commit 364e700

Please sign in to comment.