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
Move position_angle()
from SkyCoord
to BaseCoordinateFrame
#15737
Conversation
`BaseCoordinateFrame.separation()` and `SkyCoord.position_angle()` perform many analogous computations, which are now implemented in `BaseCoordinateFrame._prepare_unit_sphere_coords()`. This seems to lose some error handling in `SkyCoord.position_angle()`, but the errors that were meant to be caught there cannot be triggered.
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
bf97e42
to
7ad28fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this more like api
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously BaseCoordinateFrame
had no position_angle()
method, but now it does. That looks like a new feature to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But... you are moving it from another class. @mhvk , what say you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think from the user-perspective, there is no change of API for SkyCoord
-- it is more like a refactoring
-- while there now is a new feature on BaseFrame
, so I think "enhancement" is most appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A nice little improvement, making things more logical.
I also like the new test file. Will you be doing a follow-up PR to move the separation methods?
astropy/coordinates/baseframe.py
Outdated
------- | ||
`~astropy.coordinates.Angle` | ||
The (positive) position angle of the vector pointing from ``self`` | ||
to ``other``. If either ``self`` or ``other`` contain arrays, this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add ", measured East from North" to give people new to position angles a clue as to what to expect (though the examples help!)
astropy/coordinates/baseframe.py
Outdated
>>> c2.position_angle(c1).degree | ||
270.0 | ||
""" | ||
from .angles import position_angle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be on top? Or does it cause a circular import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few functions here that import things locally and it would be good to have a separate pull request to clean them up. I thought this line could be included in that, but this line does not exist in this file before this pull request, so we can indeed avoid some code churn by having a module level import in this pull request already.
The `position_angle()` method has been moved form `SkyCoord` to `BaseCoordinateFrame`. The method is still accesible to `SkyCoord` instances because they expose methods of their underlying frames.
7ad28fe
to
421a476
Compare
I am planning to look at the relevant tests, and not just for the separation methods but for position angle too. For example, it is not clear to me if the tests in astropy/astropy/coordinates/tests/test_sky_coord_velocities.py Lines 236 to 237 in f87e75d
|
Thanks! Let's get it in. |
Description
The first commit implements a new private method in
BaseCoordinateFrame
that simplifies the implementation ofseparation()
andposition_angle()
methods.The second commit moves
position_angle()
fromSkyCoord
toBaseCoordinateFrame
. The method remains accessible forSkyCoord
instances because they have access to methods defined both inSkyCoord
and in their underlying frame.I felt it appropriate to create a new file for testing methods that are implemented in
BaseCoordinateFrame
, but are exposed also bySkyCoord
instances. That file should also include tests forseparation()
andseparation_3d()
, but moving those tests over would be beyond the scope of this pull request, which is large enough as it is.