Skip to content
Snippets Groups Projects
Commit de206963 authored by Jutta Schnabel's avatar Jutta Schnabel
Browse files

saving dev function for first table creation

parent 5b11734a
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
! pip install km3astro
! pip install km3io
```
%% Output
Error initializing plugin EntryPoint(name='Windows (alt)', value='keyrings.alt.Windows', group='keyring.backends').
Traceback (most recent call last):
File "/home/jutta/.local/lib/python3.6/site-packages/keyring/backend.py", line 203, in _load_plugins
init_func = ep.load()
File "/home/jutta/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/Windows.py", line 9, in <module>
from . import file_base
File "/usr/lib/python3/dist-packages/keyrings/alt/file_base.py", line 13, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint(name='file', value='keyrings.alt.file', group='keyring.backends').
Traceback (most recent call last):
File "/home/jutta/.local/lib/python3.6/site-packages/keyring/backend.py", line 203, in _load_plugins
init_func = ep.load()
File "/home/jutta/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/file.py", line 11, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint(name='pyfs', value='keyrings.alt.pyfs', group='keyring.backends').
Traceback (most recent call last):
File "/home/jutta/.local/lib/python3.6/site-packages/keyring/backend.py", line 203, in _load_plugins
init_func = ep.load()
File "/home/jutta/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/pyfs.py", line 8, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Defaulting to user installation because normal site-packages is not writeable
Collecting km3astro
Downloading km3astro-0.13.1-py2.py3-none-any.whl (99 kB)
 |████████████████████████████████| 99 kB 4.2 MB/s eta 0:00:011
[?25hRequirement already satisfied: setuptools-scm in /home/jutta/.local/lib/python3.6/site-packages (from km3astro) (4.1.2)
Requirement already satisfied: tables in /home/jutta/.local/lib/python3.6/site-packages (from km3astro) (3.6.1)
Requirement already satisfied: matplotlib>=2.2 in /home/jutta/.local/lib/python3.6/site-packages (from km3astro) (3.1.1)
Requirement already satisfied: astropy>=3.0 in /usr/local/lib/python3.6/dist-packages (from km3astro) (4.0.1.post1)
Collecting healpy
Downloading healpy-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (18.1 MB)
 |████████████████████████████████| 18.1 MB 11.2 MB/s eta 0:00:01
[?25hCollecting utm
Downloading utm-0.7.0.tar.gz (8.7 kB)
Requirement already satisfied: numpy in /home/jutta/.local/lib/python3.6/site-packages (from km3astro) (1.19.1)
Requirement already satisfied: pandas in /home/jutta/.local/lib/python3.6/site-packages (from km3astro) (1.0.3)
Requirement already satisfied: setuptools>=40.6.2 in /home/jutta/.local/lib/python3.6/site-packages (from km3astro) (49.6.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/jutta/.local/lib/python3.6/site-packages (from matplotlib>=2.2->km3astro) (1.2.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/jutta/.local/lib/python3.6/site-packages (from matplotlib>=2.2->km3astro) (2.4.7)
Requirement already satisfied: cycler>=0.10 in /home/jutta/.local/lib/python3.6/site-packages (from matplotlib>=2.2->km3astro) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /home/jutta/.local/lib/python3.6/site-packages (from matplotlib>=2.2->km3astro) (2.8.1)
Requirement already satisfied: six in /home/jutta/.local/lib/python3.6/site-packages (from cycler>=0.10->matplotlib>=2.2->km3astro) (1.15.0)
Requirement already satisfied: scipy in /home/jutta/.local/lib/python3.6/site-packages (from healpy->km3astro) (1.2.3)
Requirement already satisfied: pytz>=2017.2 in /home/jutta/.local/lib/python3.6/site-packages (from pandas->km3astro) (2020.1)
Requirement already satisfied: numexpr>=2.6.2 in /home/jutta/.local/lib/python3.6/site-packages (from tables->km3astro) (2.7.1)
Building wheels for collected packages: utm
Building wheel for utm (setup.py) ... [?25ldone
[?25h Created wheel for utm: filename=utm-0.7.0-py3-none-any.whl size=6131 sha256=62f3fb73a12b4256566257597e1244da30d596454550ba5bbbd9914a56af9886
Stored in directory: /home/jutta/.cache/pip/wheels/ab/8c/43/723355279387088dd6696089e77f9ddd242ba94e71a87c800f
Successfully built utm
Installing collected packages: utm, healpy, km3astro
Successfully installed healpy-1.15.0 km3astro-0.13.1 utm-0.7.0
WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Error initializing plugin EntryPoint(name='Windows (alt)', value='keyrings.alt.Windows', group='keyring.backends').
Traceback (most recent call last):
File "/home/jutta/.local/lib/python3.6/site-packages/keyring/backend.py", line 203, in _load_plugins
init_func = ep.load()
File "/home/jutta/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/Windows.py", line 9, in <module>
from . import file_base
File "/usr/lib/python3/dist-packages/keyrings/alt/file_base.py", line 13, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint(name='file', value='keyrings.alt.file', group='keyring.backends').
Traceback (most recent call last):
File "/home/jutta/.local/lib/python3.6/site-packages/keyring/backend.py", line 203, in _load_plugins
init_func = ep.load()
File "/home/jutta/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/file.py", line 11, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint(name='pyfs', value='keyrings.alt.pyfs', group='keyring.backends').
Traceback (most recent call last):
File "/home/jutta/.local/lib/python3.6/site-packages/keyring/backend.py", line 203, in _load_plugins
init_func = ep.load()
File "/home/jutta/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/keyrings/alt/pyfs.py", line 8, in <module>
from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: km3io in /home/jutta/.local/lib/python3.6/site-packages (0.21.0)
Requirement already satisfied: awkward>=1.0.0rc2 in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (1.2.2)
Requirement already satisfied: setuptools-scm in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (4.1.2)
Requirement already satisfied: uproot>=4.0.0rc5 in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (4.0.7)
Requirement already satisfied: awkward0 in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (0.15.5)
Requirement already satisfied: numba>=0.50 in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (0.53.1)
Requirement already satisfied: uproot3>=3.11.1 in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (3.14.4)
Requirement already satisfied: docopt in /home/jutta/.local/lib/python3.6/site-packages (from km3io) (0.6.2)
Requirement already satisfied: numpy>=1.13.1 in /home/jutta/.local/lib/python3.6/site-packages (from awkward>=1.0.0rc2->km3io) (1.19.1)
Requirement already satisfied: setuptools in /home/jutta/.local/lib/python3.6/site-packages (from awkward>=1.0.0rc2->km3io) (49.6.0)
Requirement already satisfied: llvmlite<0.37,>=0.36.0rc1 in /home/jutta/.local/lib/python3.6/site-packages (from numba>=0.50->km3io) (0.36.0)
Requirement already satisfied: uproot3-methods in /home/jutta/.local/lib/python3.6/site-packages (from uproot3>=3.11.1->km3io) (0.10.1)
Requirement already satisfied: cachetools in /home/jutta/.local/lib/python3.6/site-packages (from uproot3>=3.11.1->km3io) (4.1.0)
WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
%% Cell type:markdown id: tags:
# Writing events in gammapy
Event list: https://docs.gammapy.org/0.20.1/api/gammapy.data.EventList.html
* based on astropy table
* following NASA guidelines for event lists: https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/events/ogip_94_003/ogip_94_003.html
* compatible with VO table
* no direct writing in gammapy, but helper function for table creation: https://docs.gammapy.org/0.20.1/_modules/gammapy/utils/table.html
## Definition of an EventList
> In the context of OGIP FITS files, an Event List is defined to be a FITS extension containing a list of parameters/flags associated with events recorded by an instrument (eg the time-tag, position on the detector, pulse height), and/or parameters/flags derived from these quantities (e.g., barycentric time, linearized detector coordinates, celestial coordinates, photon energy ... etc of the events) -- both the original and derived quantities will be referred to as "attributes". The list can contain the results of events arising from the cosmos (including cosmic ray events), and/or "false" background events recorded as a result of instrumental/electronic noise. For an OGIP-standard Event List, one row contains attributes of a single event; a related file format which contains multiple events per row may be advantageous for specific missions and will be defined elsewhere.
> An Event List can also be considered a Light Curve, or (binned) time series histogram, with time bins of size equal to the accuracy of the time stamp. However, when viewed as a binned light curve, the Event List has the following properties that binned light curves usually do not have and that, therefore, distinguish the event list as a special kind of binned light curve:
> The event list is a sparse histogram (i.e., only filled bins are present).
Each bin (by definition) has a population of one event.
Each bin (as defined by the value of the time stamp) may be present more than once, thus indicating populations greater than one.
> The detailed format of a given Event Lists is considered instrument-specific, and the order in which the events are listed application-specific.
%% Cell type:code id: tags:
``` python
import km3io
from km3io import OfflineReader
filename = "/home/jutta/Desktop/gitstuff/open-event-writer/datav5.40.jorcarec.aanet.00006175.root"
myfile = OfflineReader(filename)
```
%% Cell type:markdown id: tags:
# Prototype event list
https://gamma-astro-data-formats.readthedocs.io/en/v0.2/events/events.html
## By-event parameters
### Mandatory
#### EVENT_ID type: int64
Event identification number at the DL3 level. See notes on [EVENT_ID](https://gamma-astro-data-formats.readthedocs.io/en/v0.2/events/events.html#iact-events-event-id)
* As only a int64 is possible and event identification in KM3NeT contains various subparts, a conversion function between the identifiers and our internal identification is necessary.
* Identifier parts (19 digits available):
* instrument (1 digit): i - 1 km3net, 2 antares
* detector_id (3 digits): ddd
* run_id (6 digits): rrrrrr
* frame_index (6 digits): ffffff
* trigger_counter (3 digits): ttt
encoded id: idddrrrrrrffffffttt
#### TIME type: float64, unit: s
Event time (see Time: https://gamma-astro-data-formats.readthedocs.io/en/v0.2/general/time.html#time)
* KM3NeT: unix time from event time + track time
#### RA type: float, unit: deg
Reconstructed event Right Ascension (see RA / DEC: https://gamma-astro-data-formats.readthedocs.io/en/v0.2/general/coordinates.html#coords-radec ).
#### DEC type: float, unit: deg
Reconstructed event Declination (see RA / DEC: [[https://gamma-astro-data-formats.readthedocs.io/en/v0.2/general/coordinates.html#coords-radec]] ).
#### ENERGY type: float, unit: TeV
Reconstructed event energy
* In KM3NeT: given in GeV
### Optional
https://gamma-astro-data-formats.readthedocs.io/en/v0.2/events/events.html#optional-columns
## Header parameters
https://gamma-astro-data-formats.readthedocs.io/en/v0.2/events/events.html#mandatory-header-keywords
### Mandatory
The standard FITS reference time header keywords should be used (see Formats). An observatory Earth location should be given as well (see Earth location).
* HDUCLASS type: string
* Signal conformance with HEASARC/OGIP conventions (option: ‘OGIP’). See HDU classes.
* HDUDOC type: string
* Reference to documentation where data format is documented. See HDU classes.
* HDUVERS type: string
* Version of the format (e.g. ‘1.0.0’). See HDU classes.
* HDUCLAS1 type: string
* Primary extension class (option: ‘EVENTS’). See HDU classes.
* OBS_ID type: int
* Unique observation identifier (Run number)
* TSTART type: float, unit: s
* Start time of observation (relative to reference time, see Time)
* TSTOP type: float, unit: s
* End time of observation (relative to reference time, see Time)
* ONTIME type: float, unit: s
* Total good time (sum of length of all Good Time Intervals). If a Good Time Interval (GTI) table is provided, ONTIME should be calculated as the sum of those intervals. Corrections for instrumental dead time effects are NOT included.
* LIVETIME type: float, unit: s
* Total time (in seconds) on source, corrected for the total instrumental dead time effect.
* DEADC type: float
* Dead time correction, defined by LIVETIME/ONTIME. Is comprised in [0,1]. Defined to be 0 if ONTIME=0.
* EQUINOX type: float
* Equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed (options: 2000.0). See also HFWG Recommendation R3 for the OGIP standard.
* RADECSYS type: string
* Stellar reference frame used for the celestial coordinate system in which positions given in either the header or data are expressed. (options: ‘ICRS’, ‘FK5’). See also HFWG Recommendation R3 for the OGIP standard.
* ORIGIN type: string
* Organisation that created the FITS file. This can be the same as TELESCOP (e.g. “HESS”), but it could also be different if an organisation has multiple telescopes (e.g. “NASA” or “ESO”).
* TELESCOP type: string
* Telescope (e.g. ‘CTA’, ‘HESS’, ‘VERITAS’, ‘MAGIC’)
* INSTRUME type: string
* Instrument used to aquire the data contained in the file. Each organisation and telescop has to define this. E.g. for CTA it could be ‘North’ and ‘South’, or sub-array configurations, this has not been defined yet.
* CREATOR type: string
* Software that created the file. When appropriate, the value of the CREATOR keyword should also reference the specific version of the program that created the FITS file. It is intented that this keyword should refer to the program that originally defined the FITS file structure and wrote the contents. If a FITS file is subsequently copied largely intact into a new FITS by another program, then the value of the CREATOR keyword should still refer to the original program. HISTORY keywords should be used instead to document any further processing that is performed on the file after it is created. For more reading on the OGIP standard, see here.
%% Cell type:code id: tags:
``` python
from astropy.time import Time
from astropy.table import Table
from astropy.io import fits
from km3astro.coord import local_event
from km3astro.toolbox import get_ra_dec
class OpenEventList:
def __init__(self):
self.header = {"HDUCLASS": "VODF", "HDUDOC": "http://openscience.km3net.de", \
"HDUVERS": "1.0.0", "HDUCLAS1": "EVENTS", \
"OBS_ID": 0, \
"TSTART": 0.0, "TSTOP": 0.0, "ONTIME": 0.0, \
"MJDREFI": 40587, "MJDREFF": 0.0, "TIMESYS": "UTC", \
"LIVETIME": 0.0, "DEADC": 0.0, "EQUINOX": 2000.0, "RADECSYS": "ICRS", \
"ORIGIN": "KM3NeT", "TELESCOP": "KM3NeT", "INSTRUME": "ARCA", "CREATOR": ""}
self.hdu = None
def set_data(self, evtid, time, energy, ra, dec):
colid = fits.Column(name='EVENT_ID', format='K', array=np.array(evtid))
colt = fits.Column(name='TIME', format='D', unit='s', array=np.array(time))
cole = fits.Column(name='ENERGY', format='E', unit='GeV', array=np.array(energy))
colra = fits.Column(name='RA', format='E', unit='deg', array=np.array(ra))
coldec = fits.Column(name='DEC', format='E', unit='deg', array=np.array(dec))
coldefs = fits.ColDefs([colid, colt, cole, colra, coldec])
self.hdu = fits.BinTableHDU.from_columns(coldefs)
def set_header(self):
for entry in self.header:
self.hdu.header[entry] = self.header[entry]
def write_fits(self, filename):
self.hdu.writeto(filename)
class OpenEvent:
def __init__(self):
self.eventid = None #int64 encoding detector ID, runnumber, frameindex and trigger counter
self.time = None
self.direction = None
self.energy = None
def get_event_from_offlinefile(self, rootfile, entry, detector = "orca"):
self.set_eventID(rootfile.det_id[entry], rootfile.run_id[entry], rootfile.frame_index[entry], rootfile.trigger_counter[entry])
self.set_time(rootfile.t_sec[entry], rootfile.tracks[entry].t[0], rootfile.t_ns[entry])
self.set_event(rootfile.tracks[entry].dir_x[0], rootfile.tracks[entry].dir_y[0], \
rootfile.tracks[entry].dir_z[0], detector = detector)
self.set_energy(rootfile.tracks[entry].E[0])
def set_eventID(self, detid, runid, frameindex, triggercounter, detector = "km3net"):
if detector == "km3net":
instid = "1"
elif detector == "antares":
instid = "2"
else:
instid == "8"
evtstring = instid + str(detid).rjust(3, '0') + str(runid).rjust(6, '0') + \
str(frameindex).rjust(6, '0') + str(triggercounter).rjust(3, '0')
self.eventid = int(evtstring)
def get_eventID_as_string(self):
evtid = str(eventid)
if len(evtid) < 19:
print ("Wrong event ID, cannot create string!")
return None
if evtid[0] == "1":
return "km3."+evtid[1:4]+"."+evtid[4:10]+"."+evtid[10:16]+"."+evtid[16:20]
else:
return evtid[0]+"."+evtid[1:4]+"."+evtid[4:10]+"."+evtid[10:16]+"."+evtid[16:20]
def set_time(self, evttime, frametime, frametime_ns):
self.time = Time((evttime*10E9 + frametime + frametime_ns)/10E9, format = "unix")
def get_time_utc(self):
return self.time.utc.value
def set_event(self, dir_x, dir_y, dir_z, detector = "orca"):
zen = np.arcsin(dir_z) + np.pi / 2 # no idea why, but there are crazy coordinate transformations ...
az = np.arctan(dir_y/dir_x)
self.direction = local_event(az, self.time, zen, detector)
def get_ra(self, unit="deg"):
if unit == "deg":
return self.direction.icrs.ra.deg
else:
return self.direction.icrs.ra
def get_dec(self, unit="deg"):
if unit == "deg":
return oe.direction.icrs.dec.deg
else:
return self.direction.icrs.dec
def set_energy(self, energy):
self.energy = energy
def get_energy(self):
return self.energy
```
%% Cell type:code id: tags:
``` python
evtlist = {"id":[], "energy": [], "ra": [], "dec": [], "time": []}
for i in range(len(myfile.det_id)):
if i%100 == 0:
print ("Done ", i, " events.")
oe = OpenEvent()
oe.get_event_from_offlinefile(myfile, i)
evtlist["energy"].append(oe.get_energy())
evtlist["id"].append(oe.eventid)
evtlist["ra"].append(oe.get_ra())
evtlist["dec"].append(oe.get_dec())
evtlist["time"].append(oe.get_time_utc())
```
%% Output
Done 0 events.
Done 100 events.
Done 200 events.
Done 300 events.
Done 400 events.
Done 500 events.
Done 600 events.
Done 700 events.
Done 800 events.
Done 900 events.
Done 1000 events.
Done 1100 events.
Done 1200 events.
Done 1300 events.
Done 1400 events.
Done 1500 events.
Done 1600 events.
Done 1700 events.
Done 1800 events.
Done 1900 events.
Done 2000 events.
Done 2100 events.
Done 2200 events.
%% Cell type:code id: tags:
``` python
oel = OpenEventList()
oel.set_data(evtlist["id"], evtlist["time"], evtlist["energy"], evtlist["ra"], evtlist["dec"])
oel.set_header()
oel.write_fits("firstlight.fits")
```
%% Cell type:markdown id: tags:
## Reading with gammapy
%% Cell type:code id: tags:
``` python
from gammapy.data import EventList
events = EventList.read("firstlight.fits")
```
%% Output
WARNING: AstropyDeprecationWarning: Specified hdu=EVENTS not found, reading in first available table (hdu=1) instead. This will result in an error in future versions! [astropy.io.fits.connect]
%% Cell type:code id: tags:
``` python
events.energy
```
%% Output
$[0,~1.0056374,~1.0056374,~\dots,~7041.355,~10204.438,~12634.629] \; \mathrm{GeV}$
<Quantity [0.00000000e+00, 1.00563741e+00, 1.00563741e+00, ...,
7.04135498e+03, 1.02044375e+04, 1.26346289e+04] GeV>
%% Cell type:markdown id: tags:
* astropy tables have description, units and output formats per column!
* They have table and column metadata
%% Cell type:markdown id: tags:
# Open questions
* Granularity between single files: Can events from several detector configurations occur in the same file? -> influences placement of metadata between event identifier and header
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment