Installation

Currently, the recommended installation method is from source on a Linux-like environment.

Note

For Microsoft Windows users, it is recommended to run the following setup in a Windows Subsystem for Linux (WSL). Debian or Ubuntu are preferred Linux distributions. Furthermore, an optimized experience is obtained with MobaXterm.

Jupyter kernel (for ESRF users)

You can install a sloth kernel and use it directly on the ESRF cloud.

  • First of all, login into [https://jupyter-slurm.esrf.fr]

  • Open a terminal and install the kernel:

    /home/esrf/rovezzi/local/conda/envs/sloth/bin/python -m ipykernel install --user --name sloth --display-name "sloth"
    
  • You now create and run notebooks using the sloth kernel.

Note

To get your experimental data accessible into the notebook, you should create a symbolic link in your home directory.

Environment setup

The following instructions will guide you to set-up a dedicated Python environment called sloth and install a minimal version of the library.

  • We will work in $HOME/local:

    cd; mkdir local; cd local
    
  • First of all, install Mambaforge on your system. If you are on Linux, this can be done just by:

    wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh -O mambaforge.sh
    bash mambaforge.sh -b -p $HOME/local/conda
    
  • Open a shell with the Conda base environment activated. I refer to it as (base)$ in the following:

    $ source $HOME/local/conda/bin/activate
    
  • [optional] Update to the latest version of mamba, conda, python and pip:

    (base)$ mamba update -y mamba conda python pip
    
  • Install git (if not yet present in your environment):

    (base)$ mamba install -y git
    
  • Clone the Sloth repository:

    (base)$ git clone https://github.com/maurov/xraysloth.git
    

Note

if you are behind a proxy, you may need to configure git for it:

(base)$ git config --global http.proxy HOST:PORT
  • Make sure the packages listed in binder/apt.txt are available in your system, otherwise install them (if you have root access, otherwise ignore this step):

    $ grep -v '^#' apt.txt | xargs sudo apt-get install -y
    
  • Create sloth Conda environment:

    (base)$ cd xraysloth/binder
    (base)$ mamba env create -f environment.yml
    

Note

This will install a relatively large number of libraries. If you want to keep a minimal environment and install only those librariers you want, you can manually create the sloth environment:

(base)$ mamba create -n sloth python==3.9 #install then the librariers you want with `mamba install ...`
  • Activate the environment:

    (base)$ conda activate sloth
    
  • Run the postBuild script to complete install the Jupyter extensions:

    (sloth)$ bash postBuild
    
  • Enjoy!

Daily working environment

For a daily working environment, you should use a Python IDE.

Recommended IDEs are:

Note

Under Windows install it the application the standard way and use the integrated WSL extension.

Notes requirements

Currently, the mandatory requirements are:

Nevertheless, other libraries are required to fully run all the scripts:

Usage

Full documentation will reside in the docs directory at a certain point. Meanwhile, the best is to read directly the __doc__ strings in the source code. The Python files sometimes have a test/example included in the __main__ block or referring to the examples directory where each script has its own examples/tests. Unit tests are in progress and will reside in sloth.test.

The functionality of the scripts can be easily converted to Larch plugins in order to have access via the Domain Specific Language (DSL) of Larch. If you need it, just drop me a line! Some functions are already exposed to Larch. To load the plugins into Larch is described here.