-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkDD.py
executable file
·63 lines (46 loc) · 1.5 KB
/
checkDD.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python
'''Check detector distance'''
import commands
import os
import numpy
import matplotlib.pyplot as plt
import numpy as np
#dirtocheck = '/927bis/ccd/2013/Run*/2013-*/*'
dirtocheck = '/927bis/ccd/2013/Run3/2013-05-21/Commissioning/BCT/'
pattern = 'collect'
look = 'find %s -wholename "*process/xds_process_*/CORRECT.LP"' % dirtocheck
lookin = commands.getoutput(look).split('\n')
lref = 'grep "CRYSTAL TO DETECTOR DISTANCE (mm)" %s/CORRECT.LP | cut -d ")" -f 2'
linp = 'grep "DETECTOR_DISTANCE" %s/XDS.INP | cut -d "=" -f 2'
currentdir = os.getcwd()
diffs = []
distances = []
refined = []
print 'lookin', lookin
for l in lookin:
l = os.path.dirname(l)
print 'l', l
try:
inp = float(commands.getoutput(linp % l))
ref = float(commands.getoutput(lref % l))
difference = inp - ref
print 'for input distance %s the difference is %s' % (inp, difference)
if -.5 < difference < 1.5:
diffs.append(inp - ref)
distances.append(inp)
refined.append(ref)
except:
pass
d = numpy.array(diffs)
print 'differences'
print d
c = list(d)
print 'list representation of differences'
print c
m = c.index(d.max())
print 'The maximum difference occured for the distance %s (the difference was %s), the average difference is %s' % (distances[m], diffs[m], d.mean())
hist, bins = np.histogram(d, 7)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
plt.bar(center, hist, align='center', width=width)
plt.show()