test.py

Tibaldo Luigi, 01/15/2020 03:28 PM

Download (2.52 KB)

 
1
import gammalib
2
import ctools
3
import cscripts
4

    
5
chatter = 4
6
debug = True
7
model = 'subh2.xml'
8
emin = 0.1
9
emax= 199.
10
caldb = 'prod3b-v2'
11
irf = 'South_z20_50h'
12

    
13
# simulation
14
events = 'events.fits'
15

    
16
ctobssim = ctools.ctobssim()
17
ctobssim['inmodel'] = model
18
ctobssim['caldb'] = caldb
19
ctobssim['irf'] = irf
20
ctobssim['outevents'] = events
21
ctobssim['ra'] = 30.19
22
ctobssim['dec'] = -33.49
23
ctobssim['rad'] = 5.
24
ctobssim['tmin'] = 0
25
ctobssim['tmax'] = 5 * 3600.
26
ctobssim['emin'] = emin
27
ctobssim['emax'] = emax
28
ctobssim['chatter'] = chatter
29
ctobssim['debug'] = debug
30
ctobssim.logFileOpen()
31
ctobssim.execute()
32

    
33

    
34
# bin events
35
cube = 'cube.fits'
36

    
37
binning = ctools.ctbin()
38
binning['inobs'] = events
39
binning['outobs'] = cube
40
binning['ebinalg'] = 'LOG'
41
binning['emin'] = emin
42
binning['emax'] = emax
43
binning['enumbins'] = 35
44
binning['xref'] = 30.19
45
binning['yref'] = -33.49
46
binning['nxpix'] = 200
47
binning['nypix'] = 200
48
binning['binsz'] = 0.01
49
binning['coordsys'] = 'CEL'
50
binning['proj'] = 'TAN'
51
binning['chatter'] = chatter
52
binning['debug'] = debug
53
binning.logFileOpen()
54
binning.execute()
55

    
56
# create binned response
57
exp = 'expcube.fits'
58
psf = 'psfcube.fits'
59
bkg = 'bkgcube.fits'
60
binmodel  = 'binmodel.xml'
61

    
62
# exposure cube
63
expcube = ctools.ctexpcube()
64
expcube['inobs'] = events
65
expcube['incube'] = cube
66
expcube['outcube'] = exp
67
expcube['caldb'] = caldb
68
expcube['irf'] = irf
69
expcube['chatter'] = chatter
70
expcube['debug'] = debug
71
expcube.logFileOpen()
72
expcube.execute()
73

    
74
# point spread function cube
75
psfcube = ctools.ctpsfcube()
76
psfcube['inobs'] = events
77
psfcube['incube'] = 'NONE'
78
psfcube['ebinalg'] = 'LOG'
79
psfcube['emin'] = emin
80
psfcube['emax'] = emax
81
psfcube['enumbins'] = 35
82
psfcube['xref'] = 30.19
83
psfcube['yref'] = -33.49
84
psfcube['nxpix'] = 11
85
psfcube['nypix'] = 11
86
psfcube['binsz'] = 0.2
87
psfcube['coordsys'] = 'CEL'
88
psfcube['proj'] = 'TAN'
89
psfcube['outcube'] = psf
90
psfcube['caldb'] = caldb
91
psfcube['irf'] = irf
92
psfcube['chatter'] = chatter
93
psfcube['debug'] = debug
94
psfcube.logFileOpen()
95
psfcube.execute()
96

    
97
# background cube
98
bkgcube = ctools.ctbkgcube()
99
bkgcube['incube'] = cube
100
bkgcube['inobs'] = events
101
bkgcube['inmodel'] = model
102
bkgcube['outcube'] = bkg
103
bkgcube['outmodel'] = binmodel
104
bkgcube['caldb'] = caldb
105
bkgcube['irf'] = irf
106
bkgcube['chatter'] = chatter
107
bkgcube['debug'] = debug
108
bkgcube.execute()
109

    
110
# compute upper limit
111
ulimit = ctools.ctulimit()
112
ulimit['inobs'] = cube
113
ulimit['expcube'] = exp
114
ulimit['psfcube'] = psf
115
ulimit['bkgcube'] = bkg
116
ulimit['inmodel'] = binmodel
117
ulimit['srcname'] = 'hello'
118
ulimit['chatter'] = chatter
119
ulimit['debug'] = debug
120
ulimit.logFileOpen()
121
ulimit.execute()