# Install the CHARIS Data reduction pipeline¶

## Requirements¶

Python 2.7 Cython with a C compiler and OpenMP. C compilers as gcc-5, gcc-mp-5, gcc-mp-6 are acceptable.

Your computer should have at least ~2 GB of RAM to extract data cubes, and at least 2 GB/core (and at least 4 GB total) to build the calibration files. The calibration files can take a long time to generate if you do not have multiple processors.

## Dependencies¶

numpy, scipy, astropy

## Installation¶

The easy way to install is to use the setup.py in this directory with

python setup.py install


I strongly recommend that you first install the anaconda Python 2.7 from here if you are not already using anaconda: https://www.continuum.io/downloads If you are running this on a Mac, you need gcc from Xcode, and you probably need a homebrew installation of gcc-5 to enable OpenMP linking. Follow the instructions here: http://mathcancer.blogspot.com/2016/01/PrepOSXForCoding-Homebrew.html You may need to specify the C compiler when running the setup script using something like

CC=gcc-5 python setup.py install


or

CC=gcc-mp-5 python setup.py install


Type gcc [tab][tab] in a terminal to see your available gcc compilers. If you use tcsh instead of bash, your export command will be different, but something like this should work:

set CC = gcc-5
python setup.py install


You can check that the installation was successful by typing:

buildcal
Must call buildcal with at least three arguments:
1: The path to the narrow-band flatfield image
2: The wavelength, in nm, of the narrow-band image
3: The band/filter: 'J', 'H', 'K', or 'lowres'
Example: buildcal CRSA00000000.fits 1550 lowres
Optional additional arguments: filenames of darks
taken with the same observing setup.
Example: buildcal CRSA00000000.fits 1550 lowres darks/CRSA*.fits


### Windows 10 install¶

These instructions were provided by Zach Long and use the bash functionality within Windows 10. This procedure

1. Download Anaconda 2.7 Linux installer from their website

3. Navigate to the appropriate folder (the folder is in mnt/c/ somewhere, c refers to the windows C: drive or whatever the main drive is)

4. Install using “bash Anaconda2-4.3.1-Linux-x86_64.sh”

5. Install pip using “sudo apt-get install python-pip”

6. Do a “sudo pip install cython”

7. If you get an error with gcc exiting with code 1 use this command “sudo apt-get install python-dev”

8. Do another “sudo pip install cython”

9. Do a “conda install numpy” (might have to close and reopen bash for this)

10. Do a “conda install astropy”

11. Do a “pip install -U scipy” (I’m not sure why it needs the upgraded version but it does)

12. Navigate to the charis code folder again in /mnt/c/

13. Run “sudo python setup.py install”

14. Run “export KMP_AFFINITY=disabled” (this is because there is a known bug in scipy for windows bash. You’ll know if it’s happening if you get the following errors when you try to run buildcal

OMP: Error #100: Fatal system error detected.
OMP: System error #22: Invalid argument
Aborted (core dumped)


As far as I can tell you have to do it after you open a new bash terminal)

15. Done, it should work at this point, it worked for me at least. If something doesn’t work it’s usually something to do with scipy so you many need to run a sudo “pip install –upgrade pip”

16. Occasionally I have had to do a “alias sudo=’sudo env PATH=\$PATH’” if Cython decides not work because it’s using the wrong python, I’m assuming the one that came preinstalled

# Troubleshooting¶

Most of the installation issues on Macs that have been encountered so far come from slight differences in the versions and the installations of python and gcc. We recommend following the steps above thoroughly. Here are sharing some of the issues and potential solutions.

## Install gcc through Macports¶

Macports is a good alternative to download and install the correct version of gcc. First, make sure that the latest package definitions are updated with “selfupdate”, and then download and install the latest version of gcc5.

sudo port selfupdate
sudo port install gcc5


This should have installed the latest version of gcc5. You can check what versions of gcc are available by typing gcc [tab][tab]. For example on a 2017 MacBook Pro with xcode installed, these are the programs that are installed:

gcc              gcc-mp-6         gcc-ranlib-mp-6
gcc-ar-mp-6      gcc-nm-mp-6      gccmakedep


One would then run

CC=gcc-mp-6 python setup.py install


## Install the CHARIS DRP with AstroConda (or if you regular conda installation uses Python 3.xx)¶

In order to not disturb your installation of Python 3.xx (with which the pipeline is not yet compatible), we can create a separate, isolated Python environment with conda. You can find some instructions on how to do this for example at https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/. Below are the key elements:

conda create -n py27 python=2.7 anaconda


And once the installation is complete, you can activate your environment

source activate py27


To jump back out of the environment to your regular environment without having to close your terminal, you can type:

source deactivate py27