Performing linecuts using the Scissors class#

Importing the Scissors class#

from nxs_analysis_tools import Scissors, load_data
from nexusformat.nexus import NXdata, NXfield
import numpy as np

Setting up a linecut - Method 1#

You can set the data, linecut center, integration window, and integration axis when you initialize the Scissors object.

data = load_data('example_data/sample_name/15/example_hkli.nxs')
data:NXdata
  @axes = ['H', 'K', 'L']
  @signal = 'counts'
  H = float64(100)
  K = float64(150)
  L = float64(200)
  counts = float64(100x150x200)
scissors = Scissors(data, center=(0,0,0), window=(0.2,0.2,2), axis=None)

Setting up a linecut - Method 2#

…or you can set them one by one after initializing the object.

scissors = Scissors()
scissors.set_data(data)
scissors.set_center((0,0,0))
scissors.set_window((0.1,1,0.2))
Linecut axis: K
Integrated axes: ['H', 'L']

Performing a linecut#

You can use .cut_data() to perform the cut, returning an NXdata object.

linecut = scissors.cut_data()
Linecut axis: K
Integrated axes: ['H', 'L']

Plotting a linecut#

The .integration_window attribute stores a tuple of slice objects over which the integration was performed.

scissors.integration_window
(slice(-0.1, 0.1, None), slice(-1.0, 1.0, None), slice(-0.2, 0.2, None))

To show where the integration was performed, use the .highlight_integration_window() method.

scissors.highlight_integration_window()
../_images/e5ec7e6febfd3f225619c7a17c04410d723597678f8eb3f97eef3ebd193917d1.png
(<matplotlib.collections.QuadMesh at 0x7f863ab83e80>,
 <matplotlib.collections.QuadMesh at 0x7f8638a1a7a0>,
 <matplotlib.collections.QuadMesh at 0x7f8638a99990>)

The label parameter allows you to specify a label for the highlighted region.

scissors.highlight_integration_window(label='My Cut')
../_images/3d34d1d38382cd28e4373cfbb76a0ec8ba35556da4668f39b14db49be879aecd.png
(<matplotlib.collections.QuadMesh at 0x7f86384d8730>,
 <matplotlib.collections.QuadMesh at 0x7f863880a9e0>,
 <matplotlib.collections.QuadMesh at 0x7f863887dbd0>)
scissors.plot_integration_window()
../_images/8c862ffb068295f42d5ffa773c7466804623a34ceed17f6a90fcc6b010055e67.png
(<matplotlib.collections.QuadMesh at 0x7f8636210ac0>,
 <matplotlib.collections.QuadMesh at 0x7f86362c57e0>,
 <matplotlib.collections.QuadMesh at 0x7f8636257a90>)

The .plot() method of the NXdata object can be used to generate a basic plot of the linecut.

linecut.plot()
../_images/2f354e9ca32119193a7ee777c5640359808a6f33e0534d35aa95c707fcfd9d8f.png