Skip to content

Commit

Permalink
solve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
misabelber committed Apr 22, 2019
2 parents fdce732 + 2afa50f commit 4f99759
Show file tree
Hide file tree
Showing 13 changed files with 1,008 additions and 179 deletions.
17 changes: 8 additions & 9 deletions lstchain/calib/camera/calib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import numpy as np
from ctapipe.image.charge_extractors import LocalPeakIntegrator
from ctapipe.image.extractor import LocalPeakWindowSum
from ctapipe.calib.camera.gainselection import ThresholdGainSelector


Expand Down Expand Up @@ -31,20 +31,19 @@ def lst_calibration(event, telescope_id):

pedcorrectedsamples = data - np.atleast_3d(ped) / nsamples

integrator = LocalPeakIntegrator(None, None)
integration, peakpos, window = integrator.extract_charge(
pedcorrectedsamples) # these are 2D matrices num_gains * num_pixels
integrator = LocalPeakWindowSum()
integration, pulse_time = integrator(pedcorrectedsamples) # these are 2D matrices num_gains * num_pixels

signals = integration.astype(float)

dc2pe = event.mc.tel[telescope_id].dc_to_pe # numgains * numpixels
signals *= dc2pe

event.dl1.tel[telescope_id].image = signals
event.dl1.tel[telescope_id].peakpos = peakpos
event.dl1.tel[telescope_id].pulse_time = pulse_time


def gain_selection(waveform, signals, peakpos, cam_id, threshold):
def gain_selection(waveform, signals, pulse_time, cam_id, threshold):

"""
Custom lst calibration.
Expand All @@ -54,7 +53,7 @@ def gain_selection(waveform, signals, peakpos, cam_id, threshold):
----------
waveform: array of waveforms of the events
signals: array of calibrated pixel charges
peakpos: array of pixel peak positions
pulse_time: array of pixel peak positions
cam_id: str
threshold: int threshold to change form high gain to low gain
"""
Expand All @@ -80,7 +79,7 @@ def gain_selection(waveform, signals, peakpos, cam_id, threshold):

combined = signals[0].copy()
combined[signalmask] = signals[1][signalmask]
peaks = peakpos[0].copy()
peaks[signalmask] = peakpos[1][signalmask]
peaks = pulse_time[0].copy()
peaks[signalmask] = pulse_time[1][signalmask]

return combined, peaks
28 changes: 12 additions & 16 deletions lstchain/calib/camera/drs4.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import argparse
import numpy as np
from astropy.io import fits
from numba import jit


Expand All @@ -11,7 +9,8 @@ class DragonPedestal:
high_gain = 0
low_gain = 1

def __init__(self):
def __init__(self, telid=0):
self.telid = telid
self.first_capacitor = np.zeros((2, 8))
self.meanped = np.zeros((2, self.n_pixels, self.size4drs))
self.numped = np.zeros((2, self.n_pixels, self.size4drs))
Expand All @@ -26,7 +25,7 @@ def fill_pedestal_event(self, event, nr):
self.first_capacitor[self.low_gain, i] = first_cap[j]

waveform = event.r0.tel[0].waveform[:, :, :]
expected_pixel_id = event.lst.tel[0].svc.pixel_ids
expected_pixel_id = event.lst.tel[self.telid].svc.pixel_ids
self._fill_pedestal_event_jit(nr, waveform, expected_pixel_id, self.first_capacitor, self.meanped, self.numped)

@staticmethod
Expand Down Expand Up @@ -56,15 +55,12 @@ def finalize_pedestal(self):
print("Not enough events to coverage all capacitor. Please use more events to create pedestal file.")
print(err)


def get_first_capacitor(event, nr):
hg = 0
lg = 1
fc = np.zeros((2, 8))
first_cap = event.lst.tel[0].evt.first_capacitor_id[nr * 8:(nr + 1) * 8]
# First capacitor order according Dragon v5 board data format
for i, j in zip([0, 1, 2, 3, 4, 5, 6], [0, 0, 1, 1, 2, 2, 3]):
fc[hg, i] = first_cap[j]
for i, j in zip([0, 1, 2, 3, 4, 5, 6], [4, 4, 5, 5, 6, 6, 7]):
fc[lg, i] = first_cap[j]
return fc
def get_first_capacitor(self, event, nr):
fc = np.zeros((2, 8))
first_cap = event.lst.tel[self.telid].evt.first_capacitor_id[nr * 8:(nr + 1) * 8]
# First capacitor order according Dragon v5 board data format
for i, j in zip([0, 1, 2, 3, 4, 5, 6], [0, 0, 1, 1, 2, 2, 3]):
fc[self.high_gain, i] = first_cap[j]
for i, j in zip([0, 1, 2, 3, 4, 5, 6], [4, 4, 5, 5, 6, 6, 7]):
fc[self.low_gain, i] = first_cap[j]
return fc
6 changes: 3 additions & 3 deletions lstchain/calib/camera/flatfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from astropy import units as u
from ctapipe.core import Component
from ctapipe.image import ChargeExtractor
from ctapipe.image.extractor import ImageExtractor
from ctapipe.core.traits import Int, Unicode, Float, List
from ctapipe_io_lst.containers import FlatFieldContainer

Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(
self.container = FlatFieldContainer()

# load the waveform charge extractor
self.extractor = ChargeExtractor.from_name(
self.extractor = ImageExtractor.from_name(
self.charge_product,
config=self.config
)
Expand Down Expand Up @@ -138,7 +138,7 @@ def _extract_charge(self, event):
g = event.inst.subarray.tel[self.tel_id].camera
self.extractor.neighbours = g.neighbor_matrix_where

charge, peak_pos, window = self.extractor.extract_charge(waveforms)
charge, peak_pos = self.extractor(waveforms)

# sum all the samples
else:
Expand Down
4 changes: 2 additions & 2 deletions lstchain/calib/camera/pedestals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from astropy import units as u
from ctapipe.core import Component

from ctapipe.image import ChargeExtractor
from ctapipe.image.extractor import ImageExtractor
from ctapipe.core.traits import Int, Unicode, Float, List
from ctapipe_io_lst.containers import PedestalContainer

Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(
self.container = PedestalContainer()

# load the waveform charge extractor
self.extractor = ChargeExtractor.from_name(
self.extractor = ImageExtractor.from_name(
self.charge_product,
config=self.config
)
Expand Down
Loading

0 comments on commit 4f99759

Please sign in to comment.