CTAClassicalAnalysis.py
1 |
def ClassicalAnalysis(): |
---|---|
2 |
"""
|
3 |
Typical script for classical analysis of TeV data
|
4 |
(virtual at this stage, only to help organizing the implementation)
|
5 |
|
6 |
Parameters
|
7 |
- ....
|
8 |
- ....
|
9 |
|
10 |
Notes
|
11 |
- ...
|
12 |
- ...
|
13 |
"""
|
14 |
|
15 |
# Define source
|
16 |
# (some parameters to be used only for simulation case)
|
17 |
src_name= |
18 |
src_ra= |
19 |
src_dec= |
20 |
src_flux= |
21 |
src_index= |
22 |
src_emin= |
23 |
src_emax= |
24 |
src_data=''
|
25 |
|
26 |
# Simulate or load data
|
27 |
if (os.path.exists(src_data)):
|
28 |
obs = GObservations('obs.xml')
|
29 |
else:
|
30 |
... |
31 |
|
32 |
# Set analysis parameters
|
33 |
# (positions passed as GSkyDir objects)
|
34 |
on_centre= |
35 |
on_radius= |
36 |
off_centre= |
37 |
off_radius= |
38 |
off_type='Reflected' or 'Mirror' or 'Ring' |
39 |
off_pars= |
40 |
acc_curve= |
41 |
|
42 |
# Set ON region
|
43 |
# (limited to circular regions at that stage)
|
44 |
on = GRegions() |
45 |
on.append(GRegionCircle(on_centre,on_radius)) |
46 |
|
47 |
# Set OFF regions
|
48 |
# (do we want to have the OFF regions catalog build internally in the GOnOffFitter object ?)
|
49 |
# (each OFF region must be tied to a given pointing so an attribute like pointing ID should be set in each region)
|
50 |
# A single OFF region
|
51 |
off.append(GRegionCircle(off_centre,off_radius)) |
52 |
# Multiple OFF regions defined from the pointings in the observations container, typically for reflected method
|
53 |
for run in obs: |
54 |
off_centre= |
55 |
off_radius=on_radius |
56 |
off.append(GRegionCircle(off_centre,off_radius)) |
57 |
|
58 |
# Define energy binning
|
59 |
ebds = GEbounds(10, GEnergy(src_emin, "TeV"), GEnergy(src_emax, "TeV")) |
60 |
|
61 |
# Initialize analysis object
|
62 |
onoff= GOnOffFitter(obs,on,off,ebds) |
63 |
|
64 |
# Make spectra for ON and OFF regions
|
65 |
# (will create a node function internally, in counts and not intensity, need to check that this is no problem)
|
66 |
# (here, can have the alternatives of summing spectra over all regions or not, either through different methods or through a flag)
|
67 |
onoff.make_spectrum() |
68 |
onoff.make_spectra() |
69 |
|
70 |
# Compute all other relevant quantities for ON and OFF regions
|
71 |
# (how do we handle acceptance right now ? through GCTAModelRadialAcceptance extracted from obs object ?)
|
72 |
onoff.compute_exposure() |
73 |
|
74 |
# Can be done from GCTAModelRadialAcceptance.radial().eval(offset)
|
75 |
# Can start with just the value at the ventre of the OFF region, without integrating over the area
|
76 |
onoff.compute_acceptance() |
77 |
|
78 |
# Compute source flux points and significativity
|
79 |
# (will create a node function internally)
|
80 |
opt = GOptimizerLM() |
81 |
onoff.optimize(opt) |
82 |
|
83 |
# Alternative: fit some spectral function instead of making a node spectrum
|
84 |
# (check if/how a spectral model can be handled alone, without a spatial model)
|
85 |
# (also, do we want to define two models, one for ON and one for OFF ?)
|
86 |
model=GModelSpectrumPlaw(...) |
87 |
onoff2= GOnOffFitter(obs,on,off,ebds,model) |
88 |
onoff2.make_spectrum() |
89 |
onoff2.compute_exposure() |
90 |
onoff2.compute_acceptance() |
91 |
opt = GOptimizerLM() |
92 |
onoff2.optimize(opt) |
93 |
|