Installing PyORBIT#
Using PyORBIT on Windows#
Short version: don’t do it.
Long version: I never tested PyORBIT on Windows, so I cannot guarantee that the outcome of the analysis is what it is supposed to be, or if it will work at all.
Rather than trying to fix PyORBIT or Python on Windows, I usually suggest setting up an Ubuntu machine with Windows Subsystem for Linux 2. With respect to installing a virtual machine, WSL2 will use fewer computer resources while giving direct access from Windows to Linux files and vice versa.
Setting up an environment#
Before proceeding with the installation, I suggest creating an environment dedicated to PyORBIT using Python 3.10. This is the version I’m currently use to test the code.
With conda/anaconda:
conda create --name pyorbit python=3.10
If you are using a Mac with ARM architecture, the following command should force conda to install x86_64 versions of Python and all packages (many thanks to Jinglin Zhao for the tip):
CONDA_SUBDIR=osx-64 conda create -n pyorbit python=3.10
To list the available environments do:
conda env list
The active environment will be marked with a *
To activate the pyorbit environment:
conda activate pyorbit
Install using pip#
You can then install PyORBIT by using pip:
pip install pyorbit-package
Note that the name is pyorbit-package and not pyorbit, as the former was already taken by another package in PyPI (although not installable). The name for package importation will still be pyorbit:
python -c "import pyorbit"
PyORBIT only comes with the basic packages; to exploit its full potential, follow the instructions in the section Requirements. For the impatient, just do:
wget https://raw.githubusercontent.com/LucaMalavolta/PyORBIT/main/extra_requirements.txt
pip install -r extra_requirements.txt
Tip
The requirement file has weaker constraints on package versioning (see below), so remember to install PyORBIT first to avoid version incompatibilities
ARoME and PyARoME installation#
Starting from vwersion 11.3 of PyORBIT, it is possible to fit the Rossiter-McLaughlin effect using the analytical expressions by Boué et al. 2013. The code, called ARoME, and the instructions to install it, can be downloaded form the official web page.
The following instruction have been tested on Ubuntu 22.04 and 24.04 using bash as default terminal, for different versions aand architecture may not work. Contact your local expert if something is not working.
Install the ARoME library#
First of all, download and compile the arome library.
wget https://www.astro.up.pt/resources/arome/files/arome-1.0.0.tar.gz
tar -xvf arome-1.0.0.tar.gz
cd arome-1.0.0
./configure
make
sudo make install
If you have root privileges on your machine, you can install the library with the following commandf.
sudo make install
You will get a message stating where the libraries have been installed (the actual path may be different in your system):
Libraries have been installed in:
/usr/local/lib
In order for PyARoME to work, the path to the arome library must be included in your LD_LIBRARY_PATH system variable. First check if the path is present:
echo $LD_LIBRARY_PATH
>> /usr/local/lib/:
If the installation path of the library is not present, edit the .bashrc file in your home directory and add the following line:
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
Finally, you have to apply the changes by either closing and reopening the terminal, or by running
source ~/.bashrc
Note that the last command may activate your default conda environment.
Install the PyARoME package#
The original code is written in C. The Python interface used in PyORBIT is PyARoME (GitHub) by Andres Jordan. To install the package, you will need to downgrade the version of distutils to version 64 (version 65 will not work).
For this reason, I suggest to install PyARoME as the last package of the PyORBIT environment.
pip install setuptools==64
git clone https://github.com/andres-jordan/PyARoME.git
cd PyARoME
python setup.py install
If the path is not listed, you have to open the .bashrc file inyour home
If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR’ flag during linking and do at least one of the following:
add LIBDIR to the `LD_LIBRARY_PATH’ environment variable during execution
add LIBDIR to the `LD_RUN_PATH’ environment variable during linking
use the `-Wl,-rpath -Wl,LIBDIR’ linker flag
have your system administrator add LIBDIR to `/etc/ld.so.conf’
Annoying findfont problem updated#
You may get this problem, caused by the fact that Matplotlib is trying to use MicroSoft fonts not installed on your computer.
findfont: Font family 'Arial' not found.
I found several solutions around, the only ones that worked for me are Alexander Lab @ WHOI and on StackOverflow
In the first solution, you install the fonts through conda:
conda activate pyorbit
conda install -c conda-forge mscorefonts
rm ~/.cache/matplotlib -rf
In my WSL2 Ubuntu 22.04, this solution did not work, so I tried the one suggested in StackOverflow:
sudo apt install msttcorefonts -qq
rm ~/.cache/matplotlib -rf # remove cache
One of the comments suggested reinstalling findfont, but it wasn’t needed in my case.
Note that this one will only work on Ubuntu or systems using Ubuntu’s Advanced Packaging Tool (APT)
Install from the repository#
Download the latest version from the GitHub repository:
git clone https://github.com/LucaMalavolta/PyORBIT.git
If you are downloading the code from GitHub, most likely it’s because you want to try the development version
cd PyORBIT
git checkout development
Note
The development version may not be available at all times.
You can then install PyORBIT by using pip inside the code repository:
pip install .
Alternatively, you can install PyORBIT using the setup.py file:
python setup.py install
Keep in mind that you can still run PyORBIT by specifying the full path of the code. For example, if you cloned the repository in the folder ~/CODE/PyORBIT, you can run the analysis and explore the results with these scripts:
python ~/CODE/PyORBIT/PyORBIT_Run.py emcee configuration_file.yaml
python ~/CODE/PyORBIT/PyORBIT_Results.py emcee configuration_file.yaml -all
Again, I suggest to install the extra requirements following the instructions given above
If you repent and you want to go back to a previous version of PyORBIT, just install the desired version with pip:
pip install pyorbit-package==10.0.0
Requirements#
Give people credit for their work
If you are using any of those packages listed above, please be sure to cite the proper references, as stated in the relative web page.
These packages are installed automatically when using pip.
numpy,scipy,matplotlib: pretty standardnumba: open source JIT compiler, actually required as an undeclared dependency by some packages (numba home page)argparse: Parser for command-line options, arguments and sub-commands, required to pass terminal keywords (argpares home page)pyyaml: a full-featured YAML framework for the Python programming language. YAML is the language used for the configuration file (pyyaml home page, yaml home page)h5py: HDF5 for Python (h5py home page)pygtc: Make a publication-ready giant-triangle-confusogram (GTC) (pygtc home page)tqdm: A Fast, Extensible Progress Bar for Python and CLI (tqdm home page)
Basic analysis can be performed using the scipy.optimize package, however to fully unwind the power of PyORBIT these two packages should be installed:
pyDE: global optimization package ([PyDE home page])emcee: ensemble sampling toolkit for affine-invariant MCMC (emcee home page).
emcee is already included in the requirements, pyDE needs to be installed separately as the GitHub version supports multiprocessing:
pip install git+https://github.com/hpparvi/PyDE.git
THe alternative ensemble slice sampler zeus is supported as well (zeus home page).
Tip
pyDE and all the additional requirements can be installed by locating the extra_requirements.txt file in the PyORBIT repository or by downloading it directly from here and then running from a terminal:
pip install -r extra_requirements.txt
Additional requirements#
Depending on the kind of analysis you want to perform, you may need the following packages:
Transit modelling:
batman: Bad-Ass Transit Model cAlculatioN (BATMAN home page)PyTransit: a package for exoplanet transit light curve modelling ([Pttransit home page])
Gaussian Process Regression:
george: a fast and flexible Python library for Gaussian process regression (george home page)celeriteorcelerite2: an algorithm for fast and scalable Gaussian process regression (celerite home page, celerite2 home page)
Nersted Sampling:
dynesty: a pure Python Dynamic Nested Sampling package for estimating Bayesian posteriors and evidence (dynesty home page)UltraNest: fit and compare complex models reliably and rapidly with advanced sampling techniques (UltraNest home page)
Other models:
PyAstronomy: a collection of astronomy-related packages (PyAstronomy home page)starry: a suite of tools for mapping stars and exoplanets based on timeseries data (starry home page)spiderman: A fast code to simulate secondary transits and phase curves (spiderman home page)
Warning
spiderman installation with recent version of matplotlib will fail, a working version can be found at this repository and can be installed directly from terminal with this comand:
pip install git+https://github.com/LucaMalavolta/SPIDERMAN.git
as the installation of this package may result problematic for its many dependencies, it has been excluded from the extra_requirements.txt file.