Commit 4b986806 authored by Whitfield, Ross's avatar Whitfield, Ross
Browse files

Update IPTS-21442/make_4D_temp_HD.py autoreduce/reduce_HB2C.py

parent 660cec5d
import numpy as np
for t in range(5,7):
runNumbers='{}-{}'.format(95409+122*(t-5),95530+122*(t-5))
print(t,runNumbers)
LoadWANDSCD(IPTS=21442, RunNumbers=runNumbers, OutputWorkspace='data_{}K'.format(t))
ConvertWANDSCDtoQ(InputWorkspace='data_{}K'.format(t),
NormaliseBy='None', Frame='HKL',
BinningDim0='-0.1515,0.1515,101',
BinningDim1='0.8485,1.1515,101',
BinningDim2='-0.01,1.01,51',
OutputWorkspace='{}K'.format(t))
DeleteWorkspace('data_{}K'.format(t))
output=CreateMDHistoWorkspace(4, SignalInput=[0]*61*61*21*25, ErrorInput=[0]*61*61*21*25,
Extents=[-0.1525,0.1525,0.8475,1.1525,-0.025,1.025,4.5,29.5],
NumberOfBins=[61, 61, 21, 25], Names=['[H,0,0]','[0,K,0]','[0,0,L]','temperature'], Units='A^-1,A^-1,A^-1,C')
signal=np.empty((61,61,21,25))
for n, t in enumerate(range(5,30)):
signal[:,:,:,n]=mtd['{}K'.format(t)].getSignalArray()
output.setSignalArray(signal)
SliceMDHisto(InputWorkspace='output', Start='10,10,10,0', End='51,51,11,25', OutputWorkspace='slice')
......@@ -5,29 +5,47 @@ import h5py
filename = sys.argv[1]
outdir = sys.argv[2]
powder=True
with h5py.File(filename, 'r') as f:
if '/entry/DASlogs/HB2C:CS:ITEMS:Nature' in f:
nature = f['/entry/DASlogs/HB2C:CS:ITEMS:Nature/value'].value[0][0]
if nature != 'Powder':
powder=False
print("Sample is {}, skipping autoreduction\nAutoreduction is only run on Powder samples".format(nature))
sys.exit()
#sys.exit()
else:
print("Sample Nature not found, skipping autoreduction")
sys.exit()
sys.path.append("/opt/mantidnightly/bin")
from mantid.simpleapi import LoadWAND, WANDPowderReduction, SavePlot1D
van_file = '/HFIR/HB2C/IPTS-7776/nexus/HB2C_26509.nxs.h5'
data = LoadWAND(filename)
runNumber = data.getRunNumber()
cal = LoadWAND(van_file)
WANDPowderReduction(InputWorkspace=data,
CalibrationWorkspace=cal,
Target='Theta',
NumberBins=1000,
OutputWorkspace='reduced')
div = SavePlot1D('reduced', OutputType='plotly')
from postprocessing.publish_plot import publish_plot
request = publish_plot('HB2C', runNumber, files={'file': div})
if powder:
from mantid.simpleapi import LoadWAND, WANDPowderReduction, SavePlot1D
data = LoadWAND(filename)
runNumber = data.getRunNumber()
cal = LoadWAND(IPTS=7776,RunNumbers=29780)
WANDPowderReduction(InputWorkspace=data,
CalibrationWorkspace=cal,
Target='Theta',
NumberBins=1000,
OutputWorkspace='reduced')
div = SavePlot1D('reduced', OutputType='plotly')
from postprocessing.publish_plot import publish_plot
request = publish_plot('HB2C', runNumber, files={'file': div})
else: # Single Crystal
import matplotlib
import numpy as np
with h5py.File(filename, 'r') as f:
bc = np.zeros((512*480*8),dtype=np.int64)
for b in range(8):
bc += np.bincount(f['/entry/bank'+str(b+1)+'_events/event_id'].value,minlength=512*480*8)
bc = bc.reshape((480*8, 512))
bc = (bc[::4,::4] + bc[1::4,::4] + bc[2::4,::4] + bc[3::4,::4]
+ bc[::4,1::4] + bc[1::4,1::4] + bc[2::4,1::4] + bc[3::4,1::4]
+ bc[::4,2::4] + bc[1::4,2::4] + bc[2::4,2::4] + bc[3::4,2::4]
+ bc[::4,3::4] + bc[1::4,3::4] + bc[2::4,3::4] + bc[3::4,3::4])
matplotlib.image.imsave(outdir+'file.png', bc)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment