uhd_yuri_ut4_cc.jpg
eso1205a.jpg
potw1050a.jpg
eso0840a.jpg
uhd_yuri_ut4_cc.jpg

SwiftAA


 

The most comprehensive collection
of accurate astronomical algorithms in Swift.

SCROLL DOWN

SwiftAA


 

The most comprehensive collection
of accurate astronomical algorithms in Swift.

SwiftAA

Travis Codecov Carthage compatible SayThanks

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

SwiftAA provides everything you need to build our Solar System, compute length of seasons, moon phases, determine rise, transit and set times, get positions of large planetary moons, transform coordinates, determine physical details of planets, their illumination, distance etc. With a professional-grade accuracy.

SwiftAA is already used in production apps. In particular, MeteorActive, a carefully crafted iOS app to get everything about meteors.

SwiftAA is first built with an Objective-C(++) layer atop the C++ implementation by P.J. Naughter of the reference textbook Astronomical Algorithms, by Jean Meeus (2nd ed., Amazon). This C++ package is called AA+ (see below). AA+ also includes additional algorithms of the VSOP87) framework, and includes the complete support for the ELP/MPP02 theory. Thus, SwiftAA, thanks to AA+, is the most complete and accurate collection of algorithms for all things astronomical in Swift. Ongoing development is using AA+ version 1.91 (released August 1st, 2017).

But SwiftAA provides more modern and a lot more readable APIs, taking advantage of the expressiveness of Swift and its various syntax elements, making it fun and easy of use. In fact, you simply can't use AA+ without having the AA book. While SwiftAA is precisely made to be accessible by anyone. Additional functions and algorithms are added to improve even more the completeness and ease of use. In particular, SwiftAA provides units safety a lot stronger compared to C++ APIs.

Moreover, SwiftAA has a much larger unit tests coverage (>90% for the Swift code!). In fact, unit tests are being carefully written with data directly taken from Jean Meeus' textbook, AA+ own tests, USNO, SkySafari and Xephem (and thus trying to achieve a probably hypothetical consistency between these sources).

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, which allows you to use it freely in open-source or commercial products. 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, then run carthage update, and finally add the newly built SwiftAA.framework into your project (in embedded binaries).

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

Notes

AA+

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. To make the most of this code specifically, you have to have a copy of the book with you (APIs and method names are hardly understandable without knowing what they refer to).

Pull requests are 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 on Coordinates

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.

Prefixes & Conventions

Needless to say how different the syntax is between C, C++, Objective-C and Swift. The main guideline in writting SwiftAA was 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.

The constraint of having an Objective-C layer first comes 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.

Image Credits: Y. Beletsky (LCO)/ESO

eso1205a.jpg

QLFits


The macOS QuickLook plugin for FITS files

QLFits


The macOS QuickLook plugin for FITS files

QLFits is the only OSX QuickLook for FITS files. It allows astronomers worldwide to quicklook their data right into the Finder, without having to open any application. It is for OSX 10.8 and up.

QLFits 3 is an entirely new implementation of QLFits, using the open-source projects ObjCFITSIO and AstroCocoaKit written by yours truly. QLFits show all HDU headers, and draw (when possible) all 2D images and 1D spectra.

QLFits reads the following extensions: fits, fit, fts, ft, mt, imfits, imfit, uvfits, uvfit, pha, rmf, arf, rsp, pi. If your FITS file is not recognised, let me know (cedric at onekilopars.ec), the dynamic OSX type of your file might not be included in the config of the plugin (which work with a combination of file extensions, UTIs – Universal Type Identifiers – and dynamic types...)

One-line Installer: Copy-paste the following command into a Terminal window:

curl -fsSLk https://raw.github.com/onekiloparsec/QLFits/master/Scripts/install.sh | sh

(Check here that this script is harmless):

potw1050a.jpg

ObjCFITSIO


The Objective-C wrapping framework for your cfitsio library

ObjCFITSIO


The Objective-C wrapping framework for your cfitsio library

ObjCFITSIO is an asynchronous Objective-C wrapper around cfitsio bringing object concepts to the famous FITS file library used by astronomers worldwide. It is already used by the QLFits plugin, and by another app I will present soon... 

Image Credits: ESO/José Francisco Salgado

eso0840a.jpg

FITSImporter


The macOS Spotlight plugin for FITS files

FITSImporter


The macOS Spotlight plugin for FITS files

 

FITSImporter is an macOS Spotlight plugin for FITS (Flexible Image Transport System) files,
used by astronomers and observatories worldwide to store and share their data.
For macOS 10.7+. Open source on GitHub.

 
 

One-line Installer: Copy-paste the following command into a Terminal window (click here to check that it is harmless): 

curl -fsSLk https://raw.github.com/onekiloparsec/FITSImporter/master/Scripts/install.sh | sh
 

Infos right into your finder automatically

Here is a typical "Get Info" panel applied to a FITS file, with FITSImporter installed.


Search right from your finder

A typical "search" in the Finder. As you can see, you can search for FITS files using typical astronomical informations (R.A, Dec and so on).

Be careful, though, the FITSImporter is not responsible for the automatic thumbnailing of the FITS images you can see above (in the CoverFlow of the Finder). That's the role of QLFits, the macOS QuickLook plugin for FITS files.