Tips for Python beginners
Using anaconda is strongly recommended. Simply follow the instructions here for your operating system (Linux, Mac, Windows, ...). If you already feel confident with virtual environments, consider setting up a new one for allesfitter (more infos here). Otherwise, don't worry, you're good to go with the base anaconda, too.
Having installed anaconda, open a new terminal window and make sure you are in the right anaconda environment (it will say "base" or your virtual environment name at the start of the line).
If you are on a Mac, make sure to switch to a bash terminal. You can do this for this session only by executing "bash" or do it permanently by executing "chsh -s /bin/bash".
Now execute "which conda" to make sure it returns the correct path. Something like "/Users/janeeyre/opt/anaconda3/bin/conda" if you use the base anaconda.
Then execute "which pip" to make sure it returns the correct path. Something like "/Users/janeeyre/opt/anaconda3/bin/pip" if you use the base anaconda.
Some packages come pre-installed with anaconda. You can check if you have them by opening a Terminal window and executing the generic "conda list" (shows you everything) or the specific "conda list xyz"(xyz being the respective package name below).
You can install missing packages via conda:
conda install xyz
And more specific packages via pip:
pip install xyz
pip install allesfitter
Standard packages (pre-installed or install via conda):
python (>=2.7 or >=3.5)
Special packages (install via pip):
ellc (>=1.8.0) 
dynesty (>=0.9.3) 
emcee (>=3.0.0) 
celerite (>=0.3.0) 
corner (>=2.0.1) 
Even more special packages (install via pip, optional):
 semi-optional; for planets and binaries; see below for troubleshooting
 semi-optional; for Nested Sampling
 semi-optional; for MCMC
 semi-optional; for Gaussian Processes
 semi-optional; if you want corner plots (you know you do.)
 optional; if you want top-down-view plots of the orbits (you might not yet know, but you do.)
 optional; if you want to search for transits and guesstimate TTVs (you might not yet know, but you do.)
 optional; if you want to search for transits (you might not yet know, but you do.)
Trouble with Fortran and C compilers for ellc?
The package ellc needs you to have a Fortran compiler installed. Try using `pip install ellc' at first, as you would usually do. If it fails and complains about compilers, follow the steps below.
On Mac (with Intel chips) and Linux
Check if you have homebrew installed. In a terminal, execute `brew info'. If some text about kegs and files and GB appears, you're all set. If not, you have to install homebrew. Follow the instructions here.
Now open a new terminal and execute `brew install gcc'. That's all!
Now you can proceed to `pip install ellc'.
On Mac (with M1/M2 chips)
Note: Anaconda does not yet fully support the new M1 cips. As an alternative, miniforge is the earliest available conda installer that supports the new M1 chips. Its default channel, conda-forge, provides the latest packages for various architectures, including ARM64. This means that it can provide more streamlined support for M1 chips than anaconda currently can. All credit for this solution goes to Xian-Yu Wang, see here
Install Xcode using the following command: `xcode-select --install'
Install homebrew (https://brew.sh/) and gfortran using the command: `brew install gcc'
Download and install miniforge from this link
Install all the packages you need using the command: `pip install numpy matplotlib seaborn scipy astropy statsmodels emcee corner tqdm dynesty celerite h5py rebound'
Finally, install ellc and allesfitter using the following command: `pip install ellc allesfitter'
There are several steps to follow before running allesfitter on Windows. You can use the following procedure to run allesfitter on Windows. All credit for this solution goes to Xian-Yu Wang.
Install Chocolatey to manage software for Windows:
# Open PowerShell as an administrator
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install gfortran to compile ellc
choco install mingw cmake
# Install wget to download what you want
choco install wget
# Install m2-base to use common Linux commands like clear, ls -la, grep, and so on
conda install m2-base
Install Miniconda on Windows (https://docs.conda.io/en/latest/miniconda.html).
Create an environment and install packages:
# Open Conda prompt
conda create -n allesfitter python
pip install numpy matplotlib seaborn scipy astropy statsmodels emcee corner tqdm dynesty celerite h5py rebound
pip install ellc
pip install allesfitter
Run a test (03_transits_with_GPs):
# Open Conda prompt
# Download allesiffter
git clone https://github.com/MNGuenther/allesfitter.git
# Enter the folder named `03_transits_with_GPs`
# Run the test
Troubleshooting possible problems (will be resolved in future allesfitter versions):
AttributeError: module 'numpy' has no attribute 'float':
Numpy v1.24.0 has completely removed np.float. You can try to install numpy<1.23 to solve this problem or replace all np.float with np.float64. The locations of np.float can be found via this link (https://github.com/MNGuenther/allesfitter/search?q=np.float).
ValueError: cannot find context for 'fork':
The way to start a child process is different between Windows and Linux/MacOS. See the detailed explanation via this link (https://www.pythonforthelab.com/blog/differences-between-multiprocessing-windows-and-linux/). Therefore, we need to change the way to start a child process when we use allesfitter on Windows.
Replace the following code in allesfitter (https://github.com/MNGuenther/allesfitter/search?q=fork):
if os.name == 'posix':
AttributeError: module 'allesfitter.config' has no attribute 'BASEMENT':
The explanation for this error is that Windows does not copy global variables when it uses multiprocessing. Therefore, allesfitter does not find 'BASEMENT' in the child process. However, we can pass them using the initializer argument (ref: https://stackoverflow.com/questions/29835478/scope-of-global-variables-in-python-in-windows).
Add this function to mcmc.py:
Change the following code in mcmc.py:
with closing(Pool(processes=(config.BASEMENT.settings['multiprocess_cores']))) as pool:
with closing(Pool(processes=(config.BASEMENT.settings['multiprocess_cores']), initializer=init_mcmc, initargs=(datadir,))) as pool: