astropy/astropy — pull request #2951 by eteq (2014-09-16 21:33:55+00:00)
Title: Create SkyCoord from Table

This is not ready to be merged, but should be taken as a proof-of-concept that I can flesh out with proper docs and tests if we actually want to move forward with it.

The motivation is that I almost daily find myself typing things like ``SkyCoord(ra=tab['ra'],dec=tab['dec')``, which seems needlessly repetitive. So the intent of this PR is to allow the folllowing:
```
tab = ascii.read('sometablewithradec.dat')
sc = SkyCoord(tab, frame='icrs')
```
and have it work when it makes sense. (Actually, more likely is ``SkyCoord(tab, unit=u.deg)`` given that most ASCII tables don't have units, but you get the idea.)

The main problem is that "makes sense" is of course a bit ambiguous. The PR right now will accept anything that has columns where the start of the column name is a case-insensitive match to the attribute name of the coordinate frame. So, as an example, if we assume the ICRS frame, a table with columns "RA" and "Dec" would work, as would "ra" and "Dec", or "RA (J2000)" and "DEC (J2000)". This covers the vast majority of tables I find myself working with on a daily basis, and I figure any more complex matching procedure it's better to just have the user do it manually.

Thoughts on whether we should have this? @astrofrog @taldcroft @mhvk ?