Table of Contents
Polpy & threeML
Below are the instructions to install Polpy and threeML. Everything is to be done inside the Python environment.
Prerequisites
The process of installing Prerequisites varies with different operating systems.
1. If you are using a MacOSX-arm64 system, please follow:
1.1 Install miniconda3
First, we need to install miniconda Do this through:
mkdir -p ~/miniconda3 curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda3/miniconda.sh bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 rm ~/miniconda3/miniconda.sh
1.2 Conda Environment
Set up a Python virtual environment using conda (install Anaconda if you don't have it already). Do this through
conda create -n polpyenv python=3.9
Activate your conda environment
conda activate polpyenv
When you finish your analysis, you can exit the environment by
conda deactivate polpyenv
You can deactivate it through “conda deactivate”. Install pip inside conda:
conda install conda-forge::pip
1.3 Installing Necessary Packages
Install the necessary packages through the following commands:
conda install -c conda-forge numpy pandas matplotlib scipy pip install --upgrade pip setuptools wheel conda install -c conda-forge hdf5 pip install cmake conda install -c conda-forge gfortran conda install conda-forge::pygmo conda install conda-forge::numba conda install -c conda-forge pytables
2. If you are using a Linux or MacOSX-Intel system, please follow:
2.1 Use pyenv for a Virtual Environment
Creating a virtual environment allows you to install packages safely without interfering with the system Python.
You can use pyenv for this purpose (or virtualenvwrapper, instructions in this https://virtualenvwrapper.readthedocs.io/en/latest/).
You can install pyenv by executing this line in your terminal:
curl https://pyenv.run | bash
After installing the package, append the auto-loading lines printed on the terminal to ‘~/.bashrc’ or ‘~/.zshrc’, and source the files.
2.2 Establishing a Virtual Environment
We suggest fixing Python 3.9 for this work (to avoid deprecation of dependencies).
With pyenv, you can install Python 3.9 by:
pyenv install 3.9 pyenv virtualenv 3.9 polpyenv pyenv activate polpyenv
Once you are done with all your analysis, you can deactivate the virtual environment with (don't do it now but when you finish your analysis):
pyenv deactivate
2.3 Installing Necessary Packages
Install the necessary packages through the following commands:
pip install --upgrade pip setuptools wheel pip install numpy pandas matplotlib scipy pip install pygmo pip install numba
Once the prerequisites are satisfied, you can thereafter follow the steps below commonly for different systems.
Clone Repositories
Create a dedicated directory for the whole project/environment. Navigate to the folder containing the whole project:
mkdir workshop cd workshop/
Thereafter, cone the GitHub repos through:
git clone https://github.com/sujaymate/astromodels git clone --branch polpy_dev --single-branch https://github.com/sujaymate/threeML/ git clone https://github.com/JohannesBuchner/MultiNest/ git clone https://github.com/JohannesBuchner/PyMultiNest git clone --branch patch-1 --single-branch https://github.com/hellohancheng/polpy/
Installing Astromodels
Assuming you are in the “workshop” directory. Install the astromodels through:
cd astromodels/ pip install . cd ../
Installing threeML
Assuming you are in the “workshop” directory. Install the threeML through:
cd threeML/ pip install . cd ../
Installing MultiNest
Assuming you are in the “workshop” directory. Install the MultiNest through:
cd ../MultiNest/build/ cmake ../ make sudo make install cd ../..
Installing pyMultiNest
Assuming you are in the “workshop” directory. Install the __ pyMultiNest__ through:
cd PyMultiNest pip install . cd ../
Installing polpy
Assuming you are in the “workshop” directory. Install the __ polpy__ through:
cd polpy pip install . cd ../
Running example script to test Polpy & threeML
Assuming you are in the “workshop/polpy” directory. You can run the example script through:
cd examples python polar_GRB170114A.py
Optional
Thereafter, if your script running complained about the incompatibilities among Numpy, Astropy and other packages, you can downgrade your Numpy by doing this:
pip install numpy==1.26.4 --force-reinstall --no-cache-dir
Add the following lines to your .bash_profile file (or similar).
vim ~/.bash_profile
Inside add the following lines.
export OMP_NUM_THREADS=1 export MKL_NUM_THREADS=1 export NUMEXPR_NUM_THREADS=1
Save and exit the file. Then do:
source ~/.bash_profile
