This code depends upon multiple astronomical and signal processing packages and specific applications/interfaces required for functionalities and optmimisations. All these are explained bellow.
For those who want to install everything from scratch, here are the instructions. These packages were tested on different Linux distros. For Mac OS, we need some more testing since limitations may arise from:
- The
CASAmodular package (see their website for installation instructions) JaX(see their website for installation instructions)PyBDSF(see their website for installation instructions)
Install miniconda with:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh
After, create a new conda environment (e.g. python 3.8 is more appropriate to be used with CASA):
conda create -n morphen python=3.8
conda activate morphen
conda update --all
At the moment, some libraries depend on the modular CASA pacakge (in Python).
To use the collection of functions inside morphen, the recommended way to
install the modular version of CASA is using conda environments.
Another reason is that this is the easiest way to merge CASA functions with other
python interfaces, such as numpy, scipy, astropy and Jax.
To install casacore within conda, follow the instructions in this page: https://github.com/conda-forge/casacore-feedstock
conda config --add channels conda-forge
conda update --all
conda config --add channels pkgw-forge
conda update --all
Install casacore and CASA modular packages (casatools, casatasks, etc):
conda install casacore
Install CASA related packages with pip:
pip install casatools==6.4.4.31
pip install casatasks==6.4.4.31 casaplotms casadata casaviewer casampi casaplotserver casalogger
To use casaviewer (imview), you have to downgrade protobuf to version 3.20.3:
pip install protobuf==3.20.3
Then, install python related packages:
pip install ipython notebook jupyter tqdm matplotlib corner sympy cmasher coloredlogs
pip install scipy==1.10.1
pip install numpy==1.24.3 astropy==5.2.2 pandas==1.5.3 astroquery tableprint prettytable
Optmisation packages:
pip install datashader
Some utilities are used to quantify image structure. For that, python packages that are used are:
pip install scikit-image==0.20.0 scikit-learn==1.2.2
pip install petrofit
pip install photutils==1.6.0 sep fitsio
pip install astrodendro bdsf
Image fitting is performed with the LMFIT package, alongside scipy and the Monte Carlo emcee package.
pip install lmfit==1.1.0 emcee==3.1.4 h5py==3.7.0 corner arviz==0.15.1 dynesty
Note: At the momment, for an unknown reason, minimisation using Jax is not occuring in the desired
way if using the last stable
version of LMFIT (> v 1.2.1), but it does for v 1.1.0. So, while the issue is not identified,
please use the indicated particular version of LMFIT.
Some functions are decorated within the Jax framework to be optmised for CPU or to run on
Nvidia GPUs (through CUDA).
Jax can be installed with cuda-12.0. The recommended way is to install within a conda
environment (the same created before). See more instruction in https://github.com/google/jax#installation.
pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip install --upgrade "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip install --upgrade pip
pip install --upgrade "jax[cpu]"
Note: In either case, the code can be run independently of the system. Jax will automatically detect if a GPU is available or not. If not, the code will run on CPU, but will be optmised and benefit from multi-core processing.
Install Rosetta
softwareupdate --install-rosetta
and then open a new terminal.
Download and install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
arch -x86_64 chmod +x Miniconda3-latest-MacOSX-x86_64.sh
arch -x86_64 ./Miniconda3-latest-MacOSX-x86_64.sh
arch -x86_64 conda config --set auto_activate_base false
Create the environment:
arch -x86_64 conda create -n morphen python=3.8
conda activate morphen #do not use arch -x86_64 here
arch -x86_64 conda update --all
Add required channels:
arch -x86_64 conda config --add channels conda-forge
arch -x86_64 conda update --all
arch -x86_64 conda config --add channels pkgw-forge
arch -x86_64 conda update --all
Install CASA related packages with pip:
arch -x86_64 python3 -m pip install casatools==6.5.1.23
arch -x86_64 python3 -m pip install casatasks==6.5.1.23
arch -x86_64 python3 -m pip install casadata
arch -x86_64 conda install casacore
arch -x86_64 python3 -m pip install casaplotms casaviewer casampi casaplotserver casalogger
<!-- arch -x86_64 conda install casampi mpi4py -->
To use casaviewer (imview), you have to downgrade protobuf to version 3.20.3:
arch -x86_64 python3 -m pip install protobuf==3.20.3
Then, install python related packages:
arch -x86_64 pip install ipython notebook jupyter tqdm matplotlib corner sympy cmasher coloredlogs
arch -x86_64 pip install scipy==1.10.1
arch -x86_64 pip install numpy==1.24.3 astropy==5.2.2 pandas==1.5.3 astroquery tableprint prettytable
Some utilities are used to quantify image structure. For that, python packages that are used are:
arch -x86_64 pip install scikit-image==0.20.0 scikit-learn==1.2.2
arch -x86_64 pip install petrofit
arch -x86_64 pip install photutils==1.6.0 sep fitsio
arch -x86_64 pip install astrodendro bdsf
Image fitting is performed with the LMFIT package, alongside scipy and the Monte Carlo emcee package.
arch -x86_64 pip install lmfit==1.1.0 emcee==3.1.4 h5py==3.7.0 corner arviz==0.15.1
arch -x86_64 pip install --upgrade pip
arch -x86_64 pip install --upgrade "jax[cpu]"
arch -x86_64 pip install --upgrade jit
arch -x86_64 pip install dynesty
Using Jax, run time can be reduced by a factor of 10-20 if running in a CPU, or by a factor of 100-500 if running in a GPU!
However, more detailed benchmarks are required. If you would like to contribute, please contact us.

Coming out soon