Skip to content

Source code

Preliminaries

To compile luna from source, you'll need a system capable of configuring and compiling C/C++ code, and for the dependent libraries, ideally some kind of package manager. The instructions below refer to Unix-like operating systems, namely Linux and Mac OS.

Please note...

We're still in the process of optimizing the installation process, especially for lunaR which is not guaranteed to work seamlessly on all platforms.... If you are having trouble installing lunaC or lunaR, try working with the Docker container for now.

Before attempting to compile Luna, please ensure that you have the following (all of which can be obtained for free):

  • a C/C++ compiler: on Mac OSX, this can be achieved by installing Apple's XCode Command Line Tools. Open a Terminal window and type (you may get an error if they are already installed; to test whether they are already installed.):
xcode-select --install
  • a text editor: ensure you have a text editor that works with plain-text files (i.e. not a word processor), either old-school (e.g. emacs, nano, both of which are in the luna Docker container) or new-school (e.g. Atom, which is free, or Sublime Text, which is not)

  • R : the R project for statistical computing is obviously necessary to use lunaR -- but even if you don't plan to use lunaR, it will help when working with Luna output

  • optionally, a package manager: to obtain dependent libraries for Luna, a tool like Homebrew is very useful; follow the instructions on the linked page to install Homebrew

FFTW3

Beyond the preliminaries mentioned above, Luna requires FFTW3, a C subroutine library for computing the discrete Fourier transform (DFT). If FFTW is not installed on your system, choose one of the following routes to obtain it:

Option 1) Use a package manager

On a system with a package manager, e.g. such as apt or Homebrew, you can run the following to first update the required dependencies (possibly prefixing each command with sudo if needed, or installing locally):

  • On a Linux system using apt-get, first make sure everything is up-to-date:

    apt-get update 
    
    and then obtain FFTW:
    apt-get install libfftw3-dev
    

  • On a Mac using the Homebrew package manager, you might try:

brew install fftw 

These options should install FFTW so that it is accessible system-wide, so no special steps will be necessary when compiling Luna.

Option 2) Alternatively, compile FFTW from source

Go to the FFTW download page to pull the latest source. The current version used to compile Luna is 3.3.8, which you can directly download from this link: http://www.fftw.org/fftw-3.3.8.tar.gz.

Let's say you download fftw-3.3.8.tar.gz to the directory /home/joe/fftw/. The following should compile and install FFTW in that directory (i.e. rather than system-wide):

cd /home/joe/fftw/

tar -xzvf fftw-3.3.8.tar.gz

cd fftw-3.3.8

./configure --enable-shared --prefix=/home/joe/fftw/

make && make install

You'll then need to set the FFTW variable when compiling Luna (and lunaR too, if compiling that from source), as noted in the next section.

Luna base

Pull the latest Luna source code from the luna-base Bitbucket repository:

git clone https://bitbucket.org/remnrem/luna-base.git

Enter the luna-base folder:

cd luna-base

If FFTW libraries are accessible system-wide, to build luna:

  • On a Linux platform:
    make
    
  • On a Mac OSX platform:
    make ARCH=MAC
    

To specify a non-standard location of the Luna dependencies, i.e. if these were installed in /home/joe/fftw/, then set the FFTW variable equal to that location:

  • On a Linux platform
    make FFTW=/home/joe/fftw/
    
  • On a Mac OSX platform
    make ARCH=MAC FFTW=/home/joe/fftw/
    

Hopefully, this will result in a ready-to-run executable, luna, as well as destrat and some other files. Test these by typing ./luna, which should give something like:

./luna 
===================================================================
+++ luna | v0.9, 12-Feb-2019 | starting process 2019-02-21 14:57:44
===================================================================
usage: luna [sample-list|EDF] [n1] [n2] [@param-file] [sig=s1,s2] [v1=val1] < command-file

and

$ ./destrat 
error : usage: destrat stout.db {-f|-d|-s|-v|-i|-r|-c|-n|-e}

You can copy luna and destrat to any folder, e.g. likely one that is in your path, such as /usr/local/bin/, so that you can subsequently run luna by typing luna in any folder.

lunaR

This requires that you have downloaded and compiled the base version of Luna first. Make sure you are running a relatively recent version of R (which can be downloaded here): lunaR was developed on version 3.5.1. To install, if you have the devtools package, you might try this:

library(devtools)
Next, set an environment variable to LUNA_BASE point to the location of luna-base:
Sys.setenv( LUNA_BASE="/home/joe/luna-base/" ) 

Optionally, if you manually installed FFTW in a nonstandard location, then set a FFTW environment variable too:

Sys.setenv( FFTW="/home/joe/fftw/" ) 

Then run the following command to pull the package source from a Bitbucket and compile it:

devtools::install_bitbucket( "remnrem/luna" ) 

If there is an issue with permissions, you might need to write this to an alternate local library, e.g.:

devtools::install_bitbucket( "remnrem/luna" , lib="~/my-Rlib" ) 

Assuming that works, then once installed you should subsequently be able to run only this command to start the library:

library(luna)
** lunaR v0.2 17-Mar-2019
** luna v0.2 17-Mar-2019
If you specified an alternate library location, you'll need to add that too here:
library(luna,lib.loc="~/my-Rlib")

Note

Alternatively, (e.g. if you have trouble with devtools), you can obtain source code directly:

git clone https://bitbucket.org/remnrem/luna.git
Install the package, where LUNA_BASE (and if needed, FFTW) are set to the location(s) where you compiled Luna (and FFTW) as follows:
LUNA_BASE=/Users/joe/luna-base/ FFTW=/Users/joe/fftw R CMD INSTALL luna
This should then allow you to attach the lunaR library in R:
library(luna)
As above, if you don't have permission to write to the main R library, try creating a separate folder as follows:
mkdir ~/Rlib

LUNA_BASE=/Users/joe/luna-base/ FFTW=/Users/joe/fftw R CMD INSTALL --library=~/my-Rlib luna
Then, when in R, you'll need to call:
library(luna, lib.loc="~/my-Rlib")