Skip to content

Commit

Permalink
Merge pull request #1046 from watsonjj/retire_r1
Browse files Browse the repository at this point in the history
Suggestion: Retire CameraR1Calibrator
  • Loading branch information
watsonjj authored Apr 25, 2019
2 parents 87273b3 + 1435d4d commit b010cf6
Show file tree
Hide file tree
Showing 30 changed files with 53 additions and 462 deletions.
1 change: 0 additions & 1 deletion ctapipe/calib/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Camera calibration module.
"""

from .r1 import *
from .dl0 import *
from .dl1 import *
from .calibrator import *
21 changes: 0 additions & 21 deletions ctapipe/calib/camera/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from ctapipe.core import Component
from ctapipe.calib.camera import (
CameraR1Calibrator,
CameraDL0Reducer,
CameraDL1Calibrator,
)
Expand All @@ -25,9 +24,7 @@ class CameraCalibrator(Component):
"""
def __init__(self, config=None, parent=None,
r1_product=None,
extractor_name='NeighborPeakWindowSum',
eventsource=None,
**kwargs):
"""
Parameters
Expand All @@ -40,14 +37,8 @@ def __init__(self, config=None, parent=None,
Tool executable that is calling this component.
Passes the correct logger to the component.
Set to None if no Tool to pass.
r1_product : str
The R1 calibrator to use. Manually overrides the Factory.
extractor_name : str
The name of the ImageExtractor to use.
eventsource : ctapipe.io.eventsource.EventSource
EventSource that is being used to read the events. The EventSource
contains information (such as metadata or inst) which indicates
the appropriate R1Calibrator to use.
kwargs
"""
super().__init__(config=config, parent=parent, **kwargs)
Expand All @@ -57,17 +48,6 @@ def __init__(self, config=None, parent=None,
parent=self,
)

if r1_product:
self.r1 = CameraR1Calibrator.from_name(
r1_product,
parent=self,
)
else:
self.r1 = CameraR1Calibrator.from_eventsource(
eventsource,
parent=self,
)

self.dl0 = CameraDL0Reducer(parent=parent)
self.dl1 = CameraDL1Calibrator(
parent=self,
Expand All @@ -85,6 +65,5 @@ def calibrate(self, event):
event : container
A `ctapipe` event container
"""
self.r1.calibrate(event)
self.dl0.reduce(event)
self.dl1.calibrate(event)
214 changes: 0 additions & 214 deletions ctapipe/calib/camera/r1.py

This file was deleted.

31 changes: 1 addition & 30 deletions ctapipe/calib/camera/tests/test_calibrator.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
from numpy.testing import assert_allclose

from ctapipe.calib.camera import (
CameraCalibrator,
HESSIOR1Calibrator,
NullR1Calibrator
)
from ctapipe.image.extractor import LocalPeakWindowSum
from ctapipe.io import SimTelEventSource
from ctapipe.utils import get_dataset_path
from traitlets.config.configurable import Config


def test_camera_calibrator(example_event):
telid = list(example_event.r0.tel)[0]

calibrator = CameraCalibrator(r1_product="HESSIOR1Calibrator")
calibrator = CameraCalibrator()

calibrator.calibrate(example_event)
image = example_event.dl1.tel[telid].image
assert image is not None


def test_manual_r1():
calibrator = CameraCalibrator(r1_product="HESSIOR1Calibrator")
assert isinstance(calibrator.r1, HESSIOR1Calibrator)


def test_manual_extractor():
calibrator = CameraCalibrator(extractor_name="LocalPeakWindowSum")
assert isinstance(calibrator.dl1.extractor, LocalPeakWindowSum)


def test_eventsource_r1():
dataset = get_dataset_path("gamma_test_large.simtel.gz")
eventsource = SimTelEventSource(input_url=dataset)
calibrator = CameraCalibrator(eventsource=eventsource)
assert isinstance(calibrator.r1, HESSIOR1Calibrator)


def test_eventsource_override_r1():
dataset = get_dataset_path("gamma_test_large.simtel.gz")
eventsource = SimTelEventSource(input_url=dataset)
calibrator = CameraCalibrator(
eventsource=eventsource,
r1_product="NullR1Calibrator"
)
assert isinstance(calibrator.r1, NullR1Calibrator)


def test_config():
window_shift = 3
window_width = 9
Expand All @@ -56,7 +28,6 @@ def test_config():
"window_width": window_width,
}})
calibrator = CameraCalibrator(
r1_product='HESSIOR1Calibrator',
extractor_name='LocalPeakWindowSum',
config=config
)
Expand Down
17 changes: 2 additions & 15 deletions ctapipe/calib/camera/tests/test_dl0.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
from numpy.testing import assert_almost_equal

from ctapipe.calib.camera.dl0 import CameraDL0Reducer
from ctapipe.calib.camera.r1 import HESSIOR1Calibrator


def previous_calibration(event):
r1 = HESSIOR1Calibrator()
r1.calibrate(event)


def test_camera_dl0_reducer(example_event):
previous_calibration(example_event)

telid = list(example_event.r0.tel)[0]

telid = list(example_event.r1.tel)[0]
reducer = CameraDL0Reducer()
reducer.reduce(example_event)
waveforms = example_event.dl0.tel[telid].waveform
assert waveforms is not None


def test_check_r1_exists(example_event):
telid = list(example_event.r0.tel)[0]

previous_calibration(example_event)
telid = list(example_event.r1.tel)[0]
reducer = CameraDL0Reducer()
assert (reducer.check_r1_exists(example_event, telid) is True)
example_event.r1.tel[telid].waveform = None
Expand Down
5 changes: 0 additions & 5 deletions ctapipe/calib/camera/tests/test_dl1.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
from numpy.testing import assert_allclose

from ctapipe.calib.camera.dl0 import CameraDL0Reducer
from ctapipe.calib.camera.dl1 import integration_correction, \
CameraDL1Calibrator
from ctapipe.calib.camera.r1 import HESSIOR1Calibrator


def previous_calibration(event):
r1 = HESSIOR1Calibrator()
r1.calibrate(event)
dl0 = CameraDL0Reducer()
dl0.reduce(event)

Expand Down
Loading

0 comments on commit b010cf6

Please sign in to comment.