Created
February 2, 2021 10:03
-
-
Save thomasaarholt/49d86b614a784b4f1f2bff46644bb7c0 to your computer and use it in GitHub Desktop.
load xrd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] | |
| angles.append(float(x)) | |
| intensity.append(float(y)) | |
| 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