How to: install pysimdamicm [at gev]

This python package can not be installed at zev, ROOT compiled against python3 is mandatory which is not installed yet in this machine.

There are several ways to use panaSKImg or any script from pysimdamicm at gev:

  1. use the official installation (which is kept up-to-date)
  2. install pysimdamicm in your $HOME

The former does not need installation (this is already done), but requires the use of a python virtual environment. The second option requires installation.

No access at gev/zev

If you do not have access to gev/zev download the git repository from the gitlab:

[user@gev repos]$ git clone https://gitlab.in2p3.fr/damicm/pysimdamicm.git
[user@gev repos]$ cd pysimdamicm

There are several branches under development. The latest one with the full capabilities of pysimdamicm for analysis, as well as for simulations is extend_to_analysis.

[user@gev repos]$ git checkout extend_to_analysis

In this case, go directly to section 2.

1. Using the official installation

by setting the virtual environment

There are an offical installation at

/data/official_repos/pysimdamicm

under the folder

/data/official_repos/pysimdamicm/venv_analysis/

This installation has all required packages and is the one used to process automatically all data taken from the Compton setup.

OPTION A

If you do not have any previous installation of pysimdamicm under your $HOME, you just need to do the following step:

  1. Add the following lines into your .bashrc$^{[1]}$ file (or .bash_profile)
export PATH=${PATH}:/data/official_repos/pysimdamicm/venv_analysis/lib
export PATH=${PATH}:/data/official_repos/pysimdamicm/venv_analysis/bin
export PYTHONPATH=${PYTHONPATH}:/data/official_repos/pysimdamicm/lib

This extends the PATH) variable adding the direction where the pysimdamicm executables live. This will allow us to execute any script from pysimdamicm from any directory. The last line is required to use pysimdamicm package within the python infrastructure.

After that you are ready to use pysimdamicm from gev, and from any directory.

$^{[1]}$ .bashrc is a shell script that bash runs whenever it is started interactively. It initializes an interactive shell session. So, any particular environment, or customization (like aliases) should be included in this file.

OPTION B

If you already installed pysimdamicm but you want to use the official installation, you can use the python environment:

  1. Add the following lines into your .bashrc file (or .bash_profile)

    export PATH=${PATH}:/data/official_repos/pysimdamicm/venv_analysis/lib
    export PATH=${PATH}:/data/official_repos/pysimdamicm/venv_analysis/bin
    export PYTHONPATH=${PYTHONPATH}:/data/official_repos/pysimdamicm/lib
    
  2. Set the python virtual environment doing

    [user@gev ~]$ 
    [user@gev ~]$ source /data/official_repos/pysimdamicm/venv_analysis/bin/activate
    (venv_analysis) [user@gev ~]$
    

This set up pysimdamicm and all its dependencies in this particular shell, regardless of what dependencies you have in your $HOME.

As in the previous case, you can run any script of pysimdamicm from any directory. There is no limit on the number of shells using this environment.

To leave this environment just do

(venv_analysis) [user@gev ~]$
(venv_analysis) [user@gev ~]$ deactivate
[user@gev ~]$

2. Installing pysimdamicm in your home directory ($HOME)

Installation: pip or python setup.py?

A python package can be installed using pip or python setup.py. It is really important not to mix these procedures. If you choose to use pip, always reinstall using pip, and the same for the python setup.py.

Use pip if you are not going to develop code.

Use python setup.py when you have the role of develper.

Requirements

The package provides a (Distutils) setup.py to build and install pysimdamicm, as well as a list of required python packages, requirements.txt.

It has also a dependence with ROOT: you must have ROOT (version 6.18 or later) compiled against python3. See last section of this howto to install ROOT against python3 in your computer.

This is a lists of the prerequisite python packages that need to be installed to be able to build, install and run pysimdamicm. Caveat, the latest version of this list is the *requirements.txt* file not this list:

  • root-numpy 4.8.0 or later
  • matplotlib 2.2.2 or later
  • numpy 1.17.3 or later
  • scipy 1.4.1 or later
  • pandas 0.22.0 or later
  • uproot 3.11.3 or later
  • scikit-image 0.15.0 or later
  • astropy 1.3 or later

2.1 Installation via pip

Assuming you already have ROOT against python3 (gev meets this requirement, but not zev!).

By default, on linux, pip3 installs packages to

/usr/local/lib/pythonX.X/dist-packages

However using --user with the install sub-command will change this default location to

${HOME}/.local/lib/pythonX.X/site-packages/

Note that X.X is the python version (which should be 3.X).

  1. Install Requirements

    [user@gev ~]$ 
    [user@gev ~]$ cd /data/official_repos/pysimdamicm
    [user@gev pysimdamicm]$ pip3  install -r requirements.txt --user
    
  2. Install pysimdamicm

    [user@gev pysimdamicm]$ pip3 install . --user
    
  3. In order to be able to use pysimdamicm, include the directory where has been installed in your .bashrc file

    export PATH=${PATH}:${HOME}/.local/lib
    export PATH=${PATH}:${HOME}/.local/bin
    export PYTHONPATH=${HOME}/.local/lib/pythonX.X/site-packages:${PYTHONPATH}
    

Change X.X for the used python version (which should be 3.X).

2.2 Installation via python

Assuming you already have ROOT against python3 (gev meets this requirement, but not zev!).

By default, on linux, python installs packages to

/usr/local/lib/pythonX.X/dist-packages

However using --user during install will change this default location to

${HOME}/.local/lib/pythonX.X/site-packages/

Note that X.X refers to the python version (which should be 3.X).

  1. Install Requirements (this must be done with pip)

    [user@gev ~]$ 
    [user@gev ~]$ cd /data/official_repos/pysimdamicm
    [user@gev pysimdamicm]$ pip3  install -r requirements.txt --user
    
  2. Install pysimdamicm

    [user@gev pysimdamicm]$ python setup.py install --user
    
  3. In order to be able to use the pysimdamicm, include the directory where has been installed in your .bashrc file

    export PATH=${PATH}:${HOME}/.local/lib
    export PATH=${PATH}:${HOME}/.local/bin
    export PYTHONPATH=${HOME}/.local/lib/pythonX.X/site-packages:${PYTHONPATH}
    

Change X.X for the used python version (which should be 3.X).