1. Installation

1.1. Generalities

Hazel v2.0 is a Python 3 module with some wrapped compiled Fortran routines. It should be pretty easy to install once you have a working compiler in your system.

There are different ways to install Hazel v2.0, but the best is to install it into a virtual environment either with pip or conda, which makes everything much more safer, plus making sure that all packages are installed for the code. For example, once you have installed Miniconda, you can generate a new environment and install the dependencies (you can install whatever version of Python 3 you desire). For consistency, it is better to use the gfortran compilers from Anaconda. In the following we show how install all packages with Anaconda. Anyway, feel free to use the gfortran compiler from your system but you might have some issues.

For a Linux OS, type:

conda create -n hazel_env python=3.10
conda activate hazel_env
conda install -c conda-forge cython numpy h5py tqdm scipy astropy mpich mpi4py configobj gfortran_linux-64 gcc_linux-64 asciitree

A different version of Python can be installed in the environment. For Mac OS, type:

conda create -n hazel_env python=3.10
conda activate hazel_env
conda install -c conda-forge cython numpy h5py tqdm scipy astropy mpich mpi4py configobj gfortran_osx-64 gcc_osx-64 asciitree

The specific packages for the Fortran and C compilers might change depending on the version of Anaconda that you have installed in your system. Their name might also be gfortran and gcc or simply compilers. Feel free to add matplotlib for doing some plots. You will need it if you want to run some of the examples shown in this documentation in your computer.

If you also want to use the GUI, you need to add two new dependencies:

conda create -n hazel_env python=3.10
conda activate hazel_env
conda install -c conda-forge cython numpy h5py tqdm scipy astropy mpich mpi4py configobj gfortran_linux-64 gcc_linux-64 matplotlib pyqt asciitree

Remember to add ipython if you are using this shell to run Hazel v2.0. Otherwise, it will use ipython from another environment and you can get confused.

If you want to use the NLTE neural option for synthesizing the Ca II 854.2 nm line, the packages pytorch, pytorch_geometric and pytorch-scatter should be installed. Take a look at the documentation for PyTorch , PyTorch Geometric PyTorch Scatter for more information. A typical installation using pip can be done using:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.2.0+cpu

1.2. Installation from source

Since Hazel v2.0 is still in a heavy development phase, the only possible way of installing the code is via compilation of the sources. Once your environment is activated (or in your base environment if you prefer not to use a different environment), the sources can be installed by cloning this repository and installing it:

git clone https://github.com/aasensio/hazel2
python setup.py install

Do not forget to often pull from the repository and recompile the code by typing the following from the location of the sources:

git pull
python setup.py install

Improvements are pushed all the time in Hazel v2.0. In case you do not want to reinstall it after every pull or you are in fact helping on the development of the code, you can also install it in develop mode:

git pull
python setup.py develop

1.3. Requirements

Hazel v2.0 depends on the following external packages, that should be pretty straightforward to install:

  • numpy

  • h5py

  • scipy

  • astropy

  • mpich

  • mpi4py

  • configobj

  • tqdm

  • asciitree

If you want to use the GUI, you also need to install the following dependencies:

  • matplotlib

  • pyqt5

All of them can be installed in Anaconda with:

conda install numpy h5py scipy astropy mpi4py configobj tqdm pyqt maplotlib

1.4. Container

A simple way of installing Hazel v2.0, at least in Linux systems or supercomputers, is to use this Apptainer container. This container has all the dependencies installed and it is ready to be used. You can download it (we try to keep this version as updated as possible) and run it with Apptainer as:

::

apptainer run hazel.sif python invert.py

In principle, you can build your own container by going to the apptainer directory in the distribution and running:

::

apptainer build hazel.sif hazel.def

1.5. For developers

Remember that if you want to be involved in the development of the code, it is perhaps more useful to install the code using

python setup.py develop

so that you can immediately test the changes to the code. This development version can be uninstalled by typing:

python setup.py develop --uninstall

1.6. Documentation

For the compilation of the docs, you will need the following packages:

sphinx numpydoc sphinx_rtd_theme nbsphinx

1.7. Issues

MacOSX Catalina has some issues with the paths to the include files. Defining the following environment variables might help.

export CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
export CCFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
export CXXFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
export CPPFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"

1.8. Supercomputers

Configuring Hazel v2.0 for running in supercomputers should be easy. We recommend to locally create an Anaconda installation with the needed packages and follow the details given by the supercomputer staff.