Last active
September 3, 2016 15:26
-
-
Save giacomov/185760affa5e5bed5cf19cda17a79842 to your computer and use it in GitHub Desktop.
A generic EventList class
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
import numpy as np | |
class EventList(object): | |
def __init__(self, arrival_times, energies, ra=None, dec=None): | |
self._arrival_times = np.asarray(arrival_times) | |
self._energies = np.asarray(energies) | |
assert self._arrival_times.shape[0] == self._energies.shape[0] | |
# ........ | |
@classmethod | |
def from_TTE(cls, tte_file, response): | |
# Open TTE, get the arrival times, read the EBOUNDS from the response and give | |
# each event the appropriate energy according to the channel | |
with pyfits.open(tte_file) as f: | |
arrival_times = f['EVENTS'].TIME | |
channel = f['EVENTS'].PHA | |
with pyfits.open(response) as f: | |
ebounds = f['EBOUNDS'].data | |
# Loop over the events and give them the right energy according to their | |
# channel | |
energies =... | |
# then: | |
return cls(arrival_times, energies) | |
@classmethod | |
def from_FT1(cls, ft1_file): | |
# Create event list from LAT FT1 file | |
# Read the FT1 | |
with pyfits.open(ft1_file) as f: | |
arrival_times = f['EVENTS'].data.TIME | |
energies = f['EVENTS'].data.ENERGY | |
return cls(arrival_times, energies) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment