analyse.py
1 |
#! /usr/bin/env python
|
---|---|
2 |
#import os
|
3 |
#import sys
|
4 |
#import math
|
5 |
#import ctools
|
6 |
import gammalib |
7 |
|
8 |
|
9 |
# ================================ #
|
10 |
# Compare counts map and model map #
|
11 |
# ================================ #
|
12 |
def compare(cname, mname): |
13 |
"""
|
14 |
Compare counts map and model map
|
15 |
"""
|
16 |
# Print filenames
|
17 |
print cname, mname
|
18 |
|
19 |
# Load maps
|
20 |
counts = gammalib.GCTAEventCube() |
21 |
model = gammalib.GCTAEventCube() |
22 |
counts.load(cname) |
23 |
model.load(mname) |
24 |
|
25 |
# Retrieve total number of counts
|
26 |
total_counts = 0.0
|
27 |
total_model = 0.0
|
28 |
for imap in range(counts.ebins()): |
29 |
map_counts = 0.0
|
30 |
map_model = 0.0
|
31 |
for index in range(counts.map().npix()): |
32 |
map_counts += counts.map()[index, imap] |
33 |
map_model += model.map()[index, imap] |
34 |
total_counts += map_counts |
35 |
total_model += map_model |
36 |
print imap, map_counts, map_model, map_counts-map_model
|
37 |
print "Total: ", total_counts, total_model, total_counts-total_model |
38 |
print
|
39 |
|
40 |
# Return
|
41 |
return
|
42 |
|
43 |
|
44 |
# ================ #
|
45 |
# Main entry point #
|
46 |
# ================ #
|
47 |
if __name__ == '__main__': |
48 |
"""
|
49 |
Compare counts map and model map
|
50 |
"""
|
51 |
# Compare maps
|
52 |
#compare("cmap.fits", "model.fits")
|
53 |
compare("cntmap_1.fits", "modmap_1.fits") |
54 |
compare("cntmap_20.fits", "modmap_20.fits") |
55 |
compare("cntmap_40.fits", "modmap_40.fits") |
56 |
|