Skip to content

Commit

Permalink
Merge pull request #59 from cta-observatory/add_trailets
Browse files Browse the repository at this point in the history
Changes for interleaved events and old runs
  • Loading branch information
maxnoe authored Feb 12, 2021
2 parents 7633427 + 01e63fa commit 8148b86
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 22 additions & 2 deletions ctapipe_io_lst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from astropy import units as u
from pkg_resources import resource_filename
import os
from astropy.time import Time
from os import listdir
from ctapipe.core import Provenance
from ctapipe.instrument import (
Expand Down Expand Up @@ -175,6 +176,16 @@ class LSTEventSource(EventSource):
)
).tag(config=True)

calibrate_flatfields_and_pedestals = Bool(
default_value=True,
help='To be set to True for calibration processing'
).tag(config=True)

fill_timestamp = Bool(
default_value=True,
help='To be set to False for data without ucts info'
).tag(config=True)

classes = [PointingSource, EventTimeCalculator, LSTR0Corrections]

def __init__(self, input_url=None, **kwargs):
Expand Down Expand Up @@ -341,7 +352,13 @@ def _generator(self):

# gain select and calibrate to pe
if self.r0_r1_calibrator.calibration_path is not None:
self.r0_r1_calibrator.calibrate(array_event)

# skip flatfield and pedestal events if asked
if (
array_event.trigger.event_type not in {EventType.FLATFIELD, EventType.SKY_PEDESTAL}
or self.calibrate_flatfields_and_pedestals
):
self.r0_r1_calibrator.calibrate(array_event)

yield array_event

Expand Down Expand Up @@ -484,7 +501,10 @@ def fill_trigger_info(self, array_event):
tel_id = self.tel_id

trigger = array_event.trigger
trigger.time = self.time_calculator(tel_id, array_event)
if self.fill_timestamp:
trigger.time = self.time_calculator(tel_id, array_event)
else:
trigger.time = Time(0, format='mjd', scale='tai')
trigger.tels_with_trigger = [tel_id]
trigger.tel[tel_id].time = trigger.time

Expand Down
3 changes: 2 additions & 1 deletion ctapipe_io_lst/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)

from ctapipe.calib.camera.gainselection import ThresholdGainSelector
from ctapipe.containers import MonitoringContainer, ArrayEventContainer
from ctapipe.containers import MonitoringContainer, ArrayEventContainer, EventType
from ctapipe.io import HDF5TableReader


Expand Down Expand Up @@ -205,6 +205,7 @@ def update_first_capacitors(self, event: ArrayEventContainer):
)

def calibrate(self, event: ArrayEventContainer):

for tel_id in event.r0.tel:
r1 = event.r1.tel[tel_id]
waveform = r1.waveform
Expand Down

0 comments on commit 8148b86

Please sign in to comment.