Skip to content
Snippets Groups Projects
Commit 47e33f91 authored by David Fairbrother's avatar David Fairbrother
Browse files

Re #19770 Fixed missing import in workflow scripts

parent 528deade
No related branches found
No related tags found
No related merge requests found
#pylint: disable=invalid-name
#Common names
# pylint: disable=invalid-name
# Common names
import mantid.simpleapi as mantid
filename = 'fe_demo_30.sqw'
ws_in ='fe_demo_30'
ws_in = 'fe_demo_30'
#Load an SQW file and internally convert to a Multidimensional event workspace (MDEW)
if not mtd.doesExist(ws_in):
LoadSQW(filename, OutputWorkspace=ws_in)
# Load an SQW file and internally convert to a Multidimensional event workspace (MDEW)
if not mantid.mtd.doesExist(ws_in):
mantid.LoadSQW(filename, OutputWorkspace=ws_in)
#Bin the workspace in an axis aligned manner. Creates a Histogrammed MD workspace.
BinMD(InputWorkspace=ws_in,OutputWorkspace='binned_axis_aligned',AxisAligned=True,
AlignedDim0='Q_\\zeta,-1.5,5,100',
AlignedDim1='Q_\\xi,-6,6,100',
AlignedDim2='Q_\\eta,-6,6,100',
AlignedDim3='E,0,150,30')
# Bin the workspace in an axis aligned manner. Creates a Histogrammed MD workspace.
mantid.BinMD(InputWorkspace=ws_in, OutputWorkspace='binned_axis_aligned', AxisAligned=True,
AlignedDim0='Q_\\zeta,-1.5,5,100',
AlignedDim1='Q_\\xi,-6,6,100',
AlignedDim2='Q_\\eta,-6,6,100',
AlignedDim3='E,0,150,30')
#Bin the workpace using a coordinate transformation to rotate the output.. Creates a Histogrammed MD workspace.
BinMD(InputWorkspace=ws_in,OutputWorkspace='binned_rotated',AxisAligned=False,
BasisVector0='Qx,Ang,1,0.5,0,0,1,100',
BasisVector1='Qy,Ang,-0.5,1,0,0,1,100',
BasisVector2='Qz,Ang,0,0,1.25,0,1,100',
Origin='0,0,0,0')
# Bin the workpace using a coordinate transformation to rotate the output.. Creates a Histogrammed MD workspace.
mantid.BinMD(InputWorkspace=ws_in, OutputWorkspace='binned_rotated', AxisAligned=False,
BasisVector0='Qx,Ang,1,0.5,0,0,1,100',
BasisVector1='Qy,Ang,-0.5,1,0,0,1,100',
BasisVector2='Qz,Ang,0,0,1.25,0,1,100',
Origin='0,0,0,0')
#Save the MDEW workspace in the MDEW nexus format.
SaveMD(ws_in, Filename='MDEW_fe_demo_30.nxs')
# Save the MDEW workspace in the MDEW nexus format.
mantid.SaveMD(ws_in, Filename='MDEW_fe_demo_30.nxs')
#Could reload the MDEW at this point.
# Could reload the MDEW at this point.
from __future__ import (absolute_import, division, print_function)
import mantid.simpleapi as mantid
def reportUnitCell(peaks_ws):
......@@ -15,26 +16,27 @@ def reportUnitCell(peaks_ws):
#
# Exclude the monitors when loading the raw SXD file. This avoids
#
Load(Filename='SXD23767.raw',OutputWorkspace='SXD23767',LoadMonitors='Exclude')
mantid.Load(Filename='SXD23767.raw', OutputWorkspace='SXD23767', LoadMonitors='Exclude')
#
# A lower SplitThreshold, with a reasonable bound on the recursion depth, helps find weaker peaks at higher Q.
#
QLab = ConvertToDiffractionMDWorkspace(InputWorkspace='SXD23767', OutputDimensions='Q (lab frame)',
SplitThreshold=50, LorentzCorrection='1',
MaxRecursionDepth='13',Extents='-15,15,-15,15,-15,15')
QLab = mantid.ConvertToDiffractionMDWorkspace(InputWorkspace='SXD23767', OutputDimensions='Q (lab frame)',
SplitThreshold=50, LorentzCorrection='1',
MaxRecursionDepth='13', Extents='-15,15,-15,15,-15,15')
#
# NaCl has a relatively small unit cell, so the distance between peaks is relatively large. Setting the PeakDistanceThreshold
# higher avoids finding high count regions on the sides of strong peaks as separate peaks.
#
peaks_qLab = FindPeaksMD(InputWorkspace='QLab', MaxPeaks=300, DensityThresholdFactor=10,PeakDistanceThreshold=1.0)
peaks_qLab = mantid.FindPeaksMD(InputWorkspace='QLab', MaxPeaks=300, DensityThresholdFactor=10,
PeakDistanceThreshold=1.0)
#
# Fewer peaks index if Centroiding is used. This indicates that there may be an error in the centroiding algorithm,
# since the peaks seem to be less accurate.
#
#peaks_qLab = CentroidPeaksMD(InputWorkspace='QLab',PeaksWorkspace=peaks_qLab)
# peaks_qLab = CentroidPeaksMD(InputWorkspace='QLab',PeaksWorkspace=peaks_qLab)
use_fft = True
use_cubic_lat_par = False
......@@ -44,32 +46,33 @@ use_Niggli_lat_par = False
# Note: Reduced tolerance on FindUBUsingFFT will omit peaks not near the lattice. This seems to help
# find the Niggli cell correctly, with all angle 60 degrees, and all sides 3.99
#
if use_fft:
FindUBUsingFFT(PeaksWorkspace=peaks_qLab, MinD='3', MaxD='5',Tolerance=0.08)
if use_fft:
mantid.FindUBUsingFFT(PeaksWorkspace=peaks_qLab, MinD='3', MaxD='5', Tolerance=0.08)
print('\nNiggli cell found from FindUBUsingFFT:')
if use_cubic_lat_par:
FindUBUsingLatticeParameters(PeaksWorkspace=peaks_qLab, a=5.6402,b=5.6402,c=5.6402,
alpha=90,beta=90,gamma=90,NumInitial=25,Tolerance=0.12)
mantid.FindUBUsingLatticeParameters(PeaksWorkspace=peaks_qLab, a=5.6402, b=5.6402, c=5.6402,
alpha=90, beta=90, gamma=90, NumInitial=25, Tolerance=0.12)
print('\nCubic cell found directly from FindUBUsingLatticeParameters')
if use_Niggli_lat_par:
FindUBUsingLatticeParameters(PeaksWorkspace=peaks_qLab, a=3.9882,b=3.9882,c=3.9882,
alpha=60,beta=60,gamma=60,NumInitial=25,Tolerance=0.12)
mantid.FindUBUsingLatticeParameters(PeaksWorkspace=peaks_qLab, a=3.9882, b=3.9882, c=3.9882,
alpha=60, beta=60, gamma=60, NumInitial=25, Tolerance=0.12)
print('\nNiggli cell found from FindUBUsingLatticeParameters:')
reportUnitCell(peaks_qLab)
IndexPeaks(PeaksWorkspace=peaks_qLab,Tolerance=0.12,RoundHKLs=1)
mantid.IndexPeaks(PeaksWorkspace=peaks_qLab, Tolerance=0.12, RoundHKLs=1)
if use_fft or use_Niggli_lat_par:
ShowPossibleCells(PeaksWorkspace=peaks_qLab,MaxScalarError='0.5')
SelectCellOfType(PeaksWorkspace=peaks_qLab, CellType='Cubic', Centering='F', Apply=True)
mantid.ShowPossibleCells(PeaksWorkspace=peaks_qLab, MaxScalarError='0.5')
mantid.SelectCellOfType(PeaksWorkspace=peaks_qLab, CellType='Cubic', Centering='F', Apply=True)
peaks_qLab_Integrated = IntegratePeaksMD(InputWorkspace=QLab, PeaksWorkspace=peaks_qLab, PeakRadius=0.2,
BackgroundInnerRadius=0.3, BackgroundOuterRadius=0.4)
peaks_qLab_Integrated = mantid.IntegratePeaksMD(InputWorkspace=QLab, PeaksWorkspace=peaks_qLab, PeakRadius=0.2,
BackgroundInnerRadius=0.3, BackgroundOuterRadius=0.4)
binned=BinMD(InputWorkspace=QLab,AlignedDim0='Q_lab_x,-15,15,200',AlignedDim1='Q_lab_y,-15,15,200',AlignedDim2='Q_lab_z,-15,15,200')
binned = mantid.BinMD(InputWorkspace=QLab, AlignedDim0='Q_lab_x,-15,15,200', AlignedDim1='Q_lab_y,-15,15,200',
AlignedDim2='Q_lab_z,-15,15,200')
print('The final result is:')
reportUnitCell(peaks_qLab)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment