Attachment 'sortConstantsFeb2018.py'
Download 1 def sortConstantsFeb2018():
2
3 #define mapping:
4 layerToModule = {1:1, 2:6, 3:8, 4:2, 5:16, 6:3, 7:11, 8:12, 9:13, 10:17, 11:20, 12:10, 13:4, 14:9, 15:19, 16:21}
5
6 #input and output files:
7 workfile=["gain_dbstyle.txt","MIP_DBstyle_N100.txt","Pedestal_Feb2018_db.txt"]
8 outfile=["gainSorted.txt","mipSorted.txt","pedestalSorted.txt"]
9
10 #open and read files
11 for n in range (0,3):
12 f = open(workfile[n], 'r')
13 out = open(outfile[n], 'w')
14
15 for line in f:
16 #find legend and print it to output file
17 if line.startswith('#Layer') or line.startswith('#Module'):
18 print line
19 out.write(line)
20
21 else:
22 read = line.split()
23
24 #substitute layer number with module number
25 read[0]=layerToModule[int(read[0])]
26
27 #put line back together as string and write it in output file
28 str1 = ' '.join(str(item) for item in read)
29 out.write(str(str1))
30 out.write("\n")
31
32 sortConstantsFeb2018()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.