Sun position

SunCalc.getSunPositionFunction
getSunPosition(
    time::Union{DateTime,ZonedDateTime}
    lat::Real,
    lon::Real;
    keep=[:altitude, :azimuth])

Calculate the sun position for the given time and location. Return a NamedTuple or DataFrame.

Available variables:

VariableDescription
altitudeSun altitude above the horizon in radians, e.g. 0 at the horizon and π/2 at the zenith (straight over your head)
azimuthSun azimuth in radians (direction along the horizon, measured from south to west), e.g. 0 is south and π * 3/4 is northwest

Examples

using Dates, SunCalc
getSunPosition(DateTime(2000, 07, 01, 12, 00, 00), 54, 9)

getSunPosition(now(), 54, 9; keep=[:altitude])
source

Sun light times

SunCalc.getSunlightTimesFunction
getSunlightTimes(
    date::Date, 
    lat::Real,
    lon::Real,
    tz::TimeZone; 
    keep=[:solarNoon, :nadir, :sunrise, :sunset, :sunriseEnd,
    :sunsetStart, :dawn, :dusk, :nauticalDawn, :nauticalDusk,
    :nightEnd, :night, :goldenHourEnd, :goldenHour])

Calculate sunlight times for the given date and location. Return a NamedTuple or DataFrame.

Available variables:

VariableDescription
sunriseSunrise (top edge of the sun appears on the horizon)
sunriseEndSunrise ends (bottom edge of the sun touches the horizon)
goldenHourEndMorning golden hour (soft light, best time for photography) ends
solarNoonSolar noon (sun is in the highest position)
goldenHourEvening golden hour starts
sunsetStartSunset starts (bottom edge of the sun touches the horizon)
sunsetSunset (sun disappears below the horizon, evening civil twilight starts)
duskDusk (evening nautical twilight starts)
nauticalDuskNautical dusk (evening astronomical twilight starts)
nightNight starts (dark enough for astronomical observations)
nadirNadir (darkest moment of the night, sun is in the lowest position)
nightEndNight ends (morning astronomical twilight starts)
nauticalDawnNautical dawn (morning nautical twilight starts)
dawnDawn (morning nautical twilight ends, morning civil twilight starts)

Examples

using Dates, SunCalc
getSunlightTimes(today(), 54, 9; keep=[:sunrise, :sunset])

using TimeZones
getSunlightTimes(Date(2000, 07, 01), 54, 9, tz"UTC-3")

using DataFrames
days = collect(Date(2000, 07, 01):Day(1):Date(2000, 12, 31))
getSunlightTimes(days, 54, 9)
source

Moon position

SunCalc.getMoonPositionFunction
getMoonPosition(
    time::Union{DateTime,ZonedDateTime},
    lat::Real,
    lon::Real;
    keep=[:altitude, :azimuth, :distance, :parallacticAngle])

Calculate the sun position for the given time and location. Return a NamedTuple or DataFrame.

Available variables:

VariableDescription
altitudeMoon altitude above the horizon in radians
azimuthMoon azimuth in radians
distanceDistance to moon in kilometres
parallacticAngleParallactic angle of the moon in radians

Examples

using Dates, SunCalc
getMoonPosition(DateTime(2000, 07, 01, 12, 00, 00), 54, 9)

getMoonPosition(now(), 54, 9; keep=[:altitude])
source

Moon illumination

SunCalc.getMoonIlluminationFunction
getMoonIllumination(
    time::Union{Date,DateTime,ZonedDateTime};
    keep=[:fraction, :phase, :angle])

Calculate moon illumination for the given time. Return a NamedTuple or DataFrame.

Available variables:

VariableDescription
fractionIlluminated fraction of the moon; varies from 0.0 (new moon) to 1.0 (full moon)
phaseMoon phase; varies from 0.0 to 1.0, described below
angleMidpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk; the moon is waxing if the angle is negative, and waning if positive

Moon phase value should be interpreted like this:

  • 0: New Moon
  • Waxing Crescent
  • 0.25: First Quarter
  • Waxing Gibbous
  • 0.5: Full Moon
  • Waning Gibbous
  • 0.75: Last Quarter
  • Waning Crescent

Examples

using Dates, SunCalc
getMoonIllumination(Date(2000, 07, 01))

getMoonIllumination(now(), keep=[:fraction])
source