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

Conversation

seinecke
Copy link
Contributor

@seinecke seinecke commented Mar 1, 2019

When transforming from horizon frame to camera frame and back, it gives different results.
When specifying pixels in meters, everything is fine, but not for millimetres for example.

Changed
u.Quantity((x_rotated / focal_length).to_value(), u.rad)
to
delta_alt = u.Quantity((x_rotated / focal_length).to_value(u.dimensionless_unscaled), u.rad)

Added unit test to check correct handling of units.

seinecke and others added 2 commits March 1, 2019 10:55
- units in camera frame were not always taken into account
- added unit test to check correct handling of units
dneise
dneise previously approved these changes Mar 1, 2019
Copy link
Member

@dneise dneise left a comment

Choose a reason for hiding this comment

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

looks good to me ...


# 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

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.

- pointing in camera frame definition
- defined frame
- checking with 'is close' instead of 'is equal'
@maxnoe
Copy link
Member

maxnoe commented Mar 1, 2019

The tests are still failing (missing imports), you can run them locally using

 pytest ctapipe/coordinates/tests/test_coordinates.py

@seinecke
Copy link
Contributor Author

seinecke commented Mar 1, 2019

The tests are still failing (missing imports), you can run them locally using

 pytest ctapipe/coordinates/tests/test_coordinates.py

But this seems unrelated to my added code

@maxnoe
Copy link
Member

maxnoe commented Mar 1, 2019

But this seems unrelated to my added code

It fails in the test you added. You need to import stuff in the test function

@maxnoe
Copy link
Member

maxnoe commented Mar 1, 2019

Add the imports after:

 def test_cam_to_hor():

And maybe call it test_camera_units

seinecke added 2 commits March 1, 2019 13:53
- camera_coord.y.to_value instead of camera_coord.to_value
@codecov
Copy link

codecov bot commented Mar 1, 2019

Codecov Report

Merging #997 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #997      +/-   ##
==========================================
+ Coverage   78.93%   78.95%   +0.02%     
==========================================
  Files         195      195              
  Lines       11328    11340      +12     
==========================================
+ Hits         8942     8954      +12     
  Misses       2386     2386
Impacted Files Coverage Δ
ctapipe/coordinates/camera_frame.py 90.9% <100%> (ø) ⬆️
ctapipe/coordinates/tests/test_coordinates.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a40dba...8a834bc. Read the comment docs.

@thomasgas
Copy link

Just code quality not up to standards. Check the output with "Details" to see what has to be changed.

@maxnoe
Copy link
Member

maxnoe commented Mar 1, 2019

I would Merge regardless

@maxnoe maxnoe merged commit b3ba1ca into cta-observatory:master Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants