Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CameraFrame transformations for arrays of focal_length, fixes #1850 #1851

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ctapipe/coordinates/camera_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def camera_to_telescope(camera_coord, telescope_frame):
y_rotated = x_pos * sinrot + y_pos * cosrot

focal_length = camera_coord.focal_length
if focal_length.value == 0:
if focal_length.shape == () and focal_length.value == 0:
raise ValueError(
"Coordinate in CameraFrame is missing focal_length information"
)
Expand Down Expand Up @@ -178,7 +178,7 @@ def telescope_to_camera(telescope_coord, camera_frame):
y_rotated = x_pos * sinrot + y_pos * cosrot

focal_length = camera_frame.focal_length
if focal_length.value == 0:
if focal_length.shape == () and focal_length.value == 0:
raise ValueError("CameraFrame is missing focal_length information")

# this assumes an equidistant mapping function of the telescope optics
Expand Down
9 changes: 9 additions & 0 deletions ctapipe/coordinates/tests/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,12 @@ def test_camera_missing_focal_length():

with raises(ValueError):
coord.transform_to(TelescopeFrame())


def test_camera_focal_length_array():
from ctapipe.coordinates import CameraFrame, TelescopeFrame

tel_coord = SkyCoord([1, 2] * u.deg, [0, 1] * u.deg, frame=TelescopeFrame())
cam_coord = tel_coord.transform_to(CameraFrame(focal_length=[28, 17] * u.m))
assert not np.isnan(cam_coord.x).any()
assert not np.isnan(cam_coord.y).any()