-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgsm.py
More file actions
77 lines (65 loc) · 2.56 KB
/
gsm.py
File metadata and controls
77 lines (65 loc) · 2.56 KB
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
#!/usr/bin/env python
import sys, math, argparse
import os.path
import ConfigParser
from pymonetdb.sql.connections import Connection as connect
from pymonetdb.exceptions import Error as DBError
from gsm import utils as gu
from gsm.exceptions import GSMException
parser = argparse.ArgumentParser(prog='gsm')
parser.add_argument('--dbconf', '-d', help='config file of GSM database setting'\
' (default ./dbconfig.cfg)')
parser.add_argument('--conf', "-c", help='config file of input params'\
' (default ./config.cfg)')
parser.add_argument('--version', "-v", action='version', version='%(prog)s 2.1.8')
args = parser.parse_args()
dbconf = args.dbconf
conf = args.conf
if dbconf is None:
dbconf = './dbconfig.cfg'
if conf is None:
conf = './config.cfg'
if not os.path.isfile(dbconf):
raise GSMException('No valid dbconfig file is specified.')
if not os.path.isfile(conf):
raise GSMException('No valid config file is specified.')
dbcfg = ConfigParser.ConfigParser(allow_no_value=True)
dbcfg.read(dbconf)
cfg = ConfigParser.ConfigParser(allow_no_value=True)
cfg.read(conf)
basecat = cfg.get("gsmparams", "basecat")
cutoff = cfg.getfloat("gsmparams", "fluxCutoff")
if basecat == 'VLSS':
if cutoff is None:
cutoff = 4.0
elif basecat == 'TGSS':
if cutoff is None:
cutoff = 0.3
else:
raise GSMException("Basecat '%s' is not valid." % (basecat))
theta = cfg.getfloat("gsmparams", "assocTheta")
if theta is None:
theta = 0.00278
storespectraplots = cfg.getboolean("gsmparams", "storespectraplots")
try:
conn = connect(hostname = dbcfg.get("database", "host")
,database = dbcfg.get("database", "dbname")
,username = dbcfg.get("database", "uname")
,password = dbcfg.get("database", "pword")
,port = dbcfg.get("database", "port")
)
gu.expected_fluxes_in_fov(conn
,basecat
,cfg.getfloat("gsmparams", "RA")
,cfg.getfloat("gsmparams", "DEC")
,cfg.getfloat("gsmparams", "radius")
,theta
,cfg.get("gsmparams", "outfile")
,cutoff
,cfg.get("gsmparams", "patchname")
,storespectraplots
,cfg.getfloat("gsmparams", "deRuiter_radius")
)
conn.close()
except DBError, e:
raise