[AstroPy] Question on astropy.coordinates internals
Adrian Price-Whelan
adrianmpw at gmail.com
Fri Jul 7 09:04:10 EDT 2017
Hi Hervé --
> What is the correct way to check that an input is a bona fide reference frame ? Playing around, I have come with this:
Slightly better I think is to check:
isinstance(my_input_frame, coord.baseframe.BaseCoordinateFrame)
> Is there a way to access the directly the coodinate tranformation matrix ? So far, I use the transformation on each of the cartesian unit vector to build the rotation matrix, but this is a bit clunky...
Which coordinate transformation matrix? If a given transformation is
implemented as one of the MatrixTransform classes, you can get the
matrix directly from the function that implements the transformation.
These are all in astropy/coordinates/builtin_frames/. An example would
be the transformation from FK5 to Galactic coordinates, implemented in
astropy/coordinates/builtin_frames/galactic_transforms.py
With a given set of FK5 coordinates (as an FK5 instance "fk5"), you can do:
fk5_coords = coord.FK5(ra=18*u.deg, dec=-11*u.deg)
matrix = coord.builtin_frames.galactic_transforms.fk5_to_gal(fk5_coords,
coord.Galactic)
However, not all transformations are implemented as MatrixTransform's.
The coloring of the edges in the frame transform graph here:
http://docs.astropy.org/en/latest/coordinates/index.html#module-astropy.coordinates
show what the class of the transformation is. The AffineTransform
transformations (new in v2.0) return a matrix and a vector offset. The
FunctionTransform's implement the transformation directly and return
the new set of coordinates in the desired frame, so it wouldn't be
possible to get a transformation matrix from any of those.
Happy to help more if anything is unclear!
Thanks,
Adrian
On Thu, Jul 6, 2017 at 11:20 AM, Hervé Aussel <herve.aussel at cea.fr> wrote:
> Hello,
>
> I am working on a package to handle spacecrafts attitudes in python, and I would like to build on the astropy.coordinates package, especially to handle transformations between reference frames. I have a few questions regarding the internals of the package.
>
> - What is the correct way to check that an input is a bona fide reference frame ? Playing around, I have come with this:
> import astropy.coordinates as coord
> isinstance(my_input_frame, coord.baseframe.FrameMeta)
>
> - Is there a way to access the directly the coodinate tranformation matrix ? So far, I use the transformation on each of the cartesian unit vector to build the rotation matrix, but this is a bit clunky...
>
> Thanks for your help,
>
> Cheers,
>
> Hervé
>
>
>
> -----------------------------------------------------------------------------------------
> Hervé Aussel
>
> EC SPV Lead
>
> AIM Paris-Saclay phone: (+33) 01 69 08 95 79
> UMR 7158 fax : (+33) 01 69 08 65 77
> Bat 709 CE-Saclay
> Orme des Merisiers email: herve.aussel at cea.fr
> F 91 191 Gif-sur-Yvette
>
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
--
Adrian M. Price-Whelan
Lyman Spitzer, Jr. Postdoctoral Fellow
Princeton University
http://adrian.pw
More information about the AstroPy
mailing list