Skip to content

Implementing total neutron scattering data reduction using the Mantid Framework

License

Notifications You must be signed in to change notification settings

Fahima-Islam/mantid_total_scattering

 
 

Repository files navigation

DevOps Main Release (w/ Mantid Framework) Dev Release (w/o Mantid Framework)
Build Status Anaconda-Server Badge Anaconda-Server Badge
codecov Anaconda-Server Badge Anaconda-Server Badge
PyPI version

Total Scattering Data Reduction using Mantid Framework

This project is trying to implement total scattering data reduction for neutron time-of-flight diffractometers using the algorithms currently available in the Mantid framework

This entails taking raw neutron counts from detectors in the diffraction experiment and turning them into the reciprocal-space structure factor patterns, F(Q) or S(Q), and applying a Fourier Transform to real-space to give the pair distribution fuction, PDF.

This is the future backend for the ADDIE project and hopes to support multiple diffractometers performing total scattering measurements.

Structure factor S(Q) -> Pair Distribution Function G(r)

alt text

Installation

Mantid Framework Included

Anaconda (Recommended)

Setup

Add channels with dependencies, create a conda environment with python_version set to either 2.7.14 or 3.6, and activate the environment

conda config --add channels conda-forge --add channels mantid --add channels mantid/label/nightly
conda create -n mantidts_env python=${python_version}
source activate mantidts_env

Install (or Update)

conda install -c marshallmcdonnell mantid-total-scattering

Go here for how to delete an environment or use:

conda remove --name mantidts_env --all

Notes

If you have an error (see below for example) related to the libGL library, you may not have it installed for the Mantid Framework to work. See instructions here for installing the necessary libraries for different OS

Example error: ImportError: First import of "._api" failed with "libGL.so.1: cannot open shared object file...

If you have an error that another version of Mantid is installed on the machine and being imported via PYTHONPATH, you can use the following as a workaround for CLI tool:

PYTHONPATH="" mantidtotalscattering

Usage (CLI reduction tool)

To launch the total scattering script, complete the input JSON file (found in examples directory), and run:

mantidtotalscattering examples/sns/nomad_simple.json

If you need to specify the path to Mantid build, use:

MANTIDPATH=/path/to/mantid/build/bin PATH=$MANTIDPATH:$PATH PYTHONPATH=$MANTIDPATH:$PATH mantidtotalscattering <json input>

Mantid Framework Not Included (for development)

This is mainly for development if you want to use a local development build of Mantid Framework instead of one included.

PyPI (Recommended)

Install

pip install mantid-total-scattering

Anaconda

Setup

Add channels with dependencies, create a conda environment with python_version set to either 2.7 or 3.6, and activate the environment

conda config --add channels conda-forge
conda create -n mantidts_env python=${python_version}
conda activate mantidts_env

Install

conda install -c marshallmcdonnell mantid-total-scattering-python-wrapper

Development

Clone the repository to a local directory

git clone https://github.com/marshallmcdonnell/mantid_total_scattering.git
cd mantid_total_scattering

Pipenv

To setup the development environment with pipenv:

  1. Install pipenv: pip install --user pipenv or read this
  2. Setup virtualenv with dependencies and mantid_total_scattering installed: pipenv install -e .
  3. Activate the environment to run interatively: pipenv shell

NOTE: On Step 3, if you get something like "Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.", the shell is already running from install. Usually, do a deactivate and then repeat Step 3.

Tests

To build and run the tests via pytest, use:

/path/to/mantid/build/bin/mantidpython setup.py test

To build and run tests via Docker, use:

docker build -t unit-test-env -f .ci/Dockerfile.nightly_ubuntu16.04 . && docker run -t unit-test-env /bin/bash -c "mantidpython -m pytest"

About

Implementing total neutron scattering data reduction using the Mantid Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.3%
  • Other 0.7%