[AstroPy] Conversion from a Cartesian representation to SkyCoord

Tim Cornwell realtimcornwell at gmail.com
Sun Feb 11 15:25:54 EST 2018


Solved this myself:

n = numpy.sqrt(1-l**2-m**2)-1.0
dc = n + 1, l, m
target = SkyCoord(x=dc[0], y=dc[1], z=dc[2], representation='cartesian', frame=phasecentre.skyoffset_frame())
return target.transform_to(phasecentre.frame)


> On 11 Feb 2018, at 5:47 pm, Tim Cornwell <realtimcornwell at gmail.com> wrote:
> 
> I'm working with some radio data in astropy. I need to convert to and from the l, m, n. Given a position on the sky, pos, I can calculate l, m, n as follows:
> 
> todc = pos.transform_to(phasecentre.skyoffset_frame())
> dc = todc.represent_as(CartesianRepresentation)
> l, m, n = dc.y.value, dc.z.value, dc.x.value - 1
> How do I do the reverse operation? i.e. given a set of l, m, n defined with respect to phase centre how to get the SkyCoord? The easy part is the conversion between direction cosines and l, m, n:
> 
> dc = lm[2] + 1, lmn[0], lmn[1]
> Thanks, Tim
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20180211/3cdda329/attachment.html>


More information about the AstroPy mailing list