DJBen/SpaceTime

Astronomical space coordinate and time conversion. Calculate Julian day, local sidereal time and ecliptic obliquity with great precision.


Keywords
astronomy, carthage, conversion, coordinate, equatorial, julian-date, sidereal, sidereal-time, swift, swift-3
License
GPL-3.0

Documentation

Header

SpaceTime

Language License: GPL v3 Carthage compatible Build Status

Overview

Demo

You can find a demo project under SpaceTimeDemo directory. It showcases several useful scenarios.

Screenshot

Installation

Carthage

github "DJBen/SpaceTime" ~> 0.4.0

Usage

Equatorial to horizontal coordinate:

// Supply observer location and timestamp
let locTime = ObserverLocationTime(location: location, timestamp: JulianDay.now)
let vegaCoord = EquatorialCoordinate(rightAscension: radians(hours: 18, minutes: 36, seconds: 56.33635), declination: radians(degrees: 38, minutes: 47, seconds: 1.2802), distance: 1)
// Azimuth and altitude of Vega
let vegaAziAlt = HorizontalCoordinate.init(equatorialCoordinate: vegaCoord, observerInfo: locTime)

Ecliptic coordinate of Pollux at standard equinox of J2000.0.

let ra = DegreeAngle(116.328942)
let dec = DegreeAngle(28.026183)
let eclipticCoord = EclipticCoordinate(longitude: ra, latitude: dec, distance: 1, julianDay: .J2000)
eclipticCoord.longitude.wrappedValue // 113.21563
eclipticCoord.latitude.wrappedValue // 6.68417

Greenwich Mean Sidereal Time:

SiderealTime.init(julianDay: JulianDay.now)

Local Apparent Sidereal Time:

// Get location from GPS or hard code
let locTime = ObserverLocationTime(location: location, timestamp: JulianDay.now)
let localSidTime = SiderealTime.init(observerLocationTime: locTime)

More use cases can be found in the source and test cases.