Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
load xrd
def loadXRD(filename):
with open(filename, 'r') as f:
lines = f.readlines()
angles = []
intensity = []
for line in lines[1:-2]:
x, y = line.split('\n')[0].split(",")[:-1]
x = np.array(angles)
y = np.array(intensity)
scale = np.diff(x).mean()
offset = x[0]
s = hs.signals.Signal1D(y)
s.axes_manager[-1].offset = offset
s.axes_manager[-1].scale = scale
s.axes_manager[-1].units = "2 $\theta$"
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment