Skip to content

Commit

Permalink
I implemented Mysha and Max comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Toennis committed Jul 16, 2024
1 parent d845d14 commit 3daec81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 57 deletions.
52 changes: 3 additions & 49 deletions src/ctapipe/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"DL0Container",
"DL1CameraCalibrationContainer",
"DL1CameraContainer",
"DL1PedestalVarianceContainer",
"DL1Container",
"DL2Container",
"EventCalibrationContainer",
Expand Down Expand Up @@ -168,12 +167,12 @@ class EventType(enum.Enum):


class VarianceType(enum.Enum):
"""Enum of variance types used for the DL1PedestalVarianceContainer"""
"""Enum of variance types used for the VarianceContainer"""

# Simple variance of waveform
SIMPLE = 0
WAVEFORM = 0
# Variance of integrated samples of a waveform
SAMPLE = 1
INTEGRATED = 1


class PixelStatus(enum.IntFlag):
Expand Down Expand Up @@ -487,17 +486,6 @@ class ImageParametersContainer(Container):


class DL1CameraContainer(Container):
"""
Storage of output of camera calibration e.g the final calibrated
image in intensity units and the pulse time.
"""

image = Field(
None,
"Numpy array of camera image, after waveform extraction."
"Shape: (n_pixel) if n_channels is 1 or data is gain selected"
"else: (n_channels, n_pixel)",
)
peak_time = Field(
None,
"Numpy array containing position of the peak of the pulse as determined by "
Expand All @@ -520,45 +508,11 @@ class DL1CameraContainer(Container):
"pass only was returned."
),
)

parameters = Field(
None, description="Image parameters", type=ImageParametersContainer
)


class DL1PedestalVarianceContainer(Container):
"""
Storage of output of camera variance image e.g.
the variance of each pixel composed as an image.
"""

image = Field(
None,
"Numpy array of camera variance image"
"Shape: (n_pixel) if n_channels is 1 or data is gain selected"
"else: (n_channels, n_pixel)",
)
time = Field(
None,
"Trigger time for this variance image" "Value is a float",
)
VarMethod = Field(
VarianceType.SIMPLE,
"Method by which the variance was calculated"
"This can either be a plain variance"
"or a variance of integrated samples",
type=VarianceType,
)
is_valid = Field(
False,
(
"True if image extraction succeeded, False if failed "
"or in the case of TwoPass methods, that the first "
"pass only was returned."
),
)


class DL1Container(Container):
"""DL1 Calibrated Camera Images and associated data"""

Expand Down
15 changes: 7 additions & 8 deletions src/ctapipe/image/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

from ctapipe.containers import (
DL1CameraContainer,
DL1PedestalVarianceContainer,
VarianceType,
)
from ctapipe.core import TelescopeComponent
Expand Down Expand Up @@ -1307,14 +1306,14 @@ class VarianceExtractor(ImageExtractor):
"""

def __call__(self, waveforms, tel_id, trigger_time) -> DL1PedestalVarianceContainer:
variance = np.nanvar(waveforms, dtype="float32", axis=2)
return DL1PedestalVarianceContainer(
image=variance,
VarMethod=VarianceType.SIMPLE,
is_valid=True,
time=trigger_time,
def __call__(
self, waveforms, tel_id, selected_gain_channel, broken_pixels
) -> DL1CameraContainer:
container = DL1CameraContainer(
image=np.nanvar(waveforms, dtype="float32", axis=2),
)
container.meta["ExtractionMethod"] = str(VarianceType.WAVEFORM)
return container


def deconvolution_parameters(
Expand Down

0 comments on commit 3daec81

Please sign in to comment.