Skip to content

ThumbWorks/SwiftAA

 
 

Repository files navigation

arcsecond.io (backend) • arcsecond.swift (Swift SDK) • arcsecond.js (JavaScript SDK) •
SwiftAAQLFitsFITSImporterObjCFITSIO

SwiftAA

SayThanks Travis Codecov Carthage compatible

The most comprehensive and accurate collection of astronomical algorithms, in C++, Objective-C and Swift3, all in one place.

Ongoing development is written in Swift3 and using AA+ version 1.76 (released February 12th, 2017). It will soon reach version 2.0. But it is already usable (and used) in production apps.

SwiftAA is first built with an Objective-C(++) layer atop the C++ implementation of Astronomical Algorithms (see below). These algorithms also make use of the VSOP87 framework making it the most complete and accurate collection of algorithms for all things astronomical.

On top of this, SwiftAA provides modern APIs taking advantage of the expressiveness of Swift and its various modern syntax elements, making it fun and easy of use. Additional functions and algorithms are added to improve even more completeness and ease of use. In particular, SwiftAA provides units safety a lot stronger than C++ APIs.

Moreover, SwiftAA intends to provide a much improved unit tests coverage. The target is about 50% of code coverage for the milestone 2.0.

Documentation

The documentation generated from the code itself is available at http://onekiloparsec.github.io/SwiftAA.

Licence

The licence of this software is the MIT licence. But it does not apply to the AA+ Framework, which retains its own licence. Quoting the original:

AA+ Copyright :

  • You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) when your product is released in binary form.
  • You are allowed to modify the source code in any way you want except you cannot modify the copyright details at the top of each module.
  • If you want to distribute source code with your application, then you are only allowed to distribute versions released by the author. This is to maintain a single distribution point for the source code.

Installation

Using Carthage: add github "onekiloparsec/SwiftAA" to your Cartfile and then run carthage update.

Using CocoaPods: add pod 'SwiftAA' to your Podfile and then run pod update.

Introduction

The AA+ framework, written in C++ by PJ Naughter (Visual C++ MVP) is certainly the best and most complete implementation of the "Astronomical Algorithms", found in the reference textbook by Jean Meeus (purchasable from Amazon). To make the most of this code, you'd rather have a copy of the book with you.

As the author of the app iObserve (for Mac and iPad), I have myself worked a lot on implementing some of the AA algorithms for my needs. However, to push iObserve to the next level, I need to put a lot more work on these algorithms.

P.J. Naughter has kindly agreed to let me create a public repo with his code. My intention is to write a wrapper around it, to bring the AA+ framework to Apple's Swift realm (and Objective-C along the way). Pull requests will be accepted only about the Objective-C and Swift code. The AA+ code changes must be directed (as I will personnaly do if I need to) to the original source (see the AA+ website).

Caution

The coordinates computations are key for modern astronomy. However, there is no mention to modern conventions (like ICRS) in the textbook of Jean Meeus, therefore in the AA+ code. Awaiting for such improvement, any user wanting to compute coordinates transformations should be careful. For a good example of a complete implementation of such transformations, see the AstroPy excellent package.

The implementation of modern convention for coordinates, as in AstroPy, is planned for v2.1.

Notes and Conventions

Needless to say how different the syntax is between C, C++, Objective-C and Swift. The main guideline in writting SwiftAA is to build an Objective-C(++) layer that follow strictly the methods and interfaces of the underlying C++ library. Only the name of some variables were a bit "Objective-C-fied" (to avoid prefix them with the one-letter type, 'b' for boolean etc').

As Objective-C lacks namespaces, everything must be prefixed. It is a convention to use 3-letters prefixes in Objective-C. KPC stands for "kiloparsec" and is "my" usual prefix. I chose to keep the AA prefix that belongs to the C++ library as well. Hence the (rather long) 5-letters KPCAA prefix of all methods.

These constraints come from the fact that no C++ code can be written directly alongside Swift code (in the same file). And Swift doesn't have the header/implementation split into different files. Hence one must write a Objective-C++/C wrapper around it, with name prefixes.

Author

Cédric Foellmi, a.k.a. @onekiloparsec (website).
(Ph.D. in astrophysics, and former support astronomer at the European Southern Observatory in Chile).

About

The most comprehensive and accurate collection of astronomical algorithms in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 98.4%
  • Swift 0.9%
  • Objective-C++ 0.5%
  • Objective-C 0.2%
  • CMake 0.0%
  • Ruby 0.0%