coordinax.vecs#
coordinax.vecs Module.
- coordinax.vecs.vector(*args: Any, **kwargs: Any)#
Construct a vector given the arguments.
- coordinax.vecs.vector(obj: AbstractVector, /) AbstractVector
Construct a vector from a vector.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> cart = cx.vecs.CartesianPos2D.from_([1, 2], "km") >>> cx.vector(cart) is cart True
- coordinax.vecs.vector(cls: type[AbstractVector], obj: Mapping[str, Any], /) AbstractVector
Construct a vector from a mapping.
Examples
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax as cx
>>> xs = {"x": u.Quantity(1, "m"), "y": u.Quantity(2, "m"), ... "z": u.Quantity(3, "m")} >>> vec = cx.CartesianPos3D.from_(xs) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> xs = {"x": u.Quantity([1, 2], "m"), "y": u.Quantity([3, 4], "m"), ... "z": u.Quantity([5, 6], "m")} >>> vec = cx.CartesianPos3D.from_(xs) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [[1 3 5] [2 4 6]]>
- coordinax.vecs.vector(cls: type[AbstractVector], obj: AbstractQuantity, /) AbstractVector
Construct a vector from a quantity.
This will fail for most non-position vectors, except Cartesian vectors, since they generally do not have the same dimensions, nor can be converted from a Cartesian vector without additional information.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Mismatch:
>>> try: cxv.CartesianPos1D.from_(u.Quantity([1, 2, 3], "m")) ... except ValueError as e: print(e) Cannot construct <class 'coordinax...CartesianPos1D'> from 3 components.
Pos 1D:
>>> cxv.CartesianPos1D.from_(u.Quantity(1, "meter")) CartesianPos1D(x=Quantity(1, unit='m'))
>>> cxv.CartesianPos1D.from_(u.Quantity([1], "meter")) CartesianPos1D(x=Quantity(1, unit='m'))
>>> cxv.CartesianPos1D.from_(cx.Distance(1, "meter")) CartesianPos1D(x=Quantity(1, unit='m'))
>>> cxv.RadialPos.from_(u.Quantity(1, "meter")) RadialPos(r=Distance(1, unit='m'))
>>> cxv.RadialPos.from_(u.Quantity([1], "meter")) RadialPos(r=Distance(1, unit='m'))
Vel 1D:
>>> cxv.CartesianVel1D.from_(u.Quantity(1, "m/s")) CartesianVel1D(x=Quantity(1, unit='m / s'))
>>> cxv.CartesianVel1D.from_(u.Quantity([1], "m/s")) CartesianVel1D(x=Quantity(1, unit='m / s'))
>>> cxv.RadialVel.from_(u.Quantity(1, "m/s")) RadialVel(r=Quantity(1, unit='m / s'))
>>> cxv.RadialVel.from_(u.Quantity([1], "m/s")) RadialVel(r=Quantity(1, unit='m / s'))
Acc 1D:
>>> cxv.CartesianAcc1D.from_(u.Quantity(1, "m/s2")) CartesianAcc1D(x=Quantity(1, unit='m / s2'))
>>> cxv.CartesianAcc1D.from_(u.Quantity([1], "m/s2")) CartesianAcc1D(x=Quantity(1, unit='m / s2'))
>>> cxv.RadialAcc.from_(u.Quantity(1, "m/s2")) RadialAcc(r=Quantity(1, unit='m / s2'))
>>> cxv.RadialAcc.from_(u.Quantity([1], "m/s2")) RadialAcc(r=Quantity(1, unit='m / s2'))
Pos 2D:
>>> vec = cxv.CartesianPos2D.from_(u.Quantity([1, 2], "m")) >>> print(vec) <CartesianPos2D: (x, y) [m] [1 2]>
Vel 2D:
>>> vec = cxv.CartesianVel2D.from_(u.Quantity([1, 2], "m/s")) >>> print(vec) <CartesianVel2D: (x, y) [m / s] [1 2]>
Acc 2D:
>>> vec = cxv.CartesianAcc2D.from_(u.Quantity([1, 2], "m/s2")) >>> print(vec) <CartesianAcc2D: (x, y) [m / s2] [1 2]>
Pos 3D:
>>> vec = cxv.CartesianPos3D.from_(u.Quantity([1, 2, 3], "m")) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
Vel 3D:
>>> vec = cxv.CartesianVel3D.from_(u.Quantity([1, 2, 3], "m/s")) >>> print(vec) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
Acc 3D:
>>> vec = cxv.CartesianAcc3D.from_(u.Quantity([1, 2, 3], "m/s2")) >>> print(vec) <CartesianAcc3D: (x, y, z) [m / s2] [1 2 3]>
Generic 3D:
>>> vec = cxv.Cartesian3D.from_(u.Quantity([1, 2, 3], "m")) >>> print(vec) <Cartesian3D: (x, y, z) [m] [1 2 3]>
- coordinax.vecs.vector(cls: type[AbstractVector], obj: ArrayLike | list[Any], unit: Unit | UnitBase | CompositeUnit | str, /) AbstractVector
Construct a vector from an array and unit.
The
ArrayLike[Any, (*#batch, N), "..."]is expected to have the components as the last dimension.Examples
>>> import jax.numpy as jnp >>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "meter") >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]]) >>> vec = cx.CartesianPos3D.from_(xs, "meter") >>> print(vec) <CartesianPos3D: (x, y, z) [m] [[1 2 3] [4 5 6]]>
- coordinax.vecs.vector(cls: type[AbstractVector], obj: AbstractVector, /) AbstractVector
Construct a vector from another vector.
- Raises:
TypeError – If the object is not an instance of the vector class.
- Parameters:
- Return type:
Examples
>>> import coordinax as cx
Positions:
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "km")
>>> cart = cx.CartesianPos3D.from_(q) >>> print(cart) <CartesianPos3D: (x, y, z) [km] [1 2 3]>
>>> cx.vecs.AbstractPos3D.from_(cart) is cart True
>>> sph = cart.vconvert(cx.SphericalPos) >>> cx.vecs.AbstractPos3D.from_(sph) is sph True
>>> cyl = cart.vconvert(cx.vecs.CylindricalPos) >>> cx.vecs.AbstractPos3D.from_(cyl) is cyl True
Velocities:
>>> p = cx.CartesianVel3D.from_([1, 2, 3], "km/s")
>>> cart = cx.CartesianVel3D.from_(p) >>> cx.vecs.AbstractVel3D.from_(cart) is cart True
>>> sph = cart.vconvert(cx.SphericalVel, q) >>> cx.vecs.AbstractVel3D.from_(sph) is sph True
>>> cyl = cart.vconvert(cx.vecs.CylindricalVel, q) >>> cx.vecs.AbstractVel3D.from_(cyl) is cyl True
Accelerations:
>>> p = cx.CartesianVel3D.from_([1, 1, 1], "km/s")
>>> cart = cx.vecs.CartesianAcc3D.from_([1, 2, 3], "km/s2") >>> cx.vecs.AbstractAcc3D.from_(cart) is cart True
>>> sph = cart.vconvert(cx.vecs.SphericalAcc, p, q) >>> cx.vecs.AbstractAcc3D.from_(sph) is sph True
>>> cyl = cart.vconvert(cx.vecs.CylindricalAcc, p, q) >>> cx.vecs.AbstractAcc3D.from_(cyl) is cyl True
- coordinax.vecs.vector(cls: type[AbstractPos3D], obj: AbstractPos3D, /) AbstractPos3D
Construct from a 3D position.
Examples
>>> import coordinax.vecs as cxv
>>> cart = cxv.CartesianPos3D.from_([1, 2, 3], "km") >>> cxv.AbstractPos3D.from_(cart) is cart True
>>> sph = cart.vconvert(cxv.SphericalPos) >>> cxv.AbstractPos3D.from_(sph) is sph True
>>> cyl = cart.vconvert(cxv.CylindricalPos) >>> cxv.AbstractPos3D.from_(cyl) is cyl True
- coordinax.vecs.vector(cls: type[AbstractVel3D], obj: AbstractVel3D, /) AbstractVel3D
Construct from a 3D velocity.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 1, 1], "km")
>>> cart = cxv.CartesianVel3D.from_([1, 2, 3], "km/s") >>> cxv.AbstractVel3D.from_(cart) is cart True
>>> sph = cart.vconvert(cxv.SphericalVel, q) >>> cxv.AbstractVel3D.from_(sph) is sph True
>>> cyl = cart.vconvert(cxv.CylindricalVel, q) >>> cxv.AbstractVel3D.from_(cyl) is cyl True
- coordinax.vecs.vector(cls: type[AbstractAcc3D], obj: AbstractAcc3D, /) AbstractAcc3D
Construct from a 3D velocity.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 1, 1], "km") >>> p = cxv.CartesianVel3D.from_([1, 1, 1], "km/s")
>>> cart = cxv.CartesianAcc3D.from_([1, 2, 3], "km/s2") >>> cxv.AbstractAcc3D.from_(cart) is cart True
>>> sph = cart.vconvert(cxv.SphericalAcc, p, q) >>> cxv.AbstractAcc3D.from_(sph) is sph True
>>> cyl = cart.vconvert(cxv.CylindricalAcc, p, q) >>> cxv.AbstractAcc3D.from_(cyl) is cyl True
- coordinax.vecs.vector(cls: type[SphericalPos], *, r: AbstractQuantity, theta: AbstractQuantity, phi: AbstractQuantity) SphericalPos
Construct SphericalPos, allowing for out-of-range values.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Let’s start with a valid input:
>>> vec = cxv.SphericalPos.from_(r=u.Quantity(3, "km"), ... theta=u.Quantity(90, "deg"), ... phi=u.Quantity(0, "deg")) >>> print(vec) <SphericalPos: (r[km], theta[deg], phi[deg]) [ 3 90 0]>
The radial distance can be negative, which wraps the azimuthal angle by 180 degrees and flips the polar angle:
>>> vec = cxv.SphericalPos.from_(r=u.Quantity(-3, "km"), ... theta=u.Quantity(45, "deg"), ... phi=u.Quantity(0, "deg")) >>> print(vec) <SphericalPos: (r[km], theta[deg], phi[deg]) [ 3 135 180]>
The polar angle can be outside the [0, 180] deg range, causing the azimuthal angle to be shifted by 180 degrees:
>>> vec = cxv.SphericalPos.from_(r=u.Quantity(3, "km"), ... theta=u.Quantity(190, "deg"), ... phi=u.Quantity(0, "deg")) >>> print(vec) <SphericalPos: (r[km], theta[deg], phi[deg]) [ 3 170 180]>
The azimuth can be outside the [0, 360) deg range. This is wrapped to the [0, 360) deg range (actually the base from_ does this):
>>> vec = cxv.SphericalPos.from_(r=u.Quantity(3, "km"), ... theta=u.Quantity(90, "deg"), ... phi=u.Quantity(365, "deg")) >>> vec.phi Angle(Array(5, dtype=int32, ...), unit='deg')
- coordinax.vecs.vector(cls: type[LonLatSphericalPos], *, lon: AbstractQuantity, lat: AbstractQuantity, distance: AbstractQuantity) LonLatSphericalPos
Construct LonLatSphericalPos, allowing for out-of-range values.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Let’s start with a valid input:
>>> vec = cxv.LonLatSphericalPos.from_(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(0, "deg"), ... distance=u.Quantity(3, "km")) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [0 0 3]>
The distance can be negative, which wraps the longitude by 180 degrees and flips the latitude:
>>> vec = cxv.LonLatSphericalPos.from_(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(45, "deg"), ... distance=u.Quantity(-3, "km")) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [180 -45 3]>
The latitude can be outside the [-90, 90] deg range, causing the longitude to be shifted by 180 degrees:
>>> vec = cxv.LonLatSphericalPos.from_(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(-100, "deg"), ... distance=u.Quantity(3, "km")) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [180 -80 3]>
>>> vec = cxv.LonLatSphericalPos.from_(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(100, "deg"), ... distance=u.Quantity(3, "km")) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [180 80 3]>
The longitude can be outside the [0, 360) deg range. This is wrapped to the [0, 360) deg range (actually the base constructor does this):
>>> vec = cxv.LonLatSphericalPos.from_(lon=u.Quantity(365, "deg"), ... lat=u.Quantity(0, "deg"), ... distance=u.Quantity(3, "km")) >>> vec.lon Angle(Array(5, dtype=int32, ...), unit='deg')
- coordinax.vecs.vector(cls: type[MathSphericalPos], *, r: AbstractQuantity, theta: AbstractQuantity, phi: AbstractQuantity) MathSphericalPos
Construct MathSphericalPos, allowing for out-of-range values.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Let’s start with a valid input:
>>> vec = cxv.MathSphericalPos.from_(r=u.Quantity(3, "km"), ... theta=u.Quantity(90, "deg"), ... phi=u.Quantity(0, "deg")) >>> print(vec) <MathSphericalPos: (r[km], theta[deg], phi[deg]) [ 3 90 0]>
The radial distance can be negative, which wraps the azimuthal angle by 180 degrees and flips the polar angle:
>>> vec = cxv.MathSphericalPos.from_(r=u.Quantity(-3, "km"), ... theta=u.Quantity(100, "deg"), ... phi=u.Quantity(45, "deg")) >>> print(vec) <MathSphericalPos: (r[km], theta[deg], phi[deg]) [ 3 280 135]>
The polar angle can be outside the [0, 180] deg range, causing the azimuthal angle to be shifted by 180 degrees:
>>> vec = cxv.MathSphericalPos.from_(r=u.Quantity(3, "km"), ... theta=u.Quantity(0, "deg"), ... phi=u.Quantity(190, "deg")) >>> print(vec) <MathSphericalPos: (r[km], theta[deg], phi[deg]) [ 3 180 170]>
The azimuth can be outside the [0, 360) deg range. This is wrapped to the [0, 360) deg range (actually the base constructor does this):
>>> vec = cxv.MathSphericalPos.from_(r=u.Quantity(3, "km"), ... theta=u.Quantity(365, "deg"), ... phi=u.Quantity(90, "deg")) >>> vec.theta Angle(Array(5, dtype=int32, ...), unit='deg')
- coordinax.vecs.vector(cls: type[CartesianPosND] | type[CartesianVelND] | type[CartesianAccND], x: AbstractQuantity, /) CartesianPosND | CartesianVelND | CartesianAccND
Construct an N-dimensional acceleration.
Examples
>>> import unxt as u >>> import coordinax as cx
1D vector:
>>> cx.vecs.CartesianPosND.from_(u.Quantity(1, "km")) CartesianPosND(q=Quantity([1], unit='km'))
>>> cx.vecs.CartesianPosND.from_(u.Quantity([1], "km")) CartesianPosND(q=Quantity([1], unit='km'))
>>> cx.vecs.CartesianVelND.from_(u.Quantity(1, "km/s")) CartesianVelND(q=Quantity([1], unit='km / s'))
>>> cx.vecs.CartesianVelND.from_(u.Quantity([1], "km/s")) CartesianVelND(q=Quantity([1], unit='km / s'))
>>> cx.vecs.CartesianAccND.from_(u.Quantity(1, "km/s2")) CartesianAccND(q=Quantity([1], unit='km / s2'))
>>> cx.vecs.CartesianAccND.from_(u.Quantity([1], "km/s2")) CartesianAccND(q=Quantity([1], unit='km / s2'))
2D vector:
>>> cx.vecs.CartesianPosND.from_(u.Quantity([1, 2], "km")) CartesianPosND(q=Quantity([1, 2], unit='km'))
>>> cx.vecs.CartesianVelND.from_(u.Quantity([1, 2], "km/s")) CartesianVelND(q=Quantity([1, 2], unit='km / s'))
>>> cx.vecs.CartesianAccND.from_(u.Quantity([1, 2], "km/s2")) CartesianAccND(q=Quantity([1, 2], unit='km / s2'))
3D vector:
>>> cx.vecs.CartesianPosND.from_(u.Quantity([1, 2, 3], "km")) CartesianPosND(q=Quantity([1, 2, 3], unit='km'))
>>> cx.vecs.CartesianVelND.from_(u.Quantity([1, 2, 3], "km/s")) CartesianVelND(q=Quantity([1, 2, 3], unit='km / s'))
>>> cx.vecs.CartesianAccND.from_(u.Quantity([1, 2, 3], "km/s2")) CartesianAccND(q=Quantity([1, 2, 3], unit='km / s2'))
4D vector:
>>> cx.vecs.CartesianPosND.from_(u.Quantity([1, 2, 3, 4], "km")) CartesianPosND(q=Quantity([1, 2, 3, 4], unit='km'))
>>> cx.vecs.CartesianVelND.from_(u.Quantity([1, 2, 3, 4], "km/s")) CartesianVelND(q=Quantity([1, 2, 3, 4], unit='km / s'))
>>> cx.vecs.CartesianAccND.from_(u.Quantity([1, 2, 3, 4], "km/s2")) CartesianAccND(q=Quantity([1, 2, 3, 4], unit='km / s2'))
- coordinax.vecs.vector(cls: type[FourVector], obj: AbstractQuantity, /) FourVector
Construct a vector from a Quantity array.
The
Quantity[Any, (*#batch, 4), "..."]is expected to have the components as the last dimension. The 4 components are the (c x) time, x, y, z.Examples
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax as cx
>>> xs = u.Quantity([0, 1, 2, 3], "meter") # [ct, x, y, z] >>> vec = cx.FourVector.from_(xs) >>> print(vec) <FourVector: (t[m s / km], q=(x, y, z) [m]) [0. 1. 2. 3.]>
>>> xs = u.Quantity(jnp.array([[0, 1, 2, 3], [10, 4, 5, 6]]), "meter") >>> vec = cx.FourVector.from_(xs) >>> print(vec) <FourVector: (t[m s / km], q=(x, y, z) [m]) [[0.000e+00 1.000e+00 2.000e+00 3.000e+00] [3.336e-05 4.000e+00 5.000e+00 6.000e+00]]>
- coordinax.vecs.vector(q: AbstractQuantity, /) AbstractVector
Construct a vector from a quantity.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> print(cx.vecs.vector(u.Quantity(1, "km"))) <CartesianPos1D: (x) [km] [1]>
>>> print(cx.vecs.vector(u.Quantity([1], "km"))) <CartesianPos1D: (x) [km] [1]>
>>> print(cx.vecs.vector(u.Quantity(1, "km/s"))) <CartesianVel1D: (x) [km / s] [1]>
>>> print(cx.vecs.vector(u.Quantity([1], "km/s"))) <CartesianVel1D: (x) [km / s] [1]>
>>> print(cx.vecs.vector(u.Quantity(1, "km/s2"))) <CartesianAcc1D: (x) [km / s2] [1]>
>>> print(cx.vecs.vector(u.Quantity([1], "km/s2"))) <CartesianAcc1D: (x) [km / s2] [1]>
>>> print(cx.vecs.vector(u.Quantity([1, 2], "km"))) <CartesianPos2D: (x, y) [km] [1 2]>
>>> print(cx.vecs.vector(u.Quantity([1, 2], "km/s"))) <CartesianVel2D: (x, y) [km / s] [1 2]>
>>> print(cx.vecs.vector(u.Quantity([1, 2], "km/s2"))) <CartesianAcc2D: (x, y) [km / s2] [1 2]>
>>> print(cx.vecs.vector(u.Quantity([1, 2, 3], "km"))) <CartesianPos3D: (x, y, z) [km] [1 2 3]>
>>> print(cx.vecs.vector(u.Quantity([1, 2, 3], "km/s"))) <CartesianVel3D: (x, y, z) [km / s] [1 2 3]>
>>> print(cx.vecs.vector(u.Quantity([1, 2, 3], "km/s2"))) <CartesianAcc3D: (x, y, z) [km / s2] [1 2 3]>
>>> print(cx.vecs.vector(u.Quantity([0, 1, 2, 3], "km"))) <CartesianPosND: (q) [km] [[0] [1] [2] [3]]>
>>> print(cx.vecs.vector(u.Quantity([0, 1, 2, 3], "km/s"))) <CartesianVelND: (q) [km / s] [[0] [1] [2] [3]]>
>>> print(cx.vecs.vector(u.Quantity([0, 1, 2, 3], "km/s2"))) <CartesianAccND: (q) [km / s2] [[0] [1] [2] [3]]>
>>> try: print(cx.vecs.vector(u.Quantity([1], "Msun"))) ... except ValueError as e: print(e) Cannot construct a Cartesian vector from Quantity['mass']([1], unit='solMass').
- coordinax.vecs.vector(q: list[float | int], unit: str, /) AbstractVector
Construct a vector from a list and unit.
Examples
>>> import coordinax as cx
>>> print(cx.vecs.vector([1], "km")) <CartesianPos1D: (x) [km] [1]>
>>> print(cx.vecs.vector([1], "km/s")) <CartesianVel1D: (x) [km / s] [1]>
>>> print(cx.vecs.vector([1], "km/s2")) <CartesianAcc1D: (x) [km / s2] [1]>
>>> print(cx.vecs.vector([1, 2], "km")) <CartesianPos2D: (x, y) [km] [1 2]>
>>> print(cx.vecs.vector([1, 2], "km/s")) <CartesianVel2D: (x, y) [km / s] [1 2]>
>>> print(cx.vecs.vector([1, 2], "km/s2")) <CartesianAcc2D: (x, y) [km / s2] [1 2]>
>>> print(cx.vecs.vector([1, 2, 3], "km")) <CartesianPos3D: (x, y, z) [km] [1 2 3]>
>>> print(cx.vecs.vector([1, 2, 3], "km/s")) <CartesianVel3D: (x, y, z) [km / s] [1 2 3]>
>>> print(cx.vecs.vector([1, 2, 3], "km/s2")) <CartesianAcc3D: (x, y, z) [km / s2] [1 2 3]>
- coordinax.vecs.vector(cls: type[Coordinate], data: KinematicSpace | AbstractPos, frame: AbstractReferenceFrame, /) Coordinate
Construct a coordinate from data and a frame.
Examples
>>> import coordinax as cx
>>> data = cx.CartesianPos3D.from_([1, 2, 3], "kpc") >>> cx.Coordinate.from_(data, cx.frames.ICRS()) Coordinate( KinematicSpace({ 'length': CartesianPos3D( ... ) }), frame=ICRS() )
- coordinax.vecs.vector(cls: type[Coordinate], data: KinematicSpace | AbstractPos, base_frame: AbstractReferenceFrame, ops: AbstractOperator, /) Coordinate
Construct a coordinate from data and a frame.
Examples
>>> import coordinax as cx
>>> data = cx.CartesianPos3D.from_([1, 2, 3], "kpc") >>> cx.Coordinate.from_(data, cx.frames.ICRS(), cx.ops.Identity()) Coordinate( KinematicSpace({ 'length': CartesianPos3D( ... ) }), frame=TransformedReferenceFrame(base_frame=ICRS(), xop=Identity()) )
- coordinax.vecs.vector(obj: CartesianRepresentation, /) CartesianPos3D
Construct from a astropy.coordinates.CartesianRepresentation.
This re-dispatches to
coordinax.vecs.CartesianPos3D.from_().Examples
>>> import coordinax as cx >>> from astropy.coordinates import CartesianRepresentation
>>> cart = CartesianRepresentation(1, 2, 3, unit="m") >>> vec = cx.vector(cart) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1. 2. 3.]>
- coordinax.vecs.vector(obj: CylindricalRepresentation, /) CylindricalPos
Construct from a astropy.coordinates.CylindricalRepresentation.
This re-dispatches to
coordinax.vecs.CylindricalPos.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import CylindricalRepresentation
>>> cyl = CylindricalRepresentation(rho=1 * u.km, phi=2 * u.deg, ... z=30 * u.m) >>> vec = cx.vector(cyl) >>> print(vec) <CylindricalPos: (rho[km], phi[deg], z[m]) [ 1. 2. 30.]>
- coordinax.vecs.vector(obj: PhysicsSphericalRepresentation, /) SphericalPos
Construct from a astropy.coordinates.PhysicsSphericalRepresentation.
This re-dispatches to
coordinax.vecs.SphericalPos.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import PhysicsSphericalRepresentation
>>> sph = PhysicsSphericalRepresentation(r=1 * u.km, theta=2 * u.deg, ... phi=3 * u.deg) >>> vec = cx.vector(sph) >>> print(vec) <SphericalPos: (r[km], theta[deg], phi[deg]) [1. 2. 3.]>
- coordinax.vecs.vector(obj: SphericalRepresentation, /) LonLatSphericalPos
Construct from a astropy.coordinates.SphericalRepresentation.
This re-dispatches to
coordinax.vecs.LonLatSphericalPos.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import SphericalRepresentation
>>> sph = SphericalRepresentation(lon=3 * u.deg, lat=2 * u.deg, ... distance=1 * u.km) >>> vec = cx.vector(sph) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [3. 2. 1.]>
- coordinax.vecs.vector(obj: UnitSphericalRepresentation) TwoSpherePos
Construct from a astropy.coordinates.UnitSphericalRepresentation.
This re-dispatches to
coordinax.vecs.TwoSpherePos.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import UnitSphericalRepresentation
>>> sph = UnitSphericalRepresentation(lon=3 * u.deg, lat=2 * u.deg) >>> vec = cx.vector(sph) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(obj: CartesianDifferential, /) CartesianVel3D
Construct from a astropy.coordinates.CartesianDifferential.
This re-dispatches to
coordinax.vecs.CartesianVel3D.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import CartesianDifferential
>>> dcart = CartesianDifferential(1, 2, 3, unit="km/s") >>> dif = cx.vector(dcart) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(obj: CylindricalDifferential, /) CylindricalVel
Construct from a astropy.coordinates.CylindricalDifferential.
This re-dispatches to
coordinax.vecs.CylindricalVel.from_().Examples
>>> import astropy.units as u >>> import astropy.coordinates as apyc >>> import coordinax as cx
>>> dcyl = apyc.CylindricalDifferential(d_rho=1 * u.km / u.s, d_phi=2 * u.mas/u.yr, ... d_z=2 * u.km / u.s) >>> dif = cx.vector(dcyl) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(obj: PhysicsSphericalDifferential, /) SphericalVel
Construct from a astropy.coordinates.PhysicsSphericalDifferential.
This re-dispatches to
coordinax.vecs.SphericalVel.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import PhysicsSphericalDifferential
>>> dsph = PhysicsSphericalDifferential(d_r=1 * u.km / u.s, d_theta=2 * u.mas/u.yr, ... d_phi=3 * u.mas/u.yr) >>> dif = cx.vector(dsph) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(obj: SphericalDifferential, /) LonLatSphericalVel
Construct from a astropy.coordinates.SphericalDifferential.
This re-dispatches to
coordinax.vecs.LonLatSphericalVel.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import SphericalDifferential
>>> dsph = SphericalDifferential(d_distance=1 * u.km / u.s, ... d_lon=2 * u.mas/u.yr, ... d_lat=3 * u.mas/u.yr) >>> dif = cx.vector(dsph) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(obj: SphericalCosLatDifferential, /) LonCosLatSphericalVel
Construct from a astropy.coordinates.SphericalCosLatDifferential.
This re-dispatches to
coordinax.vecs.LonCosLatSphericalVel.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import SphericalCosLatDifferential
>>> dsph = SphericalCosLatDifferential(d_distance=1 * u.km / u.s, ... d_lon_coslat=2 * u.mas/u.yr, ... d_lat=3 * u.mas/u.yr) >>> dif = cx.vector(dsph) >>> print(dif) <LonCosLatSphericalVel: (lon_coslat[mas / yr], lat[mas / yr], distance[km / s]) [2. 3. 1.]>
- coordinax.vecs.vector(obj: UnitSphericalDifferential) TwoSphereVel
Construct from a astropy.coordinates.UnitSphericalDifferential.
This re-dispatches to
coordinax.vecs.TwoSphereVel.from_().Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import UnitSphericalDifferential
>>> dsph = UnitSphericalDifferential(d_lon=3 * u.deg/u.s, d_lat=2 * u.deg/u.s) >>> vel = cx.vector(dsph) >>> print(vel) <TwoSphereVel: (theta, phi) [deg / s] [2. 3.]>
- coordinax.vecs.vector(cls: type[CartesianPos3D], obj: BaseRepresentation, /) CartesianPos3D
Construct from a astropy.coordinates.BaseRepresentation.
Examples
>>> import coordinax as cx >>> from astropy.coordinates import CartesianRepresentation
>>> cart = CartesianRepresentation(1, 2, 3, unit="km") >>> vec = cx.CartesianPos3D.from_(cart) >>> print(vec) <CartesianPos3D: (x, y, z) [km] [1. 2. 3.]>
- coordinax.vecs.vector(cls: type[CylindricalPos], obj: BaseRepresentation, /) CylindricalPos
Construct from a astropy.coordinates.BaseRepresentation.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import CylindricalRepresentation
>>> cyl = CylindricalRepresentation(rho=1 * u.km, phi=2 * u.deg, ... z=30 * u.m) >>> vec = cx.vecs.CylindricalPos.from_(cyl) >>> print(vec) <CylindricalPos: (rho[km], phi[deg], z[m]) [ 1. 2. 30.]>
- coordinax.vecs.vector(cls: type[SphericalPos], obj: BaseRepresentation, /) SphericalPos
Construct from a astropy.coordinates.BaseRepresentation.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import PhysicsSphericalRepresentation
>>> sph = PhysicsSphericalRepresentation(r=1 * u.km, theta=2 * u.deg, ... phi=3 * u.deg) >>> vec = cx.SphericalPos.from_(sph) >>> print(vec) <SphericalPos: (r[km], theta[deg], phi[deg]) [1. 2. 3.]>
- coordinax.vecs.vector(cls: type[LonLatSphericalPos], obj: BaseRepresentation, /) LonLatSphericalPos
Construct from a astropy.coordinates.BaseRepresentation.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import SphericalRepresentation
>>> sph = SphericalRepresentation(lon=3 * u.deg, lat=2 * u.deg, ... distance=1 * u.km) >>> vec = cx.vecs.LonLatSphericalPos.from_(sph) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [3. 2. 1.]>
- coordinax.vecs.vector(cls: type[TwoSpherePos], obj: BaseRepresentation, /) TwoSpherePos
Construct from a astropy.coordinates.BaseRepresentation.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import UnitSphericalRepresentation
>>> sph = UnitSphericalRepresentation(lon=3 * u.deg, lat=2 * u.deg) >>> vec = cx.vecs.TwoSpherePos.from_(sph) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(cls: type[CartesianVel3D], obj: CartesianDifferential, /) CartesianVel3D
Construct from a astropy.coordinates.CartesianDifferential.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import CartesianDifferential
>>> dcart = CartesianDifferential(1, 2, 3, unit="km/s") >>> dif = cx.CartesianVel3D.from_(dcart) >>> print(vec) <TwoSpherePos: (theta, phi) [deg] [2. 3.]>
- coordinax.vecs.vector(cls: type[CylindricalVel], obj: CylindricalDifferential, /) CylindricalVel
Construct from a astropy.coordinates.CylindricalVel.
Examples
>>> import astropy.units as u >>> import astropy.coordinates as apyc >>> import coordinax as cx
>>> dcyl = apyc.CylindricalDifferential(d_rho=1 * u.km / u.s, d_phi=2 * u.mas/u.yr, ... d_z=2 * u.km / u.s) >>> vec = cx.vecs.CylindricalVel.from_(dcyl) >>> print(vec) <CylindricalVel: (rho[km / s], phi[mas / yr], z[km / s]) [1. 2. 2.]>
- coordinax.vecs.vector(cls: type[SphericalVel], obj: PhysicsSphericalDifferential, /) SphericalVel
Construct from a astropy.coordinates.PhysicsSphericalDifferential.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import PhysicsSphericalDifferential
>>> dsph = PhysicsSphericalDifferential(d_r=1 * u.km / u.s, d_theta=2 * u.mas/u.yr, ... d_phi=3 * u.mas/u.yr) >>> vec = cx.SphericalVel.from_(dsph) >>> print(vec) <SphericalVel: (r[km / s], theta[mas / yr], phi[mas / yr]) [1. 2. 3.]>
- coordinax.vecs.vector(cls: type[LonLatSphericalVel], obj: SphericalDifferential, /) LonLatSphericalVel
Construct from a astropy.coordinates.SphericalVel.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import SphericalDifferential
>>> dsph = SphericalDifferential(d_distance=1 * u.km / u.s, ... d_lon=2 * u.mas/u.yr, ... d_lat=3 * u.mas/u.yr) >>> vec = cx.vecs.LonLatSphericalVel.from_(dsph) >>> print(vec) <LonLatSphericalVel: (lon[mas / yr], lat[mas / yr], distance[km / s]) [2. 3. 1.]>
- coordinax.vecs.vector(cls: type[LonCosLatSphericalVel], obj: SphericalCosLatDifferential, /) LonCosLatSphericalVel
Construct from a astropy.coordinates.SphericalCosLatDifferential.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import SphericalCosLatDifferential
>>> dsph = SphericalCosLatDifferential(d_distance=1 * u.km / u.s, ... d_lon_coslat=2 * u.mas/u.yr, ... d_lat=3 * u.mas/u.yr) >>> vec = cx.vecs.LonCosLatSphericalVel.from_(dsph) >>> print(vec) <LonCosLatSphericalVel: (lon_coslat[mas / yr], lat[mas / yr], distance[km / s]) [2. 3. 1.]>
- coordinax.vecs.vector(cls: type[TwoSphereVel], obj: UnitSphericalDifferential, /) TwoSphereVel
Construct from a astropy.coordinates.BaseDifferential.
Examples
>>> import astropy.units as u >>> import coordinax as cx >>> from astropy.coordinates import UnitSphericalDifferential
>>> sph = UnitSphericalDifferential(d_lon=3 * u.deg/u.s, d_lat=2 * u.deg/u.s) >>> vec = cx.vecs.TwoSphereVel.from_(sph) >>> print(vec) <TwoSphereVel: (theta, phi) [deg / s] [2. 3.]>
- coordinax.vecs.vector(obj: Quantity, /) AbstractVector
Construct a vector from an Astropy Quantity.
The array is expected to have the components as the last dimension.
Examples
>>> import jax.numpy as jnp >>> from astropy.units import Quantity >>> import coordinax as cx
>>> vec = cx.vector(Quantity([1, 2, 3], "meter")) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1. 2. 3.]>
- coordinax.vecs.vector(cls: type[AbstractVector], obj: Quantity, /) AbstractVector
Construct a vector from an Astropy Quantity array.
The array is expected to have the components as the last dimension.
Examples
>>> import jax.numpy as jnp >>> from astropy.units import Quantity >>> import coordinax as cx
>>> xs = Quantity([1, 2, 3], "meter") >>> vec = cx.CartesianPos3D.from_(xs) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1. 2. 3.]>
>>> xs = Quantity(jnp.array([[1, 2, 3], [4, 5, 6]]), "meter") >>> vec = cx.CartesianPos3D.from_(xs) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [[1. 2. 3.] [4. 5. 6.]]>
>>> vec = cx.CartesianVel3D.from_(Quantity([1, 2, 3], "m/s")) >>> print(vec) <CartesianVel3D: (x, y, z) [m / s] [1. 2. 3.]>
>>> vec = cx.vecs.CartesianAcc3D.from_(Quantity([1, 2, 3], "m/s2")) >>> print(vec) <CartesianAcc3D: (x, y, z) [m / s2] [1. 2. 3.]>
>>> xs = Quantity([0, 1, 2, 3], "meter") # [ct, x, y, z] >>> vec = cx.FourVector.from_(xs) >>> print(vec) <FourVector: (t[m s / km], q=(x, y, z) [m]) [0. 1. 2. 3.]>
>>> xs = Quantity(jnp.array([[0, 1, 2, 3], [10, 4, 5, 6]]), "meter") >>> vec = cx.FourVector.from_(xs) >>> print(vec) <FourVector: (t[m s / km], q=(x, y, z) [m]) [[0.000e+00 1.000e+00 2.000e+00 3.000e+00] [3.336e-05 4.000e+00 5.000e+00 6.000e+00]]>
- coordinax.vecs.vconvert(target: type[Any], /, *args: Any, **kwargs: Any)#
Transform the current vector to the target vector.
See the dispatch implementations for more details. Not all transformations result in the target vector type, for example
vconvert(type[Cartesian3DPos], FourVector)will return a coordinax.vecs.FourVector with the spatial part in Cartesian coordinates. Likewise, coordinax.vconvert on coordinax.Coordinate instances will transform the contained vectors to the target type, returning a coordinax.Coordinate instance.Examples
>>> import jax >>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.vecs as cxv
## 1D:
Array-valued:
>>> params = {"x": jnp.array([1.0, 2.0])} >>> cxv.vconvert(cxv.RadialPos, cxv.CartesianPos1D, params) ({'r': Array([1., 2.], dtype=float32)}, {})
Quantity-valued:
>>> params = {"x": u.Quantity([1.0, 2.0], "m")} >>> cxv.vconvert(cxv.RadialPos, cxv.CartesianPos1D, params) ({'r': Quantity(Array([1., 2.], dtype=float32), unit='m')}, {})
Vector-valued:
>>> x = cxv.CartesianPos1D.from_(1, "km") >>> y = cxv.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [1]>
## 2D:
Array-valued:
Without unit information “phi” is assumed to be in radians.
>>> params = {"r": jnp.array([1.0, 2.0]), "phi": jnp.array(3)} >>> cxv.vconvert(cxv.CartesianPos2D, cxv.PolarPos, params) ({'x': Array([-0.9899925, -1.979985 ], dtype=float32), 'y': Array([0.14112, 0.28224], dtype=float32)}, {})
We can provide that unit information so that “phi” is in degrees:
>>> usys = u.unitsystem("kpc", "deg") >>> cxv.vconvert(cxv.CartesianPos2D, cxv.PolarPos, params, units=usys) ({'x': Array([0.9986295, 1.997259 ], dtype=float32), 'y': Array([0.05233596, 0.10467192], dtype=float32)}, {})
Quantity-valued:
>>> params = {"r": u.Quantity([1.0, 2.0], "m"), "phi": u.Quantity(3, "deg")} >>> cxv.vconvert(cxv.CartesianPos2D, cxv.PolarPos, params) ({'x': Quantity(Array([0.9986295, 1.997259 ], dtype=float32), unit='m'), 'y': Quantity(Array([0.05233596, 0.10467192], dtype=float32), unit='m')}, {})
Vector-valued:
>>> x = cxv.CartesianPos2D.from_([3, 4], "km") >>> y = cxv.vconvert(cxv.PolarPos, x) >>> print(y) <PolarPos: (r[km], phi[rad]) [5. 0.927]>
>>> y = cxv.vconvert(cxv.PolarPos, x, units=u.unitsystem("m", "deg")) >>> print(y) <PolarPos: (r[m], phi[deg]) [5000. 53.13]>
## 3D:
Array-valued:
>>> params = {"x": jnp.array([1.0, 2.0]), "y": jnp.array([3.0, 4.0]), ... "z": jnp.array([5.0, 6.0])} >>> params, aux = cxv.vconvert(cxv.SphericalPos, cxv.CartesianPos3D, params) >>> jax.tree.map(lambda x: jnp.round(x, 4), params) {'phi': Array([1.249 , 1.1071], dtype=float32), 'r': Array([5.9161 , 7.4832997], dtype=float32), 'theta': Array([0.5639, 0.6405], dtype=float32)}
Quantity-valued:
>>> params = {"x": u.Quantity([1.0, 2.0], "m"), ... "y": u.Quantity([3.0, 4.0], "m"), ... "z": u.Quantity([5.0, 6.0], "m")} >>> params, aux = cxv.vconvert(cxv.SphericalPos, cxv.CartesianPos3D, params) >>> jax.tree.map(lambda x: jnp.round(x, 4), params) {'phi': Quantity(Array([1.249 , 1.1071], dtype=float32), unit='rad'), 'r': Quantity(Array([5.9161 , 7.4832997], dtype=float32), unit='m'), 'theta': Quantity(Array([0.5639, 0.6405], dtype=float32), unit='rad')}
Vector-valued:
>>> x = cxv.CartesianPos3D.from_([[1, 3, 5], [2, 4, 6]], "km") >>> y = cxv.vconvert(cxv.SphericalPos, x) >>> print(y) <SphericalPos: (r[km], theta[rad], phi[rad]) [[5.916 0.564 1.249] [7.483 0.641 1.107]]>
- coordinax.vecs.vconvert(target: type[AbstractPos], current: AbstractPos, space: KinematicSpace, /) AbstractPos
Convert a position to the target type, with a KinematicSpace context.
Examples
>>> import coordinax as cx
>>> space = cx.KinematicSpace(length=cx.CartesianPos3D.from_([1, 2, 3], "m"), ... speed=cx.CartesianVel3D.from_([4, 5, 6], "m/s"))
>>> cx.vconvert(cx.SphericalPos, space["length"], space) SphericalPos( ... )
- coordinax.vecs.vconvert(target: type[AbstractVel], current: AbstractVel, space: KinematicSpace, /) AbstractVel
Convert a velocity to the target type, with a KinematicSpace context.
Examples
>>> import coordinax as cx
>>> space = cx.KinematicSpace(length=cx.CartesianPos3D.from_([1, 2, 3], "m"), ... speed=cx.CartesianVel3D.from_([4, 5, 6], "m/s"))
>>> cx.vconvert(cx.SphericalVel, space["speed"], space) SphericalVel( ... )
- coordinax.vecs.vconvert(target: type[AbstractAcc], current: AbstractAcc, space: KinematicSpace, /) AbstractAcc
Convert an acceleration to the target type, with a KinematicSpace context.
Examples
>>> import coordinax as cx
>>> space = cx.KinematicSpace(length=cx.CartesianPos3D.from_([1, 2, 3], "m"), ... speed=cx.CartesianVel3D.from_([4, 5, 6], "m/s"), ... acceleration=cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2"))
>>> cx.vconvert(cx.vecs.SphericalAcc, space["acceleration"], space) SphericalAcc( ... )
- coordinax.vecs.vconvert(target: type[AbstractPos], space: KinematicSpace, /) KinematicSpace
Represent the current vector to the target vector.
- coordinax.vecs.vconvert(to_vector: type[AbstractPos3D], from_vector: type[AbstractPos3D], params: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
AbstractPos -> CartesianPos3D -> AbstractPos.
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[CartesianPos3D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos3D -> CylindricalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> cart = {"x": 1, "y": 2, "z": 3} >>> cxv.vconvert(cxv.CylindricalPos, cxv.CartesianPos3D, cart) ({'phi': Array(1.1071488, dtype=float32, ...), 'rho': Array(2.236068, dtype=float32, ...), 'z': Array(3, dtype=int32, ...)}, {})
>>> cart = {"x": u.Quantity(1, "km"), "y": u.Quantity(2, "km"), ... "z": u.Quantity(3, "km")} >>> cxv.vconvert(cxv.CylindricalPos, cxv.CartesianPos3D, cart) ({'phi': Quantity(Array(1.1071488, dtype=float32, ...), unit='rad'), 'rho': Quantity(Array(2.236068, dtype=float32, ...), unit='km'), 'z': Quantity(Array(3, dtype=int32, ...), unit='km')}, {})
- coordinax.vecs.vconvert(to_vector: type[SphericalPos], from_vector: type[CartesianPos3D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos3D -> SphericalPos.
Examples
>>> import coordinax.vecs as cxv >>> cart = {"x": 1, "y": 2, "z": 3} >>> cxv.vconvert(cxv.SphericalPos, cxv.CartesianPos3D, cart) ({'phi': Array(1.1071488, dtype=float32, ...), 'r': Array(3.7416575, dtype=float32, ...), 'theta': Array(0.64052236, dtype=float32)}, {})
The origin is a special case, where the angles are set to 0 by convention:
>>> cart = {"x": 0, "y": 0, "z": 0} >>> cxv.vconvert(cxv.SphericalPos, cxv.CartesianPos3D, cart) ({'phi': Array(0., dtype=float32, ...), 'r': Array(0., dtype=float32, ...), 'theta': Array(0., dtype=float32)}, {})
- coordinax.vecs.vconvert(to_vector: type[AbstractSphericalPos], from_vector: type[CartesianPos3D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos3D -> AbstractSphericalPos.
Examples
>>> import coordinax.vecs as cxv >>> params = {"x": 1, "y": 2, "z": 3} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.LonLatSphericalPos, cxv.CartesianPos3D, ... params, units=usys) ({'distance': Array(3.7416575, dtype=float32, ...), 'lat': Array(53.300774, dtype=float32), 'lon': Array(63.43495, dtype=float32, ...)}, {})
>>> cxv.vconvert(cxv.MathSphericalPos, cxv.CartesianPos3D, ... params, units=usys) ({'phi': Array(36.69923, dtype=float32), 'r': Array(3.7416575, dtype=float32, ...), 'theta': Array(63.43495, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> CartesianPos3D.
Examples
>>> import coordinax.vecs as cxv >>> cyl = {"rho": 1, "phi": 90, "z": 1} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CartesianPos3D, cxv.CylindricalPos, cyl, units=usys) ({'x': Array(-4.371139e-08, dtype=float32, ...), 'y': Array(1., dtype=float32, ...), 'z': Array(1, dtype=int32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[SphericalPos], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> SphericalPos.
Examples
>>> import coordinax.vecs as cxv >>> cyl = {"rho": 1, "phi": 90, "z": 1} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.SphericalPos, cxv.CylindricalPos, cyl, units=usys) ({'phi': Array(90., dtype=float32, ...), 'r': Array(1.4142135, dtype=float32, ...), 'theta': Array(45..., dtype=float32)}, {})
The origin is a special case, where the angles are set to 0 by convention:
>>> cyl = {"rho": 0, "phi": 0, "z": 0} >>> cxv.vconvert(cxv.SphericalPos, cxv.CylindricalPos, cyl, units=usys) ({'phi': Array(0., dtype=float32, ...), 'r': Array(0., dtype=float32, ...), 'theta': Array(0., dtype=float32)}, {})
- coordinax.vecs.vconvert(to_vector: type[AbstractSphericalPos], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> AbstractSphericalPos.
Examples
>>> import coordinax.vecs as cxv >>> cyl = {"rho": 1, "phi": 90, "z": 1} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.LonLatSphericalPos, cxv.CylindricalPos, cyl, units=usys) ({'distance': Array(1.4142135, dtype=float32, ...), 'lat': Array(45., dtype=float32), 'lon': Array(90., dtype=float32, ...)}, {})
>>> cxv.vconvert(cxv.MathSphericalPos, cxv.CylindricalPos, cyl, units=usys) ({'phi': Array(45..., dtype=float32), 'r': Array(1.4142135, dtype=float32, ...), 'theta': Array(90., dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[SphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> CartesianPos3D.
Examples
>>> import coordinax.vecs as cxv >>> sph = {"r": 1, "theta": 90, "phi": 90} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CartesianPos3D, cxv.SphericalPos, sph, units=usys) ({'x': Array(-4.371139e-08, dtype=float32, ...), 'y': Array(1., dtype=float32, ...), 'z': Array(-4.371139e-08, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[SphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalPos -> CylindricalPos.
Examples
>>> import coordinax.vecs as cxv >>> sph = {"r": 1, "theta": 90, "phi": 90} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CylindricalPos, cxv.SphericalPos, sph, units=usys) ({'phi': Array(90., dtype=float32, ...), 'rho': Array(1., dtype=float32, ...), 'z': Array(-4.371139e-08, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[LonLatSphericalPos], from_vector: type[SphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalPos -> LonLatSphericalPos.
Examples
>>> import coordinax.vecs as cxv >>> sph = {"r": 1, "theta": 90, "phi": 90} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.LonLatSphericalPos, cxv.SphericalPos, sph, units=usys) ({'distance': Array(1, dtype=int32, ...), 'lat': Array(3.2016512e-06, dtype=float32, ...), 'lon': Array(90., dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[AbstractVector], from_vector: type[AbstractVector], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalVel/Acc -> LonLatSphericalVel/Acc.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> p = {"r": u.Quantity(1, "km/s"), ... "theta": u.Quantity(10, "deg/s"), ... "phi": u.Quantity(20, "deg/s")}
>>> cxv.vconvert(cxv.LonLatSphericalVel, cxv.SphericalVel, p) ({'distance': Quantity(Array(1, dtype=int32, ...), unit='km / s'), 'lat': Quantity(Array(-10, dtype=int32, ...), unit='deg / s'), 'lon': Quantity(Array(20, dtype=int32, ...), unit='deg / s')}, {})
>>> x = cxv.SphericalVel(**p) >>> y = cxv.vconvert(cxv.LonLatSphericalVel, x) >>> print(y) <LonLatSphericalVel: (lon[deg / s], lat[deg / s], distance[km / s]) [ 20 -10 1]>
>>> p = {"r": u.Quantity(1, "km/s2"), ... "theta": u.Quantity(10, "deg/s2"), ... "phi": u.Quantity(20, "deg/s2")}
>>> cxv.vconvert(cxv.LonLatSphericalAcc, cxv.SphericalAcc, p) ({'distance': Quantity(Array(1, dtype=int32, ...), unit='km / s2'), 'lat': Quantity(Array(-10, dtype=int32, ...), unit='deg / s2'), 'lon': Quantity(Array(20, dtype=int32, ...), unit='deg / s2')}, {})
>>> x = cxv.SphericalAcc(**p) >>> y = cxv.vconvert(cxv.LonLatSphericalAcc, x) >>> print(y) <LonLatSphericalAcc: (lon[deg / s2], lat[deg / s2], distance[km / s2]) [ 20 -10 1]>
- coordinax.vecs.vconvert(to_vector: type[AbstractVector], from_vector: type[AbstractVector], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalPos <-> MathSphericalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Position:
>>> p = {"r": 1, "theta": 90, "phi": 90} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.MathSphericalPos, cxv.SphericalPos, p, units=usys) ({'phi': Array(90., dtype=float32, ...), 'r': Array(1, dtype=int32, ...), 'theta': Array(90., dtype=float32, ...)}, {})
>>> cxv.vconvert(cxv.SphericalPos, cxv.MathSphericalPos, p, units=usys) ({'phi': Array(90., dtype=float32, ...), 'r': Array(1, dtype=int32, ...), 'theta': Array(90., dtype=float32, ...)}, {})
Velocity:
>>> p = {"r": u.Quantity(1, "km/s"), ... "theta": u.Quantity(10, "deg/s"), ... "phi": u.Quantity(20, "deg/s")}
>>> p, aux = cxv.vconvert(cxv.MathSphericalVel, cxv.SphericalVel, p) >>> p, aux ({'phi': Quantity(Array(10, dtype=int32, ...), unit='deg / s'), 'r': Quantity(Array(1, dtype=int32, ...), unit='km / s'), 'theta': Quantity(Array(20, dtype=int32, ...), unit='deg / s')}, {})
>>> cxv.vconvert(cxv.SphericalVel, cxv.MathSphericalVel, p) ({'phi': Quantity(Array(20, dtype=int32, ...), unit='deg / s'), 'r': Quantity(Array(1, dtype=int32, ...), unit='km / s'), 'theta': Quantity(Array(10, dtype=int32, ...), unit='deg / s')}, {})
>>> x = cxv.SphericalVel(r=u.Quantity(1, "km/s"), ... theta=u.Quantity(10, "deg/s"), ... phi=u.Quantity(20, "deg/s")) >>> y = cxv.vconvert(cxv.MathSphericalVel, x) >>> print(y) <MathSphericalVel: (r[km / s], theta[deg / s], phi[deg / s]) [ 1 20 10]>
>>> x = cxv.vconvert(cxv.SphericalVel, y) >>> print(x) <SphericalVel: (r[km / s], theta[deg / s], phi[deg / s]) [ 1 10 20]>
Acceleration:
>>> p = {"r": u.Quantity(1, "km/s2"), ... "theta": u.Quantity(10, "deg/s2"), ... "phi": u.Quantity(20, "deg/s2")}
>>> p, aux = cxv.vconvert(cxv.MathSphericalAcc, cxv.SphericalAcc, p) >>> p, aux ({'phi': Quantity(Array(10, dtype=int32, ...), unit='deg / s2'), 'r': Quantity(Array(1, dtype=int32, ...), unit='km / s2'), 'theta': Quantity(Array(20, dtype=int32, ...), unit='deg / s2')}, {})
>>> cxv.vconvert(cxv.SphericalAcc, cxv.MathSphericalAcc, p) ({'phi': Quantity(Array(20, dtype=int32, ...), unit='deg / s2'), 'r': Quantity(Array(1, dtype=int32, ...), unit='km / s2'), 'theta': Quantity(Array(10, dtype=int32, ...), unit='deg / s2')}, {})
>>> x = cxv.SphericalAcc(r=u.Quantity(1, "km/s2"), ... theta=u.Quantity(10, "deg/s2"), ... phi=u.Quantity(20, "deg/s2")) >>> y = cxv.vconvert(cxv.MathSphericalAcc, x) >>> print(y) <MathSphericalAcc: (r[km / s2], theta[deg / s2], phi[deg / s2]) [ 1 20 10]>
>>> x = cxv.vconvert(cxv.SphericalAcc, y) >>> print(x) <SphericalAcc: (r[km / s2], theta[deg / s2], phi[deg / s2]) [ 1 10 20]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[LonLatSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
LonLatSphericalPos -> CartesianPos3D.
Examples
>>> import coordinax.vecs as cxv >>> vec = {"lon": 90, "lat": 0, "distance": 1} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CartesianPos3D, cxv.LonLatSphericalPos, vec, units=usys) ({'x': Array(-4.371139e-08, dtype=float32, ...), 'y': Array(1., dtype=float32, ...), 'z': Array(-4.371139e-08, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[LonLatSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
LonLatSphericalPos -> CylindricalPos.
Examples
>>> import coordinax.vecs as cxv >>> sph = {"lon": 90, "lat": 0, "distance": 1} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CylindricalPos, cxv.LonLatSphericalPos, sph, units=usys) ({'phi': Array(90., dtype=float32, ...), 'rho': Array(1., dtype=float32, ...), 'z': Array(-4.371139e-08, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[SphericalPos], from_vector: type[LonLatSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
LonLatSphericalPos -> SphericalPos.
Examples
>>> import coordinax.vecs as cxv >>> vec = {"lon": 90, "lat": 0, "distance": 1} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.SphericalPos, cxv.LonLatSphericalPos, vec, units=usys) ({'phi': Array(90., dtype=float32, ..., 'r': Array(1, dtype=int32, ..., 'theta': Array(90., dtype=float32, ...}, {})
- coordinax.vecs.vconvert(to_vector: type[AbstractVector], from_vector: type[AbstractVector], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
LonLatSphericalVel -> SphericalVel.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> p = {"lon": u.Quantity(90, "deg/s"), ... "lat": u.Quantity(0, "deg/s"), ... "distance": u.Quantity(1, "km/s")} >>> cxv.vconvert(cxv.SphericalVel, cxv.LonLatSphericalVel, p) ({'r': Quantity(Array(1, dtype=int32, ...), unit='km / s'), 'theta': Quantity(Array(0, dtype=int32, ...), unit='deg / s'), 'phi': Quantity(Array(90, dtype=int32, ...), unit='deg / s')}, {})
>>> x = cxv.LonLatSphericalVel(**p) >>> y = cxv.vconvert(cxv.SphericalVel, x) >>> print(y) <SphericalVel: (r[km / s], theta[deg / s], phi[deg / s]) [ 1 0 90]>
>>> p = {"lon": u.Quantity(90, "deg/s2"), ... "lat": u.Quantity(0, "deg/s2"), ... "distance": u.Quantity(1, "km/s2")} >>> cxv.vconvert(cxv.SphericalAcc, cxv.LonLatSphericalAcc, p) ({'r': Quantity(Array(1, dtype=int32, ...), unit='km / s2'), 'theta': Quantity(Array(0, dtype=int32, ...), unit='deg / s2'), 'phi': Quantity(Array(90, dtype=int32, ...), unit='deg / s2')}, {})
>>> x = cxv.LonLatSphericalAcc(**p) >>> y = cxv.vconvert(cxv.SphericalAcc, x) >>> print(y) <SphericalAcc: (r[km / s2], theta[deg / s2], phi[deg / s2]) [ 1 0 90]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[MathSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
MathSphericalPos -> CartesianPos3D.
Examples
>>> import coordinax.vecs as cxv >>> vec = {"r": 1, "theta": 90, "phi": 90} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CartesianPos3D, cxv.MathSphericalPos, vec, units=usys) ({'x': Array(-4.371139e-08, dtype=float32, ...), 'y': Array(1., dtype=float32, ...), 'z': Array(-4.371139e-08, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[MathSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
MathSphericalPos -> CylindricalPos.
Examples
>>> import coordinax.vecs as cxv >>> vec = {"r": 1, "theta": 90, "phi": 90} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CylindricalPos, cxv.MathSphericalPos, vec, units=usys) ({'phi': Array(90., dtype=float32, ...), 'rho': Array(1., dtype=float32, ...), 'z': Array(-4.371139e-08, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[ProlateSpheroidalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
ProlateSpheroidalPos -> CylindricalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv >>> vec = {"mu": 1, "nu": 0.2, "phi": 90} >>> in_aux = {"Delta": 0.5} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CylindricalPos, cxv.ProlateSpheroidalPos, ... vec, in_aux=in_aux, units=usys) ({'phi': Array(90., dtype=float32, ...), 'rho': Array(0.38729832, dtype=float32, ...), 'z': Array(0.8944272, dtype=float32, ...)}, {})
TODO: example with Delta as a Quantity
- coordinax.vecs.vconvert(to_vector: type[ProlateSpheroidalPos], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> ProlateSpheroidalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> vec = {"rho": 1, "phi": 90, "z": 1} >>> out_aux = {"Delta": 0.5} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.ProlateSpheroidalPos, cxv.CylindricalPos, ... vec, out_aux=out_aux, units=usys) ({'mu': Array(2.1327822, dtype=float32, ...), 'nu': Array(0.11721778, dtype=float32, ...), 'phi': Array(90., dtype=float32, ...)}, {'Delta': Array(0.5, dtype=float32, ...)})
# <ProlateSpheroidalPos: (mu[km2], nu[km2], phi[deg]) # [ 2.133 0.117 90. ]>
TODO: example with Delta as a Quantity
- coordinax.vecs.vconvert(to_vector: type[ProlateSpheroidalPos], from_vector: type[ProlateSpheroidalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any], out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
ProlateSpheroidalPos -> ProlateSpheroidalPos.
Examples
>>> import coordinax.vecs as cxv >>> vec = {"mu": 1, "nu": 0.2, "phi": 90} >>> in_aux = {"Delta": 0.5} >>> usys = u.unitsystem("km", "deg")
Self-transforms can change the focal length:
>>> out_aux = {"Delta": 0.8} >>> cxv.vconvert(cxv.ProlateSpheroidalPos, cxv.ProlateSpheroidalPos, ... vec, in_aux=in_aux, out_aux=out_aux, units=usys) ({'mu': Array(1.1414464, dtype=float32, ...), 'nu': Array(0.44855377, dtype=float32, ...), 'phi': Array(90., dtype=float32, ...)}, {'Delta': Array(0.8, dtype=float32, ...)})
Without changing the focal length, no transform is done:
>>> cxv.vconvert(cxv.ProlateSpheroidalPos, cxv.ProlateSpheroidalPos, ... vec, in_aux=in_aux, units=usys) ({'mu': Array(1, dtype=int32, ...), 'nu': Array(0.2, dtype=float32, ...), 'phi': Array(90, dtype=int32, ...)}, {'Delta': Array(0.5, dtype=float32, ...)})
- coordinax.vecs.vconvert(to_vector: type[ProlateSpheroidalPos], from_vector: type[AbstractPos3D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any], units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
AbstractPos3D -> ProlateSpheroidalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> vec = {"x": 1, "y": 2, "z": 3} >>> out_aux = {"Delta": 0.5} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.ProlateSpheroidalPos, cxv.CartesianPos3D, ... vec, out_aux=out_aux, units=usys) ({'mu': Array(14.090316, dtype=float32, ...), 'nu': Array(0.15968415, dtype=float32, ...), 'phi': Array(63.43495, dtype=float32, ...)}, {'Delta': Array(0.5, dtype=float32, ...)})
- coordinax.vecs.vconvert(target: type[LonCosLatSphericalVel], current: AbstractVel3D, position: AbstractPos, /, **kwargs: Any) LonCosLatSphericalVel
AbstractVel3D -> LonCosLatSphericalVel.
Examples
>>> import quaxed.numpy as jnp >>> import unxt as u >>> import coordinax.vecs as cxv
>>> q = cxv.LonLatSphericalPos(lon=u.Quantity(15, "deg"), ... lat=u.Quantity(10, "deg"), ... distance=u.Quantity(1.5, "km")) >>> p = cxv.LonLatSphericalVel(lon=u.Quantity(7, "mas/yr"), ... lat=u.Quantity(0, "deg/Gyr"), ... distance=u.Quantity(-5, "km/s")) >>> newp = cxv.vconvert(cxv.LonCosLatSphericalVel, p, q) >>> print(newp) <LonCosLatSphericalVel: (lon_coslat[mas / yr], lat[deg / Gyr], distance[km / s]) [ 6.894 0. -5. ]>
- coordinax.vecs.vconvert(target: type[LonLatSphericalVel], current: LonCosLatSphericalVel, position: AbstractPos, /, **kwargs: Any) LonLatSphericalVel
LonCosLatSphericalVel -> LonLatSphericalVel.
- coordinax.vecs.vconvert(target: type[AbstractVel3D], current: LonCosLatSphericalVel, position: AbstractPos, /, **kwargs: Any) AbstractVel3D
LonCosLatSphericalVel -> AbstractVel3D.
- coordinax.vecs.vconvert(target: type[KinematicSpace], w: KinematicSpace, /) KinematicSpace
Space -> KinematicSpace.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> cx.vconvert(cx.KinematicSpace, w) KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- coordinax.vecs.vconvert(target: type[PoincarePolarVector], w: KinematicSpace, /) PoincarePolarVector
Space -> PoincarePolarVector.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> cx.vconvert(cx.vecs.PoincarePolarVector, w) PoincarePolarVector( rho=Quantity([[2.23606801, 6.40312433]], unit='m'), pp_phi=Quantity([[0., 0.]], unit='m / s(1/2)'), z=Quantity([[3, 6]], unit='m'), dt_rho=Quantity([[2.23606801, 6.40312433]], unit='m / s'), dt_pp_phi=Quantity([[0., 0.]], unit='m / s(1/2)'), dt_z=Quantity([[3, 6]], unit='m / s') )
- coordinax.vecs.vconvert(to_vector: type[CartesianPos1D], from_vector: type[RadialPos], params: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> CartesianPos1D.
The r coordinate is converted to the x coordinate of the 1D system.
- coordinax.vecs.vconvert(to_vector: type[RadialPos], from_vector: type[CartesianPos1D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos1D -> RadialPos.
The x coordinate is converted to the r coordinate of the 1D system.
- coordinax.vecs.vconvert(to_vector: type[AbstractPos2D], from_vector: type[AbstractPos2D], params: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
AbstractPos -> CartesianPos1D -> AbstractPos.
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[CartesianPos2D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any] | None]
CartesianPos2D -> PolarPos.
The x and y coordinates are converted to the radial coordinate r and the angular coordinate phi.
- coordinax.vecs.vconvert(to_vector: type[CartesianPos2D], from_vector: type[PolarPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any] | None]
PolarPos -> CartesianPos2D.
The r and phi coordinates are converted to the x and y coordinates.
- coordinax.vecs.vconvert(spatial_target: type[AbstractPos3D], current: FourVector, /, **kwargs: Any) FourVector
Convert the spatial part of a 4-vector to a different 3-vector.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> w = cx.FourVector (t=u.Quantity(1, "s"), q=u.Quantity([1, 2, 3], "m")) >>> print(cx.vconvert(cx.vecs.CylindricalPos, w)) <FourVector: (t[s], q=(rho[m], phi[rad], z[m])) [1. 2.236 1.107 3. ]>
- coordinax.vecs.vconvert(target: type[AbstractVector], current: AbstractVector, /, units: AbstractUnitSystem | None = None, **out_aux: Any) AbstractVector
AbstractPos -> vconvert_impl -> AbstractPos.
This is the base case for the transformation of position vectors.
- coordinax.vecs.vconvert(to_vector: type[AbstractVector], from_vector: type[AbstractVector], current: AbstractVector, /, **out_aux: Any) AbstractVector
Convert from one position vector to another.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos2D.from_([3, 4], "km") >>> y = cxv.vconvert(cxv.PolarPos, cxv.CartesianPos2D, x) >>> print(y) <PolarPos: (r[km], phi[rad]) [5. 0.927]>
- coordinax.vecs.vconvert(to_vector: type[AbstractVector], from_vector: type[AbstractVector], params: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
Self transform.
Examples
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.vecs as cxv
## 1D:
>>> params = {"x": 1} >>> cxv.vconvert(cxv.CartesianPos1D, cxv.CartesianPos1D, params) ({'x': 1}, {})
>>> params = {"r": 1} >>> cxv.vconvert(cxv.RadialPos, cxv.RadialPos, params) ({'r': 1}, {})
## 2D:
>>> params = {"x": 1, "y": 2} >>> cxv.vconvert(cxv.CartesianPos2D, cxv.CartesianPos2D, params) ({'x': 1, 'y': 2}, {})
>>> params = {"r": 1, "phi": 10} >>> cxv.vconvert(cxv.PolarPos, cxv.PolarPos, params) ({'r': 1, 'phi': 10}, {})
>>> params = {"theta": 10, "phi": 14} >>> cxv.vconvert(cxv.TwoSpherePos, cxv.TwoSpherePos, params) ({'theta': 10, 'phi': 14}, {})
## 3D:
>>> params = {"x": 1, "y": 2, "z": 3} >>> cxv.vconvert(cxv.CartesianPos3D, cxv.CartesianPos3D, params) ({'x': 1, 'y': 2, 'z': 3}, {})
>>> params = {"rho": 1, "phi": 2, "z": 3} >>> cxv.vconvert(cxv.CylindricalPos, cxv.CylindricalPos, params) ({'rho': 1, 'phi': 2, 'z': 3}, {})
>>> params = {"r": 1, "theta": 2, "phi": 3} >>> cxv.vconvert(cxv.SphericalPos, cxv.SphericalPos, params) ({'r': 1, 'theta': 2, 'phi': 3}, {})
>>> params = {"lon": 1, "lat": 2, "distance": 3} >>> cxv.vconvert(cxv.LonLatSphericalPos, cxv.LonLatSphericalPos, params) ({'lon': 1, 'lat': 2, 'distance': 3}, {})
>>> params = {"r": 1, "theta": 2, "phi": 3} >>> cxv.vconvert(cxv.MathSphericalPos, cxv.MathSphericalPos, params) ({'r': 1, 'theta': 2, 'phi': 3}, {})
>>> params = {"rho": 1, "pp_phi": 2, "z": 3, "dt_rho": 4, "dt_pp_phi": 5, "dt_z": 6} >>> cxv.vconvert(cxv.PoincarePolarVector, cxv.PoincarePolarVector, params) ({'rho': 1, 'pp_phi': 2, 'z': 3, 'dt_rho': 4, 'dt_pp_phi': 5, 'dt_z': 6}, {})
>>> params = {"q": jnp.array([1, 2, 3, 4])} >>> cxv.vconvert(cxv.CartesianPosND, cxv.CartesianPosND, params) ({'q': Array([1, 2, 3, 4], dtype=int32)}, {})
- coordinax.vecs.vconvert(target: type[AbstractVector], current: AbstractVector, /, *args: Any, **kw: Any) AbstractVector
Self transforms.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
## 1D:
>>> q = cxv.CartesianPos1D.from_(1, "m") >>> cxv.vconvert(cxv.CartesianPos1D, q) is q True
>>> q = cxv.RadialPos.from_(1, "m") >>> cxv.vconvert(cxv.RadialPos, q) is q True
>>> p = cxv.CartesianVel1D.from_(1, "m/s") >>> cxv.vconvert(cxv.CartesianVel1D, p) is p True >>> cxv.vconvert(cxv.CartesianVel1D, p, q) is p True
>>> p = cxv.RadialVel.from_(1, "m/s") >>> cxv.vconvert(cxv.RadialVel, p) is p True >>> cxv.vconvert(cxv.RadialVel, p, q) is p True
>>> a = cxv.CartesianAcc1D.from_(1, "m/s2") >>> cxv.vconvert(cxv.CartesianAcc1D, a) is a True >>> cxv.vconvert(cxv.CartesianAcc1D, a, p, q) is a True
>>> a = cxv.RadialAcc.from_(1, "m/s2") >>> cxv.vconvert(cxv.RadialAcc, a) is a True >>> cxv.vconvert(cxv.RadialAcc, a, p, q) is a True
## 2D:
>>> q = cxv.CartesianPos2D.from_([1, 2], "m") >>> cxv.vconvert(cxv.CartesianPos2D, q) is q True
>>> q = cxv.PolarPos(r=u.Quantity(1, "m"), phi=u.Quantity(10, "deg")) >>> cxv.vconvert(cxv.PolarPos, q) is q True
>>> q = cxv.TwoSpherePos(theta=u.Quantity(10, "deg"), phi=u.Quantity(14, "deg")) >>> cxv.vconvert(cxv.TwoSpherePos, q) is q True
>>> p = cxv.CartesianVel2D.from_([1, 2], "m/s") >>> cxv.vconvert(cxv.CartesianVel2D, p) is p True
>>> p = cxv.PolarVel(r=u.Quantity(1, "m/s"), phi=u.Quantity(10, "deg/s")) >>> cxv.vconvert(cxv.PolarVel, p) is p True
>>> a = cxv.CartesianAcc2D.from_([1, 2], "m/s2") >>> cxv.vconvert(cxv.CartesianAcc2D, a) is a True
## 3D:
Cartesian to Cartesian:
>>> vec = cxv.CartesianPos3D.from_([1, 2, 3], "km") >>> cxv.vconvert(cxv.CartesianPos3D, vec) is vec True
Cylindrical to Cylindrical:
>>> vec = cxv.CylindricalPos(rho=u.Quantity(1, "km"), ... phi=u.Quantity(2, "deg"), ... z=u.Quantity(3, "km")) >>> cxv.vconvert(cxv.CylindricalPos, vec) is vec True
Spherical to Spherical:
>>> vec = cxv.SphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(2, "deg"), ... phi=u.Quantity(3, "deg")) >>> cxv.vconvert(cxv.SphericalPos, vec) is vec True
LonLatSpherical to LonLatSpherical:
>>> vec = cxv.LonLatSphericalPos(lon=u.Quantity(1, "deg"), ... lat=u.Quantity(2, "deg"), ... distance=u.Quantity(3, "km")) >>> cxv.vconvert(cxv.LonLatSphericalPos, vec) is vec True
MathSpherical to MathSpherical:
>>> vec = cxv.MathSphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(2, "deg"), ... phi=u.Quantity(3, "deg")) >>> cxv.vconvert(cxv.MathSphericalPos, vec) is vec True
For these transformations the position does not matter since the self-transform returns the velocity unchanged.
>>> vec = cxv.CartesianPos3D.from_([1, 2, 3], "km")
Cartesian to Cartesian velocity:
>>> dif = cxv.CartesianVel3D.from_([1, 2, 3], "km/s") >>> cxv.vconvert(cxv.CartesianVel3D, dif, vec) is dif True
Cylindrical to Cylindrical velocity:
>>> dif = cxv.CylindricalVel(rho=u.Quantity(1, "km/s"), ... phi=u.Quantity(2, "mas/yr"), ... z=u.Quantity(3, "km/s")) >>> cxv.vconvert(cxv.CylindricalVel, dif, vec) is dif True
Spherical to Spherical velocity:
>>> dif = cxv.SphericalVel(r=u.Quantity(1, "km/s"), ... theta=u.Quantity(2, "mas/yr"), ... phi=u.Quantity(3, "mas/yr")) >>> cxv.vconvert(cxv.SphericalVel, dif, vec) is dif True
LonLatSpherical to LonLatSpherical velocity:
>>> dif = cxv.LonLatSphericalVel(lon=u.Quantity(1, "mas/yr"), ... lat=u.Quantity(2, "mas/yr"), ... distance=u.Quantity(3, "km/s")) >>> cxv.vconvert(cxv.LonLatSphericalVel, dif, vec) is dif True
LonCosLatSpherical to LonCosLatSpherical velocity:
>>> dif = cxv.LonCosLatSphericalVel(lon_coslat=u.Quantity(1, "mas/yr"), ... lat=u.Quantity(2, "mas/yr"), ... distance=u.Quantity(3, "km/s")) >>> cxv.vconvert(cxv.LonCosLatSphericalVel, dif, vec) is dif True
MathSpherical to MathSpherical velocity:
>>> dif = cxv.MathSphericalVel(r=u.Quantity(1, "km/s"), ... theta=u.Quantity(2, "mas/yr"), ... phi=u.Quantity(3, "mas/yr")) >>> cxv.vconvert(cxv.MathSphericalVel, dif, vec) is dif True
Similarly for the these accelerations:
>>> a = cxv.CartesianAcc3D.from_([1, 1, 1], "m/s2") >>> cxv.vconvert(cxv.CartesianAcc3D, a) is a True
## N-D:
>>> x = cxv.CartesianPosND.from_([1, 2, 3, 4], "km") >>> cxv.vconvert(cxv.CartesianPosND, x) is x True
>>> v = cxv.CartesianVelND.from_([1, 2, 3, 4], "km/s") >>> cxv.vconvert(cxv.CartesianVelND, v, x) is v True >>> cxv.vconvert(cxv.CartesianVelND, v) is v True
>>> a = cxv.CartesianAccND.from_([1, 2, 3, 4], "m/s2") >>> cxv.vconvert(cxv.CartesianAccND, a, v, x) is a True >>> cxv.vconvert(cxv.CartesianAccND, a) is a True
- coordinax.vecs.vconvert(to_vector: type[AbstractPos], from_vector: type[AbstractPos], params: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
AbstractPos -> CartesianPos1D -> AbstractPos.
- coordinax.vecs.vconvert(to_vector: type[AbstractPos], from_vector: type[AbstractPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos2D -> CartesianPos1D.
The y and z coordinates are dropped.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
## 2D:
>>> params = {"x": 1, "y": 2}
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos1D, cxv.CartesianPos2D, params) ({'x': 1}, {})
>>> x = cxv.CartesianPos2D.from_([1, 2], "km") >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.CartesianPos1D, x) >>> print(y) <CartesianPos1D: (x) [km] [1]>
>>> x = cxv.PolarPos(r=u.Quantity(1, "km"), phi=u.Quantity(10, "deg"))
>>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [1]>
## 3D:
>>> params = {"x": 1, "y": 2, "z": 3}
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos1D, cxv.CartesianPos3D, params) ({'x': 1}, {})
>>> x = cxv.CartesianPos3D.from_([1.0, 2.0, 3.0], "km") >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.CartesianPos1D, x) >>> print(y) <CartesianPos1D: (x) [km] [1.]>
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos2D, cxv.CartesianPos3D, params) ({'x': 1, 'y': 2}, {})
>>> x = cxv.CartesianPos3D.from_([1.0, 2.0, 3.0], "km")
>>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.CartesianPos2D, x) >>> print(y) <CartesianPos2D: (x, y) [km] [1. 2.]>
>>> params = {"r": 1, "theta": 14, "phi": 10} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.RadialPos, cxv.SphericalPos, ... params, units=usys) ({'r': Array(1, dtype=int32, ...)}, {})
>>> x = cxv.SphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(14, "deg"), ... phi=u.Quantity(10, "deg")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [1]>
>>> params = {"r": 1, "theta": 10, "phi": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.RadialPos, cxv.MathSphericalPos, ... params, units=usys) ({'r': Array(1, dtype=int32, ...)}, {})
>>> x = cxv.MathSphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(10, "deg"), ... phi=u.Quantity(14, "deg"))
>>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [1]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos2D], from_vector: type[CartesianPos1D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos1D -> CartesianPos2D.
The x coordinate is converted to the x coordinate of the 2D system. The y coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos1D(x=u.Quantity(1.0, "km")) >>> x2 = cxv.vconvert(cxv.CartesianPos2D, x) >>> print(x2) <CartesianPos2D: (x, y) [km] [1. 0.]>
>>> x3 = cxv.vconvert(cxv.CartesianPos3D, x, y=u.Quantity(14, "km")) >>> print(x3) <CartesianPos3D: (x, y, z) [km] [ 1. 14. 0.]>
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[CartesianPos1D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos1D -> PolarPos.
The x coordinate is converted to the radial coordinate r. The phi coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos1D(x=u.Quantity(1.0, "km")) >>> x2 = cxv.vconvert(cxv.PolarPos, x) >>> print(x2) <PolarPos: (r[km], phi[rad]) [1. 0.]>
>>> x3 = cxv.vconvert(cxv.PolarPos, x, phi=u.Quantity(14, "deg")) >>> print(x3) <PolarPos: (r[km], phi[deg]) [ 1. 14.]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[CartesianPos1D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos1D -> CartesianPos3D.
The x coordinate is converted to the x coordinate of the 3D system. The y and z coordinates are keyword arguments and default to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos1D(x=u.Quantity(1, "km")) >>> x2 = cxv.vconvert(cxv.CartesianPos3D, x) >>> print(x2) <CartesianPos3D: (x, y, z) [km] [1 0 0]>
>>> x3 = cxv.vconvert(cxv.CartesianPos3D, x, y=u.Quantity(14, "km")) >>> print(x3) <CartesianPos3D: (x, y, z) [km] [ 1 14 0]>
- coordinax.vecs.vconvert(to_vector: type[AbstractPos3D], from_vector: type[CartesianPos1D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos1D -> SphericalPos | MathSphericalPos.
The x coordinate is converted to the radial coordinate r. The theta and phi coordinates are keyword arguments and default to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
SphericalPos:
>>> x = cxv.CartesianPos1D(x=u.Quantity(1, "km")) >>> x2 = cxv.vconvert(cxv.SphericalPos, x) >>> print(x2) <SphericalPos: (r[km], theta[rad], phi[rad]) [1. 0. 0.]>
>>> x3 = cxv.vconvert(cxv.SphericalPos, x, phi=u.Quantity(14, "deg")) >>> print(x3) <SphericalPos: (r[km], theta[rad], phi[deg]) [ 1 0 14]>
MathSphericalPos: Note that
thetaandphihave different meanings in this context.>>> x2 = cxv.vconvert(cxv.MathSphericalPos, x) >>> print(x2) <MathSphericalPos: (r[km], theta[rad], phi[rad]) [1. 0. 0.]>
>>> x3 = cxv.vconvert(cxv.MathSphericalPos, x, phi=u.Quantity(14, "deg")) >>> print(x3) <MathSphericalPos: (r[km], theta[rad], phi[deg]) [ 1. 0. 14.]>
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[CartesianPos1D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> CartesianPos2D.
The x coordinate is converted to the radial coordinate rho. The phi and z coordinates are keyword arguments and default to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos1D(x=u.Quantity(1, "km")) >>> x2 = cxv.vconvert(cxv.CylindricalPos, x) >>> print(x2) <CylindricalPos: (rho[km], phi[rad], z[km]) [1. 0. 0.]>
>>> x3 = cxv.vconvert(cxv.CylindricalPos, x, phi=u.Quantity(14, "deg")) >>> print(x3) <CylindricalPos: (rho[km], phi[deg], z[km]) [ 1 14 0]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos2D], from_vector: type[RadialPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> CartesianPos2D.
The r coordinate is converted to the cartesian coordinate x. The y coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.RadialPos(r=u.Quantity(1, "km")) >>> x2 = cxv.vconvert(cxv.CartesianPos2D, x) >>> print(x2) <CartesianPos2D: (x, y) [km] [1 0]>
>>> x3 = cxv.vconvert(cxv.CartesianPos2D, x, y=u.Quantity(14, "km")) >>> print(x3) <CartesianPos2D: (x, y) [km] [ 1 14]>
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[RadialPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> PolarPos.
The r coordinate is converted to the radial coordinate r. The phi coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.RadialPos(r=u.Quantity(1, "km")) >>> x2 = cxv.vconvert(cxv.PolarPos, x) >>> print(x2) <PolarPos: (r[km], phi[rad]) [1. 0.]>
>>> x3 = cxv.vconvert(cxv.PolarPos, x, phi=u.Quantity(14, "deg")) >>> print(x3) <PolarPos: (r[km], phi[deg]) [ 1 14]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[RadialPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> CartesianPos3D.
The r coordinate is converted to the x coordinate of the 3D system. The y and z coordinates are keyword arguments and default to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.RadialPos(r=u.Quantity(1.0, "km")) >>> y = cxv.vconvert(cxv.CartesianPos3D, x) >>> print(y) <CartesianPos3D: (x, y, z) [km] [1. 0. 0.]>
>>> y = cxv.vconvert(cxv.CartesianPos3D, x, y=u.Quantity(14, "km")) >>> print(y) <CartesianPos3D: (x, y, z) [km] [ 1. 14. 0.]>
- coordinax.vecs.vconvert(to_vector: type[AbstractPos3D], from_vector: type[RadialPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> SphericalPos | MathSphericalPos.
The r coordinate is converted to the radial coordinate r. The theta and phi coordinates are keyword arguments and default to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.RadialPos(r=u.Quantity(1, "km"))
SphericalPos:
>>> y = cxv.vconvert(cxv.SphericalPos, x) >>> print(y) <SphericalPos: (r[km], theta[rad], phi[rad]) [1. 0. 0.]>
>>> y = cxv.vconvert(cxv.SphericalPos, x, phi=u.Quantity(14, "deg")) >>> print(y) <SphericalPos: (r[km], theta[rad], phi[deg]) [ 1 0 14]>
MathSphericalPos:
>>> y = cxv.vconvert(cxv.MathSphericalPos, x) >>> print(y) <MathSphericalPos: (r[km], theta[rad], phi[rad]) [1. 0. 0.]>
>>> y = cxv.vconvert(cxv.MathSphericalPos, x, phi=u.Quantity(14, "deg")) >>> print(y) <MathSphericalPos: (r[km], theta[rad], phi[deg]) [ 1. 0. 14.]>
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[RadialPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
RadialPos -> CylindricalPos.
The r coordinate is converted to the radial coordinate rho. The phi and z coordinates are keyword arguments and default to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.RadialPos(r=u.Quantity(1.0, "km")) >>> y = cxv.vconvert(cxv.CylindricalPos, x) >>> print(y) <CylindricalPos: (rho[km], phi[rad], z[km]) [1. 0. 0.]>
>>> y = cxv.vconvert(cxv.CylindricalPos, x, phi=u.Quantity(14, "deg")) >>> print(y) <CylindricalPos: (rho[km], phi[deg], z[km]) [ 1. 14. 0.]>
- coordinax.vecs.vconvert(to_vector: type[AbstractPos3D], from_vector: type[CartesianPos2D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
AbstractPos2D -> Cartesian2D -> Cartesian3D -> AbstractPos3D.
The 2D vector is in the xy plane. The z coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos2D.from_([1, 2], "km")
>>> y = cxv.vconvert(cxv.CylindricalPos, x, z=u.Quantity(14, "km")) >>> print(y) <CylindricalPos: (rho[km], phi[rad], z[km]) [ 2.236 1.107 14. ]>
>>> y = cxv.vconvert(cxv.SphericalPos, x, z=u.Quantity(14, "km")) >>> print(y) <SphericalPos: (r[km], theta[rad], phi[rad]) [14.177 0.158 1.107]>
>>> y = cxv.vconvert(cxv.MathSphericalPos, x, z=u.Quantity(14, "km")) >>> print(y) <MathSphericalPos: (r[km], theta[rad], phi[rad]) [14.177 1.107 0.158]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[PolarPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
AbstractPos2D -> PolarPos -> Cylindrical -> AbstractPos3D.
The 2D vector is in the xy plane. The z coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.PolarPos(r=u.Quantity(1, "km"), phi=u.Quantity(10, "deg"))
>>> x2 = cxv.vconvert(cxv.CartesianPos3D, x, z=u.Quantity(14, "km")) >>> print(x2) <CartesianPos3D: (x, y, z) [km] [ 0.985 0.174 14. ]>
- coordinax.vecs.vconvert(to_vector: type[RadialPos], from_vector: type[CartesianPos2D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos2D -> RadialPos.
The x and y coordinates are converted to the radial coordinate r.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos2D.from_([1, 2], "km")
>>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [2.236]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos3D], from_vector: type[CartesianPos2D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos2D -> CartesianPos3D.
The x and y coordinates are converted to the x and y coordinates of the 3D system. The z coordinate is a keyword argument and defaults to 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos2D.from_([1, 2], "km")
>>> x2 = cxv.vconvert(cxv.CartesianPos3D, x, z=u.Quantity(14, "km")) >>> print(x2) <CartesianPos3D: (x, y, z) [km] [ 1 2 14]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos1D], from_vector: type[PolarPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
PolarPos -> CartesianPos1D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.PolarPos(r=u.Quantity(1, "km"), phi=u.Quantity(10, "deg"))
>>> with warnings.catch_warnings(action="ignore"): ... x2 = cxv.vconvert(cxv.CartesianPos1D, x) >>> print(x2) <CartesianPos1D: (x) [km] [0.985]>
- coordinax.vecs.vconvert(to_vector: type[SphericalPos], from_vector: type[PolarPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
PolarPos -> SphericalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.PolarPos(r=u.Quantity(1, "km"), phi=u.Quantity(10, "deg"))
>>> x2 = cxv.vconvert(cxv.SphericalPos, x, theta=u.Quantity(14, "deg")) >>> print(x2) <SphericalPos: (r[km], theta[deg], phi[deg]) [ 1 14 10]>
- coordinax.vecs.vconvert(to_vector: type[MathSphericalPos], from_vector: type[PolarPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
PolarPos -> MathSphericalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.PolarPos(r=u.Quantity(1, "km"), phi=u.Quantity(10, "deg"))
>>> y = cxv.vconvert(cxv.MathSphericalPos, x, theta=u.Quantity(14, "deg")) >>> print(y) <MathSphericalPos: (r[km], theta[deg], phi[deg]) [ 1 10 14]>
- coordinax.vecs.vconvert(to_vector: type[CylindricalPos], from_vector: type[PolarPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
PolarPos -> CylindricalPos.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.PolarPos(r=u.Quantity(1, "km"), phi=u.Quantity(10, "deg"))
>>> x2 = cxv.vconvert(cxv.CylindricalPos, x, z=u.Quantity(14, "km")) >>> print(x2) <CylindricalPos: (rho[km], phi[deg], z[km]) [ 1 10 14]>
>>> x2 = cxv.vconvert(cxv.CylindricalPos, x) >>> print(x2) <CylindricalPos: (rho[km], phi[deg], z[km]) [ 1 10 0]>
- coordinax.vecs.vconvert(to_vector: type[RadialPos], from_vector: type[CartesianPos3D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos3D -> RadialPos.
Examples
>>> import warnings >>> import coordinax.vecs as cxv
>>> params = {"x": 1, "y": 2, "z": 3}
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.RadialPos, cxv.CartesianPos3D, params) ({'r': Array(3.7416575, dtype=float32, ...)}, {})
>>> x = cxv.CartesianPos3D.from_([1.0, 2.0, 3.0], "km") >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [3.742]>
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[CartesianPos3D], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CartesianPos3D -> Cartesian2D -> AbstractPos2D.
Examples
>>> import warnings >>> import coordinax as cx
>>> params = {"x": 1, "y": 2, "z": 3} >>> with warnings.catch_warnings(action="ignore"): ... cx.vecs.vconvert(cx.vecs.PolarPos, cx.vecs.CartesianPos3D, params) ({'r': Array(2.236068, dtype=float32, ...), 'phi': Array(1.1071488, dtype=float32, ...)}, {})
>>> x = cx.CartesianPos3D.from_([1.0, 2.0, 3.0], "km") >>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cx.vecs.PolarPos, x) >>> print(y) <PolarPos: (r[km], phi[rad]) [2.236 1.107]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos1D], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> CartesianPos1D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"rho": 1, "phi": 10, "z": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos1D, cxv.CylindricalPos, ... params, units=usys) ({'x': Array(0.9848077, dtype=float32, ...)}, {})
>>> x = cx.vecs.CylindricalPos(rho=u.Quantity(1.0, "km"), ... phi=u.Quantity(10.0, "deg"), ... z=u.Quantity(14, "km")) >>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cx.vecs.CartesianPos1D, x) >>> print(y) <CartesianPos1D: (x) [km] [0.985]>
- coordinax.vecs.vconvert(to_vector: type[RadialPos], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> RadialPos.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"rho": 1, "phi": 10, "z": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.RadialPos, cxv.CylindricalPos, params, units=usys) ({'r': Array(1, dtype=int32, ...)}, {})
>>> x = cxv.CylindricalPos(rho=u.Quantity(1, "km"), ... phi=u.Quantity(10, "deg"), ... z=u.Quantity(14, "km")) >>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cxv.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [1]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos2D], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> CartesianPos2D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"rho": 1, "phi": 10, "z": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos2D, cxv.CylindricalPos, ... params, units=usys) ({'x': Array(0.9848077, dtype=float32, ...), 'y': Array(0.17364818, dtype=float32, ...)}, {})
>>> x = cxv.CylindricalPos(rho=u.Quantity(1, "km"), ... phi=u.Quantity(10, "deg"), ... z=u.Quantity(14, "km")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.CartesianPos2D, x) >>> print(y) <CartesianPos2D: (x, y) [km] [0.985 0.174]>
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[CylindricalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
CylindricalPos -> PolarPos.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"rho": 1, "phi": 10, "z": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.PolarPos, cxv.CylindricalPos, ... params, units=usys) ({'r': Array(1, dtype=int32, ...), 'phi': Array(10., dtype=float32, ...)}, {})
>>> x = cxv.CylindricalPos(rho=u.Quantity(1, "km"), ... phi=u.Quantity(10, "deg"), ... z=u.Quantity(14, "km")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.PolarPos, x) >>> print(y) <PolarPos: (r[km], phi[deg]) [ 1 10]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos1D], from_vector: type[SphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalPos -> CartesianPos1D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"r": 1, "theta": 14, "phi": 10} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos1D, cxv.SphericalPos, ... params, units=usys) ({'x': Array(0.23824656, dtype=float32, ...)}, {})
>>> x = cxv.SphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(14, "deg"), ... phi=u.Quantity(10, "deg")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.CartesianPos1D, x) >>> print(y) <CartesianPos1D: (x) [km] [0.238]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos2D], from_vector: type[SphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalPos -> CartesianPos2D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"r": 1, "theta": 14, "phi": 10} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos2D, cxv.SphericalPos, ... params, units=usys) ({'x': Array(0.23824656, dtype=float32, ...), 'y': Array(0.0420093, dtype=float32, ...)}, {})
>>> x = cxv.SphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(14, "deg"), ... phi=u.Quantity(10, "deg")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.CartesianPos2D, x) >>> print(y) <CartesianPos2D: (x, y) [km] [0.238 0.042]>
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[SphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
SphericalPos -> PolarPos.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"r": 1, "theta": 14, "phi": 10} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.PolarPos, cxv.SphericalPos, ... params, units=usys) ({'r': Array(0.2419219, dtype=float32, ...), 'phi': Array(10., dtype=float32, ...)}, {})
>>> x = cxv.SphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(14, "deg"), ... phi=u.Quantity(10, "deg")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.PolarPos, x) >>> print(y) <PolarPos: (r[km], phi[deg]) [ 0.242 10. ]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos1D], from_vector: type[MathSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
MathSphericalPos -> CartesianPos1D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"r": 1, "theta": 10, "phi": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos1D, cxv.MathSphericalPos, ... params, units=usys) ({'x': Array(0.23824656, dtype=float32, ...)}, {})
>>> x = cx.vecs.MathSphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(10, "deg"), ... phi=u.Quantity(14, "deg"))
>>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cx.vecs.CartesianPos1D, x) >>> print(y) <CartesianPos1D: (x) [km] [0.238]>
- coordinax.vecs.vconvert(to_vector: type[CartesianPos2D], from_vector: type[MathSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
MathSphericalPos -> CartesianPos2D.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"r": 1, "theta": 10, "phi": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.CartesianPos2D, cxv.MathSphericalPos, ... params, units=usys) ({'x': Array(0.23824656, dtype=float32, ...), 'y': Array(0.0420093, dtype=float32, ...)}, {})
>>> x = cx.vecs.MathSphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(10, "deg"), ... phi=u.Quantity(14, "deg"))
>>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cx.vecs.CartesianPos2D, x) >>> print(y) <CartesianPos2D: (x, y) [km] [0.238 0.042]>
- coordinax.vecs.vconvert(to_vector: type[PolarPos], from_vector: type[MathSphericalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
MathSphericalPos -> PolarPos.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax.vecs as cxv
>>> params = {"r": 1, "theta": 10, "phi": 14} >>> usys = u.unitsystem("km", "deg")
>>> with warnings.catch_warnings(action="ignore"): ... cxv.vconvert(cxv.PolarPos, cxv.MathSphericalPos, ... params, units=usys) ({'r': Array(0.2419219, dtype=float32, ...), 'phi': Array(10., dtype=float32, ...)}, {})
>>> x = cxv.MathSphericalPos(r=u.Quantity(1, "km"), ... theta=u.Quantity(10, "deg"), ... phi=u.Quantity(14, "deg")) >>> with warnings.catch_warnings(action="ignore"): ... y = cxv.vconvert(cxv.PolarPos, x) >>> print(y) <PolarPos: (r[km], phi[deg]) [ 0.242 10. ]>
- coordinax.vecs.vconvert(to_vector: type[AbstractPos], from_vector: type[ProlateSpheroidalPos], p: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None, units: AbstractUnitSystem | None = None) tuple[dict[str, Any], dict[str, Any]]
ProlateSpheroidalPos -> AbstractPos.
Examples
>>> import warnings >>> import unxt as u >>> import coordinax as cx
>>> x = cx.vecs.ProlateSpheroidalPos( ... mu=u.Quantity(2, "km2"), ... nu=u.Quantity(0.5, "km2"), ... phi=u.Quantity(0.5, "rad"), ... Delta=u.Quantity(1, "km"), ... )
>>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cx.vecs.CartesianPos1D, x) >>> print(y) <CartesianPos1D: (x) [km] [0.621]>
>>> with warnings.catch_warnings(action="ignore"): ... y = cx.vconvert(cx.vecs.RadialPos, x) >>> print(y) <RadialPos: (r) [km] [0.707]>
>>> with warnings.catch_warnings(action="ignore"): ... x2 = cx.vconvert(cx.vecs.CartesianPos2D, x) >>> print(x2) <CartesianPos2D: (x, y) [km] [0.621 0.339]>
>>> with warnings.catch_warnings(action="ignore"): ... x2 = cx.vconvert(cx.vecs.PolarPos, x) >>> print(x2) <PolarPos: (r[km], phi[rad]) [0.707 0.5 ]>
>>> import coordinax.vecs as cxv >>> vec = {"mu": 1, "nu": 0.2, "phi": 90} >>> in_aux = {"Delta": 0.5} >>> usys = u.unitsystem("km", "deg")
>>> cxv.vconvert(cxv.CylindricalPos, cxv.ProlateSpheroidalPos, ... vec, in_aux=in_aux, units=usys) ({'phi': Array(90., dtype=float32, ...), 'rho': Array(0.38729832, dtype=float32, ...), 'z': Array(0.8944272, dtype=float32, ...)}, {})
>>> cxv.vconvert(cxv.CartesianPos3D, cxv.ProlateSpheroidalPos, ... vec, in_aux=in_aux, units=usys) ({'x': Array(-1.6929347e-08, dtype=float32, ...), 'y': Array(0.38729832, dtype=float32, ...), 'z': Array(0.8944272, dtype=float32, ...)}, {})
- coordinax.vecs.vconvert(target: type[KinematicSpace], w: PoincarePolarVector, /) KinematicSpace
Space -> PoincarePolarVector.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> cx.vconvert(cx.vecs.PoincarePolarVector, w) PoincarePolarVector( rho=Quantity([[2.23606801, 6.40312433]], unit='m'), pp_phi=Quantity([[0., 0.]], unit='m / s(1/2)'), z=Quantity([[3, 6]], unit='m'), dt_rho=Quantity([[2.23606801, 6.40312433]], unit='m / s'), dt_pp_phi=Quantity([[0., 0.]], unit='m / s(1/2)'), dt_z=Quantity([[3, 6]], unit='m / s') )
>>> cx.vconvert(cx.KinematicSpace, w) KinematicSpace({ 'length': CartesianPos3D( x=Quantity([[1, 4]], unit='m'), y=Quantity([[2, 5]], unit='m'), z=Quantity([[3, 6]], unit='m') ), 'speed': CartesianVel3D( x=Quantity([[1, 4]], unit='m / s'), y=Quantity([[2, 5]], unit='m / s'), z=Quantity([[3, 6]], unit='m / s') ) })
- coordinax.vecs.vconvert(to_dif_cls: type[AbstractVector], from_dif_cls: type[AbstractVector], p_dif: dict[str, Any], p_pos: dict[str, Any], /, *, in_aux: dict[str, Any] | None = None, out_aux: dict[str, Any] | None = None) tuple[dict[str, Any], dict[str, Any] | None]
AbstractVel1D -> AbstractVel1D.
- Parameters:
to_dif_cls – The target type of the vector differential.
from_dif_cls – The type of the vector differential to transform.
p_dif – The data of the vector differential to transform.
p_pos – The data of the position vector used to transform the differential.
in_aux – The input auxiliary data to the transform.
out_aux – THe output auxiliary data to the transform.
args (Any)
kwargs (Any)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Let’s start in 1D:
>>> q = {"x": u.Quantity([1.0], "km")} >>> p = {"x": u.Quantity([1.0], "km/s")} >>> newp = cxv.vconvert(cxv.RadialVel, cxv.CartesianVel1D, p, q) >>> print(newp) ({'r': Quantity(Array([1.], dtype=float32), unit='km / s')}, {})
>>> q = {"x": u.Quantity([1.0], "km")} >>> a = {"x": u.Quantity([1.0], "km/s2")} >>> newa = cxv.vconvert(cxv.RadialAcc, cxv.CartesianAcc1D, a, q) >>> print(newa) ({'r': Quantity(Array([1.], dtype=float32), unit='km / s2')}, {})
- coordinax.vecs.vconvert(to_dif_cls: type[AbstractVector], from_dif: AbstractVector, from_pos: AbstractPos, /, **kwargs: Any) AbstractVector
Differential -> Differential.
This is the base case for the transformation of vector differentials.
- Parameters:
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Let’s start in 1D:
>>> q = cxv.CartesianPos1D.from_(1.0, "km") >>> p = cxv.CartesianVel1D.from_(1.0, "km/s") >>> newp = cxv.vconvert(cxv.RadialVel, p, q) >>> print(newp) <RadialVel: (r) [km / s] [1.]>
>>> a = cxv.CartesianAcc1D(x=u.Quantity(1.0, "km/s2")) >>> print(cxv.vconvert(cxv.RadialAcc, a, p, q)) <RadialAcc: (r) [km / s2] [1.]>
Now in 2D:
>>> q = cxv.CartesianPos2D.from_([1.0, 2.0], "km") >>> p = cxv.CartesianVel2D.from_([1.0, 2.0], "km/s") >>> newp = cxv.vconvert(cxv.PolarVel, p, q) >>> print(newp) <PolarVel: (r[km / s], phi[rad / s]) [2.236 0. ]>
>>> a = cxv.CartesianAcc2D.from_([1.0, 2.0], "km/s2") >>> print(cxv.vconvert(cxv.PolarAcc, a, p, q)) <PolarAcc: (r[km / s2], phi[rad / s2]) [2.236 0. ]>
And in 3D:
>>> q = cxv.CartesianPos3D.from_([1.0, 2.0, 3.0], "km") >>> p = cxv.CartesianVel3D.from_([1.0, 2.0, 3.0], "km/s") >>> newp = cxv.vconvert(cxv.SphericalVel, p, q) >>> print(newp.round(2)) <SphericalVel: (r[km / s], theta[rad / s], phi[rad / s]) [ 3.74 -0. 0. ]>
>>> a = cxv.CartesianAcc3D.from_([1.0, 2.0, 3.0], "km/s2") >>> print(cxv.vconvert(cxv.SphericalAcc, a, p, q).round(2)) <SphericalAcc: (r[km / s2], theta[rad / s2], phi[rad / s2]) [ 3.74 -0. 0. ]>
- coordinax.vecs.vconvert(to_acc_cls: type[AbstractAcc], from_acc: AbstractAcc, from_vel: AbstractVel, from_pos: AbstractPos, /, **kwargs: Any) AbstractAcc
AbstractAcc -> Cartesian -> AbstractAcc.
This is the base case for the transformation of accelerations.
Let $mathbf{x}$ be a position vector in one representation $mathbf{y}$ a position vector in another representation related by:
$$ mathbf{y} = f(mathbf{x}) $$
where $f$ is a differentiable function mapping between the coordinate systems.
The Jacobian matrix $J$ of the transformation is:
$$ J = frac{partial mathbf{y}}{partial mathbf{x}}$$
The coordinate transformation of the acceleration is given by the chain rule:
$$ ddot{mathbf{y}} = dot{J} dot{mathbf{x}} + J ddot{mathbf{x}}$$
where $dot{J}$ is the time derivative of the Jacobian matrix. This function assumes that the representation conversion is time-invariant, so $dot{J} = 0$. Thus, the transformation simplifies to:
$$ ddot{mathbf{y}} = J ddot{mathbf{x}}$$
This function implements this transformation.
- Parameters:
to_acc_cls – The target type of the vector acceleration.
from_acc – The vector acceleration to transform.
from_vel – The velocity vector used to transform the acceleration.
from_pos – The position vector used to transform the acceleration.
**kwargs (Any) – Additional keyword arguments.
args (Any)
**kwargs
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Let’s start in 1D:
>>> q = cxv.CartesianPos1D(x=u.Quantity(1.0, "km")) >>> p = cxv.CartesianVel1D(x=u.Quantity(1.0, "km/s")) >>> a = cxv.CartesianAcc1D(x=u.Quantity(1.0, "km/s2")) >>> print(cxv.vconvert(cxv.RadialAcc, a, p, q)) <RadialAcc: (r) [km / s2] [1.]>
Now in 2D:
>>> q = cxv.CartesianPos2D.from_([1.0, 2.0], "km") >>> p = cxv.CartesianVel2D.from_([1.0, 2.0], "km/s") >>> a = cxv.CartesianAcc2D.from_([1.0, 2.0], "km/s2") >>> print(cxv.vconvert(cxv.PolarAcc, a, p, q)) <PolarAcc: (r[km / s2], phi[rad / s2]) [2.236 0. ]>
And in 3D:
>>> q = cxv.CartesianPos3D.from_([1.0, 2.0, 3.0], "km") >>> p = cxv.CartesianVel3D.from_([1.0, 2.0, 3.0], "km/s") >>> a = cxv.CartesianAcc3D.from_([1.0, 2.0, 3.0], "km/s2") >>> print(cxv.vconvert(cxv.SphericalAcc, a, p, q).round(2)) <SphericalAcc: (r[km / s2], theta[rad / s2], phi[rad / s2]) [ 3.74 -0. 0. ]>
- coordinax.vecs.vconvert(target: type[AbstractPos], w: Coordinate, /) Coordinate
Transform the vector representation of a coordinate.
Examples
>>> import coordinax as cx
>>> frame = cx.frames.NoFrame() >>> data = cx.CartesianPos3D.from_([1, 2, 3], "kpc") >>> w = cx.Coordinate(data, frame)
>>> cx.vconvert(cx.SphericalPos, w) Coordinate( KinematicSpace({ 'length': SphericalPos( ... ) }), frame=NoFrame() )
- coordinax.vecs.normalize_vector(x: Any, /)#
Return the unit vector.
- coordinax.vecs.normalize_vector(x: jaxtyping.Shaped[Array, '*batch N'], /) jaxtyping.Shaped[Array, '*batch N']
Return the unit vector.
Examples
>>> import jax.numpy as jnp >>> import coordinax as cx
>>> x = jnp.asarray([2, 0]) >>> cx.vecs.normalize_vector(x) Array([1., 0.], dtype=float32)
>>> x = jnp.asarray([0, 2]) >>> cx.vecs.normalize_vector(x) Array([0., 1.], dtype=float32)
- coordinax.vecs.normalize_vector(x: jaxtyping.Shaped[AbstractQuantity, '*batch N'], /) jaxtyping.Shaped[AbstractQuantity, '*batch N']
Return the unit vector.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> x = u.Quantity(jnp.asarray([2, 0]), "km") >>> cx.vecs.normalize_vector(x) Quantity(Array([1., 0.], dtype=float32), unit='')
>>> x = u.Quantity(jnp.asarray([0, 2]), "s") >>> cx.vecs.normalize_vector(x) Quantity(Array([0., 1.], dtype=float32), unit='')
- coordinax.vecs.normalize_vector(obj: CartesianPos3D, /) Cartesian3D
Return the norm of the vector.
This has length 1.
Note
The unit vector is dimensionless, even if the input vector has units. This is because the unit vector is a ratio of two quantities: each component and the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
- Parameters:
x (Any)
Examples
>>> import coordinax.vecs as cxv >>> q = cxv.CartesianPos3D.from_([1, 2, 3], "km") >>> print(cxv.normalize_vector(q)) <Cartesian3D: (x, y, z) [] [0.267 0.535 0.802]>
- coordinax.vecs.cartesian_vector_type(obj: Any, /)#
Return the corresponding Cartesian vector type.
Examples
>>> import coordinax.vecs as cxv
>>> cxv.cartesian_vector_type(cxv.RadialPos) <class 'coordinax...CartesianPos1D'>
>>> cxv.cartesian_vector_type(cxv.SphericalPos) <class 'coordinax...CartesianPos3D'>
>>> cxv.cartesian_vector_type(cxv.RadialVel) <class 'coordinax...CartesianVel1D'>
>>> cxv.cartesian_vector_type(cxv.TwoSphereAcc) <class 'coordinax...CartesianAcc2D'>
>>> cxv.cartesian_vector_type(cxv.SphericalVel) <class 'coordinax...CartesianVel3D'>
>>> cxv.cartesian_vector_type(cxv.CartesianAcc3D) <class 'coordinax...CartesianAcc3D'>
>>> cxv.cartesian_vector_type(cxv.SphericalAcc) <class 'coordinax...CartesianAcc3D'>
>>> cxv.cartesian_vector_type(cxv.FourVector) <class 'coordinax...CartesianPos3D'>
>>> cxv.cartesian_vector_type(cxv.CartesianPosND) <class 'coordinax...CartesianPosND'>
>>> cxv.cartesian_vector_type(cxv.CartesianVelND) <class 'coordinax...CartesianVelND'>
>>> cxv.cartesian_vector_type(cxv.CartesianAccND) <class 'coordinax...CartesianAccND'>
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractPos3D] | AbstractPos3D, /) type[CartesianPos3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractVel3D] | AbstractVel3D, /) type[CartesianVel3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractAcc3D] | AbstractAcc3D, /) type[CartesianAcc3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractPosND] | AbstractPosND, /) type[CartesianPosND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractVelND] | AbstractVelND, /) type[CartesianVelND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractAccND] | AbstractAccND, /) type[CartesianAccND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- coordinax.vecs.cartesian_vector_type(obj: type[PoincarePolarVector] | PoincarePolarVector, /) NoReturn
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
Examples
>>> import coordinax as cx >>> try: cx.vecs.cartesian_vector_type(cx.vecs.PoincarePolarVector) ... except NotImplementedError as e: ... print(e) PoincarePolarVector does not have a corresponding Cartesian class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractPos1D] | AbstractPos1D, /) type[AbstractPos1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractVel1D] | AbstractVel1D, /) type[AbstractVel1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractAcc1D] | AbstractAcc1D, /) type[AbstractAcc1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractPos2D] | AbstractPos2D, /) type[CartesianPos2D]
- Parameters:
obj (Any)
- Return type:
AbstractPos2D -> CartesianPos2D.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractVel2D] | AbstractVel2D, /) type[CartesianVel2D]
- Parameters:
obj (Any)
- Return type:
AbstractVel2D -> CartesianVel2D.
- coordinax.vecs.cartesian_vector_type(obj: type[AbstractAcc2D] | AbstractAcc2D, /) type[CartesianAcc2D]
- Parameters:
obj (Any)
- Return type:
AbstractPos -> CartesianAcc2D.
- coordinax.vecs.cartesian_vector_type(obj: type[FourVector] | FourVector, /) type[CartesianPos3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding Cartesian vector class.
- Parameters:
obj (
Any)- Return type:
- coordinax.vecs.time_derivative_vector_type(obj: Any, /)#
Return the corresponding time derivative vector type.
Examples
>>> import coordinax as cx
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianPos1D) <class 'coordinax...CartesianVel1D'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianVel1D) <class 'coordinax...CartesianAcc1D'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.RadialPos) <class 'coordinax...RadialVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.RadialVel) <class 'coordinax...RadialAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianPos2D) <class 'coordinax...CartesianVel2D'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianVel2D) <class 'coordinax...CartesianAcc2D'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.PolarPos) <class 'coordinax...PolarVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.PolarVel) <class 'coordinax...PolarAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianPos3D) <class 'coordinax...CartesianVel3D'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianVel3D) <class 'coordinax...CartesianAcc3D'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CylindricalPos) <class 'coordinax...CylindricalVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CylindricalVel) <class 'coordinax...CylindricalAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.SphericalPos) <class 'coordinax...SphericalVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.SphericalVel) <class 'coordinax...SphericalAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.MathSphericalPos) <class 'coordinax...MathSphericalVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.MathSphericalVel) <class 'coordinax...MathSphericalAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.LonLatSphericalPos) <class 'coordinax...LonLatSphericalVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.LonLatSphericalVel) <class 'coordinax...LonLatSphericalAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.LonCosLatSphericalVel) <class 'coordinax...LonLatSphericalAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.ProlateSpheroidalPos) <class 'coordinax...ProlateSpheroidalVel'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.ProlateSpheroidalVel) <class 'coordinax...ProlateSpheroidalAcc'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianPosND) <class 'coordinax...CartesianVelND'>
>>> cx.vecs.time_derivative_vector_type(cx.vecs.CartesianVelND) <class 'coordinax...CartesianAccND'>
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianPos3D] | CartesianPos3D, /) type[CartesianVel3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CylindricalPos] | CylindricalPos, /) type[CylindricalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[SphericalPos] | SphericalPos, /) type[SphericalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[MathSphericalPos] | MathSphericalPos, /) type[MathSphericalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[LonLatSphericalPos] | LonLatSphericalPos, /) type[LonLatSphericalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[ProlateSpheroidalPos] | ProlateSpheroidalPos, /) type[ProlateSpheroidalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianVel3D] | CartesianVel3D, /) type[CartesianAcc3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CylindricalVel] | CylindricalVel, /) type[CylindricalAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[SphericalVel] | SphericalVel, /) type[SphericalAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[MathSphericalVel] | MathSphericalVel, /) type[MathSphericalAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[LonLatSphericalVel] | LonLatSphericalVel, /) type[LonLatSphericalAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[LonCosLatSphericalVel] | LonCosLatSphericalVel, /) type[LonLatSphericalAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[ProlateSpheroidalVel] | ProlateSpheroidalVel, /) type[ProlateSpheroidalAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianPosND] | CartesianPosND, /) type[CartesianVelND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianVelND] | CartesianVelND, /) type[CartesianAccND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianPos1D] | CartesianPos1D, /) type[CartesianVel1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[RadialPos] | RadialPos, /) type[RadialVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianVel1D] | CartesianVel1D, /) type[CartesianAcc1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[RadialVel] | RadialVel, /) type[RadialAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianPos2D] | CartesianPos2D, /) type[CartesianVel2D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[PolarPos] | PolarPos, /) type[PolarVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[TwoSpherePos] | TwoSpherePos, /) type[TwoSphereVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[CartesianVel2D] | CartesianVel2D, /) type[CartesianAcc2D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[PolarVel] | PolarVel, /) type[PolarAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_derivative_vector_type(obj: type[TwoSphereVel] | TwoSphereVel, /) type[TwoSphereAcc]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- Parameters:
obj (
Any)- Return type:
- coordinax.vecs.time_antiderivative_vector_type(obj: Any, /)#
Return the corresponding time antiderivative vector type.
Examples
>>> import coordinax as cx
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianVel1D) <class 'coordinax...CartesianPos1D'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianAcc1D) <class 'coordinax...CartesianVel1D'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.RadialVel) <class 'coordinax...RadialPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.RadialAcc) <class 'coordinax...RadialVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianVel2D) <class 'coordinax...CartesianPos2D'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianAcc2D) <class 'coordinax...CartesianVel2D'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.PolarVel) <class 'coordinax...PolarPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.PolarAcc) <class 'coordinax...PolarVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianVel3D) <class 'coordinax...CartesianPos3D'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianAcc3D) <class 'coordinax...CartesianVel3D'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CylindricalVel) <class 'coordinax...CylindricalPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CylindricalAcc) <class 'coordinax...CylindricalVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.SphericalVel) <class 'coordinax...SphericalPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.SphericalAcc) <class 'coordinax...SphericalVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.MathSphericalVel) <class 'coordinax...MathSphericalPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.MathSphericalAcc) <class 'coordinax...MathSphericalVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.LonLatSphericalVel) <class 'coordinax...LonLatSphericalPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.LonCosLatSphericalVel) <class 'coordinax...LonLatSphericalPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.LonLatSphericalAcc) <class 'coordinax...LonLatSphericalVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.ProlateSpheroidalVel) <class 'coordinax...ProlateSpheroidalPos'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.ProlateSpheroidalAcc) <class 'coordinax...ProlateSpheroidalVel'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianVelND) <class 'coordinax...CartesianPosND'>
>>> cx.vecs.time_antiderivative_vector_type(cx.vecs.CartesianAccND) <class 'coordinax...CartesianVelND'>
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianVel3D] | CartesianVel3D, /) type[CartesianPos3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CylindricalVel] | CylindricalVel, /) type[CylindricalPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[SphericalVel] | SphericalVel, /) type[SphericalPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[MathSphericalVel] | MathSphericalVel, /) type[MathSphericalPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time derivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[LonLatSphericalVel] | LonLatSphericalVel, /) type[LonLatSphericalPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[LonCosLatSphericalVel] | LonCosLatSphericalVel, /) type[LonLatSphericalPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[ProlateSpheroidalVel] | ProlateSpheroidalVel, /) type[ProlateSpheroidalPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianAcc3D] | CartesianAcc3D, /) type[CartesianVel3D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CylindricalAcc] | CylindricalAcc, /) type[CylindricalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[SphericalAcc] | SphericalAcc, /) type[SphericalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[MathSphericalAcc] | MathSphericalAcc, /) type[MathSphericalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[LonLatSphericalAcc] | LonLatSphericalAcc, /) type[LonLatSphericalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[ProlateSpheroidalAcc] | ProlateSpheroidalAcc, /) type[ProlateSpheroidalVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianVelND] | CartesianVelND, /) type[CartesianPosND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianAccND] | CartesianAccND, /) type[CartesianVelND]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianVel1D] | CartesianVel1D, /) type[CartesianPos1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[RadialVel] | RadialVel, /) type[RadialPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianAcc1D] | CartesianAcc1D, /) type[CartesianVel1D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[RadialAcc] | RadialAcc, /) type[RadialVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianVel2D] | CartesianVel2D, /) type[CartesianPos2D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[PolarVel] | PolarVel, /) type[PolarPos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[TwoSphereVel] | TwoSphereVel, /) type[TwoSpherePos]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[CartesianAcc2D] | CartesianAcc2D, /) type[CartesianVel2D]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[PolarAcc] | PolarAcc, /) type[PolarVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- coordinax.vecs.time_antiderivative_vector_type(obj: type[TwoSphereAcc] | TwoSphereAcc, /) type[TwoSphereVel]
- Parameters:
obj (Any)
- Return type:
Return the corresponding time antiderivative class.
- Parameters:
obj (
Any)- Return type:
- coordinax.vecs.time_nth_derivative_vector_type(obj: Any, /, *, n: int)#
Return the corresponding time nth derivative vector type.
Examples
>>> import coordinax as cx
>>> cx.vecs.RadialPos.time_nth_derivative_cls(n=0) <class 'coordinax...RadialPos'>
>>> cx.vecs.RadialPos.time_nth_derivative_cls(n=1) <class 'coordinax...RadialVel'>
>>> cx.vecs.RadialPos.time_nth_derivative_cls(n=2) <class 'coordinax...RadialAcc'>
>>> cx.vecs.RadialVel.time_nth_derivative_cls(n=-1) <class 'coordinax...RadialPos'>
>>> cx.vecs.RadialVel.time_nth_derivative_cls(n=0) <class 'coordinax...RadialVel'>
>>> cx.vecs.RadialVel.time_nth_derivative_cls(n=1) <class 'coordinax...RadialAcc'>
>>> cx.vecs.RadialAcc.time_nth_derivative_cls(n=-2) <class 'coordinax...RadialPos'>
>>> cx.vecs.RadialAcc.time_nth_derivative_cls(n=-1) <class 'coordinax...RadialVel'>
>>> cx.vecs.RadialAcc.time_nth_derivative_cls(n=0) <class 'coordinax...RadialAcc'>
- coordinax.vecs.time_nth_derivative_vector_type(obj: type[AbstractVector] | AbstractVector, /, *, n: int) type[AbstractVector]
- Parameters:
- Return type:
- Parameters:
- Return type:
- exception coordinax.vecs.IrreversibleDimensionChange#
Bases:
UserWarningRaised when a dimension change is irreversible.
This exception is raised when a dimension change is irreversible. For example, changing from Cartesian3D to a Cartesian2D is irreversible because the z-component is lost.
Examples
>>> import warnings >>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> with warnings.catch_warnings(record=True, action="always") as w: ... _ = vec.vconvert(cx.vecs.CartesianPos2D) >>> print(w[0].message) irreversible dimension change
- add_note()#
Exception.add_note(note) – add a note to the exception
- args#
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- coordinax.vecs.is_vectorlike(obj: Any, /)#
Check if the object is a AbstractVectorLike object.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> cx.vecs.is_vectorlike(vec) True
>>> space = cx.vecs.KinematicSpace.from_(vec) >>> cx.vecs.is_vectorlike(space) True
>>> coord = cx.Coordinate.from_(vec, cx.frames.ICRS()) >>> cx.vecs.is_vectorlike(coord) True
>>> cx.vecs.is_vectorlike(42) False
- Parameters:
obj (
Any)- Return type:
TypeGuard[AbstractVectorLike]
- coordinax.vecs.is_vector(obj: Any, /)#
Check if the object is a AbstractVector object.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> cx.vecs.is_vector(vec) True
>>> space = cx.vecs.KinematicSpace.from_(vec) >>> cx.vecs.is_vector(space) False
>>> coord = cx.Coordinate.from_(vec, cx.frames.ICRS()) >>> cx.vecs.is_vector(coord) True
>>> cx.vecs.is_vector(42) False
- Parameters:
obj (
Any)- Return type:
TypeGuard[AbstractVector]
- class coordinax.vecs.AbstractVectorLike#
Bases:
ArrayValue,LaxBinaryOpsMixin[Any,Any],LaxRoundMixin[AbstractVectorLike],LaxUnaryMixin[Any]Base class for all vector-like types.
A vector is a collection of components that can be represented in different coordinate systems. This class provides a common interface for all vector-like types, which includes vectors but also other types like collections of vectors that share some properties and methods.
- vconvert()#
Convert the vector(s) to another type. For example, a Cartesian position vector can be converted to a spherical position vector.
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
- uconvert()#
Convert the vector(s) to a different unit system. For example, a Cartesian position vector in meters can be converted to kilometers.
- astype()#
Cast the fields of the vector to a new dtype.
- Parameters:
- Return type:
- round()#
Round the fields of the vector to a given number of decimals.
- to_device()#
Move the fields of the vector to a new device.
Examples
>>> import unxt as u >>> import coordinax as cx
Scalar vectors have length 0:
>>> vec = cx.vecs.CartesianPos1D.from_([1], "m") >>> len(vec) 0
Vectors with certain lengths:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1], "m")) >>> len(vec) 1
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> len(vec) 2
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property dtype#
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property ndim#
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property size#
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractVector#
Bases:
IPythonReprMixin,AstropyRepresentationAPIMixin,NumpyInvertMixin[Any],LaxLenMixin,AbstractVectorLikeBase class for all vector types.
A vector is a collection of components that can be represented in different coordinate systems. This class provides a common interface for all vector types. All fields of the vector are expected to be components of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
Scalar vectors have length 0:
>>> vec = cx.vecs.CartesianPos1D.from_([1], "m") >>> len(vec) 0
Vectors with certain lengths:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1], "m")) >>> len(vec) 1
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> len(vec) 2
String representation of vectors:
a vector with only axis fields
>>> vec1 = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(str(vec1)) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
a vector with additional attributes
>>> vec2 = vec1.vconvert(cx.vecs.ProlateSpheroidalPos, Delta=u.Quantity(1, "m")) >>> print(str(vec2)) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1, unit='m') [14.374 0.626 1.107]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AttrFilter(*_, **__)#
Bases:
objectFlag to filter out VectorAttribute fields.
Examples
>>> import dataclasses >>> from dataclassish import field_items >>> import coordinax as cx
>>> class TestPos(cx.vecs.AbstractPos): ... x: int ... attr: float = cx.vecs.VectorAttribute(default=2.0) ... _dimensionality = 1
>>> obj = TestPos(x=1)
>>> [(f.name, getattr(obj, f.name)) for f in dataclasses.fields(obj)] [('x', 1), ('attr', 2.0)]
>>> field_items(obj) (('x', 1), ('attr', 2.0))
>>> field_items(cx.vecs.AttrFilter, obj) (('x', 1),)
- class coordinax.vecs.VectorAttribute(*, default: ~typing.Any = <MISSING>, converter: ~collections.abc.Callable[[~typing.Any], ~coordinax._src.vectors.base.attribute.Return] = <function identity>)#
Bases:
Generic[Return]Descriptor for attributes (non-coordinate fields) on a vector.
Examples
>>> import coordinax as cx
>>> class TestPos(cx.vecs.AbstractPos): ... x: int ... attr: float = cx.vecs.VectorAttribute(default=2.0) ... _dimensionality = 1
vector-attributes are used to define fields on a vector that are not one of the coordinates.
>>> obj = TestPos(x=1) >>> obj.components ('x',)
- class coordinax.vecs.ToUnitsOptions(*values)#
Bases:
EnumOptions for the units argument of AbstractVector.uconvert.
- consistent = 'consistent'#
Convert to consistent units.
- class coordinax.vecs.AbstractPos#
Bases:
AvalMixin,NumpyNegMixin[coordinax.vecs.AbstractPos],AbstractVectorAbstract representation of coordinates in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- time_derivative_cls#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractVel#
Bases:
AvalMixin,AbstractVectorAbstract representation of vector differentials in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- time_derivative_cls#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractAcc#
Bases:
AvalMixin,AbstractVectorAbstract representation of vector differentials in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- time_derivative_cls#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractPos1D#
Bases:
AbstractPosAbstract representation of 1D coordinates in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos1D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractVel1D#
Bases:
AbstractVelAbstract representation of 1D differentials in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel1D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractAcc1D#
Bases:
AbstractAccAbstract representation of 1D acceleration in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc1D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.RadialPos(r: ArgT | PassThroughTs)#
Bases:
AbstractPos1DRadial vector representation.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.RadialPos(u.Quantity([2], "m")) >>> print(vec) <RadialPos: (r) [m] [[2]]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos1D
- components = ('r',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'r': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Shaped[AbstractDistance, '*#batch']# Radial distance \(r \in [0,+\infty)\).
- class coordinax.vecs.RadialVel(r: Any)#
Bases:
AbstractVel1DRadial velocity.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.RadialVel(u.Quantity([2], "m/s")) >>> print(vec) <RadialVel: (r) [m / s] [[2]]>
- Parameters:
r (
Any)
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel1D
- components = ('r',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'r': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# Radial speed \(dr/dt \in (-\infty,+\infty)\).
- class coordinax.vecs.RadialAcc(r: Any)#
Bases:
AbstractAcc1DRadial Acceleration.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.RadialAcc(u.Quantity([2], "m/s2")) >>> print(vec) <RadialAcc: (r) [m / s2] [[2]]>
- Parameters:
r (
Any)
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc1D
- components = ('r',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'r': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# Radial acceleration \(d^2r/dt^2 \in (-\infty,+\infty)\).
- class coordinax.vecs.CartesianPos1D(x: Any)#
Bases:
AbstractCartesian,AbstractPos1DCartesian vector representation.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos1D.from_([2], "m") >>> vec CartesianPos1D(x=Quantity(2, unit='m'))
Vectors support the basic math operations:
>>> (vec + vec).x Quantity(Array(4, dtype=int32), unit='m')
>>> (vec - vec).x Quantity(Array(0, dtype=int32), unit='m')
>>> (3 * vec).x Quantity(Array(6, dtype=int32), unit='m')
- Parameters:
x (
Any)
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos1D
- components = ('x',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
CartesianVel1D
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Shaped[Quantity[PhysicalType('length')], '*#batch']# X coordinate \(x \in (-\infty,+\infty)\).
- class coordinax.vecs.CartesianVel1D(x: Any)#
Bases:
AbstractCartesian,AbstractVel1DCartesian differential representation.
- Parameters:
x (
Any)
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel1D
- components = ('x',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractPos1D | None = None, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx >>> q = cx.vecs.CartesianVel1D.from_([-1], "km/s") >>> q.norm() Quantity(Array(1, dtype=int32), unit='km / s')
- Parameters:
_ (
AbstractPos1D|None)- Return type:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianPos1D
- time_derivative_cls#
alias of
CartesianAcc1D
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# X differential \(dx/dt \in (-\infty,+\infty\))`.
- class coordinax.vecs.CartesianAcc1D(x: Any)#
Bases:
AbstractCartesian,AbstractAcc1DCartesian differential representation.
- Parameters:
x (
Any)
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc1D
- components = ('x',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractPos1D | None = None, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx >>> q = cx.vecs.CartesianAcc1D.from_([-1], "km/s2") >>> q.norm() Quantity(Array(1, dtype=int32), unit='km / s2')
- Parameters:
_ (
AbstractPos1D|None)- Return type:
Real[Quantity[PhysicalType('acceleration')], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianVel1D
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# X differential \(d^2x/dt^2 \in (-\infty,+\infty\))`.
- class coordinax.vecs.AbstractPos2D#
Bases:
AbstractPosAbstract representation of 2D coordinates in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos2D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractVel2D#
Bases:
AbstractVelAbstract representation of 2D vector differentials.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel2D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractAcc2D#
Bases:
AbstractAccAbstract representation of 2D vector accelerations.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc2D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.TwoSpherePos(theta: Any, phi: ArgT | PassThroughTs)#
Bases:
AbstractPos2DPos on the 2-Sphere.
The space of coordinates on the unit sphere is called the 2-sphere or $S^2$. It is a two-dimensional surface embedded in three-dimensional space, defined by the set of all points at a unit distance from a central point. Mathematically, this is:
$$ S^2 = { mathbf{x} in mathbb{R}^3 | |mathbf{x}| = 1 }. $$
Note
This class follows the Physics conventions (ISO 80000-2:2019).
- Parameters:
See also
NoneThe counterpart in $R^3$, adding the polar distance coordinate $r$.
Examples
>>> import unxt as u >>> import coordinax as cx
We can construct a 2-spherical coordinate:
>>> s2 = cx.vecs.TwoSpherePos(theta=u.Quantity(0, "deg"), ... phi=u.Quantity(180, "deg"))
This coordinate has corresponding velocity class:
>>> s2.time_derivative_cls <class 'coordinax...TwoSphereVel'>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos2D
- components = ('theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angle'), 'theta': PhysicalType('angle')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
TwoSphereVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
theta:
Shaped[AbstractAngle, '*#batch']# Inclination angle \(\theta \in [0,180]\).
-
phi:
Shaped[AbstractAngle, '*#batch']# Azimuthal angle \(\phi \in [0,360)\).
- class coordinax.vecs.TwoSphereVel(theta: Any, phi: Any)#
Bases:
AbstractVel2DVel on the 2-Sphere.
The space of coordinates on the unit sphere is called the 2-sphere or $S^2$. It is a two-dimensional surface embedded in three-dimensional space, defined by the set of all points at a unit distance from a central point. Mathematically, this is:
$$ S^2 = { mathbf{x} in mathbb{R}^3 | |mathbf{x}| = 1 }. $$
Note
This class follows the Physics conventions (ISO 80000-2:2019).
- Parameters:
See also
NoneThe counterpart in $R^3$, adding the polar distance coordinate $d_r$.
Examples
>>> import unxt as u >>> import coordinax as cx
We can construct a 2-spherical velocity:
>>> s2 = cx.vecs.TwoSphereVel(theta=u.Quantity(0, "deg/s"), ... phi=u.Quantity(2, "deg/s"))
This coordinate has corresponding position and acceleration class:
>>> s2.time_antiderivative_cls <class 'coordinax...TwoSpherePos'>
>>> s2.time_derivative_cls <class 'coordinax...TwoSphereAcc'>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel2D
- components = ('theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'theta': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
TwoSpherePos
- time_derivative_cls#
alias of
TwoSphereAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.TwoSphereAcc(theta: Any, phi: Any)#
Bases:
AbstractAcc2DVel on the 2-Sphere.
The space of coordinates on the unit sphere is called the 2-sphere or $S^2$. It is a two-dimensional surface embedded in three-dimensional space, defined by the set of all points at a unit distance from a central point. Mathematically, this is:
$$ S^2 = { mathbf{x} in mathbb{R}^3 | |mathbf{x}| = 1 }. $$
Note
This class follows the Physics conventions (ISO 80000-2:2019).
- Parameters:
See also
NoneThe counterpart in $R^3$, adding the polar distance coordinate $d_r$.
Examples
>>> import unxt as u >>> import coordinax as cx
We can construct a 2-spherical acceleration:
>>> s2 = cx.vecs.TwoSphereAcc(theta=u.Quantity(0, "deg/s2"), ... phi=u.Quantity(2, "deg/s2"))
This coordinate has corresponding velocity class:
>>> s2.time_antiderivative_cls <class 'coordinax...TwoSphereVel'>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc2D
- components = ('theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angular acceleration'), 'theta': PhysicalType('angular acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
TwoSphereVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.PolarPos(r: ArgT | PassThroughTs, phi: ArgT | PassThroughTs)#
Bases:
AbstractPos2DPolar vector representation.
- Parameters:
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos2D
- components = ('r', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angle'), 'r': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Return type:
Shaped[AbstractDistance, '*#batch']
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.PolarPos(r=u.Quantity(1, "m"), ... phi=u.Quantity(90, "deg")) >>> vec.norm() Distance(Array(1, dtype=int32, ...), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Shaped[AbstractDistance, '*#batch']# Radial distance \(r \in [0,+\infty)\).
-
phi:
Shaped[AbstractAngle, '*#batch']# Polar angle, generally \(\phi \in [0,2\pi)\).
We use the symbol phi to adhere to the ISO standard 31-11.
- class coordinax.vecs.PolarVel(r: Any, phi: Any)#
Bases:
AbstractVel2DPolar Velocity.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vev = cx.vecs.PolarVel(r=u.Quantity(1, "m/s"), phi=u.Quantity(90, "deg/s")) >>> print(vev) <PolarVel: (r[m / s], phi[deg / s]) [ 1 90]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel2D
- components = ('r', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'r': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# Radial speed \(dr/dt \in [-\infty,+\infty]\).
-
phi:
Real[Quantity[PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})], '*#batch']# Polar angular speed \(d\phi/dt \in [-\infty,+\infty]\).
- class coordinax.vecs.PolarAcc(r: Any, phi: Any)#
Bases:
AbstractAcc2DPolar acceleration.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> acc = cx.vecs.PolarAcc(r=u.Quantity(1, "m/s2"), ... phi=u.Quantity(3, "deg/s2")) >>> print(acc) <PolarAcc: (r[m / s2], phi[deg / s2]) [1 3]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc2D
- components = ('r', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angular acceleration'), 'r': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# Radial acceleration \(d^2r/dt^2 \in [-\infty,+\infty]\).
-
phi:
Real[Quantity[PhysicalType('angular acceleration')], '*#batch']# Polar angular acceleration \(d^2\phi/dt^2 \in [-\infty,+\infty]\).
- class coordinax.vecs.CartesianPos2D(x: Any, y: Any)#
Bases:
AbstractCartesian,AbstractPos2DCartesian 2D Position.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> print(vec) <CartesianPos2D: (x, y) [m] [1 2]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos2D
- components = ('x', 'y')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType('length'), 'y': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
CartesianVel2D
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Shaped[Quantity[PhysicalType('length')], '*#batch']# X coordinate \(x \in (-\infty,+\infty)\).
-
y:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Y coordinate \(y \in (-\infty,+\infty)\).
- class coordinax.vecs.CartesianVel2D(x: Any, y: Any)#
Bases:
AbstractCartesian,AbstractVel2DCartesian 2D Velocity.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVel2D.from_([1, 2], "m/s") >>> print(vec) <CartesianVel2D: (x, y) [m / s] [1 2]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel2D
- components = ('x', 'y')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType({'speed', 'velocity'}), 'y': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractPos2D | None = None, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx >>> v = cx.vecs.CartesianVel2D.from_([3, 4], "km/s") >>> v.norm() Quantity(Array(5., dtype=float32), unit='km / s')
- Parameters:
_ (
AbstractPos2D|None)- Return type:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianPos2D
- time_derivative_cls#
alias of
CartesianAcc2D
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# X coordinate differential \(\dot{x} \in (-\infty,+\infty)\).
-
y:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# Y coordinate differential \(\dot{y} \in (-\infty,+\infty)\).
- class coordinax.vecs.CartesianAcc2D(x: Any, y: Any)#
Bases:
AbstractCartesian,AbstractAcc2DCartesian Acceleration 3D.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianAcc2D.from_([1, 2], "m/s2") >>> print(vec) <CartesianAcc2D: (x, y) [m / s2] [1 2]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc2D
- components = ('x', 'y')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType('acceleration'), 'y': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractVel2D | None = None, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx >>> v = cx.vecs.CartesianAcc2D.from_([3, 4], "km/s2") >>> v.norm() Quantity(Array(5., dtype=float32), unit='km / s2')
- Parameters:
_ (
AbstractVel2D|None)- Return type:
Real[Quantity[PhysicalType('acceleration')], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianVel2D
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# X coordinate acceleration \(\frac{d^2 x}{dt^2} \in (-\infty,+\infty)\).
-
y:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# Y coordinate acceleration \(\frac{d^2 y}{dt^2} \in (-\infty,+\infty)\).
- class coordinax.vecs.AbstractPos3D#
Bases:
AbstractPosAbstract representation of 3D coordinates in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractVel3D#
Bases:
AbstractVelAbstract representation of 3D vector differentials.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractAcc3D#
Bases:
AbstractAccAbstract representation of 3D vector accelerations.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.CartesianPos3D(x: Any, y: Any, z: Any)#
Bases:
AbstractCartesian,AbstractPos3DCartesian 3D Position.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_(u.Quantity([1, 2, 3], "m")) >>> print(vec) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ('x', 'y', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType('length'), 'y': PhysicalType('length'), 'z': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
CartesianVel3D
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Shaped[Quantity[PhysicalType('length')], '*#batch']# X coordinate \(x \in (-\infty,+\infty)\).
-
y:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Y coordinate \(y \in (-\infty,+\infty)\).
-
z:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Z coordinate \(z \in (-\infty,+\infty)\).
- class coordinax.vecs.CartesianVel3D(x: Any, y: Any, z: Any)#
Bases:
AbstractCartesian,AbstractVel3DCartesian 3D Velocity.
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(vec) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('x', 'y', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType({'speed', 'velocity'}), 'y': PhysicalType({'speed', 'velocity'}), 'z': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractPos3D | None = None, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx >>> c = cx.CartesianVel3D.from_([1, 2, 3], "km/s") >>> c.norm() Quantity(Array(3.7416575, dtype=float32), unit='km / s')
- Parameters:
_ (
AbstractPos3D|None)- Return type:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianPos3D
- time_derivative_cls#
alias of
CartesianAcc3D
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# `dx/dt in [-infty, infty].
- Type:
X speed
- Type:
math
- class coordinax.vecs.CartesianAcc3D(x: Any, y: Any, z: Any)#
Bases:
AbstractCartesian,AbstractAcc3DCartesian differential representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ('x', 'y', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'x': PhysicalType('acceleration'), 'y': PhysicalType('acceleration'), 'z': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractVel3D | None = None, __: AbstractPos3D | None = None, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx >>> c = cx.vecs.CartesianAcc3D.from_([1, 2, 3], "km/s2") >>> c.norm() Quantity(Array(3.7416575, dtype=float32), unit='km / s2')
- Parameters:
_ (
AbstractVel3D|None)__ (
AbstractPos3D|None)
- Return type:
Real[Quantity[PhysicalType('acceleration')], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianVel3D
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# `d^2x/dt^2 in [-infty, infty].
- Type:
X acceleration
- Type:
math
- class coordinax.vecs.CylindricalPos(rho: ArgT | PassThroughTs, phi: ArgT | PassThroughTs, z: Any)#
Bases:
AbstractPos3DCylindrical vector representation.
This adheres to ISO standard 31-11.
- Parameters:
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ('rho', 'phi', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angle'), 'rho': PhysicalType('length'), 'z': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Return type:
Shaped[Quantity[PhysicalType('length')], '*#batch']
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv >>> c = cxv.CylindricalPos(rho=u.Quantity(3, "km"), ... phi=u.Quantity(0, "deg"), ... z=u.Quantity(4, "km")) >>> c.norm() Quantity(Array(5., dtype=float32, ...), unit='km')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
CylindricalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
rho:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Cylindrical radial distance \(\rho \in [0,+\infty)\).
-
phi:
Shaped[AbstractAngle, '*#batch']# Azimuthal angle, generally \(\phi \in [0,360)\).
-
z:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Height \(z \in (-\infty,+\infty)\).
- class coordinax.vecs.CylindricalVel(rho: Any, phi: Any, z: Any)#
Bases:
AbstractVel3DCylindrical velocity.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CylindricalVel(rho=u.Quantity(1, "km/s"), ... phi=u.Quantity(2, "deg/s"), ... z=u.Quantity(3, "km/s")) >>> print(vec) <CylindricalVel: (rho[km / s], phi[deg / s], z[km / s]) [1 2 3]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('rho', 'phi', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'rho': PhysicalType({'speed', 'velocity'}), 'z': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CylindricalPos
- time_derivative_cls#
alias of
CylindricalAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
rho:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# `drho/dt in [-infty, infty].
- Type:
Cyindrical radial speed
- Type:
math
- class coordinax.vecs.CylindricalAcc(rho: Any, phi: Any, z: Any)#
Bases:
AbstractAcc3DCylindrical acceleration representation.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CylindricalAcc(rho=u.Quantity(1, "km/s2"), ... phi=u.Quantity(2, "deg/s2"), ... z=u.Quantity(3, "km/s2")) >>> print(vec) <CylindricalAcc: (rho[km / s2], phi[deg / s2], z[km / s2]) [1 2 3]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ('rho', 'phi', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angular acceleration'), 'rho': PhysicalType('acceleration'), 'z': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CylindricalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
rho:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# `d^2rho/dt^2 in [-infty, infty].
- Type:
Cyindrical radial acceleration
- Type:
math
- class coordinax.vecs.AbstractSphericalPos#
Bases:
AbstractPos3DAbstract spherical vector representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractSphericalVel#
Bases:
AbstractVel3DSpherical differential representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.AbstractSphericalAcc#
Bases:
AbstractAcc3DSpherical acceleration representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.SphericalPos(r: ArgT | PassThroughTs, theta: Any, phi: ArgT | PassThroughTs)#
Bases:
AbstractSphericalPosSpherical-Polar coordinates.
Note
This class follows the Physics conventions (ISO 80000-2:2019).
- Parameters:
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ('r', 'theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angle'), 'r': PhysicalType('length'), 'theta': PhysicalType('angle')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
SphericalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Shaped[AbstractDistance, '*#batch']# Radial distance \(r \in [0,+\infty)\).
-
theta:
Shaped[AbstractAngle, '*#batch']# Inclination angle \(\theta \in [0,180]\).
-
phi:
Shaped[AbstractAngle, '*#batch']# Azimuthal angle, generally \(\phi \in [0,360)\).
- class coordinax.vecs.SphericalVel(r: Any, theta: Any, phi: Any)#
Bases:
AbstractSphericalVelSpherical velocity.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('r', 'theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'r': PhysicalType({'speed', 'velocity'}), 'theta': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
SphericalPos
- time_derivative_cls#
alias of
SphericalAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# `dr/dt in [-infty, infty].
- Type:
Radial speed
- Type:
math
- class coordinax.vecs.SphericalAcc(r: Any, theta: Any, phi: Any)#
Bases:
AbstractSphericalAccSpherical differential representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ('r', 'theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angular acceleration'), 'r': PhysicalType('acceleration'), 'theta': PhysicalType('angular acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
SphericalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# `d^2r/dt^2 in [-infty, infty].
- Type:
Radial acceleration
- Type:
math
- class coordinax.vecs.MathSphericalPos(r: ArgT | PassThroughTs, theta: ArgT | PassThroughTs, phi: Any)#
Bases:
AbstractSphericalPosSpherical vector representation.
Note
This class follows the Mathematics conventions.
- Parameters:
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ('r', 'theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angle'), 'r': PhysicalType('length'), 'theta': PhysicalType('angle')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Return type:
Shaped[AbstractDistance, '*#batch']
Examples
>>> import unxt as u >>> import coordinax as cx >>> s = cx.vecs.MathSphericalPos(r=u.Quantity(3, "km"), ... theta=u.Quantity(90, "deg"), ... phi=u.Quantity(0, "deg")) >>> s.norm() Distance(Array(3, dtype=int32, ...), unit='km')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
MathSphericalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Shaped[AbstractDistance, '*#batch']# Radial distance \(r \in [0,+\infty)\).
-
theta:
Shaped[AbstractAngle, '*#batch']# Azimuthal angle, generally \(\theta \in [0,360)\).
-
phi:
Shaped[AbstractAngle, '*#batch']# Inclination angle \(\phi \in [0,180]\).
- class coordinax.vecs.MathSphericalVel(r: Any, theta: Any, phi: Any)#
Bases:
AbstractSphericalVelSpherical differential representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('r', 'theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'r': PhysicalType({'speed', 'velocity'}), 'theta': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
MathSphericalPos
- time_derivative_cls#
alias of
MathSphericalAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# `dr/dt in [-infty, infty].
- Type:
Radial speed
- Type:
math
- class coordinax.vecs.MathSphericalAcc(r: Any, theta: Any, phi: Any)#
Bases:
AbstractSphericalAccSpherical acceleration representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ('r', 'theta', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'phi': PhysicalType('angular acceleration'), 'r': PhysicalType('acceleration'), 'theta': PhysicalType('angular acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
MathSphericalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
r:
Real[Quantity[PhysicalType('acceleration')], '*#batch']# `d^2r/dt^2 in [-infty, infty].
- Type:
Radial acceleration
- Type:
math
- class coordinax.vecs.LonLatSphericalPos(lon: ArgT | PassThroughTs, lat: Any, distance: ArgT | PassThroughTs)#
Bases:
AbstractSphericalPosSpherical vector representation.
Note
This class follows the Geographic / Astronomical convention.
- Parameters:
lon (
Union[TypeVar(ArgT),TypeVar(PassThroughTs)]) – The longitude (azimuthal) angle [0, 360) [deg] where 0 is the x-axis.lat (
Any) – The latitude (polar angle) [-90, 90] [deg] where 90 is the z-axis.distance (
Union[TypeVar(ArgT),TypeVar(PassThroughTs)]) – Radial distance r (slant distance to origin),
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.LonLatSphericalPos(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(0, "deg"), ... distance=u.Quantity(3, "km")) >>> print(vec) <LonLatSphericalPos: (lon[deg], lat[deg], distance[km]) [0 0 3]>
The longitude and latitude angles are in the range [0, 360) and [-90, 90] degrees, and the radial distance is non-negative. When initializing, the longitude is wrapped to the [0, 360) degrees range.
>>> vec = cx.vecs.LonLatSphericalPos(lon=u.Quantity(365, "deg"), ... lat=u.Quantity(90, "deg"), ... distance=u.Quantity(3, "km")) >>> vec.lon Angle(Array(5, dtype=int32, ...), unit='deg')
The latitude is not wrapped, but it is checked to be in the [-90, 90] degrees range.
>>> import jax >>> with jax.disable_jit(): ... try: ... cx.vecs.LonLatSphericalPos(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(100, "deg"), ... distance=u.Quantity(3, "km")) ... except Exception as e: ... print(e) The inclination angle must be in the range [0, pi]...
Likewise, the radial distance is checked to be non-negative.
>>> with jax.disable_jit(): ... try: ... cx.vecs.LonLatSphericalPos(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(0, "deg"), ... distance=u.Quantity(-3, "km")) ... except Exception as e: ... print(e) Distance must be non-negative.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ('lon', 'lat', 'distance')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'distance': PhysicalType('length'), 'lat': PhysicalType('angle'), 'lon': PhysicalType('angle')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Return type:
Shaped[AbstractDistance, '*#batch']
Examples
>>> import unxt as u >>> import coordinax as cx >>> s = cx.vecs.LonLatSphericalPos(lon=u.Quantity(0, "deg"), ... lat=u.Quantity(90, "deg"), ... distance=u.Quantity(3, "km")) >>> s.norm() Distance(Array(3, dtype=int32, ...), unit='km')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
LonLatSphericalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
lon:
Shaped[AbstractAngle, '*#batch']# Longitude (azimuthal) angle \(\in [0,360)\).
-
lat:
Shaped[AbstractAngle, '*#batch']# Latitude (polar) angle \(\in [-90,90]\).
-
distance:
Shaped[AbstractDistance, '*#batch']# Radial distance \(r \in [0,+\infty)\).
- class coordinax.vecs.LonLatSphericalVel(lon: Any, lat: Any, distance: Any)#
Bases:
AbstractSphericalVelSpherical velocity.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('lon', 'lat', 'distance')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'distance': PhysicalType({'speed', 'velocity'}), 'lat': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'lon': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
LonLatSphericalPos
- time_derivative_cls#
alias of
LonLatSphericalAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
lon:
Real[Quantity[PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})], '*#batch']# `dlon/dt in [-infty, infty].
- Type:
Longitude speed
- Type:
math
- class coordinax.vecs.LonLatSphericalAcc(lon: Any, lat: Any, distance: Any)#
Bases:
AbstractSphericalAccSpherical acceleration representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ('lon', 'lat', 'distance')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'distance': PhysicalType('acceleration'), 'lat': PhysicalType('angular acceleration'), 'lon': PhysicalType('angular acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
LonLatSphericalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
lon:
Real[Quantity[PhysicalType('angular acceleration')], '*#batch']# `d^2lon/dt^2 in [-infty, infty].
- Type:
Longitude acceleration
- Type:
math
- class coordinax.vecs.LonCosLatSphericalVel(lon_coslat: Any, lat: Any, distance: Any)#
Bases:
AbstractSphericalVelSpherical differential representation.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('lon_coslat', 'lat', 'distance')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'distance': PhysicalType({'speed', 'velocity'}), 'lat': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'}), 'lon_coslat': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
LonLatSphericalPos
- time_derivative_cls#
alias of
LonLatSphericalAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
lon_coslat:
Real[Quantity[PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})], '*#batch']# `dlon/dt in [-infty, infty].
- Type:
Longitude * cos(Latitude) speed
- Type:
math
- class coordinax.vecs.ProlateSpheroidalPos(mu: Any, nu: Any, phi: ArgT | PassThroughTs, *, Delta: Shaped[Quantity[PhysicalType('length')], ''])#
Bases:
AbstractPos3DProlate spheroidal coordinates as defined by Dejonghe & de Zeeuw 1988.
Note that valid coordinates have: $- mu >= Delta^2 - |nu| <= Delta^2 - Delta > 0$
- Parameters:
mu (
Any) – The spheroidal mu coordinate. This is called lambda by Dejonghe & de Zeeuw. Surfaces of constant mu are ellipsoids with foci at the origin and at (Delta, 0, 0).nu (
Any) – The spheroidal nu coordinate. Surfaces of constant nu are hyperboloids of two sheets.phi (
Union[TypeVar(ArgT),TypeVar(PassThroughTs)]) – Azimuthal angle [0, 360) [deg] where 0 is the x-axis.Delta (
Shaped[Quantity[PhysicalType('length')], '']) – The focal length of the coordinate system. Must be > 0.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> vec = cxv.ProlateSpheroidalPos( ... mu=u.Quantity(3.0, "km2"), ... nu=u.Quantity(0.5, "km2"), ... phi=u.Quantity(0.25, "rad"), ... Delta=u.Quantity(1.5, "km"), ... ) >>> print(vec) <ProlateSpheroidalPos: (mu[km2], nu[km2], phi[rad]) Delta=Quantity(1.5, unit='km') [3. 0.5 0.25]>
This fails with a zero or negative Delta:
>>> try: vec = cxv.ProlateSpheroidalPos( ... mu=u.Quantity(3.0, "km2"), ... nu=u.Quantity(0.5, "km2"), ... phi=u.Quantity(0.25, "rad"), ... Delta=u.Quantity(0.0, "km"), ... ) ... except Exception as e: pass
Or with invalid mu and nu:
>>> try: vec = cxv.ProlateSpheroidalPos( ... mu=u.Quantity(0.5, "km2"), ... nu=u.Quantity(0.5, "km2"), ... phi=u.Quantity(0.25, "rad"), ... Delta=u.Quantity(1.5, "km"), ... ) ... except Exception as e: pass
We can convert to other coordinates:
>>> sph = vec.vconvert(cxv.SphericalPos) >>> print(sph) <SphericalPos: (r[km], theta[rad], phi[rad]) [1.118 0.752 0.25 ]>
However, this is generally a one-way conversion, as the focal length parameter Delta is not retained through the conversion. To convert back to prolate spheroidal coordinates, we need to provide the focal length again:
>>> vec2 = sph.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "km")) >>> print(vec2.round(3)) <ProlateSpheroidalPos: (mu[km2], nu[km2], phi[rad]) Delta=Quantity(1.5, unit='km') [3. 0.5 0.25]>
>>> print((vec2 - vec).vconvert(cxv.CartesianPos3D)) <CartesianPos3D: (x, y, z) [km] [0. 0. 0.]>
-
Delta:
Shaped[Quantity[PhysicalType('length')], '']# Focal length of the coordinate system.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPos3D
- components = ('mu', 'nu', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'mu': PhysicalType('area'), 'nu': PhysicalType('area'), 'phi': PhysicalType('angle')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
ProlateSpheroidalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
mu:
Real[Quantity[PhysicalType('area')], '*#batch']# Spheroidal mu coordinate \(\mu \in [0,+\infty)\) (called \(\lambda\) in some Galactic dynamics contexts).
-
nu:
Real[Quantity[PhysicalType('area')], '*#batch']# Spheroidal nu coordinate \(\lambda \in [-\infty,+\infty)\).
-
phi:
Shaped[AbstractAngle, '*#batch']# Azimuthal angle, generally \(\phi \in [0,360)\).
- class coordinax.vecs.ProlateSpheroidalVel(mu: Any, nu: Any, phi: Any)#
Bases:
AbstractVel3DProlate spheroidal differential representation.
- Parameters:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos3D.from_(u.Quantity([1, 2, 3], "kpc")) >>> v = cxv.CartesianVel3D.from_(u.Quantity([4, 5, 6], "km/s"))
>>> px = x.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(4, "kpc")) >>> pv = v.vconvert(cxv.ProlateSpheroidalVel, px)
>>> print(pv.vconvert(cxv.CartesianVel3D, px)) <CartesianVel3D: (x, y, z) [km / s] [4. 5. 6.]>
>>> print(pv.vconvert(cxv.CartesianVel3D, x, Delta=u.Quantity(4, "kpc"))) <CartesianVel3D: (x, y, z) [km / s] [4. 5. 6.]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVel3D
- components = ('mu', 'nu', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'mu': PhysicalType({'diffusivity', 'kinematic viscosity'}), 'nu': PhysicalType({'diffusivity', 'kinematic viscosity'}), 'phi': PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
ProlateSpheroidalPos
- time_derivative_cls#
alias of
ProlateSpheroidalAcc
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
mu:
Real[Quantity[PhysicalType({'diffusivity', 'kinematic viscosity'})], '*#batch']# Prolate spheroidal mu speed $dmu/dt in [-infty, infty]$.
-
nu:
Real[Quantity[PhysicalType({'diffusivity', 'kinematic viscosity'})], '*#batch']# Prolate spheroidal nu speed $dnu/dt in [-infty, infty]$.
-
phi:
Real[Quantity[PhysicalType({'angular frequency', 'angular speed', 'angular velocity'})], '*#batch']# Azimuthal speed $dphi/dt in [-infty, infty]$.
- class coordinax.vecs.ProlateSpheroidalAcc(mu: Any, nu: Any, phi: Any)#
Bases:
AbstractAcc3DProlate spheroidal acceleration representation.
- Parameters:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
>>> x = cxv.CartesianPos3D.from_(u.Quantity([1, 2, 3], "kpc")) >>> v = cxv.CartesianVel3D.from_(u.Quantity([4, 5, 6], "km/s")) >>> a = cxv.CartesianAcc3D.from_(u.Quantity([4, 5, 6], "km/s2"))
>>> px = x.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(4, "kpc")) >>> pa = a.vconvert(cxv.ProlateSpheroidalAcc, v, px)
>>> print(pa.vconvert(cxv.CartesianAcc3D, v, px)) <CartesianAcc3D: (x, y, z) [km / s2] [4. 5. 6.]>
>>> print(pa.vconvert(cxv.CartesianAcc3D, v, x, Delta=u.Quantity(4, "kpc"))) <CartesianAcc3D: (x, y, z) [km / s2] [4. 5. 6.]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAcc3D
- components = ('mu', 'nu', 'phi')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'mu': PhysicalType({'dose of ionizing radiation', 'specific energy'}), 'nu': PhysicalType({'dose of ionizing radiation', 'specific energy'}), 'phi': PhysicalType('angular acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
ProlateSpheroidalVel
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
mu:
Real[Quantity[PhysicalType({'dose of ionizing radiation', 'specific energy'})], '*#batch']# Prolate spheroidal mu acceleration $d^2mu/dt^2 in [-infty, infty]$.
-
nu:
Real[Quantity[PhysicalType({'dose of ionizing radiation', 'specific energy'})], '*#batch']# Prolate spheroidal nu acceleration $d^2nu/dt^2 in [-infty, infty]$.
-
phi:
Real[Quantity[PhysicalType('angular acceleration')], '*#batch']# Azimuthal acceleration $d^2phi/dt^2 in [-infty, infty]$.
- class coordinax.vecs.Cartesian3D(x: Any, y: Any, z: Any)#
Bases:
AvalMixin,AbstractVectorGeneric 3D Cartesian coordinates.
The fields of this class are not restricted to any specific dimensions. For specific dimensions, use the specialized classes:
coordinax.vecs.CartesianPos3D
coordinax.vecs.CartesianVel3D
coordinax.vecs.CartesianAcc3D
Examples
>>> import coordinax as cx >>> vec = cx.vecs.Cartesian3D.from_([1, 2, 3], "kg m /s") >>> print(vec) <Cartesian3D: (x, y, z) [kg m / s] [1 2 3]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- components = ('x', 'y', 'z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- property dimensions: dict[str, PhysicalType]#
Vector physical dimensions.
Examples
>>> import coordinax as cx
>>> cx.vecs.Cartesian3D.dimensions <property object at ...>
>>> q = cx.vecs.Cartesian3D.from_([1, 2, 3], "km") >>> q.dimensions {'x': PhysicalType('length'), 'y': PhysicalType('length'), 'z': PhysicalType('length')}
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Compute the norm of the vector.
- Return type:
Examples
>>> import coordinax as cx >>> q = cx.vecs.Cartesian3D.from_([1, 2, 3], "km") >>> print(q.norm()) Quantity['length'](3.7416575, unit='km')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
x:
Shaped[AbstractQuantity, '*#batch']#
-
y:
Shaped[AbstractQuantity, '*#batch']#
-
z:
Shaped[AbstractQuantity, '*#batch']#
- class coordinax.vecs.AbstractPos4D#
Bases:
AbstractPosAbstract representation of 4D coordinates in different systems.
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.FourVector(t: ~typing.Any, q: ~dataclassish._src.converters.ArgT | ~dataclassish._src.converters.PassThroughTs, *, c: ~jaxtyping.Shaped[Quantity[PhysicalType({'speed', 'velocity'})], ''] = VectorAttribute(default=Quantity(Array(299792.47, dtype=float32, weak_type=True), unit='km / s'), converter=<function identity>))#
Bases:
AbstractPos4D3+1 vector representation.
The 3+1 vector representation is a 4-vector with 3 spatial coordinates and 1 time coordinate.
- Parameters:
Examples
>>> import unxt as u >>> import coordinax as cx
Create a 3+1 vector with a time and 3 spatial coordinates:
>>> w = cx.FourVector (t=u.Quantity(1, "s"), q=u.Quantity([1, 2, 3], "m")) >>> print(w) <FourVector: (t[s], q=(x, y, z) [m]) [1 1 2 3]>
Note that we used a shortcut to create the 3D vector by passing a
(*batch, 3)array to the q argument. This assumes that q is a coordinax.CartesianPos3D and uses thecoordinax.CartesianPos3D.from_()method to create the 3D vector.We can also create a 3D vector explicitly:
>>> q = cx.SphericalPos(theta=u.Quantity(1, "deg"), phi=u.Quantity(2, "deg"), ... r=u.Quantity(3, "m")) >>> w = cx.FourVector (t=u.Quantity(1, "s"), q=q) >>> print(w) <FourVector: (t[s], q=(r[m], theta[deg], phi[deg])) [1 3 1 2]>
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
-
c:
Shaped[Quantity[PhysicalType({'speed', 'velocity'})], '']# Speed of light, by default
Quantity(299_792.458, "km/s").
- cartesian_type#
alias of
CartesianPos3D
- components = ('t', 'q')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- property dimensions: dict[str, PhysicalType]#
Vector physical dimensions.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> cx.FourVector.dimensions <property object at ...>
>>> w = cx.FourVector (t=u.Quantity(1, "s"), q=u.Quantity([1, 2, 3], "m")) >>> w.dimensions {'t': PhysicalType('time'), 'q': {'x': PhysicalType('length'), 'y': PhysicalType('length'), 'z': PhysicalType('length')}}
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the vector norm \(\sqrt{(ct)^2 - (x^2 + y^2 + z^2)}\).
- Return type:
Shaped[Quantity[PhysicalType('length')], '*#batch']
Examples
>>> import unxt as u >>> import coordinax as cx
>>> w = cx.FourVector (t=u.Quantity(1, "s"), q=u.Quantity([1, 2, 3], "m")) >>> w.norm() Quantity(Array(299792.47+0.j, dtype=complex64), unit='km')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
t:
Real[Quantity[PhysicalType('time')], '*#batch']|Real[Quantity[PhysicalType('time')], '']# Time coordinate.
-
q:
AbstractPos3D# Spatial coordinates.
- class coordinax.vecs.AbstractPosND#
Bases:
AbstractPosAbstract representation of N-D coordinates in different systems.
- property T: Self#
Transpose the vector.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[[1, 2]], [[3, 4]]], "m") >>> vec.shape (2, 1)
>>> vec.T.shape (1, 2)
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPosND
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the N-dimensional position.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[[1, 2]], [[3, 4]]], "m") >>> vec.shape (2, 1)
>>> vec.flatten().shape (2,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
The last axis is interpreted as the feature axis. The matrix transpose is performed on the last two batch axes.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianPosND(u.Quantity([[[1, 2, 3]], ... [[4, 5, 6]]], "m")) >>> vec.shape (2, 1)
>>> vec.mT.shape (1, 2)
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the N-dimensional position.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[1, 2], [3, 4]], "m") >>> vec.shape (2,)
>>> vec.reshape(1, 2, 1).shape (1, 2, 1)
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[[1, 2]], [[3, 4]]], "m") >>> vec.shape (2, 1)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
q:
AbstractVar[Real[Quantity[PhysicalType('length')], '*#batch']]#
- class coordinax.vecs.AbstractVelND#
Bases:
AbstractVelAbstract representation of N-D vector differentials.
- property T: Self#
Transpose the vector.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[[1, 2]], [[3, 4]]], "m/s") >>> vec.shape (2, 1)
>>> vec.T.shape (1, 2)
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVelND
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[1, 2], [3, 4]], "m/s") >>> vec.flatten() CartesianVelND(q=Quantity([[1, 2], [3, 4]], unit='m / s'))
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: AbstractVelND#
Transpose the vector.
The last axis is interpreted as the feature axis. The matrix transpose is performed on the last two batch axes.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[[1, 2]], [[3, 4]]], "m/s") >>> vec.shape (2, 1)
>>> vec.mT.shape (1, 2)
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos2D.from_([1, 1], "km") >>> p = cx.vecs.PolarVel(r=u.Quantity(1, "km/s"), phi=u.Quantity(1, "deg/s"))
>>> p.norm(q).uconvert('km / s') Quantity(Array(1.0003046, dtype=float32), unit='km / s')
- Parameters:
q (
AbstractPos)- Return type:
Quantity[PhysicalType({'speed', 'velocity'})]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the vector.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianVelND(u.Quantity([1, 2, 3], "m/s")) >>> vec.shape ()
>>> vec.reshape(1, 1).shape (1, 1)
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[1, 2], [3, 4]], "m/s") >>> vec.shape (2,)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
q:
AbstractVar[Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']]#
- class coordinax.vecs.AbstractAccND#
Bases:
AbstractAccAbstract representation of N-D vector differentials.
- property T: AbstractAccND#
Transpose the vector’s batch axes, preserving the feature axis.
Examples
>>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND.from_([[[1, 2, 3]], [[4, 5, 6]]], "m/s2") >>> vec.shape (2, 1) >>> vec.T.shape (1, 2)
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAccND
- components = ()#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector’s batch dimensions, preserving the component axis.
- Return type:
Examples
>>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND.from_([[[1, 2, 3]], [[4, 5, 6]]], "m/s2") >>> vec.shape (2, 1)
>>> vec.flatten().shape (2,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: AbstractAccND#
Transpose the vector.
The last axis is interpreted as the feature axis. The matrix transpose is performed on the last two batch axes.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND(u.Quantity([[[1, 2, 3]], ... [[4, 5, 6]]], "m/s2")) >>> vec.shape (2, 1)
>>> vec.mT.shape (1, 2)
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(p: AbstractVel, q: AbstractPos, /)#
Return the norm of the vector.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([3, 4, 0], "m/s2")
>>> a = a.vconvert(cx.vecs.CylindricalAcc, p, q)
>>> a.norm(p, q) Quantity(Array(5..., dtype=float32), unit='m / s2')
- Parameters:
self (
AbstractAcc)p (
AbstractVel)q (
AbstractPos)
- Return type:
Quantity[PhysicalType('acceleration')]
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the vector.
Examples
>>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND.from_([1, 2, 3], "m/s2") >>> vec.shape ()
>>> vec.reshape(1, 1).shape (1, 1)
- Parameters:
- Return type:
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND(u.Quantity([[[1, 2, 3]], ... [[4, 5, 6]]], "m/s2")) >>> vec.shape (2, 1)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
q:
AbstractVar[Real[Quantity[PhysicalType('acceleration')], '*#batch']]#
- class coordinax.vecs.CartesianPosND(q: Any)#
Bases:
AbstractPosND,AbstractCartesian,NumpyNegMixinN-dimensional Cartesian vector representation.
Examples
>>> import coordinax as cx >>> import unxt as u
A 1D vector:
>>> q = cx.vecs.CartesianPosND.from_([[1]], "km") >>> q.q Quantity(Array([[1]], dtype=int32), unit='km') >>> q.shape (1,)
A 2D vector:
>>> q = cx.vecs.CartesianPosND(u.Quantity([1, 2], "km")) >>> q.q Quantity(Array([1, 2], dtype=int32), unit='km') >>> q.shape ()
A 3D vector:
>>> q = cx.vecs.CartesianPosND(u.Quantity([1, 2, 3], "km")) >>> q.q Quantity(Array([1, 2, 3], dtype=int32), unit='km') >>> q.shape ()
A 4D vector:
>>> q = cx.vecs.CartesianPosND(u.Quantity([1, 2, 3, 4], "km")) >>> q.q Quantity(Array([1, 2, 3, 4], dtype=int32), unit='km') >>> q.shape ()
A 5D vector:
>>> q = cx.vecs.CartesianPosND(u.Quantity([1, 2, 3, 4, 5], "km")) >>> q.q Quantity(Array([1, 2, 3, 4, 5], dtype=int32), unit='km') >>> q.shape ()
- Parameters:
q (
Any)
- property T: Self#
Transpose the vector.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[[1, 2]], [[3, 4]]], "m") >>> vec.shape (2, 1)
>>> vec.T.shape (1, 2)
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianPosND
- components = ('q',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'q': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the N-dimensional position.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[[1, 2]], [[3, 4]]], "m") >>> vec.shape (2, 1)
>>> vec.flatten().shape (2,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
The last axis is interpreted as the feature axis. The matrix transpose is performed on the last two batch axes.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianPosND(u.Quantity([[[1, 2, 3]], ... [[4, 5, 6]]], "m")) >>> vec.shape (2, 1)
>>> vec.mT.shape (1, 2)
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Return type:
Shaped[Quantity[PhysicalType('length')], '*#batch']
Examples
>>> import unxt as u >>> import coordinax as cx
A 3D vector:
>>> q = cx.vecs.CartesianPosND(u.Quantity([1, 2, 3], "km")) >>> q.norm() Quantity(Array(3.7416575, dtype=float32), unit='km')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the N-dimensional position.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[1, 2], [3, 4]], "m") >>> vec.shape (2,)
>>> vec.reshape(1, 2, 1).shape (1, 2, 1)
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPosND.from_([[[1, 2]], [[3, 4]]], "m") >>> vec.shape (2, 1)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_derivative_cls#
alias of
CartesianVelND
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.CartesianVelND(q: Any)#
Bases:
AbstractCartesian,AbstractVelNDCartesian differential representation.
Examples
>>> import unxt as u >>> import coordinax as cx
A 1D vector:
>>> q = cx.vecs.CartesianVelND(u.Quantity([[1]], "km/s")) >>> q.q Quantity(Array([[1]], dtype=int32), unit='km / s') >>> q.shape (1,)
A 2D vector:
>>> q = cx.vecs.CartesianVelND(u.Quantity([1, 2], "km/s")) >>> q.q Quantity(Array([1, 2], dtype=int32), unit='km / s') >>> q.shape ()
A 3D vector:
>>> q = cx.vecs.CartesianVelND(u.Quantity([1, 2, 3], "km/s")) >>> q.q Quantity(Array([1, 2, 3], dtype=int32), unit='km / s') >>> q.shape ()
A 4D vector:
>>> q = cx.vecs.CartesianVelND(u.Quantity([1, 2, 3, 4], "km/s")) >>> q.q Quantity(Array([1, 2, 3, 4], dtype=int32), unit='km / s') >>> q.shape ()
A 5D vector:
>>> q = cx.vecs.CartesianVelND(u.Quantity([1, 2, 3, 4, 5], "km/s")) >>> q.q Quantity(Array([1, 2, 3, 4, 5], dtype=int32), unit='km / s') >>> q.shape ()
- Parameters:
q (
Any)
- property T: Self#
Transpose the vector.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[[1, 2]], [[3, 4]]], "m/s") >>> vec.shape (2, 1)
>>> vec.T.shape (1, 2)
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianVelND
- components = ('q',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'q': PhysicalType({'speed', 'velocity'})}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[1, 2], [3, 4]], "m/s") >>> vec.flatten() CartesianVelND(q=Quantity([[1, 2], [3, 4]], unit='m / s'))
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: AbstractVelND#
Transpose the vector.
The last axis is interpreted as the feature axis. The matrix transpose is performed on the last two batch axes.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[[1, 2]], [[3, 4]]], "m/s") >>> vec.shape (2, 1)
>>> vec.mT.shape (1, 2)
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(_: AbstractPosND | None = None, /)#
Return the norm of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
A 3D vector:
>>> c = cx.vecs.CartesianVelND(u.Quantity([1, 2, 3], "km/s")) >>> c.norm() Quantity(Array(3.7416575, dtype=float32), unit='km / s')
- Parameters:
_ (
AbstractPosND|None)- Return type:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the vector.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianVelND(u.Quantity([1, 2, 3], "m/s")) >>> vec.shape ()
>>> vec.reshape(1, 1).shape (1, 1)
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianVelND.from_([[1, 2], [3, 4]], "m/s") >>> vec.shape (2,)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianPosND
- time_derivative_cls#
alias of
CartesianAccND
- classmethod time_nth_derivative_cls(*, n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.CartesianAccND(q: Any)#
Bases:
AbstractCartesian,AbstractAccNDCartesian N-dimensional acceleration representation.
Examples
>>> import unxt as u >>> import coordinax as cx
A 1D vector:
>>> q = cx.vecs.CartesianAccND(u.Quantity([[1]], "km/s2")) >>> q.q Quantity(Array([[1]], dtype=int32), unit='km / s2') >>> q.shape (1,)
A 2D vector:
>>> q = cx.vecs.CartesianAccND(u.Quantity([1, 2], "km/s2")) >>> q.q Quantity(Array([1, 2], dtype=int32), unit='km / s2') >>> q.shape ()
A 3D vector:
>>> q = cx.vecs.CartesianAccND(u.Quantity([1, 2, 3], "km/s2")) >>> q.q Quantity(Array([1, 2, 3], dtype=int32), unit='km / s2') >>> q.shape ()
A 4D vector:
>>> q = cx.vecs.CartesianAccND(u.Quantity([1, 2, 3, 4], "km/s2")) >>> q.q Quantity(Array([1, 2, 3, 4], dtype=int32), unit='km / s2') >>> q.shape ()
A 5D vector:
>>> q = cx.vecs.CartesianAccND(u.Quantity([1, 2, 3, 4, 5], "km/s2")) >>> q.q Quantity(Array([1, 2, 3, 4, 5], dtype=int32), unit='km / s2') >>> q.shape ()
- Parameters:
q (
Any)
- property T: AbstractAccND#
Transpose the vector’s batch axes, preserving the feature axis.
Examples
>>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND.from_([[[1, 2, 3]], [[4, 5, 6]]], "m/s2") >>> vec.shape (2, 1) >>> vec.T.shape (1, 2)
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- cartesian_type#
alias of
CartesianAccND
- components = ('q',)#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'q': PhysicalType('acceleration')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector’s batch dimensions, preserving the component axis.
- Return type:
Examples
>>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND.from_([[[1, 2, 3]], [[4, 5, 6]]], "m/s2") >>> vec.shape (2, 1)
>>> vec.flatten().shape (2,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: AbstractAccND#
Transpose the vector.
The last axis is interpreted as the feature axis. The matrix transpose is performed on the last two batch axes.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND(u.Quantity([[[1, 2, 3]], ... [[4, 5, 6]]], "m/s2")) >>> vec.shape (2, 1)
>>> vec.mT.shape (1, 2)
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm(velocity: AbstractVelND | None = None, position: AbstractPosND | None = None, /)#
Return the norm of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
A 3D vector:
>>> c = cx.vecs.CartesianAccND(u.Quantity([1, 2, 3], "km/s2")) >>> c.norm() Quantity(Array(3.7416575, dtype=float32), unit='km / s2')
- Parameters:
velocity (
AbstractVelND|None)position (
AbstractPosND|None)
- Return type:
Real[Quantity[PhysicalType('acceleration')], '*#batch']
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the vector.
Examples
>>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND.from_([1, 2, 3], "m/s2") >>> vec.shape ()
>>> vec.reshape(1, 1).shape (1, 1)
- Parameters:
- Return type:
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import unxt as u >>> import coordinax as cx >>> vec = cx.vecs.CartesianAccND(u.Quantity([[[1, 2, 3]], ... [[4, 5, 6]]], "m/s2")) >>> vec.shape (2, 1)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- time_antiderivative_cls#
alias of
CartesianVelND
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
- class coordinax.vecs.PoincarePolarVector(rho: Any, pp_phi: Real[Quantity[PhysicalType('unknown')], '*#batch'], z: Any, dt_rho: Any, dt_pp_phi: Real[Quantity[PhysicalType('unknown')], '*#batch'], dt_z: Any)#
Bases:
AbstractPosPoincare vector + differential.
- Parameters:
- property T: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.T.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~unxt._src.quantity.base.AbstractQuantity]] = <class 'dict'>)#
Return the vector as a Mapping.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractQuantity]]) – The type of the mapping to return.- Returns:
The vector as a mapping.
- Return type:
Mapping[str, Quantity]
See also
NoneThis applies recursively to the components of the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the vector as a mapping:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.asdict() {'x': Quantity(Array([[1, 2], [3, 4]], dtype=int32), unit='m'), 'y': Quantity(Array(0, dtype=int32, ...), unit='m')}
- components = ('rho', 'pp_phi', 'z', 'dt_rho', 'dt_pp_phi', 'dt_z')#
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.devices mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})
- dimensions = {'dt_pp_phi': PhysicalType('unknown'), 'dt_rho': PhysicalType({'speed', 'velocity'}), 'dt_z': PhysicalType({'speed', 'velocity'}), 'pp_phi': PhysicalType('unknown'), 'rho': PhysicalType('length'), 'z': PhysicalType('length')}#
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.dtypes mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- property mT: Self#
Transpose the vector.
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can transpose a vector:
>>> vec = cx.CartesianPos3D(x=u.Quantity([[0, 1], [2, 3]], "m"), ... y=u.Quantity([[0, 1], [2, 3]], "m"), ... z=u.Quantity([[0, 1], [2, 3]], "m")) >>> vec.mT.x Quantity(Array([[0, 2], [1, 3]], dtype=int32), unit='m')
- property ndim: int#
Number of array dimensions (axes).
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can get the number of dimensions of a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([1, 2], "m") >>> vec.ndim 0
>>> vec = cx.vecs.CartesianPos2D.from_([[1, 2], [3, 4]], "m") >>> vec.ndim 1
ndimis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.ndim 2
- norm()#
Return the norm of the vector.
- Returns:
The norm of the vector.
- Return type:
Quantity
Examples
>>> import unxt as u >>> import coordinax as cx
>>> v = cx.vecs.CartesianPos1D.from_([-1], "km") >>> v.norm() BareQuantity(Array(1., dtype=float32), unit='km')
>>> v = cx.vecs.CartesianPos2D.from_([3, 4], "km") >>> v.norm() BareQuantity(Array(5., dtype=float32), unit='km')
>>> v = cx.vecs.PolarPos(r=u.Quantity(3, "km"), phi=u.Quantity(90, "deg")) >>> v.norm() Distance(Array(3, dtype=int32, ...), unit='km')
>>> v = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> v.norm() BareQuantity(Array(3.7416575, dtype=float32), unit='m')
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- represent_as(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVel]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.
- Return type:
Examples
>>> import coordinax as cx
Transforming a Position:
>>> q_cart = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> q_sph = q_cart.represent_as(cx.SphericalPos) >>> q_sph SphericalPos( ... ) >>> q_sph.r Distance(Array(3.7416575, dtype=float32), unit='m')
Transforming a Velocity:
>>> v_cart = cx.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.represent_as(cx.SphericalVel, q_cart) >>> v_sph SphericalVel( ... )
Transforming an Acceleration:
>>> a_cart = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.represent_as(cx.vecs.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Return the shape of the vector.
Examples
>>> import unxt as u >>> import coordinax as cx
We can get the shape of a vector:
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([1, 2], "m")) >>> vec.shape (2,)
>>> vec = cx.vecs.CartesianPos1D(x=u.Quantity([[1, 2], [3, 4]], "m")) >>> vec.shape (2, 2)
shapeis calculated from the broadcasted shape. We can see this by creating a 2D vector in which the components have different shapes:>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> space = cx.KinematicSpace(length=vec) >>> space.shape (2, 2)
- property shapes: MappingProxyType#
Get the shapes of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.shapes mappingproxy({'x': (), 'y': (), 'z': ()})
- property size#
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> cx.vecs.CartesianPos2D.from_([1, 2], "m").sizes mappingproxy({'x': 1, 'y': 1})
>>> cx.vecs.CartesianPos2D.from_([[1, 2], [1, 2]], "m").sizes mappingproxy({'x': 2, 'y': 2})
- classmethod time_nth_derivative_cls(n: int)#
Return the corresponding time nth derivative class.
- Parameters:
n (
int)- Return type:
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
Examples
>>> import coordinax as cx >>> vec = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> vec.units mappingproxy({'x': Unit("km"), 'y': Unit("km"), 'z': Unit("km")})
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type:
-
rho:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Cylindrical radial distance \(\rho \in [0,+\infty)\).
-
pp_phi:
Real[Quantity[PhysicalType('unknown')], '*#batch']# Poincare phi-like variable.
-
z:
Shaped[Quantity[PhysicalType('length')], '*#batch']# Height \(z \in (-\infty,+\infty)\).
-
dt_rho:
Real[Quantity[PhysicalType({'speed', 'velocity'})], '*#batch']# `drho/dt in [-infty, infty].
- Type:
Cyindrical radial speed
- Type:
math
-
dt_pp_phi:
Real[Quantity[PhysicalType('unknown')], '*#batch']# Poincare phi-like velocity variable.
- class coordinax.vecs.KinematicSpace(*args: Mapping[PhysicalType | str, Any] | tuple[PhysicalType | str, Any] | Iterable[tuple[PhysicalType | str, Any]], **kwargs: Any)#
Bases:
AbstractVectorLike,ImmutableMap[str,AbstractVector],Generic[PosT]A collection of vectors that acts like the primary vector.
- Parameters:
*args (
Mapping[PhysicalType|str,Any] |tuple[PhysicalType|str,Any] |Iterable[tuple[PhysicalType|str,Any]]) – See input to dict for the input data.**kwargs (
Any) – See input to dict for the input data.
Examples
>>> import coordinax as cx
>>> x = cx.CartesianPos3D.from_([1, 2, 3], "km") >>> v = cx.CartesianVel3D.from_([4, 5, 6], "km/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "km/s^2")
All the vectors can be brought together into a space:
>>> space = cx.KinematicSpace(length=x, speed=v, acceleration=a) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [km] [1 2 3]>, 'speed': <CartesianVel3D: (x, y, z) [km / s] [4 5 6]>, 'acceleration': <CartesianAcc3D: (x, y, z) [km / s2] [7 8 9]> })
The vectors can initialized from unxt.Quantity objects and can have (brodcastable) batch shapes:
>>> w = cx.KinematicSpace( ... length=u.Quantity([[8.5, 0, 0], [10, 0, 0]], "kpc"), ... speed=u.Quantity([0, 200, 0], "km/s")) >>> print(w) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [kpc] [[ 8.5 0. 0. ] [10. 0. 0. ]]>, 'speed': <CartesianVel3D: (x, y, z) [km / s] [ 0 200 0]> })
The vectors can then be accessed by key:
>>> space["length"] CartesianPos3D( ... )
The space can also be converted to different representations. If the conversion is on the primary vector, the other vectors will be correspondingly converted.
>>> space.vconvert(cx.SphericalPos) KinematicSpace({ 'length': SphericalPos( ... ), 'speed': SphericalVel( ... ), 'acceleration': SphericalAcc( ... ) })
>>> cx.vconvert(cx.SphericalPos, space) KinematicSpace({ 'length': SphericalPos( ... ), 'speed': SphericalVel( ... ), 'acceleration': SphericalAcc( ... ) })
Actions on the space are done on the contained vectors.
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> w.ndim 2
>>> w.shape (1, 2)
>>> w.shapes mappingproxy({'length': (1, 2), 'speed': (1, 2)})
>>> w.mT.shapes mappingproxy({'length': (2, 1), 'speed': (2, 1)})
There are convenience ways to initialize the vectors in the space:
>>> space = cx.KinematicSpace.from_({"length": u.Quantity([1, 2, 3], "km"), ... "speed": u.Quantity([4, 5, 6], "km/s")}) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [km] [1 2 3]>, 'speed': <CartesianVel3D: (x, y, z) [km / s] [4 5 6]> })
- property T: Self#
Transpose each vector in the space.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> w.T.shapes mappingproxy({'length': (2, 1), 'speed': (2, 1)})
- asdict(*, dict_factory: ~collections.abc.Callable[[~typing.Any], ~collections.abc.Mapping[str, ~coordinax._src.vectors.base.vector.AbstractVector]] = <class 'dict'>)#
Return the vector collection as a Mapping.
See also
NoneThis applies recursively to the components of the vector.
- Parameters:
dict_factory (
Callable[[Any],Mapping[str,AbstractVector]])- Return type:
- components#
Descriptor for class properties.
- Parameters:
fget (classmethod | staticmethod) – The class/staticmethod wrapped function to be used as the getter for the class-level property.
Examples
>>> from coordinax._src.utils import classproperty >>> class MyConstants: ... @classproperty ... def pau(cls) -> float: ... return 4.71 >>> MyConstants.pau 4.71
- copy()#
Return a copy of the vector.
- Return type:
Self
Examples
>>> import coordinax as cx
>>> vec = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> print(vec.copy()) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
- property devices: MappingProxyType#
Get the devices of the vector’s components.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> w.devices mappingproxy({'length': mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)}), 'speed': mappingproxy({'x': CpuDevice(id=0), 'y': CpuDevice(id=0), 'z': CpuDevice(id=0)})})
- property dtype#
- property dtypes: MappingProxyType#
Get the dtypes of the vector’s components.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> w.dtypes mappingproxy({'length': mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')}), 'speed': mappingproxy({'x': dtype('int32'), 'y': dtype('int32'), 'z': dtype('int32')})})
- flatten()#
Flatten the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.flatten().shape (4,)
- classmethod from_(cls: type[AbstractVectorLike], *args: Any, **kwargs: Any)#
Create a vector-like object from arguments.
Examples
>>> import coordinax.vecs as cxv
>>> q = cxv.CartesianPos3D.from_([1, 2, 3], "m") >>> print(q) <CartesianPos3D: (x, y, z) [m] [1 2 3]>
>>> v = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> print(v) <CartesianVel3D: (x, y, z) [m / s] [1 2 3]>
>>> space = cxv.KinematicSpace.from_(q) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- from_(cls: type[AbstractVector], *args: Any, **kwargs: Any) AbstractVector
- Parameters:
- Return type:
Create a vector from arguments.
See coordinax.vector for more information.
- from_(cls: type[KinematicSpace], obj: KinematicSpace, /) KinematicSpace
- Parameters:
- Return type:
Construct a Space, returning the KinematicSpace.
Examples
>>> import coordinax as cx
>>> q = cx.KinematicSpace.from_(cx.CartesianPos3D.from_([1, 2, 3], "m")) >>> cx.KinematicSpace.from_(q) is q True
- from_(cls: type[KinematicSpace], obj: AbstractPos, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> w = cx.KinematicSpace.from_(q) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.CartesianVel3D.from_([4, 5, 6], "m/s") >>> w = cx.KinematicSpace.from_(q, p) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ) })
- from_(cls: type[KinematicSpace], q: AbstractPos, p: AbstractVel, a: AbstractAcc, /) KinematicSpace
- Parameters:
- Return type:
Construct a coordinax.KinematicSpace from a coordinax.AbstractPos.
Examples
>>> import coordinax as cx
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "m") >>> p = cx.vecs.CartesianVel3D.from_([4, 5, 6], "m/s") >>> a = cx.vecs.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> w = cx.KinematicSpace.from_(q, p, a) >>> w KinematicSpace({ 'length': CartesianPos3D( ... ), 'speed': CartesianVel3D( ... ), 'acceleration': CartesianAcc3D( ... ) })
- from_(cls: type[KinematicSpace], obj: Mapping[str, Any]) KinematicSpace
- Parameters:
- Return type:
Construct a KinematicSpace from a Mapping.
Examples
>>> import unxt as u >>> import coordinax as cx
>>> space = cx.KinematicSpace.from_({ 'length': u.Quantity([1, 2, 3], "m") }) >>> print(space) KinematicSpace({ 'length': <CartesianPos3D: (x, y, z) [m] [1 2 3]> })
- Parameters:
cls (
type[AbstractVectorLike])args (
Any)kwargs (
Any)
- Return type:
- get(key: K, /, default: V | _T | None = None)#
Get an item by key.
Examples
>>> from xmmutablemap import ImmutableMap >>> d = ImmutableMap(a=1, b=2) >>> d.get("a") 1 >>> d.get("c") >>> d.get("c", 3) 3
- items()#
Return the items.
- Return type:
Examples
>>> from xmmutablemap import ImmutableMap >>> d = ImmutableMap(a=1, b=2) >>> d.items() dict_items([('a', 1), ('b', 2)])
- keys()#
Return the keys.
Examples
>>> from xmmutablemap import ImmutableMap >>> d = ImmutableMap(a=1, b=2) >>> d.keys() dict_keys(['a', 'b'])
- property ndim: int#
Get the number of dimensions of the vector.
When represented as a single array, the vector has an additional dimension at the end for the components.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([7, 8, 9], "m/s") ... )
>>> w.ndim 2
- property q: PosT#
Get the position vector of the space.
- ravel()#
Ravel the vector.
- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m")) >>> vec.shape (2, 2)
>>> vec.ravel().shape (4,)
- reshape(*shape: Any, order: str = 'C')#
Reshape the components of the vector.
- Parameters:
- Return type:
Self
Examples
We assume the following imports:
>>> import unxt as u >>> import coordinax as cx
We can reshape a vector:
>>> vec = cx.vecs.CartesianPos2D(x=u.Quantity([[1, 2], [3, 4]], "m"), ... y=u.Quantity(0, "m"))
>>> vec.reshape(4) CartesianPos2D(x=Quantity([1, 2, 3, 4], unit='m'), y=Quantity([0, 0, 0, 0], unit='m'))
- round(decimals: int = 0)#
Round the components of the vector.
- Parameters:
decimals (
int) – The number of decimals to round to.- Return type:
Self
Examples
>>> import unxt as u >>> import coordinax as cx
We can round a vector:
>>> vec = cx.vecs.CartesianPos2D.from_([[1.1, 2.2], [3.3, 4.4]], "m") >>> vec.round(0) CartesianPos2D(x=Quantity([1., 3.], unit='m'), y=Quantity([2., 4.], unit='m'))
- property shape: tuple[int, ...]#
Get the shape of the vector’s components.
When represented as a single array, the vector has an additional dimension at the end for the components.
- property shapes: MappingProxyType#
Get the shapes of the spaces’s fields.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> w.shapes mappingproxy({'length': (1, 2), 'speed': (1, 2)})
- property size: int#
Total number of elements in the vector.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") )
>>> w.size 2
- property sizes: MappingProxyType#
Get the sizes of the vector’s components.
Examples
>>> import coordinax as cx
>>> w = cx.KinematicSpace( ... length=cx.CartesianPos3D.from_([[[1, 2, 3], [4, 5, 6]]], "m"), ... speed=cx.CartesianVel3D.from_([[[1, 2, 3], [4, 5, 6]]], "m/s") ... )
>>> w.sizes mappingproxy({'length': 6, 'speed': 6})
- to_device(device: None | Device = None)#
Move the vector to a new device.
Examples
>>> from jax import devices >>> import unxt as u >>> import coordinax as cx
We can move a vector to a new device:
>>> vec = cx.vecs.CartesianPos1D(u.Quantity([1, 2], "m")) >>> vec.to_device(devices()[0]) CartesianPos1D(x=Quantity([1, 2], unit='m'))
- tree_flatten()#
Flatten dict to the values (and keys).
This is used for JAX’s tree flattening.
Examples
>>> import jax >>> from xmmutablemap import ImmutableMap >>> d = ImmutableMap(a=1, b=2) >>> d.tree_flatten() ((1, 2), ('a', 'b'))
>>> jax.tree.flatten(d) ([1, 2], PyTreeDef(CustomNode(ImmutableMap[('a', 'b')], [*, *])))
- classmethod tree_unflatten(aux_data: Annotated[tuple[K, ...], Doc('The keys.')], children: Annotated[tuple[V, ...], Doc('The values.')])#
Unflatten into an ImmutableMap from the keys and values.
This is used for JAX’s tree un-flattening.
Examples
>>> import jax >>> from xmmutablemap import ImmutableMap >>> d = ImmutableMap(a=1, b=2) >>> flat = d.tree_flatten() >>> ImmutableMap.tree_unflatten(*flat) ImmutableMap({1: 'a', 2: 'b'})
>>> jax.tree.unflatten(jax.tree.structure(d), flat) ImmutableMap({'a': (1, 2), 'b': ('a', 'b')})
- uconvert(*args: Any, **kw: Any)#
Convert the vector to the given units.
This just forwards to unxt.uconvert, reversing the order of the arguments to match the unxt API.
Examples
>>> import coordinax as cx
>>> vec = cx.vecs.CartesianPos3D.from_([1, 2, 3], "km")
>>> vec.uconvert({"length": "km"}) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> vec.uconvert(cx.vecs.ToUnitsOptions.consistent) CartesianPos3D( x=Quantity(1, unit='km'), y=Quantity(2, unit='km'), z=Quantity(3, unit='km') )
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> print(vec.uconvert(usys)) <CartesianPos3D: (x, y, z) [m] [1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic")) <CartesianPos3D: (x, y, z) [kpc] [3.241e-17 6.482e-17 9.722e-17]>
- property units: MappingProxyType#
Get the units of the vector’s components.
- values()#
Return the values.
- Return type:
Examples
>>> from xmmutablemap import ImmutableMap >>> d = ImmutableMap(a=1, b=2) >>> d.values() dict_values([1, 2])
- vconvert(target: type, *args: Any, **kwargs: Any)#
Represent the vector as another type.
This just forwards to coordinax.vconvert.
- Parameters:
target (type[coordinax.AbstractVectorLike]) – The type to represent the vector as.
*args (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.**kwargs (
Any) – Extra arguments. These are passed to coordinax.vconvert and might be used, depending on the dispatched method. E.g. for transforming an acceleration, generally the first argument is the velocity (coordinax.AbstractVel) followed by the position (coordinax.AbstractPos) at which the acceleration is defined. In general this is a required argument, though it is not for Cartesian-to-Cartesian transforms – see https://en.wikipedia.org/wiki/Tensors_in_curvilinear_coordinates for more information.self (AbstractVectorLike)
- Return type:
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- vconvert(self: AbstractVectorLike, target: type, *args: Any, **kwargs: Any) AbstractVectorLike
- Parameters:
self (AbstractVectorLike)
target (type)
args (Any)
kwargs (Any)
- Return type:
Represent the vector as another type, forwarding to coordinax.vconvert.
Examples
>>> import unxt as u >>> import coordinax.vecs as cxv
Transforming a Position:
>>> q_cart = cxv.CartesianPos3D.from_([1, 2, 3], "m")
>>> q_sph = q_cart.vconvert(cxv.SphericalPos) >>> print(q_sph) <SphericalPos: (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
>>> q_ps = q_cart.vconvert(cxv.ProlateSpheroidalPos, Delta=u.Quantity(1.5, "m")) >>> print(q_ps) <ProlateSpheroidalPos: (mu[m2], nu[m2], phi[rad]) Delta=Quantity(1.5, unit='m') [14.89 1.36 1.107]>
>>> print((q_ps.vconvert(cxv.CartesianPos3D) - q_cart).round(3)) <CartesianPos3D: (x, y, z) [m] [-0. 0. 0.]>
Transforming a Velocity:
>>> v_cart = cxv.CartesianVel3D.from_([1, 2, 3], "m/s") >>> v_sph = v_cart.vconvert(cxv.SphericalVel, q_cart) >>> print(v_sph) <SphericalVel: (r[m / s], theta[rad / s], phi[rad / s]) [ 3.742e+00 -8.941e-08 0.000e+00]>
Transforming an Acceleration:
>>> a_cart = cxv.CartesianAcc3D.from_([7, 8, 9], "m/s2") >>> a_sph = a_cart.vconvert(cxv.SphericalAcc, v_cart, q_cart) >>> print(a_sph) <SphericalAcc: (r[m / s2], theta[rad / s2], phi[rad / s2]) [13.363 0.767 -1.2 ]>
- Parameters:
self (
AbstractVectorLike)target (type)
args (Any)
kwargs (Any)
- Return type: