N-dimensional representation classes
For the examples below the following imports have already been executed:
>>> import astropy.units as u
>>> import numpy as np
>>> import gala.dynamics as gd
Introduction
The Astropy representations framework presently only support 3D positions and differential
objects. The NDCartesianRepresentation
and
NDCartesianDifferential
classes add Cartesian
representation classes that can handle arbitrary numbers of dimensions. For
example, 2D coordinates:
>>> xy = np . arange ( 16 ) . reshape ( 2 , 8 ) * u . kpc
>>> rep = gd . NDCartesianRepresentation ( xy )
>>> rep
<NDCartesianRepresentation (x1, x2) in kpc
[(0., 8.), (1., 9.), (2., 10.), (3., 11.), (4., 12.), (5., 13.),
(6., 14.), (7., 15.)]>
4D coordinates:
>>> x = np . arange ( 16 ) . reshape ( 4 , 4 ) * u . kpc
>>> rep = gd . NDCartesianRepresentation ( x )
>>> rep
<NDCartesianRepresentation (x1, x2, x3, x4) in kpc
[(0., 4., 8., 12.), (1., 5., 9., 13.), (2., 6., 10., 14.),
(3., 7., 11., 15.)]>
These can be passed in to the PhaseSpacePosition
or Orbit
classes as with any of the Astropy
core representation objects:
>>> xy = np . arange ( 16 ) . reshape ( 2 , 8 ) * u . kpc
>>> vxy = np . arange ( 16 ) . reshape ( 2 , 8 ) / 10. * u . kpc / u . Myr
>>> w = gd . PhaseSpacePosition ( pos = xy , vel = vxy )
>>> fig = w . plot ()
(Source code
, png
, pdf
)
However, certain functionality such as representation transformations, dynamical
quantity calculation, and coordinate frame transformations are disabled when the
number of dimensions is not 3 (i.e. when not using the Astropy core
representation classes).
N-dimensional representations API
Class Inheritance Diagram
digraph inheritance26a4766685 {
bgcolor=transparent;
rankdir=LR;
size="8.0, 12.0";
"BaseDifferential" [URL="https://docs.astropy.org/en/stable/api/astropy.coordinates.BaseDifferential.html#astropy.coordinates.BaseDifferential",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A base class representing differentials of representations."];
"BaseRepresentationOrDifferential" -> "BaseDifferential" [arrowsize=0.5,style="setlinewidth(0.5)"];
"BaseRepresentation" [URL="https://docs.astropy.org/en/stable/api/astropy.coordinates.BaseRepresentation.html#astropy.coordinates.BaseRepresentation",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base for representing a point in a 3D coordinate system."];
"BaseRepresentationOrDifferential" -> "BaseRepresentation" [arrowsize=0.5,style="setlinewidth(0.5)"];
"BaseRepresentationOrDifferential" [URL="https://docs.astropy.org/en/stable/api/astropy.coordinates.BaseRepresentationOrDifferential.html#astropy.coordinates.BaseRepresentationOrDifferential",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="3D coordinate representations and differentials."];
"ShapedLikeNDArray" -> "BaseRepresentationOrDifferential" [arrowsize=0.5,style="setlinewidth(0.5)"];
"CartesianDifferential" [URL="https://docs.astropy.org/en/stable/api/astropy.coordinates.CartesianDifferential.html#astropy.coordinates.CartesianDifferential",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Differentials in of points in 3D cartesian coordinates."];
"BaseDifferential" -> "CartesianDifferential" [arrowsize=0.5,style="setlinewidth(0.5)"];
"CartesianRepresentation" [URL="https://docs.astropy.org/en/stable/api/astropy.coordinates.CartesianRepresentation.html#astropy.coordinates.CartesianRepresentation",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Representation of points in 3D cartesian coordinates."];
"BaseRepresentation" -> "CartesianRepresentation" [arrowsize=0.5,style="setlinewidth(0.5)"];
"NDArrayShapeMethods" [URL="https://docs.astropy.org/en/stable/api/astropy.utils.shapes.NDArrayShapeMethods.html#astropy.utils.shapes.NDArrayShapeMethods",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin class to provide shape-changing methods."];
"NDCartesianDifferential" [URL="../api/gala.dynamics.representation_nd.NDCartesianDifferential.html#gala.dynamics.representation_nd.NDCartesianDifferential",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Differentials in of points in ND cartesian coordinates."];
"NDMixin" -> "NDCartesianDifferential" [arrowsize=0.5,style="setlinewidth(0.5)"];
"CartesianDifferential" -> "NDCartesianDifferential" [arrowsize=0.5,style="setlinewidth(0.5)"];
"NDCartesianRepresentation" [URL="../api/gala.dynamics.representation_nd.NDCartesianRepresentation.html#gala.dynamics.representation_nd.NDCartesianRepresentation",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Representation of points in ND cartesian coordinates."];
"NDMixin" -> "NDCartesianRepresentation" [arrowsize=0.5,style="setlinewidth(0.5)"];
"CartesianRepresentation" -> "NDCartesianRepresentation" [arrowsize=0.5,style="setlinewidth(0.5)"];
"NDMixin" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled"];
"ShapedLikeNDArray" [URL="https://docs.astropy.org/en/stable/api/astropy.utils.shapes.ShapedLikeNDArray.html#astropy.utils.shapes.ShapedLikeNDArray",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin class to provide shape-changing methods."];
"NDArrayShapeMethods" -> "ShapedLikeNDArray" [arrowsize=0.5,style="setlinewidth(0.5)"];
}