Skip to main content

Repository for useful python data analysis functions for the Diamond Magnetic Materials Group

Project description

PyPI License

mmg_toolbox

Repository for useful python data analysis functions for the Diamond Magnetic Materials Group

Source https://github.com/DiamondLightSource/mmg_toolbox
PyPI pip install mmg_toolbox
Documentation https://diamondlightsource.github.io/mmg_toolbox
Releases https://github.com/DiamondLightSource/mmg_toolbox/releases

Installation

Requires: Python >=3.10, Numpy, h5py, matplotlib, hdfmap, nexus2srs

python -m pip install mmg_toolbox

@DLS

mmg_toolbox is available via the module system:

$ module load mmg
(python)$ dataviewer
# OR
(python)$ create_notebooks

Usage - Read a NeXus scan file

Read data from a NeXus scan file in a python prompt or script

from mmg_toolbox import data_file_reader
scan = data_file_reader('12345.nxs', beamline='i16')
print(scan)  # print a metadata string

scan.plot.plot()  # plot defaults
scan.plot.show()

Usage - DataViewer

Start the dataviewer from a terminal

$ dataviewer

Or, to open the data viewer in the current folder:

$ dataviewer .

Or, to open the file viewer for a specific file:

dataviewer path/to/file.nxs

Usage - Scripting

mmg_toolbox contains many useful tools for data analysis in python scripts, for example:

import matplotlib.pyplot as plt
from mmg_toolbox import Experiment

exp = Experiment('/path/to/files')

# list scans
all_scans = exp.all_scan_numbers()  # {scan_number: filename}
print('\n'.join(exp.scans_str(*all_scans)))

exp.plot(1108746, 1108747, 1108748)

scans = exp.scans(*range(-10, 0))
for scan in scans:
    scan.plot()
    axes, signal = scan.eval('axes, signal')

create_notebooks

the create_notebooks script is included as a simple way to get started and create some default scripts in your working directory. By default you will be prompted to provide a beamline and a directory or visit ID. The script can then start a Jupyter Lab instance in that directory.

command
$ create_notebooks interactively create scripts and start jupyter
$ create_notebooks -b i10-1 . create i10-1 specific scripts in the current directory
$ create_notebooks --help additional options

Dataviewer

mmg_toolbox contains a tkinter based dataviewer for viewing data in NeXus files. Various plotting and processing capabilities are available. mmg_dataviewer

Feedback

mmg_toolbox is still under development, so if you have any feedback, found any bugs or have any feature requests - please do let me know!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mmg_toolbox-0.6.3.tar.gz (222.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mmg_toolbox-0.6.3-py3-none-any.whl (255.2 kB view details)

Uploaded Python 3

File details

Details for the file mmg_toolbox-0.6.3.tar.gz.

File metadata

  • Download URL: mmg_toolbox-0.6.3.tar.gz
  • Upload date:
  • Size: 222.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for mmg_toolbox-0.6.3.tar.gz
Algorithm Hash digest
SHA256 fd88087f7a39b07ced10108ed052b752dacf496c8be486565a4a61e77c2ec5f2
MD5 f3133f46ead5e965142d922d7866d41a
BLAKE2b-256 78e5864e1b2c5fc326c4e9f83cbf7d031522546a69d7d64fd7d84bd90ee00cda

See more details on using hashes here.

Provenance

The following attestation bundles were made for mmg_toolbox-0.6.3.tar.gz:

Publisher: pypi-publish.yml on DiamondLightSource/mmg_toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mmg_toolbox-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: mmg_toolbox-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 255.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for mmg_toolbox-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b7159b2a96f8363e80c875b3130c0c0fa0b3d8b25445e019b2d5fc7f1bc3ee3d
MD5 2641b3f49f240892d38a7754979a982f
BLAKE2b-256 658c57afdaa10c9246de538be4e327e34c1c119fab6b87e3514fd1cce29ad9f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mmg_toolbox-0.6.3-py3-none-any.whl:

Publisher: pypi-publish.yml on DiamondLightSource/mmg_toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page