This repository contains the Swiss Ephemeris, packaged with a wrapper written in Swift. All Swiss Ephemeris C code has not been modified, is accessible and can be called directly after importing the package. If you program in C, or are familiar with the original library it is possible to ignore the Swift code.
I am working on a Swift wrapper for convenience and accessibility for developers who are not familiar with C, but would like to leverage the power of this ephemeris. This is still a work in progress, and the current state of the wrapper only utilizes a small percentage of what the ephemeris offers.
The package is available through Swift Package Manager
This project is under the licensing model
a) GNU public license version 2 or later outlined in the section on
How to license the Swiss Ephemeris on the description of the Astrodienst Swiss Ephemeris. Please familiarize yourself with the licensing requirements before getting started.
At the moment the JPL-Ephemeris files that are included are the following.
|Type||File Numbering||Time Period|
|Planet||seplm60 - seplm132||11 Aug 13000 BCE – Jan 16800 CE|
|seplm06 - seplm54|
|sepl0 - sepl162|
|Asteroid||seasm06 - seasm54||5401 BCE - 4800 CE – 5399 CE|
|seas_06 - seas_48|
|Moon||semom60 - semom132||11 Aug 13000 BCE – Jan 16800 CE|
|semom06 - semom54|
|semo_00 - semo_162|
It is crucial that the path to the JPL-Ephemeris files is set at runtime before getting any astrological data. Various documentation and examples that exist out there have this step as optional, but the functionality of this library will be greatly limited if not taken. Since Swift tools version 5.3 it is possible to bundle resources as a part of a Swift package. This allows adding the JPL file as a resource to the package, and setting the resource path as the path to the ephemeris files.
This method should be called once at the entry point of your app. By default, the
Bundle.module resource path of this package that holds the JPL files is set as the ephemeris path. However, It is also possible to pass in
path parameter to set a different ephemeris files that you have bundled in your app.
// Sets ephemeris path to the JPL resources. JPLFileManager.setEphemerisPath() // Set a path to JPL files added to your app bundle. let path = "URL to your ephemeris files" JPLFileManager.setEphemerisPath(path: )
To get coordinate data for a planet, moon or lunar node create a
T is the type of IPL body category. This type contains more than astrological data, including the latitudinal and longitudinal speed, and distance in AU for any planetary body.
let now = Date() // Astronomical and astrological information for the moon at this point in time. let moonCoordinate = Coordinate<Planet>(planet: .moon, date: now) // The moon's longitude. moonCoordinate.longitude // The moon's latitude. moonCoordinate.latitude // The distance in AU from the earth. moonCoordinate.distance // The speed in longitude (deg/day). moonCoordinate.speedLongitude // The speed in latitude (deg/day). moonCoordinate.speedLatitude // The speed in distance (AU/day). moonCoordinate.speedDistance
Astrological information about the tropical zodiacal location of a celestial body is also available from the same
// Date for 12.14.2019 13:39 UT/GMT let date = Date(timeIntervalSince1970: 598023482.487818) // Astronomical and astrological information for the sun on December 14th 2019. let sunCoordinate = Coordinate<Planet>(planet: .sun, date: date) // This will return 21 Degrees Sagittarius ♐︎ 46' 49''. sunCoordinate.formatted // It is also possible to get the degree, minute and second as properties of the Coordinate. let degree = sunCoordinate.degree let minute = sunCoordinate.minute let second = sunCoordinate.second
To create an aspect between two
CelestialBody types use
Transit contains start and end date properties of the transit with an accuracy of one hour.
// Create a pair of celestial bodies. let moonTrueNode = Pair<Planet, LunarNode>(a: .moon, b: .trueNode) // Transit contains start and end date properties. let transit = Transit(pair: moonTrueNode, date: Date(), orb: 8.0)
To get the house layout for a date, location, and house system create a
HouseSystem determines the type of astrological house system that is set. All house
Cusp properties can be used to create an
Aspect with a
/// Create a date and location let now = Date() let latitude: Double = 37.5081153 let longitude: Double = -122.2854528 /// All house cusps, Ascendent, and MC are properties on `houses`. let houses = HouseCusps(date: date, latitude: latitude, longitude: longitude, houseSystem: .placidus) /// Get the formatted astrological position. let ascendentFormatted = houses.ascendent.formatted /// Or the precise degree let degree = houses.ascendent.degree
enum types for
LunarNode correspond to IPL numbers in the ephemeris. Other celestial bodies such as stars as fictitious points still need to be added. The type numbering is not comprehensive, but can be easily extended to match the celestial body that is not available in the package. All of the types conform to the
CelestialBody protocol which makes it so different categories of celestial points can be mapped to the tropical zodiac both in aspect and position.
|Last commit: 1 week ago|