-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunLC.py
56 lines (42 loc) · 1.74 KB
/
runLC.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
import sys
from fermipy import utils
utils.init_matplotlib_backend()
from fermipy.gtanalysis import GTAnalysis
from fermipy.utils import *
import yaml
import pprint
import numpy
import argparse
from fermipy.gtanalysis import GTAnalysis
def main():
usage = "usage: %(prog)s [config file]"
description = "Run fermipy analysis chain."
parser = argparse.ArgumentParser(usage=usage,description=description)
parser.add_argument('--config', default = 'sample_config.yaml')
parser.add_argument('--source', default = None)
args = parser.parse_args()
gta = GTAnalysis(args.config)
if args.source is None:
src_name = gta.roi.sources[0].name
gta.setup()
gta.optimize()
if (gta.roi[src_name]['ts'] > 1000. and
gta.roi[src_name]['SpectrumType'] == 'PowerLaw'):
gta.set_source_spectrum(src_name, spectrum_type='LogParabola',
spectrum_pars={'beta' : {'value' : 0.0, 'scale' : 1.0,
'min' : 0.0, 'max' : 2.0}})
gta.free_source(src_name)
gta.fit()
gta.free_source(src_name, False)
loc = gta.localize(src_name, free_radius=1.0, update=True, make_plots=True)
model = {'Index' : 2.0, 'SpatialModel' : 'PointSource'}
srcs = gta.find_sources(model=model, sqrt_ts_threshold=5.0,
min_separation=0.5)
sed = gta.sed(src_name, free_radius=1.0, make_plots=True)
gta.tsmap(make_plots=True)
gta.tsmap(prefix='excludeSource', exclude=[src_name], make_plots=True)
gta.write_roi('fit0')
lc = gta.lightcurve(src_name, binsz=86400.*28.0, free_radius=3.0, use_scaled_srcmap=True,
multithread=False)
if __name__ == "__main__":
main()