\(\renewcommand\AA{\mathring{A}}\)
MSlice Testing¶
Introduction¶
MSlice is a tool for visualizing cuts and slices of inelastic neutron scattering data. This version uses Mantid to process the data and plots it using matplotlib. It includes both a GUI and a commandline interface with a script generator.
See here for the current MSlice documentation: http://mantidproject.github.io/mslice
Set Up¶
Ensure you have the ISIS Sample Data available on your machine.
Open
Interfaces
>Direct
>MSlice
Go to the
Data Loading
tab and selectMAR21335_Ei60meV.nxs
from the sample data.Click
Load Data
This should open the
Workspace Manager
tab with a workspace calledMAR21335_Ei60meV
Default Settings¶
In the
Options
menu, changeDefault Energy Units
frommeV
tocm-1
andCut algorithm default
fromRebin (Averages Counts)
toIntegration (Sum Counts)
.The
en
setting on theSlice
tab changes frommeV
tocm-1
and the values in the row labelledy
change.Navigate to the
Cut
tabVerify that
en
is set tocm-1
andCut Algorithm
toIntegration (Sum Counts)
Change both settings back to their original values,
Default Energy Units
tomeV
andCut algorithm default
toRebin (Averages Counts)
.
Taking Slices¶
1. Plotting a Slice¶
In the
Workspace Manager
tab select the workspaceMAR21335_Ei60meV
Click
Display
in theSlice
tab without changing the default valuesOn the slice plot, click
Keep
2. Modifying a Slice¶
Modify the slice settings in the
Slice
tab, for instance the values for x forfrom
to1.5
andto
to5.5
, and clickDisplay
A second slice plot should open with a plot reflecting your changes in the settings
The original slice plot should remain unchanged
3. The Plots Tab¶
Navigate to the
Plots
tab of MSlice and check that there are entries for two plotsOpen the
Plots
tab of Mantid and check that there are no entries for plotsSelect one of the plots in the
Plots
tab of MSlice and click onHide
, the corresponding plot should disappearNow click on
Show
for this plot and it should re-appear againDouble-click on elements of the original slice plot and modify settings, for instance the plot itself and the colorbar axes
Change the plot title and the y axis label to LaTeX, for instance
$\mathrm{\AA}^{-1}$
, and ensure the text is displayed correctly (for$\mathrm{\AA}^{-1}$
it should be \(\mathrm{\AA}^{-1}\))Ensure that the slice plot changes accordingly
Click
Make Current
on the original slice plotModify the slice settings in the
Slice
tab again and clickDisplay
This time the new slice plot overwrites the original slice plot
4. Overplot Recoil Lines and Bragg Peaks¶
Navigate to the
Information
menu on the slice plotSelect
Hydrogen
from the submenu forRecoil lines
. A blue line should appear on the slice plot.Select two or three materials from the submenu for
Bragg peaks
and ensure that Bragg peaks in different colours per material are plotted on the slice plot.Make sure that when deselecting one of the materials only the respective Bragg peaks are removed from the slice plot but the ones still selected remain.
5. The Plot Toolbar¶
In the plot window, check that the following buttons are working as expected: Zoom in, Zoom out,
Legends
(add a recoil line to display a legend first), Save, Copy, Print and Plot Options. Modify plot options and make sure that the plot changes accordingly.
6. Generate a Script¶
Navigate to the
File
menu on the slice plotSelect
Generate Script to Clipboard
and paste the script into the Mantid editor. Please note that on LinuxCtrl + V
might not work as expected. Useshift insert
instead in this case.Run the script and check that the same slice plot is displayed
Taking Cuts¶
1. Plotting a Cut¶
In the
Workspace Manager
tab select the workspaceMAR21335_Ei60meV
Navigate to the
Cut
tabIn the row labelled
along
, set thefrom
value to0
and theto
value to10
In the row labelled
over
, set thefrom
value to-5
and theto
value to5
Click
Plot
. A new window with a cut plot should open.
2. Changing the intensity of a Cut¶
Navigate to the
Intensity
menu on the cut plotSelect
Chi''(Q,E)
and set a value of100
The y axis of the cut plot should change to a higher maximal value
3. Modifying a Cut¶
Check that the menu item
Recoil lines
is disabled within the menu itemInformation
.Modify the step size on the
Cut
tab to0.02
and clickPlot Over
. A second cut should appear on the cut plot in a different colour.Click on Plot Options on the cut plot and modify settings
Ensure that the cut plot changes accordingly
Click on Save to Workbench on the
Cut
tab and check that in Mantid a workspace with the nameMAR21335_Ei60meV_cut(-5.000,5.000)
appearsIn the row labelled
over
, set thefrom
value to-1
and theto
value to1
and clickPlot
Navigate to the tab
MD Histo
tab and check that there are at least two entries,MAR21335_Ei60meV_cut(-5.000,5.000)
andMAR21335_Ei60meV_cut(-1.000,1.000)
. Please note that there might be more entries from the previous tests.Select
MAR21335_Ei60meV_cut(-1.000,1.000)
and clickSave to Workbench
Check that in Mantid a workspace with the name
MAR21335_Ei60meV_cut(-1.000,1.000)
appearsNavigate to the
Cut
tabIn the row labelled
along
, selectDeltaE
In the row labelled
over
, select2Theta
In the row labelled
along
, set thefrom
value to-5
and theto
value to5
In the row labelled
over
, set thefrom
value to30
and theto
value to60
Click
Plot
4. Interactive Cuts¶
Navigate to the
Slice
tab of theWorkspace Manager
tabClick
Display
in theSlice
tab without changing the default valuesOn the slice plot, select
Interactive Cuts
Use the cursor to select a rectangular region in the slice plot. A second window with a cut plot should open.
Check that the menu item
Intensity
is disabled as well as the itemRecoil lines
within the menu itemInformation
in the new plot windowCheck that the
File
menu only has one menu item,Close
Change the rectangle by changing its size or dragging it to a different area of the slice plot. The cut plot should update accordingly.
Click on
Save Cut to Workspace
and check theMD Histo
tab of the Workspace Manager to verify that the new workspace was addedClick on Flip Integration Axis. The y axis label changes from
Energy Transfer (meV)
to \(|Q| (\mathrm{\AA}^{-1})\) or vice versa, depending on the initial label.
5. Overplot Bragg Peaks¶
Navigate to the
Information
menu on the cut plotSelect
Aluminium
from the submenu forBragg peaks
. Green lines should appear on the cut plot with a respective legend entry.Deselect
Aluminium
form the submenu forBragg peaks
. Both green lines and the respective legend entry should disappear.
6. Generate a Script¶
Navigate to the
Cut
tabIn the row labelled
along
, select|Q|
and set thefrom
value to0
and theto
value to10
In the row labelled
over
, set thefrom
value to-5
and theto
value to5
Click
Plot
. A new window with a cut plot should open.Navigate to the
Information
menu on the cut plotSelect
Aluminium
from the submenu forBragg peaks
. Green lines should appear on the cut plot with a respective legend entry.Navigate to the
File
menu on a cut plot. Please note that this needs to be a cut plot created via theCut
tab and not an interactive cut.Select
Generate Script to Clipboard
and paste the script into the Mantid editor. Please note that on LinuxCtrl + V
might not work as expected. Useshift insert
instead in this case.Run the script and check that the same cut plot is displayed
7. Waterfall Plots¶
Navigate to the
Cut
tabIn the row labelled
along
, set thefrom
value to0
and theto
value to10
In the row labelled
over
, set thefrom
value to-5
and theto
value to5
as well as thewidth
value to2
Click
Plot
. A new window with a cut plot should open.Click
Waterfall
and set thex
value to0.5
, then hit enter. The cuts are now plotted with a0.5
offset in direction of the x axis.Set the
y
value to2
and hit enter. The cuts are now plotted with an additional offset (2
) in direction of the y axis.
The Command Line Interface¶
1. Use the Mantid Editor¶
Close all plots currently open but not the MSlice interface
Copy the following code into the Mantid editor. You might have to modify the file path for the Load command to the correct location of
MAR21335_Ei60meV.nxs
.
import mslice.cli as mc
ws = mc.Load('C:\\MAR21335_Ei60meV.nxs')
wsq = mc.Cut(ws, '|Q|', 'DeltaE, -1, 1')
mc.PlotCut(wsq)
ws2d = mc.Slice(ws, '|Q|, 0, 10, 0.01', 'DeltaE, -5, 55, 0.5')
mc.PlotSlice(ws2d)
2. Run an Example Script¶
Run the script.
There should be two new windows with a slice plot and a cut plot
3. Use the Jupyter QtConsole¶
Repeat the same test by copying the script into the Jupyter QtConsole of the MSlice interface
The Workspace Manager¶
1. Check Scale and Subtract¶
Select the
MAR21335_Ei60meV
workspace in theWorkspace Manager
, click onSave
and selectASCII
A file dialog opens and allows entering a name for saving the file
Verify that a txt file with the selected name has been created and contains ASCII data (the first line should be
# X , Y , E
)Select the
MAR21335_Ei60meV
workspace again, click onRename
and rename the workspaceIn the
Slice
tab of the renamed workspace click onDisplay
and verify that the original slice plot is displayedSelect the renamed workspace and click on
Delete
The renamed workspace should disappear and the
Workspace Manager
should be emptyGo to the
Data Loading
tab and selectMAR21335_Ei60meV.nxs
from the sample data.Click
Load Data
Select the
MAR21335_Ei60meV
workspace again, click onCompose
, selectScale
and enter a scale factor of 2, then clickOk
A new workspace with the name
MAR21335_Ei60meV_scaled
appearsSelect the
MAR21335_Ei60meV_scaled
workspace and click onSubtract
. SelectMAR21335_Ei60meV
in the dialog that opens and clickOk
.A new workspace with the name
MAR21335_Ei60meV_scaled_subtracted
appearsIn the
Workspace Manager
tab select the workspaceMAR21335_Ei60meV
Navigate to the
Cut
tabIn the row labelled
along
, set thefrom
value to0
and theto
value to10
In the row labelled
over
, set thefrom
value to-5
and theto
value to5
Click
Plot
.Follow the same steps for the workspaces
MAR21335_Ei60meV_scaled
andMAR21335_Ei60meV_scaled_subtracted
but clickPlot Over
for these twoThe cut plot window should now contain three differently coloured lines with corresponding legends. The line for
MAR21335_Ei60meV
will be exactly covered by the line forMAR21335_Ei60meV_scaled_subtracted
. The line forMAR21335_Ei60meV_scaled
will be scaled by factor2.0
.
2. Check Delete and Sum¶
Delete all workspaces apart from the
MAR21335_Ei60meV
workspaceScale the
MAR21335_Ei60meV
workspace with a factor of1.0
A new workspace with the name
MAR21335_Ei60meV_scaled
appearsSelect the
MAR21335_Ei60meV
workspace again, click onAdd
and selectMAR21335_Ei60meV_scaled
, then clickOk
A new workspace with the name
MAR21335_Ei60meV_sum
appearsDelete the workspace with the name
MAR21335_Ei60meV_scaled
Scale the
MAR21335_Ei60meV
workspace with a factor of2.0
A new workspace with the name
MAR21335_Ei60meV_scaled
appearsIn the
Workspace Manager
tab select the workspaceMAR21335_Ei60meV_scaled
Navigate to the
Cut
tabIn the row labelled
along
, set thefrom
value to0
and theto
value to10
In the row labelled
over
, set thefrom
value to-5
and theto
value to5
Click
Plot
.Follow the same steps for the workspace
MAR21335_Ei60meV_sum
but clickPlot Over
There should be two differently coloured lines with corresponding legends that match exactly