-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""This script generates an example effective area | ||
It complies to the specifications at http://gamma-astro-data-formats.readthedocs.org/en/latest/irfs/effective_area/index.html | ||
""" | ||
|
||
from astropy.io import fits | ||
from astropy.table import Table | ||
import numpy as np | ||
|
||
e_bins = 20 | ||
o_bins = 5 | ||
e_axis = np.logspace(-1,2,e_bins+1) | ||
o_axis = np.linspace(0,3,o_bins+1) | ||
effarea = np.ones([e_bins, o_bins]) * 3e5 | ||
|
||
table = Table([[e_axis[:-1]],[e_axis[1:]], | ||
[o_axis[:-1]],[o_axis[1:]], | ||
[effarea]], | ||
names=('ENERG_LO', 'ENERG_HI', | ||
'THETA_LO', 'THETA_HI', | ||
'EFFAREA')) | ||
|
||
data = table.as_array() | ||
header = fits.Header() | ||
header['OBS_ID'] = 31415 , 'Observation ID' | ||
header['LO_THRES'] = 0.1 , 'Low energy threshold [TeV]' | ||
header['HI_THRES'] = 50 , 'High energy threshold [TeV]' | ||
header['RAD_MAX'] = 0.1, 'On region radius for point-like observations' | ||
|
||
tbhdu = fits.BinTableHDU(data, header, name='EFFECTIVE AREA') | ||
|
||
for colname in table.colnames: | ||
tbhdu.columns[colname].unit = str(table[colname].unit) | ||
|
||
prihdu = fits.PrimaryHDU() | ||
|
||
thdulist = fits.HDUList([prihdu, tbhdu]) | ||
thdulist.writeto('aeff_2d_example.fits', clobber=True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters