cta_classic.py

Knödlseder Jürgen, 04/29/2013 06:01 PM

Download (1.66 KB)

 
1
def classic():
2
    """
3
    """
4
    # Set regions
5
    on  = GRegions()
6
    off = GRegions()
7
    on.append(GRegionCircle(83.0, 22.0, 1.0))
8
    off.append(GRegionCircle(89.0, 25.0, 2.0))
9
    
10
    # Define energy binning
11
    ebds = GEbounds(10, GEnergy(0.1, "TeV"), GEnergy(100.0, "TeV"))
12
    
13
    # Load observation container
14
    obs = GObservations("obs.xml")
15
    
16
    # Build spectra (container that creates one spectrum per observation)
17
    #spec_on  = GSpectra(obs, on,  ebds)
18
    #spec_off = GSpectra(obs, off, ebds)
19
    
20
    # Derive spectrum (will create a node function internally)
21
    #function = GOnOffFitter(spec_on, spec_off)
22
    function = GCTAOnOffFitter(obs, ebds, on, off)
23
    function.alpha(3.7)
24
    function.alpha_geometric()
25
    opt      = GOptimizerLM()
26
    function.optimize(opt)
27
    
28
    # Build spectral model
29
    models = GModelsSpectrum()
30
    models.append(GModelSpectrumPlaw(...))
31

    
32
    # Derive model parameters
33
    function = GCTAOnOffFitter(obs, ebds, on, off, models)
34
    #function = GOnOffFitter(spec_on, spec_off, models)
35
    opt      = GOptimizerLM()
36
    function.optimize(opt)
37

    
38
######################
39
class GCTAOnOffFitter {
40
public:
41
    GCTAOnOffFitter(const GObservations& obs, const GEbounds& ebds,
42
                    const GRegions& on, const GRegions& off)
43
    GCTAOnOffFitter(const GObservations& obs, const GEbounds& ebds,
44
                    const GRegions& on, const GRegions& off, const GModels& models)
45
protected:
46
    GEbounds                  m_ebds;
47
    GRegions                  m_reg_on;
48
    GRegions                  m_reg_off;
49
    std::vector<GSpectrum>    m_spec_on;
50
    std::vector<GSpectrum>    m_spec_off;
51
    std::vector<GCTAResponse> m_rsp;
52
};