suncalc
| Kind | kit |
|---|---|
| Categories | science astronomy |
| Keywords | sun moon astronomy solar lunar |
Sun and moon position, times, and illumination calculations for Kit
Files
| File | Description |
|---|---|
kit.toml | Package manifest with metadata and dependencies |
src/main.kit | Sun/moon position, times, and illumination calculations |
tests/suncalc.test.kit | Tests for sun position, times, moon phases, and twilight |
LICENSE | MIT license file |
Dependencies
No Kit package dependencies.
Installation
kit add gitlab.com/kit-lang/packages/kit-suncalc.gitUsage
import Kit.SuncalcLicense
MIT License - see LICENSE for details.
Exported Functions & Types
to-radians
Convert degrees to radians.
Float -> Float
to-degrees
Convert radians to degrees.
Float -> Float
get-position
Get sun position for a given timestamp and location
Parameters:
Returns a record with: - azimuth: Sun azimuth in radians (direction along the horizon, south = 0, west = positive) - altitude: Sun altitude in radians (above the horizon)
Float -> Float -> Float -> {azimuth: Float, altitude: Float}
pos = get-position 1362441600000.0 50.5 30.5
azimuth-degrees = to-degrees pos.azimuthget-times
Get sun times for a given date and location
Parameters:
Returns a record with timestamps (ms) for various sun events: - solar-noon: Sun is at highest point - nadir: Sun is at lowest point (opposite of noon) - sunrise/sunset: Sun appears/disappears on horizon (-0.833 degrees) - sunrise-end/sunset-start: Bottom edge of sun touches horizon (-0.3 degrees) - dawn/dusk: Civil twilight (-6 degrees) - nautical-dawn/nautical-dusk: Nautical twilight (-12 degrees) - night-end/night: Astronomical twilight (-18 degrees) - golden-hour-end/golden-hour: Golden hour (6 degrees)
Float -> Float -> Float -> Float -> {solar-noon: Float, nadir: Float, sunrise: Float, sunset: Float, sunrise-end: Float, sunset-start: Float, dawn: Float, dusk: Float, nautical-dawn: Float, nautical-dusk: Float, night-end: Float, night: Float, golden-hour-end: Float, golden-hour: Float}
times = get-times 1362441600000.0 50.5 30.5 0.0
sunrise-ms = times.sunriseget-moon-position
Get moon position for a given timestamp and location
Parameters:
Returns a record with: - azimuth: Moon azimuth in radians - altitude: Moon altitude in radians (includes atmospheric refraction) - distance: Distance to moon in kilometers - parallactic-angle: Parallactic angle in radians
Float -> Float -> Float -> {azimuth: Float, altitude: Float, distance: Float, parallactic-angle: Float}
pos = get-moon-position 1362441600000.0 50.5 30.5
distance-km = pos.distanceget-moon-illumination
Get moon illumination for a given timestamp
Parameters:
Returns a record with: - fraction: Illuminated fraction (0 to 1) - phase: Moon phase (0 = new moon, 0.25 = first quarter, 0.5 = full moon, 0.75 = last quarter) - angle: Midpoint angle in radians of the illuminated limb
Float -> {fraction: Float, phase: Float, angle: Float}
illum = get-moon-illumination 1362441600000.0
percent-lit = illum.fraction * 100.0get-moon-times
Get moon rise and set times for a given date and location
Parameters:
Returns a record with: - rise: Option Float - moonrise time in ms (Some value or None) - set: Option Float - moonset time in ms (Some value or None) - always-up?: Bool - moon never sets on this day - always-down?: Bool - moon never rises on this day
Float -> Float -> Float -> {rise: Option Float, set: Option Float, always-up?: Bool, always-down?: Bool}
times = get-moon-times 1362441600000.0 50.5 30.5
match times.rise
| Some r -> IO.println "Moonrise: ${Float.to-string r}"
| None -> IO.println "No moonrise today"moon-phase-name
Get the name of a moon phase from a phase value
Parameters:
Returns a string describing the moon phase: - "new-moon" (0 and 1) - "waxing-crescent" (0-0.25) - "first-quarter" (0.25) - "waxing-gibbous" (0.25-0.5) - "full-moon" (0.5) - "waning-gibbous" (0.5-0.75) - "last-quarter" (0.75) - "waning-crescent" (0.75-1)
Float -> String
illum = get-moon-illumination 1362441600000.0
name = moon-phase-name illum.phasesun-up?
Check if the sun is up (above horizon) at a given time and location.
Float -> Float -> Float -> Bool
night?
Check if it's night (sun below -18 degrees) at a given time and location.
Float -> Float -> Float -> Bool
twilight?
Check if it's twilight at a given time and location.
Float -> Float -> Float -> Bool
golden-hour?
Check if it's golden hour at a given time and location.
Float -> Float -> Float -> Bool
full-moon?
Check if it's a full moon (within 10% of full).
Float -> Bool
new-moon?
Check if it's a new moon (within 10% of new).
Float -> Bool
moon-illumination-percent
Get moon illumination as a percentage.
Float -> Float