aboutsummaryrefslogtreecommitdiff
path: root/scripts/ave-resolution
blob: a69c456e7aa7146d958ecf1b632ed2f3b898f8c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Find mean diffracting resolution
#
# Copyright © 2014-2015 Deutsches Elektronen-Synchrotron DESY,
#                       a research centre of the Helmholtz Association.
#
# Author:
#    2014-2015 Thomas White <taw@physics.org>
#

import sys
import numpy
import matplotlib.pyplot as plt

f = open(sys.argv[1])
a = []

while True:
    fline = f.readline()
    if not fline:
        break
    if fline.find("diffraction_resolution_limit") != -1:
        res = float(fline.split('= ')[1].split(' ')[0].rstrip("\r\n"))
	a.append(res)
        continue

f.close()

b = numpy.array(a)
print " Mean: %.2f nm^-1 = %.2f A" % (numpy.mean(b),10.0/numpy.mean(b))
print " Best: %.2f nm^-1 = %.2f A" % (numpy.max(b),10.0/numpy.max(b))
print "Worst: %.2f nm^-1 = %.2f A" % (numpy.min(b),10.0/numpy.min(b))
print "Std deviation: %.2f nm^-1" % (numpy.std(b))

plt.hist(a,bins=30)
plt.title('Resolution based on indexing results')
plt.xlabel('Resolution / nm^-1')
plt.ylabel('Frequency')
plt.grid(True)
plt.show()