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

Support different frames for set_line_hillas #2131

Merged
merged 1 commit into from
Nov 23, 2022
Merged
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
16 changes: 14 additions & 2 deletions ctapipe/visualization/mpl_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
from astropy import units as u
from astropy.coordinates import Angle
from astropy.coordinates import Angle, SkyCoord
from matplotlib import pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.lines import Line2D
Expand Down Expand Up @@ -68,6 +68,7 @@ def __init__(
# transform to the new frame.
self.tel_coords = subarray.tel_coords.transform_to(frame).cartesian
self.unit = self.tel_coords.x.unit
self.frame = frame

# set up colors per telescope type
tel_types = [str(tel) for tel in subarray.tels.values()]
Expand Down Expand Up @@ -321,6 +322,9 @@ def set_line_hillas(self, hillas_dict, core_dict, range, **kwargs):
"""

coords = self.tel_coords
# transform to GroundFrame
positions_in_frame = SkyCoord(coords, frame=self.frame)
coords = positions_in_frame.transform_to(GroundFrame())
c = self.tel_colors

r = np.array([-range, range])
Expand All @@ -334,7 +338,15 @@ def set_line_hillas(self, hillas_dict, core_dict, range, **kwargs):

x = x_0 + np.cos(psi).value * r
y = y_0 + np.sin(psi).value * r
self.axes.plot(x, y, color=c[idx], **kwargs)

# transform back to desired frame
new_coords = (
SkyCoord(x, y, z=0, unit="m", frame=GroundFrame())
.transform_to(self.frame)
.cartesian
)

self.axes.plot(new_coords.x, new_coords.y, color=c[idx], **kwargs)
self.axes.scatter(x_0, y_0, color=c[idx])

def add_labels(self):
Expand Down