-
Notifications
You must be signed in to change notification settings - Fork 8
/
hitran2.py
86 lines (61 loc) · 1.47 KB
/
hitran2.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# this function scans the isotopologue properties from the hitran webiste
# The website is more complete thant the molparam.txt file and the HAPI interface
#Author: Simon Grimm
#February 2019
import pandas as pd
def main():
url="http://hitran.org/docs/iso-meta/"
data = pd.read_html(url, header=0)
print(len(data))
abundance= []
m = []
Q0 = []
iso = []
g = []
qfile = []
Formula = []
for j in range(len(data)):
#for j in range(3):
#print(data[j])
data[j].to_csv('test.csv')
l= data[j].values.tolist()
#print(l)
#print("****")
#print(l[j])
#print(l[j][4])
for i in range(len(l)):
#Abundance
a = str(l[i][4])
#replace E notation
a1=float(a.replace('\xa0×\xa010', 'E'))
abundance.append(a1)
#Molar Mass
m.append(l[i][5])
#Formula
Formula.append(l[i][2])
#Q(296 K)
q0 = str(l[i][6])
#replace E notation
q0 = float(q0.replace('\xa0×\xa010', 'E'))
Q0.append(q0)
#g
g.append(l[i][8])
#iso , molecule + local ID
index = str(l[i][1])
if(index == "11"):
index = "A"
if(index == "12"):
index = "B"
if(j < 9):
index = " " + str(j+1) + index
else:
index = str(j+1) + index
iso.append(index)
#qfile
qfile.append(l[i][7])
f = open('Hitran_species.dat', 'w')
for i in range(len(iso)):
print("%3s %-16.12s %-16.12s %-16s %-16s %-16s %-16s" % (iso[i], abundance[i], m[i], Q0[i], qfile[i], g[i], Formula[i]), file=f)
f.close()
if __name__ == '__main__':
main()