astropy/photutils — pull request #182 by larrybradley (2014-10-10 20:54:08+00:00)
Title: Return pixel positions as single-dimensional columns

This PR addresses #141.

I did not split the input center column if the positions are input `SkyCoord`. In that case, they are still returned as a column of `SkyCoord` objects, e.g.,:

```
aperture_sum ... center_input
MJy / sr ...
------------- ... ------------------------------------------------------
5915.7501418 ...
1631.4685787 ...
1854.4486789 ...
```

Saving such a table to an ascii format results in a literal representation:
```
aperture_sum xcenter_pixel ycenter_pixel center_input
5915.750141803959 7.548988470491622 331.64300721143013 ""
1631.468578699616 17.949988574503323 225.5000061500001 ""
1854.4486788993265 11.106988506073321 404.95700794457025 ""
```

I would much prefer that the `SkyCoords` column be split into separate columns, e.g., "Galactic l" and "Galactic b" columns of floats with units (e.g. deg). There does not seem to be a good way to do that with `SkyCoords`. One could do `skycoords.l` and `skycoords.b`, but that's only valid for Galactic coords. For ICRS instead, it would require `skycoords.ra` and `skycoords.dec` (and the column names would need to change). `skycoords.to_string()` strips the units (and gives less numerical precision).

One way would be to loop through the `SkyCoords` with:
```
skycoord[i].frame.represent_as(SphericalRepresentation).lon.value
skycoord[i].frame.represent_as(SphericalRepresentation).lat.value
```
and then assigning the column units with
```
skycoord[0].frame.represent_as(SphericalRepresentation).lon.unit
skycoord[0].frame.represent_as(SphericalRepresentation).lat.unit
```
But I don't think that works with cartesian representations.

Is there a good way to pull the individual coordinate values and units out of a `SkyCoord` object?