DRP installation
The MEGARA pipeline is a Python package, for Python 3.9 or greater.
The easiest method of installing megaradrp is using pip inside a virtual
environment.
You can install official relares or the development version.
All the commands in the following sections, starting with $
are to be run under bash shell.
Install with pip
A virtual environment creates isolated Python installations, with (potentially) different package versions. We will use the venv package (a module in the standard library) here, although the virtualenv package can also be used.
The steps to run MEGARA DRP in a virtual environment are:
Create a virtual environment
A virtual environment will have a name and a path. In order to create a virtual environment called e.g. megara using venv:
With virtualenv:
The directory /path/to represents the location of the environment.
It can be any valid directory path. If the path name is not specified, it will be created in the working directory (notice that virtual environments shouldn’t be moved after creation).
Activate the environment
After creating the environment, the directory /path/to/megara
contains a Python tree. One of the directories is
/path/to/megara/bin, which contains a script called activate. To
activate the environment, we source (a bash shell command) this script
file:
which yields a different system prompt to the user:
Now, the name of the environment appears before the standard prompt. We can use the environment only on those consoles / terminals where we have previously activated it.
Install megaradrp with pip
After the activation, we can install megaradrp with pip. This is the standard Python tool for package management. It will download the package and its dependencies, unpack everything and compile when needed.
What follows is a sample of the output:
(megara) $ pip install megaradrp
Test the installation
Now we can test the installation by running the numina command:
(megara) $ numina show-instruments
The particular output of the command may change, but Instrument: MEGARA text
should always appear.
Update within the environment
In order to update the MEGARA DRP to the latest stable release, the user should execute:
(megara) $ pip install -U megaradrp
Deactivate the environment
To exit the environment is enough to exit the terminal or run the command deactivate.
Install in conda
Conda was created with a target similar to virtualenv, but know has extended its functionallity to package management for different languages.
You can install miniconda or anaconda. The difference is that miniconda provides a light-weight environment and anaconda comes with lots of Python packages.
If you have updated the $PATH variable during install, you can call
conda commands directly in the shell, like this:
If not, you will need to add the path to the command (an example path
could be miniconda3/bin), like:
If that is the case, you should add that path every time you run a conda command hereafter. Alternatively, you can initialize conda for your own shell by doing:
This works as it is if you are using a login-shell (terminal), but if you are using an xterm, you might also need to do:
(do a backup copy of ~/.bashrc if you have one already),
and open a new terminal/xterm. Below, we will write the commands without the
full path, for simplicity. If you are using conda version 4.4+ your terminal
will open in the conda (base) environment. If you want to avoid that
permanently just do: conda config --set auto_activate_base false.
Once conda is installed according to the instructions above, the steps to run MEGARA DRP under conda would be the following:
Create a conda environment
We first recommend that you update your conda installation to its latest by doing:
With conda, environments are created in a centralised manner (under
directory ./envs in your conda tree), we do not pass the path to the
environment.
One could remove this environment (and all its content), if needed, by simply doing:
Install megaradrp with conda
Packages can be installed before activating the environment. We provide conda packages for megaradrp in the conda-forge channel
Activate the environment
The functionality is similar to virtualenv:
Again, after activating the environment, the name of the environment appears before the standard prompt. We can use the environment only on those consoles / terminals where we have previously activated it.
Test the installation
Now we can test the installation by running the numina command:
(megara) $ numina show-instruments
Update within the environment
In order to update the MEGARA DRP within the conda environment the user should execute:
(megara) $ conda update megaradrp
Deactivate the environment
To exit the environment is enough to exit the terminal or run the command source deactivate
Update outside the environment
Once outside the conda environment one can also update the MEGARA DRP installation by doing:
If you want to deactivate the conda (base) environment entirely you can run again:
Development version
For those of you interested in installing the development version, please consult the instructions at the readthedocs.org webpage at https://megaradrp.readthedocs.io/en/latest/installation.html. The use of the development version is recommended to have access to the latest DRP improvements.