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()
(<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')
(<matplotlib.collections.QuadMesh at 0x7f86384d8730>,
<matplotlib.collections.QuadMesh at 0x7f863880a9e0>,
<matplotlib.collections.QuadMesh at 0x7f863887dbd0>)
scissors.plot_integration_window()
(<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()