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

fixed bug in coordinate transformation #997

Merged
merged 5 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -85,8 +85,8 @@ def camera_to_telescope(camera_coord, telescope_frame):
# as an Attribute of `CameraFrame` that maps f(r, focal_length) -> theta,
# where theta is the angle to the optical axis and r is the distance
# to the camera center in the focal plane
delta_alt = u.Quantity((x_rotated / focal_length).to_value(), u.rad)
delta_az = u.Quantity((y_rotated / focal_length).to_value(), u.rad)
delta_alt = u.Quantity((x_rotated / focal_length).to_value(u.dimensionless_unscaled), u.rad)
delta_az = u.Quantity((y_rotated / focal_length).to_value(u.dimensionless_unscaled), u.rad)

representation = UnitSphericalRepresentation(lat=delta_alt, lon=delta_az)

Expand Down
24 changes: 24 additions & 0 deletions ctapipe/coordinates/tests/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@ def test_cam_to_tel():
assert camera_coord.separation_3d(camera_coord2)[0] == 0 * u.m


def test_cam_to_hor():
# Coordinates in any frame can be given as a numpy array of the xyz positions
# e.g. in this case the position on pixels in the camera
pix_x = [1] * u.m
pix_y = [1] * u.m

focal_length = 15000 * u.mm

# first define the camera frame
pointing = SkyCoord(alt=70*u.deg, az=0*u.deg,frame=AltAz())
camera_frame = CameraFrame(focal_length=focal_length)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointing needs to go here


# transform
camera_coord = SkyCoord(pix_x, pix_y, frame=camera_frame)
altaz_coord = camera_coord.transform_to(AltAz())

# transform back
altaz_coord2 = SkyCoord(az=altaz_coord.az, alt=altaz_coord.alt, frame=hf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hf is undefined (should be defined above or just add AltAz() here.

camera_coord2 = altaz_coord2.transform_to(camera_frame)

# check transform
assert camera_coord.x == camera_coord2.x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use assert np.isclose(camera_coord.x.to_value(u.m), camera_coord2.to_value(u.m), comparing floats for equality is often not a good idea.



def test_ground_to_tilt():
from ctapipe.coordinates import GroundFrame, TiltedGroundFrame

Expand Down