astropy/astropy — pull request #2586 by taldcroft (2014-05-31 17:50:19+00:00)
Title: Dynamic coordinate preferred representation

This is a proof of concept for a way to allow dynamic preferred representation for coordinates (low-level and high-level). DO NOT MERGE now.

Example:
```
>>> import astropy.units as u
>>> from astropy.coordinates import *
>>> c = ICRS(1*u.deg, 2*u.deg)
>>> c.ra

>>> c.preferred_representation = CartesianRepresentation
>>> c

>>> c.x

>>> c.ra # I don't quite understand why the ra property goes to __getattr__ in this case
ERROR: AttributeError: 'ICRS' object has no attribute 'ra' [astropy.coordinates.baseframe]
Traceback (most recent call last):
File "", line 1, in
c.ra
File "astropy/coordinates/baseframe.py", line 546, in __getattr__
.format(self.__class__.__name__, attr))
AttributeError: 'ICRS' object has no attribute 'ra'

>>> c.data # Still Spherical underneath the hood

>>> sc = SkyCoord(1*u.deg, 2*u.deg)
>>> sc.frame.preferred_representation = CartesianRepresentation
>>> sc

>>> sc.x

```