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

Celestial frame hardcoded to 2 axes? #21

Open
mdboom opened this issue Aug 27, 2015 · 2 comments
Open

Celestial frame hardcoded to 2 axes? #21

mdboom opened this issue Aug 27, 2015 · 2 comments

Comments

@mdboom
Copy link
Contributor

mdboom commented Aug 27, 2015

I don't know if this is a bug or not, but it's come up in the work to serialize frames to/from ASDF.

If I assign a reference_frame on a CelestialFrame to a coordinate that has inherently 3 axes, it doesn't complain, but then len(axes_names) != naxes.

In [17]: import gwcs

In [18]: x = gwcs.CelestialFrame(reference_frame=coordinates.Galactic())

In [19]: x.axes_names
Out[19]: [u'lon', u'lat', u'distance']

In [20]: x.naxes
Out[20]: 2
@nden
Copy link
Collaborator

nden commented Aug 27, 2015

@eteq I am using frame.representation_component_names to get the default names of the frame axes but this includes also distance. What is the correct way to get the default axes names in a frame?

Also gwcs.CelestialFrame.naxes is hardcoded as 2. This isn't always correct (e.g. Galactocentric ). Is there a way to get the number of axes in an instance of one of the builtin_frames?

nden added a commit to nden/gwcs that referenced this issue Aug 27, 2015
@nden nden mentioned this issue Aug 27, 2015
nden added a commit that referenced this issue Aug 27, 2015
@eteq
Copy link
Contributor

eteq commented Sep 2, 2015

@nden - if what you want is the names specifically for the default representation (as opposed to the current one for a particular object, which can change at runtime), then this is probably the way to go:

>>> g = coordinates.Galactic()
>>> g.default_representation
astropy.coordinates.representation.SphericalRepresentation
>>> g.representation_info[g.default_representation]
{u'names': (u'l', u'b', u'distance'),
 u'units': (Unit("deg"), Unit("deg"), None)}
>>> g.representation_info[g.default_representation]['names']
(u'l', u'b', u'distance')

Internally, that's basically what representation_component_names does, but it gives you the names for the current representation, which is not necessarily always the default. (But maybe that's actually what you want?)

@nden @mdboom - As for CelestialFrame.naxes, I would think it should be hardcoded to 3. All coordinate frame objects by design are 3-dimensional: they use the representation heirarchy, and currently those are all 3D. UnitSphericalRepresentation is a bit subtle in that it seems to be 2D, but in fact it's interpreted as points on the unit sphere. So you can do this:

>>> s = UnitSphericalRepresentation(10*u.deg, 42*u.deg)
>>> s.to_cartesian()
<CartesianRepresentation (x, y, z) [dimensionless]
    (0.73185479, 0.12904574, 0.66913061)>

And you can see that it's actually 3D.

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

No branches or pull requests

3 participants