runRui.py
952 Bytes
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
#prepare inputs.txt for sw.exe
import re
#f = open("data/time_series_taoSW1D_wso_CR1888.dat","r")
f = open("all.dat","r")
lines = f.readlines()
rsun = 6.95e5
au = 1.496e8
filename = "inputs.txt"
fmt = 'e'
with open(filename, "w") as myFile:
for i in range(11,len(lines)):
x = lines[i].strip()
y = re.sub(' +', ' ',x).split(' ')
time = float(y[0])
rsrci = float(y[9])*rsun/au
rtgti = 1.0
qfi = 0.0
n = float(y[1])
if n < 0 :
n = nPrevious
t = float(y[2])
if t < 0 :
t = tPrevious
v = float(y[3])
if v < 0 :
v = vPrevious
newline = ['',format(time,'.0f'),format(n, fmt),format(t, fmt),format(v, fmt),y[4],y[5],y[6],y[7],y[8],format(rsrci, fmt),y[10],format(rtgti, fmt),y[12],format(qfi, fmt)]
myFile.write(' '.join(newline)+'\n')
if n > 0 :
nPrevious = n
if t > 0 :
tPrevious = t
if v > 0 :
vPrevious = v
myFile.close()
f.close()