forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetStaticPars.py
67 lines (60 loc) · 2.21 KB
/
GetStaticPars.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
64
65
66
67
import sys
class GetStaticParameters:
def __init__(self, element, edge):
self.element = element
self.edge = edge
config_file = "/users/blissadm/local/spec/userconf/EdgeScan.dat"
#config_file = "EdgeScan.dat"
self.STATICPARS_DICT = {}
self.STATICPARS_DICT = self._readParamsFromFile(config_file)
def _readParamsFromFile(self, config_file):
try:
f = open(config_file)
array = []
for line in f:
if not line.startswith('#'):
array.append(line.split())
else:
pass
except:
return []
else:
larr = []
for k in range(len(array)):
if self.element == array[k][1] and self.edge[0] == array[k][2]:
larr = list(map(float,array[k][3:13]))
larr.append(float(array[k][17]))
if self.edge == "K":
to_delete = [1,2,3,4,5,6,7]
else:
try:
if int(self.edge[1]) == 1:
to_delete = [0,1,2,4,5,6,7]
elif int(self.edge[1]) == 2:
to_delete = [0,1,2,3,5,6,7]
else:
to_delete = [0,1,2,3,4,6,7]
except:
to_delete = [0,1,2,3,4,6,7]
for ii in sorted(to_delete, reverse=True):
del larr[ii]
static_pars = {}
larr[0] /= 1000
static_pars["edgeEnergy"] = larr[0]
static_pars["startEnergy"] = larr[0] - 0.05
static_pars["endEnergy"] = larr[0] + 0.05
static_pars["findattEnergy"] = larr[0] + 0.03
static_pars["remoteEnergy"] = larr[0]+1
static_pars["eroi_min"] = larr[1]
static_pars["eroi_max"] = larr[2]
return static_pars
if __name__ == '__main__' :
if len(sys.argv) != 3:
print("Usage: element edge")
sys.exit(0)
cg = GetStaticParameters(sys.argv[1], sys.argv[2])
print(cg.STATICPARS_DICT)
bb = cg.STATICPARS_DICT
bb["element"] = sys.argv[1]
bb["edge"] = sys.argv[2]
print(bb)