-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadBHoutput_old.py
executable file
·49 lines (31 loc) · 1.1 KB
/
ReadBHoutput_old.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
#!/usr/bin/python
# This script reads the output files and gets BH info
# this happens without repeating steps
import sys
files=[]
for lines in open('outfiles.list').readlines():
fields=lines.split()
files.append(fields[0])
# fields[0] is the first element in the one-element list.
outfile=open('out.bh','w') # file for outputs
for i in range(len(files)):
print i, 'file = ', files[i]
if i != len(files)-1:
nextfile=str(files[i+1]) # I want it to read the next file
# now find the line to stop at.
f = open(nextfile)
for line in f:
if line.startswith('Restart Step:'):
N = line[13:-1]+'.00000' # dont include the \n
break
else : N = 'gobbledygook'
badline='Calculating Gravity, Step:'+N
filestring=files[i]+'\n'
outfile.write(filestring) # want to print which outfile the lines are from
f = open(files[i])
for line in f:
if line.startswith(badline): break #if this line is encountered, quit!
else:
if line.startswith('BHSink'):
#sweet now I just need to get it in the file.
outfile.write(line)