-
Notifications
You must be signed in to change notification settings - Fork 2
/
gsf.py
63 lines (61 loc) · 2.13 KB
/
gsf.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
from __future__ import print_function
import os
import sys
import warnings
from optparse import OptionParser
from gsf_core import *
#Parse the commands#
#-------------------#
parser = OptionParser()
parser.add_option("-w", "--warning", dest="warning",
action="store_true", default=False,
help="Stop ignoring the warnings.")
parser.add_option("-o", "--overwrite", dest="overwrite",
action="store_true", default=False,
help="Overwrite the object information with the command-line inputs.")
parser.add_option("-r", "--refit", dest="refit", action="store_true", default=False,
help="Refit the SED though there is a result found.")
(options, args) = parser.parse_args()
if len(args) == 0:
raise AssertionError("The config file is not specified!")
else:
configName = args[0] #Get the input configure file information.
#Some times the warning may stop the code, so we ignore the warnings by default.
if options.warning:
pass
else:
warnings.simplefilter("ignore")
if options.refit:
refit = True
else:
refit = False
#The starter of this module#
#--------------------------#
print("\n")
print("############################")
print("# Galaxy SED Fitter starts #")
print("############################")
print("\n")
#->The object can be provided by the configure file or be overwrite with the
#command-line inputs
len_args = len(args)
if not options.overwrite:
if len_args > 1:
print("**Warning[UniFit]: there are more arguments may not be used...")
gsf_fitter(configName, refit=refit)
else:
if len_args < 4:
raise AssertionError("The object information is lacking!")
if len_args == 4:
targname = args[1]
redshift = eval(args[2])
distance = None
sedFile = args[3]
elif len_args == 5:
targname = args[1]
redshift = eval(args[2])
distance = eval(args[3]) #The distance should be in Mpc.
sedFile = args[4]
else:
print("**Warning[UniFit]: there are more arguments may not be used...")
gsf_fitter(configName, targname, redshift, distance, sedFile, refit=refit)