Script-Wiki.py

Martin Pierrick, 06/30/2013 03:35 PM

Download (2.49 KB)

 
1
// Set input parameters
2
GRegions      on_regions = load_region("user input");
3
GRegions      exclusion_regions = load_region("user input");
4
GObservations obs("obs.xml");
5
GModels       models("models.xml");
6
GEbounds      energy_bounds("ebds.fits"');
7

    
8
// Fill spectrum
9
runs = GCTAOnOffObservations(obs, energy_bounds);
10
for run in runs.observations:
11
    // run is a GCTAOnOffSpectrum
12
    run.set_on_region(on_region)
13
    run.set_exclusion_regions(exclusion_regions)
14
    run.compute_off_regions()
15
    run.fill_spectra() # fills n_on, n_off
16
run.save("onoff.xml");
17

    
18
// Compute background acceptance 
19
GCTAOnOffObservations runs("onoff.xml");
20
for run in runs.observations:
21
    run.compute_bg_acceptance() // fills bg_acceptance_on,off
22
run.save("onoff.xml");
23

    
24
// Compute response
25
GCTAOnOffObservations runs("onoff.xml");
26
runs.models(models);
27
for run in runs.observations:
28
    run.compute_response() # fills gamma_exposure, energy_resolution
29
run.save("onoff.xml");
30

    
31
// Come back one month later and fit a model
32
GCTAOnOffObservations runs("onoff.xml");
33
runs.fit_parametric_model(models)
34
runs.compute_flux_points(models)
35

    
36

    
37
class GCTAOnOffObservations:
38
   """Container for spectra; one spectrum per run"""
39
   std::vector<GCTAOnOffObservation> observations
40

    
41
   def compute_total_observations():
42
       """Sum run-spectra into total spectrum.
43
       Store again in spectra member"""
44

    
45
class GCTAOnOffObservation:
46
   """Represents all data / response / analysis parameters
47
   for one run"""
48
   Regions on_regions
49
   Regions off_regions
50

    
51
   Regions on_exclusion_regions
52
   Regions off_exclusion_regions
53

    
54
   GCTAOnOffSpectrum spectrum
55
   GCTAOnOffResponse response
56

    
57
   compute_significance()
58
   compute_flux()
59

    
60
   load()
61
   save()
62

    
63

    
64
class GCTAOnOffResponse:
65
   GArf gamma_exposure
66
   GRmf energy_resolution
67
   GCTABackgroundAcceptanceSpectrum bg_acceptance_on
68
   GCTABackgroundAcceptanceSpectrum bg_acceptance_off
69

    
70
class GCTAOnOffSpectrum:
71
   GCountsSpectrum n_on
72
   GCountsSpectrum n_off
73

    
74
class GCountsSpectrum:
75
   GEbounds energy_bounds
76
   std::vector<double> counts
77
   to_pha()
78
   from_pha()
79
   fill_from(GEventList events)
80

    
81
class GArf:
82
   GEbounds energy_bounds
83
   std::vector<double> effective_area
84
   double obs_time
85
   to_arf()
86
   from_arf()
87
   fill_from(GResponse response, GModel model)
88

    
89
class GRmf:
90
   GMatrix energy_resolution_matrix
91
   to_rmf()
92
   from_rmf()
93

    
94
class GCTABackgroundAcceptanceSpectrum:
95
   GEbounds energy_bounds
96
   std::vector<double> effective_area
97
   double obs_time
98
   to_arf()
99
   from_arf()
100
   fill_from(GResponse response, GModel model)