Introduction

This section contains different Jupyter notebooks showing how to use models of the QENS library. The sub-folder using_mantid details how to proceed if you want to use Mantid (link).

Note that in order to open and run these examples, you need jupyter, matplotlib, ipywidgets (for interactive plots), lmfit (fitting for some of the examples), bumps (fitting for some of the examples), h5py (loading reference data for some of the examples).

The data required to run some of the notebooks and scripts are located in the data subfolder.

Summary of the Jupyter notebooks

The following table summarizes some of the main features of the Jupyter notebooks in the examples folder.

Name “_fit.ipynb”

External input datafile

Composed models

Background

Resolution

bumps_BrownianDiff

X

X

bumps_ChudleyElliottDiff

bumps_DeltaLorentz

X

X

bumps_IsoRot

X

X

bumps_JumpDiffIsoRot

X

X

bumps_JumpDiff

X

X

bumps_waterIN5_delta_two_lorentz

X

X

bumps_waterIN5_lorentzian_plus_isorotdiff

X

X

X

bumps_waterIN5_teixeira

X

X

lmfit_EquivalentSitesCircle

lmfit_GaussianModel3D

lmfit_lorentzian_and_backgd

X

lmfit_two_lorentzian

X

X

X

lmfit_waterIN5_teixeira

X

X

scipy_JumpSitesLogNormDist

scipy_lorentzian

Using the jupyter notebooks in a virtual environment

  • If not already installed on your computer, download and install Python (version>=3.8), for example, from https://www.python.org/downloads/. In the following instructions, replace python by the path to the version of python you want to use.

  • Download or clone the QENSmodels repository at https://github.com/QENSlibrary/QENSmodels

  • Create virtual environment and activate it (optional)

    cd QENSmodels/docs
    python -m venv .venv
    
    To activate your virtual environment
    • on Unix or MacOS

      python -m venv .venv
      source .venv/bin/activate
      
    • on Windows

      python -m venv .venv
      .\.venv\Scripts\activate
      
  • Upgrade pip (optional)

    python -m pip install --upgrade pip
    
  • Install the library and the additional required packages. In a terminal run

    python -m pip install -e  '\path_to_QENS_library/.[examples]'
    
  • In order to use the examples, simply type jupyter lab in a terminal.

Short tutorials on Jupyter notebooks