Commit 7a3bbda3 authored by Owen Arnold's avatar Owen Arnold
Browse files

Process fits script v1

parent a5b9734a
import os.path
import numpy as np
this_dir = os.path.dirname(os.path.abspath(__file__))
# Open the file containing the TOF values. I assume that these are ordered in an ascending fashion according to the filenames.
spectra = open(os.path.join(this_dir, 'Scan000_Spectra.txt'),'r')
tofs = []
for line in spectra:
tofs.append(float(line.split('\t')[0].strip()))
spectra.close()
size = len(os.listdir(this_dir))
yslices = []
eslices = []
xValues = []
validslices = 0
for i in range(0, size):
try:
file = os.path.join(this_dir, 'Scan000_{:05d}.fits'.format(i))
ws =LoadFITS(file)
inner = ws[0]
yslices.append(inner.extractY())
eslices.append(inner.extractE())
tofcenter = tofs[i]
xValues.append(tofcenter)
DeleteWorkspace(ws)
validslices +=1
except ValueError:
# ignore anything that isn't one or our image fit files
pass
yValues = np.hstack(yslices).flatten()
eValues = np.hstack(eslices).flatten()
print("Combining {0} images".format(validslices))
combined = CreateWorkspace(DataX=xValues, DataY=yValues, DataE=eValues, NSpec=512*512)
# Optionally save the output
SaveNexus(InputWorkspace=combined, Filename=os.path.join(this_dir, 'combined'))
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