make_solidangle_image.py

Knödlseder Jürgen, 01/17/2014 11:22 PM

Download (867 Bytes)

 
1
# Create allsky images of solid angle for various projections
2
import gammalib
3

    
4
#projection = 'AIT'
5
#projection = 'CAR'
6
#projection = 'TAN'
7
#projection = 'MER'
8
#projection = 'AZP'
9
projection = 'STG'
10

    
11
x, y = 0, 0
12
#dx, dy = 1, 1
13
#nx, ny = 360, 180
14
dx, dy = 0.5, 0.5
15
nx, ny = 720, 380
16
nmaps = 1
17
image = gammalib.GSkymap(projection, "CEL", x, y,
18
                         -dx, dy, nx, ny, nmaps)
19

    
20
# Fill the sky map with the model image
21
total = 0.0
22
for pix in range(image.npix()):
23
    try:
24
        solidangle = image.solidangle(pix)
25
        total      = total + solidangle
26
        image[pix] = gammalib.rad2deg/dx * gammalib.rad2deg/dy * solidangle
27
    except RuntimeError:
28
        pass
29
print('Total solid angle: %f sr' % total)
30

    
31
# Save the image to a FITS file
32
filename = 'test_{0}.fits'.format(projection)
33
print('Writing {0}'.format(filename))
34
image.save(filename, True)