Skip to content

Commit

Permalink
remove CamerHillasParametersContainer from rest
Browse files Browse the repository at this point in the history
  • Loading branch information
StFroese committed Sep 15, 2023
1 parent 87073c6 commit 2b038da
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 101 deletions.
24 changes: 0 additions & 24 deletions ctapipe/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,30 +324,6 @@ def dl1_file(dl1_tmp_path, prod5_gamma_simtel_path):
return output


@pytest.fixture(scope="session")
def dl1_camera_frame_file(dl1_tmp_path, prod5_gamma_simtel_path):
"""
DL1 file containing both images and parameters from a gamma simulation set.
"""
from ctapipe.tools.process import ProcessorTool

output = dl1_tmp_path / "gamma_camera_frame.dl1.h5"

# prevent running process multiple times in case of parallel tests
with FileLock(output.with_suffix(output.suffix + ".lock")):
if output.is_file():
return output

argv = [
f"--input={prod5_gamma_simtel_path}",
f"--output={output}",
"--camera-frame",
"--write-images",
]
assert run_tool(ProcessorTool(), argv=argv, cwd=dl1_tmp_path) == 0
return output


@pytest.fixture(scope="session")
def dl2_only_file(dl2_tmp_path, prod5_gamma_simtel_path):
"""
Expand Down
26 changes: 0 additions & 26 deletions ctapipe/io/tests/test_hdf5eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
import numpy as np
import pytest

from ctapipe.containers import (
CameraHillasParametersContainer,
CameraTimingParametersContainer,
)
from ctapipe.io import DataLevel, EventSource, HDF5EventSource


Expand Down Expand Up @@ -196,25 +192,3 @@ def test_read_dl2(dl2_shower_geometry_file):
impact = e.dl2.tel[tel_id].impact[algorithm]
assert impact.prefix == algorithm + "_tel_impact"
assert impact.distance is not None


def test_dl1_camera_frame(dl1_camera_frame_file):
with HDF5EventSource(dl1_camera_frame_file) as s:
tel_id = None
for e in s:
for tel_id, dl1 in e.dl1.tel.items():
assert isinstance(
dl1.parameters.hillas, CameraHillasParametersContainer
)
assert isinstance(
dl1.parameters.timing, CameraTimingParametersContainer
)
assert dl1.parameters.hillas.intensity is not None

for tel_id, sim in e.simulation.tel.items():
assert isinstance(
sim.true_parameters.hillas, CameraHillasParametersContainer
)
assert sim.true_parameters.hillas.intensity is not None

assert tel_id is not None, "did not test any events"
8 changes: 4 additions & 4 deletions ctapipe/reco/tests/test_ImPACT.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from numpy.testing import assert_allclose

from ctapipe.containers import (
CameraHillasParametersContainer,
HillasParametersContainer,
ReconstructedEnergyContainer,
ReconstructedGeometryContainer,
)
Expand All @@ -25,9 +25,9 @@ def setup_class(self):
self.impact_reco = ImPACTReconstructor(root_dir=".")
self.horizon_frame = AltAz()

self.h1 = CameraHillasParametersContainer(
x=1 * u.deg,
y=1 * u.deg,
self.h1 = HillasParametersContainer(
fov_lon=1 * u.deg,
fov_lat=1 * u.deg,
r=1 * u.deg,
phi=Angle(0 * u.rad),
intensity=100,
Expand Down
4 changes: 0 additions & 4 deletions ctapipe/tools/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ class ProcessorTool(Tool):
"store DL1/Event/Telescope muon parameters in output",
"don't store DL1/Event/Telescope muon parameters in output",
),
"camera-frame": (
{"ImageProcessor": {"use_telescope_frame": False}},
"Use camera frame for image parameters instead of telescope frame",
),
}

classes = (
Expand Down
5 changes: 2 additions & 3 deletions ctapipe/tools/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def test_stage_1_dl1(tmp_path, dl1_image_file, dl1_parameters_file):
f"--config={config}",
f"--input={dl1_image_file}",
f"--output={dl1b_from_dl1a_file}",
"--camera-frame",
"--write-parameters",
"--overwrite",
],
Expand Down Expand Up @@ -114,8 +113,8 @@ def test_stage_1_dl1(tmp_path, dl1_image_file, dl1_parameters_file):
"obs_id",
"event_id",
"tel_id",
"camera_frame_hillas_intensity",
"camera_frame_hillas_x",
"hillas_intensity",
"hillas_fov_lon",
"concentration_cog",
"leakage_pixels_width_1",
)
Expand Down
41 changes: 7 additions & 34 deletions ctapipe/visualization/tests/test_mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
from matplotlib import __version__ as mpl_version

from ctapipe.calib.camera.calibrator import CameraCalibrator
from ctapipe.containers import (
CameraHillasParametersContainer,
HillasParametersContainer,
)
from ctapipe.containers import HillasParametersContainer
from ctapipe.coordinates.telescope_frame import TelescopeFrame
from ctapipe.instrument import PixelShape, SubarrayDescription

Expand Down Expand Up @@ -90,19 +87,6 @@ def test_camera_display_single(prod5_lst_cam, tmp_path):
fig.savefig(tmp_path / "result.png")


def test_hillas_overlay_camera_frame(prod5_lst_cam, tmp_path):
from ctapipe.visualization import CameraDisplay

fig, ax = plt.subplots()
disp = CameraDisplay(prod5_lst_cam, ax=ax)
hillas = CameraHillasParametersContainer(
x=0.1 * u.m, y=-0.1 * u.m, length=0.5 * u.m, width=0.2 * u.m, psi=90 * u.deg
)

disp.overlay_moments(hillas, color="w")
fig.savefig(tmp_path / "result.png")


def test_hillas_overlay(prod5_lst_cam, tmp_path):
from ctapipe.visualization import CameraDisplay

Expand Down Expand Up @@ -205,16 +189,13 @@ def test_array_display(prod5_mst_nectarcam):
# ...with scalar color
ad.set_vector_uv(np.array([1, 2, 3]) * u.m, np.array([1, 2, 3]) * u.m, c=3)

geom = prod5_mst_nectarcam.camera.geometry
geom = prod5_mst_nectarcam.camera.geometry.transform_to(TelescopeFrame())
rot_angle = 20 * u.deg
hillas = CameraHillasParametersContainer(x=0 * u.m, y=0 * u.m, psi=rot_angle)

# test using hillas params CameraFrame:
hillas_dict = {
1: CameraHillasParametersContainer(length=100.0 * u.m, psi=90 * u.deg),
2: CameraHillasParametersContainer(length=20000 * u.cm, psi="95deg"),
}
hillas = HillasParametersContainer(
fov_lon=0 * u.deg, fov_lat=0 * u.deg, psi=rot_angle
)

# test using hillas params for divergent pointing in telescopeframe:
grad = 2
intercept = 1

Expand All @@ -226,19 +207,11 @@ def test_array_display(prod5_mst_nectarcam):
cleaning_mask=np.ones(geom.n_pixels, dtype=bool),
)
gradient_dict = {1: timing_rot20.slope.value, 2: timing_rot20.slope.value}

core_dict = {
tel_id: dl1.parameters.core.psi for tel_id, dl1 in event.dl1.tel.items()
}
ad.set_vector_hillas(
hillas_dict=hillas_dict,
core_dict=core_dict,
length=500,
time_gradient=gradient_dict,
angle_offset=0 * u.deg,
)
ad.set_line_hillas(hillas_dict=hillas_dict, core_dict=core_dict, range=300)

# test using hillas params for divergent pointing in telescopeframe:
hillas_dict = {
1: HillasParametersContainer(
fov_lon=1.0 * u.deg, fov_lat=1.0 * u.deg, length=1.0 * u.deg, psi=90 * u.deg
Expand Down
8 changes: 2 additions & 6 deletions ctapipe/visualization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from astropy.coordinates import Angle

from ..containers import CameraHillasParametersContainer, HillasParametersContainer
from ..containers import HillasParametersContainer


def build_hillas_overlay(hillas, unit, with_label=True, n_sigma=1):
Expand All @@ -15,16 +15,12 @@ def build_hillas_overlay(hillas, unit, with_label=True, n_sigma=1):
except u.UnitsError:
raise ValueError("hillas must be in same frame as geometry")

# strip off any units
if isinstance(hillas, HillasParametersContainer):
cog_x = hillas.fov_lon.to_value(unit)
cog_y = hillas.fov_lat.to_value(unit)
elif isinstance(hillas, CameraHillasParametersContainer):
cog_x = hillas.x.to_value(unit)
cog_y = hillas.y.to_value(unit)
else:
raise TypeError(
"hillas must be a (Camera)HillasParametersContainer" f", got: {hillas} "
"hillas must be a HillasParametersContainer" f", got: {hillas} "
)

psi_rad = hillas.psi.to_value(u.rad)
Expand Down

0 comments on commit 2b038da

Please sign in to comment.