-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_calc_Te.py
executable file
·65 lines (49 loc) · 1.67 KB
/
db_calc_Te.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
#! /usr/bin/python3
# Filename: db_fit_spec.py
# Aim: to load the data base and then to fit spectra.
import argparse, sqlite3
import numpy as np
from fastspec import db
def calc_te(T_c,T_l,d_v,freq=1.3,r_he2h=0.1):
T_e = np.power(7103.3* np.power(freq,1.1)*(T_c/T_l)/d_v/(1+r_he2h),0.87)
return T_e
def load_data(conn):
try:
cur = conn.cursor()
cur.execute('''SELECT
SpFitHa.GName,
Flux_peak1,
FWHM1,
Tb_vgps
FROM
SpFitHa
LEFT JOIN PhyPara ON
SpFitHa.GName = PhyPara.GName
ORDER BY
SpFitHa.GName ''')
data_list = cur.fetchall()
except sqlite3.Error as err:
print(err)
data_list = None
return data_list
def main(args):
db_conn = db.create_connection(args.file_db)
with db_conn:
data_list = load_data(db_conn)
for source in data_list:
t_c = source['Tb_vgps']
t_l = source['Flux_peak1']*12/2.
d_v = source['FWHM1']
try:
t_e = calc_te(t_c,t_l,d_v)
if t_l > 0.5:
print(source['GName']+' - Te {:5.0f} K - Tc {:4.0f} K - Tl {:6.3f} K'.format(t_e,t_c,t_l))
except:
continue
return 0
#----------------------------------
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('file_db', type=str,help='The sqlite database file')
args = parser.parse_args()
main(args)