coordinax.vectors#
The coordinax.vectors module provides vector objects for storing and transforming coordinate data with explicit chart and representation semantics.
Overview#
A vector stores three pieces: data (component values), chart (coordinate system), and representation (transformation law).
For design philosophy, practical patterns, and worked examples, see Working With Vectors. For mathematical foundations, see spec Β§ Vectors.
Quick Start#
import coordinax.main as cx
import coordinax.charts as cxc
import coordinax.representations as cxr
import unxt as u
# ββ Point ββββββββββββββββββββββββββββββββββββββββββββββββββ
p = cx.Point.from_([1, 2, 3], "m")
p_sph = cx.cconvert(p, cxc.sph3d)
# ββ Tangent ββββββββββββββββββββββββββββββββββββββββββββββββ
# A velocity vector β transforms by Jacobian pushforward
v = cx.Tangent.from_(
{"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
cxc.cart3d,
cxr.coord_vel,
)
# Convert a Tangent β must supply the base Point via `at=`
v_sph = v.cconvert(cxc.sph3d, at=p)
# ββ Coordinate βββββββββββββββββββββββββββββββββββββββββββββ
# Bundle: base Point + named Tangent fibre fields
pv = cx.Coordinate(point=p, velocity=v)
pv_sph = pv.cconvert(cxc.sph3d) # converts point AND velocity together
See Working With Vectors and Working With Tangent Vectors for all construction patterns and design rationale.
Functional API#
Constructors & Conversion#
Point.from_: flexible multiple-dispatch constructor from arrays, quantities, or dictionariescconvert: coordinate conversion between charts (representation-aware)uconvert: unit conversion
Shape & Structure#
flatten(): flatten all components to a 1D viewreshape(*shape): reshape components while preserving chart semantics__getitem__(): slice and index vectors
Arithmetic & Operations#
Vectors support JAX-style arithmetic via quax operators:
+,-: vector addition and subtraction*,/: scalar multiplication and divisionnorm(): Euclidean norm of componentscopy(): create a copy (viadataclass.replace)
Additional utilities:
astype(dtype): cast components to a new dtyperound(decimals): round componentsto_device(device): move to a new device
Available Objects#
Point: a geometric point storing data + chart + representation (alwaysPointGeometry)Tangent: a tangent-space vector with explicit basis and semantic kind (velocity, displacement, acceleration)Coordinate: a vector bundle β aPointpaired with namedTangentfibre fields anchored at that pointAbstractVector: base class defining the vector interfaceToUnitsOptions: configuration for unit conversion behavior
Design & Integration#
For design philosophy, architecture, and immutability details, see Working With Vectors. For tangent-vector patterns (basis, semantic kind, Jacobian pushforward), see Working With Tangent Vectors. For JAX integration patterns (PyTree, scalar-first design, vmap/jit/grad), see Working With Vectors.
.. py:module:: coordinax.vectors
coordinax.vectors Module.
.. py:function:: cconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Transform the current vector to the target chart.
This is an abstract API definition. See the main coordinax package for concrete implementations.
.. rubric:: Examples
import coordinax.representations as cxr import coordinax.charts as cxc
Define a point in Cartesian coordinates:
p = {βxβ: 1.0, βyβ: 2.0, βzβ: 3.0}
Convert it to spherical coordinates:
cxr.cconvert(p, cxc.cart3d, cxr.point, cxc.sph3d, cxr.point) {βrβ: Array(3.74165739, dtype=float64, β¦), βthetaβ: Array(0.64052231, dtype=float64), βphiβ: Array(1.10714872, dtype=float64, β¦)}
.. py:function:: cconvert(obj: NoneType, /, *fixed_args: Any, **fixed_kw: Any) -> Any :noindex:
Return a partial function for vector conversion.
Convert a point from Cartesian coordinates to spherical coordinates:
import coordinax.representations as cxr import coordinax.charts as cxc
Define a point in Cartesian coordinates:
q = {βxβ: 1.0, βyβ: 2.0, βzβ: 3.0}
Convert it to spherical coordinates:
map = cxr.cconvert(None, cxc.cart3d, cxr.point, cxc.sph3d) map(q) {βrβ: Array(3.74165739, dtype=float64, β¦), βthetaβ: Array(0.64052231, dtype=float64), βphiβ: Array(1.10714872, dtype=float64, β¦)}
.. py:function:: cconvert(x: Any, from_chart: coordinax._src.base.charts.AbstractChart, from_rep: coordinax.representations._src.rep.Representation, to_chart: coordinax._src.base.charts.AbstractChart, to_rep: coordinax.representations._src.rep.Representation, /, *, at: dict[str, typing.Any] | None = None, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> Any :noindex:
Convert point data between charts.
Convert a point from Cartesian coordinates to spherical coordinates:
import coordinax.representations as cxr import coordinax.charts as cxc
Define a point in Cartesian coordinates:
p = {βxβ: 1.0, βyβ: 2.0, βzβ: 3.0}
Convert it to spherical coordinates:
q = cxr.cconvert(p, cxc.cart3d, cxr.point, cxc.sph3d, cxr.point) q {βrβ: Array(3.74165739, dtype=float64, β¦), βthetaβ: Array(0.64052231, dtype=float64), βphiβ: Array(1.10714872, dtype=float64, β¦)}
The output q represents the same geometric point but expressed in the
target chart.
The representation remains unchanged; only the chart changes:
cxr.cconvert(q, cxc.sph3d, cxr.point, cxc.cart3d, cxr.point) {βxβ: Array(1., dtype=float64), βyβ: Array(2., dtype=float64), βzβ: Array(3., dtype=float64)}
Letβs work through more examples.
Cartesian to Spherical (with units):
import unxt as u p = {βxβ: u.Q(1.0, βmβ), βyβ: u.Q(0.0, βmβ), βzβ: u.Q(0.0, βmβ)} cxr.cconvert(p, cxc.cart3d, cxr.point, cxc.sph3d, cxr.point) {βrβ: Q(1., βmβ), βthetaβ: Q(1.57079633, βradβ), βphiβ: Q(0., βradβ)}
Cylindrical to Cartesian (without units):
p = {βrhoβ: 3.0, βphiβ: 0, βzβ: 4.0} cxr.cconvert(p, cxc.cyl3d, cxr.point, cxc.cart3d, cxr.point) {βxβ: Array(3., dtype=float64, β¦), βyβ: Array(0., dtype=float64, β¦), βzβ: 4.0}
Polar to Cartesian (2D):
p = {βrβ: u.Q(5.0, βmβ), βthetaβ: u.Q(90, βdegβ)} cxr.cconvert(p, cxc.polar2d, cxr.point, cxc.cart2d, cxr.point) {βxβ: Q(3.061617e-16, βmβ), βyβ: Q(5., βmβ)}
Between Spherical variants (Spherical to LonLatSpherical):
p = {βrβ: u.Q(1.0, βmβ), βthetaβ: u.Q(45, βdegβ), βphiβ: u.Q(0, βdegβ)} cxr.cconvert(p, cxc.sph3d, cxr.point, cxc.lonlat_sph3d, cxr.point) {βlonβ: Q(0, βdegβ), βlatβ: Q(45., βdegβ), βdistanceβ: Q(1., βmβ)}
Identity conversion (same chart):
p = {βxβ: u.Q(2.0, βmβ), βyβ: u.Q(3.0, βmβ)} cxr.cconvert(p, cxc.cart2d, cxr.point, cxc.cart2d, cxr.point) is p True
.. py:function:: cconvert(x: Any, from_chart: coordinax._src.base.charts.AbstractChart, from_rep: coordinax.representations._src.rep.Representation, to_chart: coordinax._src.base.charts.AbstractChart, /, *, at: dict[str, typing.Any] | None = None, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> Any :noindex:
Convert point data between charts.
Convert a point from Cartesian coordinates to spherical coordinates:
import coordinax.representations as cxr import coordinax.charts as cxc
Define a point in Cartesian coordinates:
p = {βxβ: 1.0, βyβ: 2.0, βzβ: 3.0}
Convert it to spherical coordinates:
q = cxr.cconvert(p, cxc.cart3d, cxr.point, cxc.sph3d) q {βrβ: Array(3.74165739, dtype=float64, β¦), βthetaβ: Array(0.64052231, dtype=float64), βphiβ: Array(1.10714872, dtype=float64, β¦)}
The output q represents the same geometric point but expressed in the
target chart.
The representation remains unchanged; only the chart changes:
cxr.cconvert(q, cxc.sph3d, cxr.point, cxc.cart3d) {βxβ: Array(1., dtype=float64), βyβ: Array(2., dtype=float64), βzβ: Array(3., dtype=float64)}
.. py:function:: cconvert(x: Any, from_chart: coordinax._src.base.charts.AbstractChart, from_geom: coordinax.representations._src.geom.PointGeometry, from_rep: coordinax.representations._src.rep.Representation, to_chart: coordinax._src.base.charts.AbstractChart, to_geom: coordinax.representations._src.geom.PointGeometry, to_rep: coordinax.representations._src.rep.Representation, /, *, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> Any :noindex:
Convert point data between charts.
This function delegates to coordinax.charts.pt_map. The representation
arguments are checked to ensure they correspond to canonical point data:
Convert a point from Cartesian coordinates to spherical coordinates:
import coordinax.representations as cxr import coordinax.charts as cxc
Define a point in Cartesian coordinates:
p = {βxβ: 1.0, βyβ: 2.0, βzβ: 3.0}
Convert it to spherical coordinates:
cxr.cconvert(p, cxc.cart3d, cxr.point_geom, cxr.point, β¦ cxc.sph3d, cxr.point_geom, cxr.point) {βrβ: Array(3.74165739, dtype=float64, β¦), βthetaβ: Array(0.64052231, dtype=float64), βphiβ: Array(1.10714872, dtype=float64, β¦)}
.. py:function:: cconvert(x: Any, from_chart: coordinax._src.base.charts.AbstractChart, from_geom: coordinax.representations._src.geom.TangentGeometry, from_rep: coordinax.representations._src.rep.Representation, to_chart: coordinax._src.base.charts.AbstractChart, to_geom: coordinax.representations._src.geom.TangentGeometry, to_rep: coordinax.representations._src.rep.Representation, /, *, at: dict[str, typing.Any] | None = None, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> Any :noindex:
Convert tangent data between charts via Jacobian pushforward.
import jax.numpy as jnp import coordinax.charts as cxc import coordinax.representations as cxr
v = {βrβ: jnp.array(5.0), βthetaβ: jnp.array(1.0), βphiβ: jnp.array(2.0)} at = {βrβ: jnp.array(3.0), βthetaβ: jnp.array(0.5), βphiβ: jnp.array(0.0)} cxr.cconvert(v, cxc.sph3d, cxr.tangent_geom, cxr.coord_disp, β¦ cxc.sph3d, cxr.tangent_geom, cxr.phys_disp, at=at) {βrβ: Array(5., dtype=float64, β¦), βthetaβ: Array(3., dtype=float64, β¦), βphiβ: Array(β¦, dtype=float64, β¦)}
v = {βxβ: jnp.array(1.0), βyβ: jnp.array(0.0)} at = {βxβ: jnp.array(1.0), βyβ: jnp.array(0.0)} cxr.cconvert(v, cxc.cart2d, cxr.coord_disp, cxc.polar2d, cxr.coord_disp, at=at) {βrβ: Array(1., β¦), βthetaβ: Array(0., β¦)}
.. py:function:: cconvert(from_vec: coordinax.vectors._src.point.Point, to_chart: coordinax._src.base.charts.AbstractChart, /, *, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> coordinax.vectors._src.point.Point :noindex:
Convert a point from one chart to another.
import unxt as u import coordinax.main as cx
vec = cx.Point.from_([1, 1, 1], βmβ) print(vec) <Point: chart=Cart3D (x, y, z) [m] [1 1 1]>
sph_vec = cx.cconvert(vec, cx.sph3d) print(sph_vec) <Point: chart=Spherical3D (r[m], theta[rad], phi[rad]) [1.732 0.955 0.785]>
.. py:function:: cconvert(from_vec: coordinax.vectors._src.point.Point, from_chart: coordinax._src.base.charts.AbstractChart, to_chart: coordinax._src.base.charts.AbstractChart, /, *, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> coordinax.vectors._src.point.Point :noindex:
Convert a vector from one chart to another.
import unxt as u import coordinax.main as cx
vec = cx.Point.from_([1, 1, 1], βmβ) sph_vec = cx.cconvert(vec, cx.cart3d, cx.sph3d) print(sph_vec) <Point: chart=Spherical3D (r[m], theta[rad], phi[rad]) [1.732 0.955 0.785]>
.. py:function:: cconvert(from_vec: coordinax.vectors._src.tangent.Tangent, to_chart: coordinax._src.base.charts.AbstractChart, /, *, at: Any = None, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> coordinax.vectors._src.tangent.Tangent :noindex:
Convert a tangent Tangent from one chart to another.
The at parameter provides the base point at which the tangent map
(Jacobian pushforward) is evaluated. It may be a Point instance
(whose .data is used) or a raw CDict.
import unxt as u import coordinax.main as cx import coordinax.charts as cxc import coordinax.representations as cxr
v = cx.Tangent.from_( β¦ {βxβ: u.Q(1.0, βm/sβ), βyβ: u.Q(0.0, βm/sβ), βzβ: u.Q(0.0, βm/sβ)}, β¦ cxc.cart3d, cxr.coord_basis, cxr.vel, β¦ ) pt = cx.Point.from_([1.0, 0.0, 0.0], βmβ) v_sph = cx.cconvert(v, cxc.sph3d, at=pt) v_sph.chart Spherical3D(M=Rn(3))
.. py:function:: cconvert(from_vec: coordinax.vectors._src.tangent.Tangent, from_chart: coordinax._src.base.charts.AbstractChart, to_chart: coordinax._src.base.charts.AbstractChart, /, *, at: Any = None, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> coordinax.vectors._src.tangent.Tangent :noindex:
Convert a tangent Tangent from one chart to another (explicit from-chart).
import unxt as u import coordinax.main as cx import coordinax.charts as cxc import coordinax.representations as cxr
v = cx.Tangent.from_( β¦ {βxβ: u.Q(1.0, βm/sβ), βyβ: u.Q(0.0, βm/sβ), βzβ: u.Q(0.0, βm/sβ)}, β¦ cxc.cart3d, cxr.coord_basis, cxr.vel, β¦ ) pt = cx.Point.from_([1.0, 0.0, 0.0], βmβ) v_sph = cx.cconvert(v, cxc.cart3d, cxc.sph3d, at=pt) v_sph.chart Spherical3D(M=Rn(3))
.. py:function:: cconvert(pv: coordinax.vectors._src.bundle.Coordinate, to_chart: coordinax._src.base.charts.AbstractChart, /, *, usys: unxt._src.unitsystems.base.AbstractUnitSystem | None = None) -> coordinax.vectors._src.bundle.Coordinate :noindex:
Convert a Coordinate to a new chart.
Delegates to Coordinate.cconvert().
import coordinax.main as cx import coordinax.charts as cxc
pt = cx.Point.from_([1.0, 0.0, 0.0], βmβ) pv = cx.Coordinate(point=pt) pv_sph = cx.cconvert(pv, cxc.sph3d) pv_sph.point.chart Spherical3D(M=Rn(3))
:type args: :sphinx_autodoc_typehints_type:\:py\:data\:\~typing.Any` :param args: :type kwargs: :sphinx_autodoc_typehints_type::py:data:`~typing.Any``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:\:py\:data\:\~typing.Any``
.. py:class:: AbstractVector() :module: coordinax.vectors :canonical: coordinax.vectors._src.base.AbstractVector
Bases: :py:class:~quax._core.ArrayValue, :py:class:~quax_blocks._src.binary.LaxBinaryOpsMixin\ [:py:obj:~typing.Any, :py:obj:~typing.Any], :py:class:~quax_blocks._src.round.LaxRoundMixin\ [:py:class:AbstractVector], :py:class:~quax_blocks._src.unary.LaxUnaryMixin\ [:py:obj:~typing.Any], :py:class:~typing.Generic\ [:py:obj:~coordinax.vectors._src.base.ChartT, :py:obj:~coordinax.vectors._src.base.GeomT, :py:obj:~coordinax.vectors._src.base.BasisT, :py:obj:~coordinax.vectors._src.base.SemanticT, :py:obj:~coordinax.vectors._src.base.V]
Abstract base class for all vector-like objects in coordinax.
AbstractVector binds three pieces of geometric information β data,
chart, and representation β into a single JAX-compatible, immutable object
that can represent points, tangent vectors, or higher-order tensors on a
smooth manifold.
Concretely, a vector stores:
data β a mapping from component name to scalar leaves (typically
unxt.Quantity), one entry per coordinate axis.chart β an
~coordinax.charts.AbstractChartthat names the coordinates, records their physical dimensions, and knows how to transition to every other chart in the same atlas.rep β a
~coordinax.representations.Representationthat encodes the geometric kind of the vector (e.g. base-manifold point, tangent displacement, physical-basis velocity) and therefore the correct transformation law under chart changes.
All concrete subclasses are immutable Equinox PyTrees and
quax.ArrayValue subclasses. Arithmetic operations (+, -,
*, β¦) are handled via Quax dispatch over JAX primitives so that
jit, vmap, and grad all work transparently.
.. attribute:: data
Mapping from chart component name to scalar value. Each leaf is
typically a `unxt.Quantity`; components are expected to be scalar
leaves so that batching is achieved through JAX broadcasting.
:type: Any
.. attribute:: chart
The chart instance (e.g. `coordinax.charts.cart3d`) that defines the
component schema and coordinate-system geometry.
:type: ChartT
.. attribute:: rep
The representation (e.g. `coordinax.representations.point`) that
selects the transformation semantics for chart conversions.
:type: coordinax.representations.Representation
.. attribute:: M
The manifold on which the vector lives.
:type: coordinax.manifolds.AbstractManifold
.. attribute:: shape
The batch shape of the vector (abstract; implemented by subclasses).
:type: tuple[int, ...]
.. method:: from_(*args, **kwargs) -> AbstractVector
Multiple-dispatch constructor. Dispatches are registered externally
via ``plum``; call ``.methods`` to inspect all overloads.
.. method:: cconvert(*args, **kwargs) -> AbstractVector
Convert to another chart or representation, forwarding to
`coordinax.representations.cconvert`.
.. method:: to_cartesian() -> AbstractVector
Shorthand for ``self.cconvert(self.chart.cartesian)``.
.. method:: uconvert(*args, **kwargs) -> AbstractVector
Convert component units by forwarding to `unxt.uconvert`.
.. method:: astype(dtype, **kwargs) -> AbstractVector
Cast all component leaves to a new dtype.
.. method:: copy() -> Self
Shallow copy via `dataclasses.replace`.
.. method:: flatten() -> Self
Flatten all component leaves.
.. method:: ravel() -> Self
Return a flattened copy (alias of ``flatten``).
.. method:: reshape(*shape) -> Self
Return a reshaped copy.
.. method:: round(decimals=0) -> Self
Return a rounded copy.
.. method:: to_device(device=None) -> Self
Move all leaves to the specified JAX device.
.. method:: is_like(obj) -> TypeIs[Self]
Class method; return ``True`` if *obj* is an instance of this class.
.. seealso::
:py:obj:`coordinax.vectors.Point`
Concrete default implementation.
:py:obj:`coordinax.vectors.AbstractCoordinate`
Vectors bound to a reference frame.
:py:obj:`coordinax.representations.cconvert`
Chart/representation conversion.
:py:obj:`coordinax.charts.AbstractChart`
Chart objects defining coordinate systems.
.. rubric:: Notes
Immutability: __setitem__ raises TypeError; use
dataclassish.replace to derive modified copies.
Not supported: materialise() (raises RuntimeError),
__complex__, __float__, __int__, __index__ (all raise
NotImplementedError), __hash__ (raises TypeError in practice
because JAX arrays are not hashable).
Dispatch: from_, cconvert, and uconvert are all
plum-dispatched. To inspect all registered overloads at runtime,
call .methods on the function object.
.. rubric:: Examples
Concrete instances are created through coordinax.vectors.Point:
import coordinax.vectors as cxv # AbstractVector not in main import coordinax.main as cx
vec = cxv.Point.from_([1, 2, 3], βmβ) print(vec) <Point: chart=Cart3D (x, y, z) [m] [1 2 3]>
cxv.AbstractVector.is_like(vec) True
Convert to spherical coordinates:
print(vec.cconvert(cx.sph3d)) <Point: chart=Spherical3D (r[m], theta[rad], phi[rad]) [3.742 0.641 1.107]>
Convert units:
print(vec.uconvert({u.dimension(βlengthβ): βkmβ})) <Point: chart=Cart3D (x, y, z) [km] [0.001 0.002 0.003]>
Arithmetic works under jit and vmap:
import jax print(jax.jit(lambda v: v * 2)(vec)) <Point: chart=Cart3D (x, y, z) [m] [2 4 6]>
.. py:attribute:: AbstractVector.data :module: coordinax.vectors :type: ~equinox._module._better_abstract.AbstractVar[~typing.Any]
The data for each component.
.. py:attribute:: AbstractVector.chart :module: coordinax.vectors :type: ~equinox._module._better_abstract.AbstractVar[~coordinax.vectors._src.base.ChartT]
The chart of the vector, e.g. `cxc.cart3d`.
.. py:attribute:: AbstractVector.rep :module: coordinax.vectors :type: ~equinox._module._better_abstract.AbstractVar[~coordinax.representations._src.rep.Representation[~coordinax.vectors._src.base.GeomT, ~coordinax.vectors._src.base.BasisT, ~coordinax.vectors._src.base.SemanticT]]
The `coordinax.representations.Representation`, e.g. `cxr.point`.
.. py:attribute:: AbstractVector.frame :module: coordinax.vectors :type: ~equinox._module._better_abstract.AbstractVar[~coordinax.frames._src.base.AbstractReferenceFrame]
The reference frame of the point. Defaults to ``cxf.noframe``.
.. py:method:: AbstractVector.from_(cls: type[~coordinax.vectors._src.base.AbstractVector], *args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors :classmethod:
Create a vector-like object from arguments.
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point.
>>> import coordinax.main as cx
>>> vec1 = cx.Point.from_([1, 2, 3], "m")
>>> vec2 = cx.Point.from_(vec1)
>>> print(vec2)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a vector from an object, and chart and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and chart info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, /) -> Any
:noindex:
Construct a point from an object.
Note that this is a pretty limited constructor since it often lacks the
necessary information to do a proper construction.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> Any
:noindex:
Construct a cartesian vector from an array and unit.
The ``ArrayLike[Any, (*#batch, N), "..."]`` is expected to have the
components as the last dimension.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> Any
:noindex:
Construct a vector from an array, unit, and chart.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> Any
:noindex:
Construct a vector from an array, unit, chart, and rep.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km")
>>> p2 = cx.Point.from_(p, cxf.alice)
>>> p2.frame
Alice()
>>> # Replace an existing frame
>>> p3 = cx.Point.from_(p2, cxf.noframe)
>>> p3.frame == cxf.noframe
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from any object with a frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> p = cx.Point.from_(
... {"x": u.Q(1, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")},
... cxf.alice,
... )
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxr.point, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.rep
point
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km", cxf.alice)
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent (identity / fast path).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v)
>>> v2 is v
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel)
>>> v.chart
Cart3D(M=Rn(3))
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and a tangent Representation.
Extracts ``basis`` and ``semantic`` from the representation. Raises
``TypeError`` if the representation's geometry kind is not
``TangentGeometry``.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
>>> v.semantic == cxr.vel
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data and chart (rep inferred from data).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data alone (chart and rep inferred).
>>> import coordinax.main as cx
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array and unit (chart inferred).
>>> import coordinax.main as cx
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s")
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and chart.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, and Representation.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, Representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel, cxf.alice
... )
>>> v.basis == cxr.coord_basis
True
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from array, unit, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: unxt._src.quantity.base.AbstractQuantity, unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from a Quantity, unit, chart, basis, and semantic.
The Quantity is converted to the given unit before construction.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... u.Q([1.0, 2.0, 3.0], "m/s"), "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v, cxf.alice)
>>> v2.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data with a frame (chart and rep inferred).
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and frame (basis/semantic inferred).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, semantic, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], pv: coordinax.vectors._src.bundle.Coordinate, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Identity: return the same Coordinate unchanged.
>>> import coordinax.main as cx
>>> pv = cx.Coordinate(point=cx.Point.from_([1.0, 2.0, 3.0], "m"))
>>> cx.Coordinate.from_(pv) is pv
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], p: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Wrap a single ``Point`` as a point-only bundle (no field vectors).
>>> import coordinax.main as cx
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> pv = cx.Coordinate.from_(p)
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], data: collections.abc.Mapping[str, typing.Any], /, *, point: coordinax.vectors._src.point.Point | None = None) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Create a ``Coordinate`` from a mapping of named objects.
The mapping may contain a ``"point"`` key for the base; the explicit
``point`` keyword argument takes precedence if both are supplied.
>>> import unxt as u
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> vel = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
... cxc.cart3d, cxr.coord_vel)
>>> pv = cx.Coordinate.from_({"point": p, "velocity": vel})
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cartesian.CartesianRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CartesianRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CartesianRepresentation
>>> vec = CartesianRepresentation(1, 2, 3, unit="km")
>>> cxv.Point.from_(vec)
Point({'x': Q(1., 'km'), 'y': Q(2., 'km'), 'z': Q(3., 'km')}, chart=Cart3D(M=Rn(3)))
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cylindrical.CylindricalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CylindricalRepresentation.
>>> import astropy.units as apyu
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CylindricalRepresentation
>>> vec = CylindricalRepresentation(rho=1 * apyu.km, phi=90 * apyu.deg,
... z=3 * apyu.km)
>>> cxv.Point.from_(vec)
Point(
{'rho': Q(1., 'km'), 'phi': Q(90., 'deg'), 'z': Q(3., 'km')},
chart=Cylindrical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.PhysicsSphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy PhysicsSphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import PhysicsSphericalRepresentation
>>> import astropy.units as apyu
>>> vec = PhysicsSphericalRepresentation(
... r=1 * apyu.kpc, theta=45 * apyu.deg, phi=90 * apyu.deg)
>>> cxv.Point.from_(vec)
Point(
{'r': Q(1., 'kpc'), 'theta': Q(45., 'deg'), 'phi': Q(90., 'deg')},
chart=Spherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.SphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import SphericalRepresentation
>>> import astropy.units as apyu
>>> vec = SphericalRepresentation(
... lon=90 * apyu.deg, lat=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.baseframe.BaseCoordinateFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy frame with data.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.ICRS(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = apyc.Galactocentric(
... x=1 * apyu.kpc, y=2 * apyu.kpc, z=3 * apyu.kpc
... )
>>> cxv.Point.from_(vec)
Point(
{'x': Q(1., 'kpc'), 'y': Q(2., 'kpc'), 'z': Q(3., 'kpc')},
chart=Cart3D(M=Rn(3)), frame=Galactocentric(...)
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.sky_coordinate.SkyCoord, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SkyCoord.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.SkyCoord(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = vec.transform_to(apyc.Galactocentric())
>>> cxv.Point.from_(vec)
Point(
{'x': Q(-9.08123957, 'kpc'), 'y': Q(0.21365468, 'kpc'), 'z': Q(0.2056243, 'kpc')},
chart=Cart3D(M=Rn(3)),
frame=Galactocentric(
galcen=Point(
{ 'lon': Q(266.4051, 'deg'), 'lat': Q(-28.936175, 'deg'),
'distance': Q(8.122, 'kpc')
},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
),
roll=Angle(0., 'deg'),
z_sun=Q(20.8, 'pc')
)
)
:type cls: :sphinx_autodoc_typehints_type:`\:py\:class\:\`type\`\\ \\\[\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\`\]`
:param cls:
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:property:: AbstractVector.M :module: coordinax.vectors :type: ~coordinax._src.base.manifold.AbstractManifold
The manifold of the vector, from the chart.
.. py:method:: AbstractVector.cconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Represent the vector as another type.
This forwards to `coordinax.representations.cconvert`.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> print(vec.cconvert(cx.sph3d))
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. py:method:: AbstractVector.to_cartesian() :module: coordinax.vectors
Return the vector in a Cartesian chart.
This just forwards to `coordinax.cartesian_chart` and `cconvert`.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m").cconvert(cx.sph3d)
>>> print(vec)
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
>>> print(vec.to_cartesian())
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
.. py:method:: AbstractVector.uconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Convert the vector to the given units.
This just forwards to `unxt.uconvert`, reversing the order of the
arguments to match the `unxt` API.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert({"length": "km"}))
<Point: chart=Cart3D (x, y, z) [km]
[1 2 3]>
.. py:function:: uconvert(self, usys: unxt._src.unitsystems.base.AbstractUnitSystem, /) -> Any
:noindex:
Convert the vector to the given units.
:param usys: The units to convert to according to the physical type of the
components. This is passed to [`unxt.unitsystem`][].
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. rubric:: Examples
>>> import unxt as u
>>> import coordinax.main as cx
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert(usys))
<Point: chart=Cart3D (x, y, z) [m]
[1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic"))
<Point: chart=Cart3D (x, y, z) [kpc]
[3.241e-17 6.482e-17 9.722e-17]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
.. py:property:: AbstractVector.shape :module: coordinax.vectors :abstractmethod: :type: tuple[int, β¦]
Return the shape of the vector.
.. py:method:: AbstractVector.astype(dtype: ~typing.Any, /, **kwargs: ~typing.Any) :module: coordinax.vectors
Cast the vector to a new dtype.
.. rubric:: Examples
>>> import quaxed.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
We can cast a vector to a new dtype:
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec.astype(jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
>>> print(jnp.astype(vec, jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
:type dtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param dtype:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: AbstractVector.copy() :module: coordinax.vectors
Return a copy of the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec.copy())
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:method:: AbstractVector.flatten() :module: coordinax.vectors
Flatten the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: AbstractVector.ravel() :module: coordinax.vectors
Return a flattened vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: AbstractVector.reshape(*shape: int) :module: coordinax.vectors
Return a reshaped vector.
:type shape: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param shape:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: AbstractVector.round(decimals: int = 0) :module: coordinax.vectors
Return a rounded vector.
:type decimals: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param decimals:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: AbstractVector.to_device(device: None | ~jaxlib._jax.Device = None) :module: coordinax.vectors
Move the vector to a new device.
:type device: :sphinx_autodoc_typehints_type:`\:py\:obj\:\`None\` \| \:py\:class\:\`\~jaxlib.\_jax.Device\``
:param device:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:property:: AbstractVector.dtype :module: coordinax.vectors
.. py:property:: AbstractVector.ndim :module: coordinax.vectors
.. py:property:: AbstractVector.size :module: coordinax.vectors
.. py:method:: AbstractVector.is_like(obj: ~typing.Any, /) :module: coordinax.vectors :classmethod:
Check if the object is a `AbstractVector` object.
.. rubric:: Examples
>>> import coordinax.vectors as cxv
>>> vec = cxv.Point.from_([1, 2, 3], "m")
>>> cxv.AbstractVector.is_like(vec)
True
>>> cxv.AbstractVector.is_like(42)
False
:type obj: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param obj:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.TypeIs\`\\ \\\[\:py\:class\:\`\~typing.Self\`\]`
.. py:method:: AbstractVector.norm(*args: ~coordinax.vectors._src.base.AbstractVector) :module: coordinax.vectors
:type args: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
:param args:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.base.AbstractQuantity\``
.. py:method:: AbstractVector.to_frame(toframe: ~coordinax.frames._src.base.AbstractReferenceFrame, /, t: ~unxt._src.quantity.quantity.Quantity | None = None) :module: coordinax.vectors
Transform the vector to a specified reference frame.
:param toframe: The target reference frame.
:type toframe: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.frames.\_src.base.AbstractReferenceFrame\``
:param t: The evolution parameter (e.g. time). Defaults to 0 s.
:type t: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.quantity.Quantity\` \| \:py\:obj\:\`None\``
:returns: New vector with the data transformed into ``toframe`` and
``frame=toframe``.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 2, 3], "kpc", cxf.alice)
>>> p.to_frame(cxf.alice) is p
True
.. py:class:: Point(data: dict[str, ~typing.Any], chart: ~coordinax.vectors._src.point.ChartT, frame: ~typing.Any = NoFrame()) :module: coordinax.vectors :final: :canonical: coordinax.vectors._src.point.Point
Bases: :py:class:~coordinax.vectors._src.mixins.AstropyRepresentationAPIMixin, :py:class:~quax_blocks._src.unary.NumpyInvertMixin\ [:py:obj:~typing.Any], :py:class:~quax_blocks._src.container.LaxLenMixin, :py:class:~coordinax.vectors._src.base.AbstractVector\ [:py:obj:~coordinax.vectors._src.point.ChartT, :py:class:~coordinax.representations._src.geom.PointGeometry, :py:class:~coordinax.representations._src.basis.NoBasis, :py:class:~coordinax.representations._src.semantics.Location, :py:obj:~coordinax.vectors._src.point.V], :py:class:~typing.Generic\ [:py:obj:~coordinax.vectors._src.point.ChartT, :py:obj:~coordinax.vectors._src.point.V]
A coordinate-carrying geometric point.
A Point stores three pieces of information:
data: a mapping from component name to scalar-like value (typically
unxt.Quantity),chart: a chart object describing the coordinate system and component schema, and
rep: a representation describing the geometric meaning of the components and therefore the correct transformation law.
The design goal is to make the public API simple (construct, convert,
index) while keeping the mathematics correct and the numerical kernels
JAX-friendly (operate on scalar leaves; rely on jit/vmap).
Mathematical background:
Let \(M\) be a manifold and let \((U,\varphi)\) be a chart with coordinate map \(\varphi: U \to \mathbb{R}^n\). Coordinax distinguishes:
Point (representation cxr.point)
A point \(p \in M\) represented by its chart coordinates \(q = \varphi(p)\).
A point transforms by coordinate change: \(q' = (\varphi' \circ
\varphi^{-1})(q)\).
In Euclidean charts, point coordinates may have *heterogeneous physical
dimensions* (e.g. spherical $(r,\theta,\phi)$ mixes length and angle).
This is expected.
:type data: :sphinx_autodoc_typehints_type:\:py\:class\:\dict`\ \[:py:class:`str`, :py:data:`~typing.Any`] :param data: Mapping from chart component name to scalar value. Each leaf may be a unxt.Quantity (recommended) or an array-like. Components are expected to be *scalar leaves*; batching happens via broadcasting of these leaves. :type chart: :sphinx_autodoc_typehints_type::py:class:`~typing.TypeVar`\ \(``ChartT``, bound= :py:class:`~coordinax._src.base.charts.AbstractChart`\ \[:py:data:`~typing.Any`, :py:data:`~typing.Any`, :py:data:`~typing.Any`]) :param chart: A chart instance (e.g.cxc.cart3d, cxc.sph3d`) that defines component
names and per-component physical dimensions.
.. rubric:: Examples
Construct a point in Cartesian 3D and convert to spherical:
import coordinax.main as cx import coordinax.charts as cxc import unxt as u cart = cx.Point.from_({βxβ: u.Q(1, βmβ), βyβ: u.Q(1, βmβ), βzβ: u.Q(1, βmβ)}, β¦ cxc.cart3d) sph = cart.cconvert(cxc.sph3d) sph[βrβ] Q(1.73205081, βmβ)
.. rubric:: Notes
Notes on units and array shape:
A
Pointdoes not require that all components share one unit. This is essential for charts like spherical coordinates where point components naturally mix dimensions.Batching is represented by broadcasting the component leaves; the conceptual shape of the
Pointisbroadcast_shapes(*(v.shape for v in data.values())).
Core operations:
Indexing:
vec["x"]returns a component leaf.Conversion:
vec.cconvert(target_chart, at=...)converts the vector totarget_chart. ForPointthis is a coordinate transform.
:type frame: :sphinx_autodoc_typehints_type:\:py\:data\:\~typing.Any``
:param frame:
.. py:attribute:: Point.data :module: coordinax.vectors :type: dict[str, ~typing.Any]
The data for each component.
.. py:attribute:: Point.chart :module: coordinax.vectors :type: ~coordinax.vectors._src.point.ChartT
The chart of the vector, e.g. `cxc.cart3d`.
.. py:attribute:: Point.frame :module: coordinax.vectors :type: ~coordinax.frames._src.base.AbstractReferenceFrame :value: NoFrame()
The reference frame of the point. Defaults to ``cxf.noframe``.
.. py:property:: Point.rep :module: coordinax.vectors :type: ~coordinax.representations._src.rep.Representation[~coordinax.representations._src.geom.PointGeometry, ~coordinax.representations._src.basis.NoBasis, ~coordinax.representations._src.semantics.Location]
The representation of the vector.
.. py:property:: Point.shape :module: coordinax.vectors :type: tuple[int, β¦]
Return the shape of the vector.
.. py:property:: Point.M :module: coordinax.vectors :type: ~coordinax._src.base.manifold.AbstractManifold
The manifold of the vector, from the chart.
.. py:method:: Point.astype(dtype: ~typing.Any, /, **kwargs: ~typing.Any) :module: coordinax.vectors
Cast the vector to a new dtype.
.. rubric:: Examples
>>> import quaxed.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
We can cast a vector to a new dtype:
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec.astype(jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
>>> print(jnp.astype(vec, jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
:type dtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param dtype:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: Point.cconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Represent the vector as another type.
This forwards to `coordinax.representations.cconvert`.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> print(vec.cconvert(cx.sph3d))
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. py:method:: Point.copy() :module: coordinax.vectors
Return a copy of the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec.copy())
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:property:: Point.dtype :module: coordinax.vectors
.. py:method:: Point.flatten() :module: coordinax.vectors
Flatten the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Point.from_(cls: type[~coordinax.vectors._src.base.AbstractVector], *args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors :classmethod:
Create a vector-like object from arguments.
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point.
>>> import coordinax.main as cx
>>> vec1 = cx.Point.from_([1, 2, 3], "m")
>>> vec2 = cx.Point.from_(vec1)
>>> print(vec2)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a vector from an object, and chart and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and chart info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, /) -> Any
:noindex:
Construct a point from an object.
Note that this is a pretty limited constructor since it often lacks the
necessary information to do a proper construction.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> Any
:noindex:
Construct a cartesian vector from an array and unit.
The ``ArrayLike[Any, (*#batch, N), "..."]`` is expected to have the
components as the last dimension.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> Any
:noindex:
Construct a vector from an array, unit, and chart.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> Any
:noindex:
Construct a vector from an array, unit, chart, and rep.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km")
>>> p2 = cx.Point.from_(p, cxf.alice)
>>> p2.frame
Alice()
>>> # Replace an existing frame
>>> p3 = cx.Point.from_(p2, cxf.noframe)
>>> p3.frame == cxf.noframe
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from any object with a frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> p = cx.Point.from_(
... {"x": u.Q(1, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")},
... cxf.alice,
... )
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxr.point, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.rep
point
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km", cxf.alice)
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent (identity / fast path).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v)
>>> v2 is v
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel)
>>> v.chart
Cart3D(M=Rn(3))
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and a tangent Representation.
Extracts ``basis`` and ``semantic`` from the representation. Raises
``TypeError`` if the representation's geometry kind is not
``TangentGeometry``.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
>>> v.semantic == cxr.vel
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data and chart (rep inferred from data).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data alone (chart and rep inferred).
>>> import coordinax.main as cx
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array and unit (chart inferred).
>>> import coordinax.main as cx
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s")
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and chart.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, and Representation.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, Representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel, cxf.alice
... )
>>> v.basis == cxr.coord_basis
True
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from array, unit, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: unxt._src.quantity.base.AbstractQuantity, unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from a Quantity, unit, chart, basis, and semantic.
The Quantity is converted to the given unit before construction.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... u.Q([1.0, 2.0, 3.0], "m/s"), "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v, cxf.alice)
>>> v2.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data with a frame (chart and rep inferred).
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and frame (basis/semantic inferred).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, semantic, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], pv: coordinax.vectors._src.bundle.Coordinate, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Identity: return the same Coordinate unchanged.
>>> import coordinax.main as cx
>>> pv = cx.Coordinate(point=cx.Point.from_([1.0, 2.0, 3.0], "m"))
>>> cx.Coordinate.from_(pv) is pv
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], p: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Wrap a single ``Point`` as a point-only bundle (no field vectors).
>>> import coordinax.main as cx
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> pv = cx.Coordinate.from_(p)
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], data: collections.abc.Mapping[str, typing.Any], /, *, point: coordinax.vectors._src.point.Point | None = None) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Create a ``Coordinate`` from a mapping of named objects.
The mapping may contain a ``"point"`` key for the base; the explicit
``point`` keyword argument takes precedence if both are supplied.
>>> import unxt as u
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> vel = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
... cxc.cart3d, cxr.coord_vel)
>>> pv = cx.Coordinate.from_({"point": p, "velocity": vel})
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cartesian.CartesianRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CartesianRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CartesianRepresentation
>>> vec = CartesianRepresentation(1, 2, 3, unit="km")
>>> cxv.Point.from_(vec)
Point({'x': Q(1., 'km'), 'y': Q(2., 'km'), 'z': Q(3., 'km')}, chart=Cart3D(M=Rn(3)))
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cylindrical.CylindricalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CylindricalRepresentation.
>>> import astropy.units as apyu
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CylindricalRepresentation
>>> vec = CylindricalRepresentation(rho=1 * apyu.km, phi=90 * apyu.deg,
... z=3 * apyu.km)
>>> cxv.Point.from_(vec)
Point(
{'rho': Q(1., 'km'), 'phi': Q(90., 'deg'), 'z': Q(3., 'km')},
chart=Cylindrical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.PhysicsSphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy PhysicsSphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import PhysicsSphericalRepresentation
>>> import astropy.units as apyu
>>> vec = PhysicsSphericalRepresentation(
... r=1 * apyu.kpc, theta=45 * apyu.deg, phi=90 * apyu.deg)
>>> cxv.Point.from_(vec)
Point(
{'r': Q(1., 'kpc'), 'theta': Q(45., 'deg'), 'phi': Q(90., 'deg')},
chart=Spherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.SphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import SphericalRepresentation
>>> import astropy.units as apyu
>>> vec = SphericalRepresentation(
... lon=90 * apyu.deg, lat=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.baseframe.BaseCoordinateFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy frame with data.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.ICRS(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = apyc.Galactocentric(
... x=1 * apyu.kpc, y=2 * apyu.kpc, z=3 * apyu.kpc
... )
>>> cxv.Point.from_(vec)
Point(
{'x': Q(1., 'kpc'), 'y': Q(2., 'kpc'), 'z': Q(3., 'kpc')},
chart=Cart3D(M=Rn(3)), frame=Galactocentric(...)
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.sky_coordinate.SkyCoord, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SkyCoord.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.SkyCoord(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = vec.transform_to(apyc.Galactocentric())
>>> cxv.Point.from_(vec)
Point(
{'x': Q(-9.08123957, 'kpc'), 'y': Q(0.21365468, 'kpc'), 'z': Q(0.2056243, 'kpc')},
chart=Cart3D(M=Rn(3)),
frame=Galactocentric(
galcen=Point(
{ 'lon': Q(266.4051, 'deg'), 'lat': Q(-28.936175, 'deg'),
'distance': Q(8.122, 'kpc')
},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
),
roll=Angle(0., 'deg'),
z_sun=Q(20.8, 'pc')
)
)
:type cls: :sphinx_autodoc_typehints_type:`\:py\:class\:\`type\`\\ \\\[\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\`\]`
:param cls:
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: Point.is_like(obj: ~typing.Any, /) :module: coordinax.vectors :classmethod:
Check if the object is a `AbstractVector` object.
.. rubric:: Examples
>>> import coordinax.vectors as cxv
>>> vec = cxv.Point.from_([1, 2, 3], "m")
>>> cxv.AbstractVector.is_like(vec)
True
>>> cxv.AbstractVector.is_like(42)
False
:type obj: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param obj:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.TypeIs\`\\ \\\[\:py\:class\:\`\~typing.Self\`\]`
.. py:property:: Point.ndim :module: coordinax.vectors
.. py:method:: Point.norm(*args: ~coordinax.vectors._src.base.AbstractVector) :module: coordinax.vectors
:type args: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
:param args:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.base.AbstractQuantity\``
.. py:method:: Point.ravel() :module: coordinax.vectors
Return a flattened vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Point.represent_as(target: ~typing.Any, *args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Represent the vector as another type.
This just forwards to `coordinax.cconvert`.
:param target: The representation type to convert to, e.g. `cxc.sph3d`.
:type target: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:type \*args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param \*args: Extra arguments. These are passed to `coordinax.cconvert` and might
be used, depending on the dispatched method. E.g. for transforming a
velocity or acceleration vector, generally the first argument is the
position vector at which the differential 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.
:type \*\*kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param \*\*kwargs: Extra arguments. These are passed to `coordinax.cconvert` and might
be used, depending on the dispatched method. E.g. for transforming a
velocity or acceleration vector, generally the first argument is the
position vector at which the differential 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.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
Transforming a Position:
>>> q_cart = cx.Point.from_([1, 2, 3], "m")
>>> q_sph = q_cart.represent_as(cxc.sph3d)
>>> print(q_sph)
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
.. py:method:: Point.reshape(*shape: int) :module: coordinax.vectors
Return a reshaped vector.
:type shape: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param shape:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Point.round(decimals: int = 0) :module: coordinax.vectors
Return a rounded vector.
:type decimals: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param decimals:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:property:: Point.size :module: coordinax.vectors
.. py:method:: Point.to_cartesian() :module: coordinax.vectors
Return the vector in a Cartesian chart.
This just forwards to `coordinax.cartesian_chart` and `cconvert`.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m").cconvert(cx.sph3d)
>>> print(vec)
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
>>> print(vec.to_cartesian())
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
.. py:method:: Point.to_device(device: None | ~jaxlib._jax.Device = None) :module: coordinax.vectors
Move the vector to a new device.
:type device: :sphinx_autodoc_typehints_type:`\:py\:obj\:\`None\` \| \:py\:class\:\`\~jaxlib.\_jax.Device\``
:param device:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Point.to_frame(toframe: ~coordinax.frames._src.base.AbstractReferenceFrame, /, t: ~unxt._src.quantity.quantity.Quantity | None = None) :module: coordinax.vectors
Transform the vector to a specified reference frame.
:param toframe: The target reference frame.
:type toframe: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.frames.\_src.base.AbstractReferenceFrame\``
:param t: The evolution parameter (e.g. time). Defaults to 0 s.
:type t: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.quantity.Quantity\` \| \:py\:obj\:\`None\``
:returns: New vector with the data transformed into ``toframe`` and
``frame=toframe``.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 2, 3], "kpc", cxf.alice)
>>> p.to_frame(cxf.alice) is p
True
.. py:method:: Point.uconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Convert the vector to the given units.
This just forwards to `unxt.uconvert`, reversing the order of the
arguments to match the `unxt` API.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert({"length": "km"}))
<Point: chart=Cart3D (x, y, z) [km]
[1 2 3]>
.. py:function:: uconvert(self, usys: unxt._src.unitsystems.base.AbstractUnitSystem, /) -> Any
:noindex:
Convert the vector to the given units.
:param usys: The units to convert to according to the physical type of the
components. This is passed to [`unxt.unitsystem`][].
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. rubric:: Examples
>>> import unxt as u
>>> import coordinax.main as cx
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert(usys))
<Point: chart=Cart3D (x, y, z) [m]
[1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic"))
<Point: chart=Cart3D (x, y, z) [kpc]
[3.241e-17 6.482e-17 9.722e-17]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
.. py:class:: Coordinate(point: ~typing.Any, **fields: ~typing.Any) :module: coordinax.vectors :final: :canonical: coordinax.vectors._src.bundle.Coordinate
Bases: :py:class:~coordinax.vectors._src.base.AbstractVector
A vector bundle anchored at a base point.
A Coordinate stores:
A base point \(q \in M\) (a
~coordinax.vectors.Point).A collection of named fibre vectors \(\{v_i\}\) anchored at \(q\) (each a
~coordinax.vectors.TangentwithTangentGeometryrep, e.g. velocity, displacement, acceleration).
On construction every fibre vector is automatically frame-aligned to the reference frame of the base point:
Frame-alignment via
~coordinax.vectors.AbstractVector.to_frameensurespv["velocity"].frame == pv.point.frame.
Fibre vectors are not chart-aligned on construction; each fibre
retains the chart it was supplied with. Chart conversion is handled
lazily: ~coordinax.vectors.Coordinate.cconvert pushes each fibre
forward using the Jacobian at the base point expressed in the fibreβs
current chart.
Coordinate conversion (chart change) is handled automatically: the base converts as a point map, and each fibre vector converts via the Jacobian pushforward at the base.
:param point: Base point. Must be an instance of ~coordinax.vectors.Point.
:type point: :sphinx_autodoc_typehints_type:\:py\:data\:\~typing.Any` :param \*\*fields: Named fibre vectors anchored at ``point``. Must have ``TangentGeometry`` representation (i.e.~coordinax.vectors.Tangent instances). Shapes must be broadcastable with ``point``. :type \*\*fields: :sphinx_autodoc_typehints_type::py:data:`~typing.Any``
.. rubric:: Examples
import unxt as u import coordinax.main as cx import coordinax.charts as cxc import coordinax.representations as cxr
point = cx.Point.from_([1.0, 0.0, 0.0], βmβ) vel = cx.Tangent.from_( β¦ {βxβ: u.Q(1.0, βm/sβ), βyβ: u.Q(0.0, βm/sβ), βzβ: u.Q(0.0, βm/sβ)}, β¦ cxc.cart3d, cxr.coord_vel) pv = cx.Coordinate(point=point, velocity=vel) pv.point.chart Cart3D(M=Rn(3))
Convert to spherical β point converts as a point map, velocity via Jacobian:
pv_sph = pv.cconvert(cxc.sph3d) pv_sph.point.chart Spherical3D(M=Rn(3)) pv_sph[βvelocityβ].chart Spherical3D(M=Rn(3))
.. py:attribute:: Coordinate.point :module: coordinax.vectors :type: ~coordinax.vectors._src.point.Point
Base point of the bundle. Must be a ``Point`` instance.
.. py:property:: Coordinate.data :module: coordinax.vectors :type: ~typing.Any
Component data of the base point.
.. py:property:: Coordinate.chart :module: coordinax.vectors :type: ~coordinax._src.base.charts.AbstractChart
Chart of the base point.
.. py:property:: Coordinate.rep :module: coordinax.vectors :type: ~coordinax.representations._src.rep.Representation
Representation of the base point (always PointGeometry).
.. py:property:: Coordinate.manifold :module: coordinax.vectors :type: ~coordinax._src.base.manifold.AbstractManifold
Manifold of the base point.
.. py:property:: Coordinate.frame :module: coordinax.vectors :type: ~coordinax.frames._src.base.AbstractReferenceFrame
Reference frame of the bundle β always equal to ``point.frame``.
.. py:method:: Coordinate.keys() :module: coordinax.vectors
Return field names (excluding base point).
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~collections.abc.KeysView\`\\ \\\[\:py\:class\:\`str\`\]`
.. rubric:: Examples
>>> import unxt as u
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> base = cx.Point.from_([1.0, 0.0, 0.0], "m")
>>> vel = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
... cxc.cart3d, cxr.coord_vel)
>>> pv = cx.Coordinate(point=base, velocity=vel)
>>> list(pv.keys())
['velocity']
.. py:method:: Coordinate.values() :module: coordinax.vectors
Return field vectors (excluding base point).
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~collections.abc.ValuesView\`\\ \\\[\:py\:class\:\`\~coordinax.vectors.\_src.tangent.Tangent\`\]`
.. py:method:: Coordinate.items() :module: coordinax.vectors
Return ``(name, vector)`` pairs for fields (excluding base point).
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~collections.abc.ItemsView\`\\ \\\[\:py\:class\:\`str\`\, \:py\:class\:\`\~coordinax.vectors.\_src.tangent.Tangent\`\]`
.. py:method:: Coordinate.cconvert(to_chart: ~coordinax._src.base.charts.AbstractChart, /, *, field_charts: ~collections.abc.Mapping[str, ~coordinax._src.base.charts.AbstractChart] | None = None, usys: ~unxt._src.unitsystems.base.AbstractUnitSystem | None = None) :module: coordinax.vectors
Convert the bundle to a new coordinate chart.
Algorithm:
1. Convert base as a point map: ``new_point = cconvert(point, to_chart)``.
2. For each field vector, apply the tangent pushforward at ``point``
via ``cconvert(vec, field_to_chart, at=point)``.
:param to_chart: Target chart for the base and (by default) all fields.
:type to_chart: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.\_src.base.charts.AbstractChart\``
:param field_charts: Per-field target chart overrides.
:type field_charts: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~collections.abc.Mapping\`\\ \\\[\:py\:class\:\`str\`\, \:py\:class\:\`\~coordinax.\_src.base.charts.AbstractChart\`\] \| \:py\:obj\:\`None\``
:param usys: Unit system for the conversion.
:type usys: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.unitsystems.base.AbstractUnitSystem\` \| \:py\:obj\:\`None\``
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.bundle.Coordinate\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> import coordinax.representations as cxr
>>> point = cx.Point.from_([1.0, 0.0, 0.0], "m")
>>> vel = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
... cxc.cart3d, cxr.coord_vel)
>>> pv = cx.Coordinate(point=point, velocity=vel)
>>> sph = pv.cconvert(cxc.sph3d)
>>> sph.point.chart
Spherical3D(M=Rn(3))
>>> sph["velocity"].chart
Spherical3D(M=Rn(3))
.. py:property:: Coordinate.shape :module: coordinax.vectors :type: tuple[int, β¦]
Broadcast shape of base point and all field vectors.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> pv = cx.Coordinate(point=cx.Point.from_([1.0, 2.0, 3.0], "m"))
>>> pv.shape
()
.. py:property:: Coordinate.M :module: coordinax.vectors :type: ~coordinax._src.base.manifold.AbstractManifold
The manifold of the vector, from the chart.
.. py:method:: Coordinate.astype(dtype: ~typing.Any, /, **kwargs: ~typing.Any) :module: coordinax.vectors
Cast the vector to a new dtype.
.. rubric:: Examples
>>> import quaxed.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
We can cast a vector to a new dtype:
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec.astype(jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
>>> print(jnp.astype(vec, jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
:type dtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param dtype:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: Coordinate.copy() :module: coordinax.vectors
Return a copy of the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec.copy())
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:property:: Coordinate.dtype :module: coordinax.vectors
.. py:method:: Coordinate.flatten() :module: coordinax.vectors
Flatten the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Coordinate.from_(cls: type[~coordinax.vectors._src.base.AbstractVector], *args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors :classmethod:
Create a vector-like object from arguments.
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point.
>>> import coordinax.main as cx
>>> vec1 = cx.Point.from_([1, 2, 3], "m")
>>> vec2 = cx.Point.from_(vec1)
>>> print(vec2)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a vector from an object, and chart and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and chart info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, /) -> Any
:noindex:
Construct a point from an object.
Note that this is a pretty limited constructor since it often lacks the
necessary information to do a proper construction.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> Any
:noindex:
Construct a cartesian vector from an array and unit.
The ``ArrayLike[Any, (*#batch, N), "..."]`` is expected to have the
components as the last dimension.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> Any
:noindex:
Construct a vector from an array, unit, and chart.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> Any
:noindex:
Construct a vector from an array, unit, chart, and rep.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km")
>>> p2 = cx.Point.from_(p, cxf.alice)
>>> p2.frame
Alice()
>>> # Replace an existing frame
>>> p3 = cx.Point.from_(p2, cxf.noframe)
>>> p3.frame == cxf.noframe
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from any object with a frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> p = cx.Point.from_(
... {"x": u.Q(1, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")},
... cxf.alice,
... )
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxr.point, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.rep
point
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km", cxf.alice)
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent (identity / fast path).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v)
>>> v2 is v
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel)
>>> v.chart
Cart3D(M=Rn(3))
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and a tangent Representation.
Extracts ``basis`` and ``semantic`` from the representation. Raises
``TypeError`` if the representation's geometry kind is not
``TangentGeometry``.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
>>> v.semantic == cxr.vel
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data and chart (rep inferred from data).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data alone (chart and rep inferred).
>>> import coordinax.main as cx
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array and unit (chart inferred).
>>> import coordinax.main as cx
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s")
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and chart.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, and Representation.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, Representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel, cxf.alice
... )
>>> v.basis == cxr.coord_basis
True
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from array, unit, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: unxt._src.quantity.base.AbstractQuantity, unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from a Quantity, unit, chart, basis, and semantic.
The Quantity is converted to the given unit before construction.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... u.Q([1.0, 2.0, 3.0], "m/s"), "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v, cxf.alice)
>>> v2.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data with a frame (chart and rep inferred).
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and frame (basis/semantic inferred).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, semantic, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], pv: coordinax.vectors._src.bundle.Coordinate, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Identity: return the same Coordinate unchanged.
>>> import coordinax.main as cx
>>> pv = cx.Coordinate(point=cx.Point.from_([1.0, 2.0, 3.0], "m"))
>>> cx.Coordinate.from_(pv) is pv
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], p: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Wrap a single ``Point`` as a point-only bundle (no field vectors).
>>> import coordinax.main as cx
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> pv = cx.Coordinate.from_(p)
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], data: collections.abc.Mapping[str, typing.Any], /, *, point: coordinax.vectors._src.point.Point | None = None) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Create a ``Coordinate`` from a mapping of named objects.
The mapping may contain a ``"point"`` key for the base; the explicit
``point`` keyword argument takes precedence if both are supplied.
>>> import unxt as u
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> vel = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
... cxc.cart3d, cxr.coord_vel)
>>> pv = cx.Coordinate.from_({"point": p, "velocity": vel})
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cartesian.CartesianRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CartesianRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CartesianRepresentation
>>> vec = CartesianRepresentation(1, 2, 3, unit="km")
>>> cxv.Point.from_(vec)
Point({'x': Q(1., 'km'), 'y': Q(2., 'km'), 'z': Q(3., 'km')}, chart=Cart3D(M=Rn(3)))
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cylindrical.CylindricalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CylindricalRepresentation.
>>> import astropy.units as apyu
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CylindricalRepresentation
>>> vec = CylindricalRepresentation(rho=1 * apyu.km, phi=90 * apyu.deg,
... z=3 * apyu.km)
>>> cxv.Point.from_(vec)
Point(
{'rho': Q(1., 'km'), 'phi': Q(90., 'deg'), 'z': Q(3., 'km')},
chart=Cylindrical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.PhysicsSphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy PhysicsSphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import PhysicsSphericalRepresentation
>>> import astropy.units as apyu
>>> vec = PhysicsSphericalRepresentation(
... r=1 * apyu.kpc, theta=45 * apyu.deg, phi=90 * apyu.deg)
>>> cxv.Point.from_(vec)
Point(
{'r': Q(1., 'kpc'), 'theta': Q(45., 'deg'), 'phi': Q(90., 'deg')},
chart=Spherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.SphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import SphericalRepresentation
>>> import astropy.units as apyu
>>> vec = SphericalRepresentation(
... lon=90 * apyu.deg, lat=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.baseframe.BaseCoordinateFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy frame with data.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.ICRS(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = apyc.Galactocentric(
... x=1 * apyu.kpc, y=2 * apyu.kpc, z=3 * apyu.kpc
... )
>>> cxv.Point.from_(vec)
Point(
{'x': Q(1., 'kpc'), 'y': Q(2., 'kpc'), 'z': Q(3., 'kpc')},
chart=Cart3D(M=Rn(3)), frame=Galactocentric(...)
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.sky_coordinate.SkyCoord, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SkyCoord.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.SkyCoord(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = vec.transform_to(apyc.Galactocentric())
>>> cxv.Point.from_(vec)
Point(
{'x': Q(-9.08123957, 'kpc'), 'y': Q(0.21365468, 'kpc'), 'z': Q(0.2056243, 'kpc')},
chart=Cart3D(M=Rn(3)),
frame=Galactocentric(
galcen=Point(
{ 'lon': Q(266.4051, 'deg'), 'lat': Q(-28.936175, 'deg'),
'distance': Q(8.122, 'kpc')
},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
),
roll=Angle(0., 'deg'),
z_sun=Q(20.8, 'pc')
)
)
:type cls: :sphinx_autodoc_typehints_type:`\:py\:class\:\`type\`\\ \\\[\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\`\]`
:param cls:
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: Coordinate.is_like(obj: ~typing.Any, /) :module: coordinax.vectors :classmethod:
Check if the object is a `AbstractVector` object.
.. rubric:: Examples
>>> import coordinax.vectors as cxv
>>> vec = cxv.Point.from_([1, 2, 3], "m")
>>> cxv.AbstractVector.is_like(vec)
True
>>> cxv.AbstractVector.is_like(42)
False
:type obj: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param obj:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.TypeIs\`\\ \\\[\:py\:class\:\`\~typing.Self\`\]`
.. py:property:: Coordinate.ndim :module: coordinax.vectors
.. py:method:: Coordinate.norm(*args: ~coordinax.vectors._src.base.AbstractVector) :module: coordinax.vectors
:type args: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
:param args:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.base.AbstractQuantity\``
.. py:method:: Coordinate.ravel() :module: coordinax.vectors
Return a flattened vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Coordinate.reshape(*shape: int) :module: coordinax.vectors
Return a reshaped vector.
:type shape: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param shape:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Coordinate.round(decimals: int = 0) :module: coordinax.vectors
Return a rounded vector.
:type decimals: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param decimals:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:property:: Coordinate.size :module: coordinax.vectors
.. py:method:: Coordinate.to_cartesian() :module: coordinax.vectors
Return the vector in a Cartesian chart.
This just forwards to `coordinax.cartesian_chart` and `cconvert`.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m").cconvert(cx.sph3d)
>>> print(vec)
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
>>> print(vec.to_cartesian())
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
.. py:method:: Coordinate.to_device(device: None | ~jaxlib._jax.Device = None) :module: coordinax.vectors
Move the vector to a new device.
:type device: :sphinx_autodoc_typehints_type:`\:py\:obj\:\`None\` \| \:py\:class\:\`\~jaxlib.\_jax.Device\``
:param device:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Coordinate.to_frame(toframe: ~coordinax.frames._src.base.AbstractReferenceFrame, /, t: ~unxt._src.quantity.quantity.Quantity | None = None) :module: coordinax.vectors
Transform the vector to a specified reference frame.
:param toframe: The target reference frame.
:type toframe: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.frames.\_src.base.AbstractReferenceFrame\``
:param t: The evolution parameter (e.g. time). Defaults to 0 s.
:type t: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.quantity.Quantity\` \| \:py\:obj\:\`None\``
:returns: New vector with the data transformed into ``toframe`` and
``frame=toframe``.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 2, 3], "kpc", cxf.alice)
>>> p.to_frame(cxf.alice) is p
True
.. py:method:: Coordinate.uconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Convert the vector to the given units.
This just forwards to `unxt.uconvert`, reversing the order of the
arguments to match the `unxt` API.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert({"length": "km"}))
<Point: chart=Cart3D (x, y, z) [km]
[1 2 3]>
.. py:function:: uconvert(self, usys: unxt._src.unitsystems.base.AbstractUnitSystem, /) -> Any
:noindex:
Convert the vector to the given units.
:param usys: The units to convert to according to the physical type of the
components. This is passed to [`unxt.unitsystem`][].
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. rubric:: Examples
>>> import unxt as u
>>> import coordinax.main as cx
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert(usys))
<Point: chart=Cart3D (x, y, z) [m]
[1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic"))
<Point: chart=Cart3D (x, y, z) [kpc]
[3.241e-17 6.482e-17 9.722e-17]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
.. py:class:: Tangent(data: dict[str, ~coordinax.vectors._src.tangent.V], chart: ~coordinax.vectors._src.tangent.ChartT, basis: ~coordinax.vectors._src.tangent.BasisT, semantic: ~coordinax.vectors._src.tangent.SemanticT, frame: ~typing.Any = NoFrame()) :module: coordinax.vectors :final: :canonical: coordinax.vectors._src.tangent.Tangent
Bases: :py:class:~coordinax.vectors._src.mixins.AstropyRepresentationAPIMixin, :py:class:~quax_blocks._src.unary.NumpyInvertMixin\ [:py:obj:~typing.Any], :py:class:~quax_blocks._src.container.LaxLenMixin, :py:class:~coordinax.vectors._src.base.AbstractVector\ [:py:obj:~coordinax.vectors._src.tangent.ChartT, :py:class:~coordinax.representations._src.geom.TangentGeometry, :py:obj:~coordinax.vectors._src.tangent.BasisT, :py:obj:~coordinax.vectors._src.tangent.SemanticT, :py:obj:~coordinax.vectors._src.tangent.V], :py:class:~typing.Generic\ [:py:obj:~coordinax.vectors._src.tangent.ChartT, :py:obj:~coordinax.vectors._src.tangent.BasisT, :py:obj:~coordinax.vectors._src.tangent.SemanticT, :py:obj:~coordinax.vectors._src.tangent.V]
A tangent-geometry vector with explicit basis and semantic kind.
A Tangent stores four pieces of information:
data: a mapping from component name to scalar-like value (typically
unxt.Quantity),chart: a chart object describing the coordinate system and component schema,
basis: an
~coordinax.representations.AbstractLinearBasisspecifying the basis in which tangent components are expressed (e.g.~coordinax.representations.CoordinateBasisor~coordinax.representations.PhysicalBasis), andsemantic: an
~coordinax.representations.AbstractTangentSemanticKindgiving the physical interpretation of the tangent vector (e.g.~coordinax.representations.Velocity,~coordinax.representations.Displacement).
The representation is computed from these, always with
~coordinax.representations.TangentGeometry as the geometry kind:
.. math::
\mathrm{rep} = (
\mathrm{TangentGeometry},\, \mathrm{basis},\, \mathrm{semantic}
).
This is contrast to ~coordinax.vectors.Point, which stores a fixed
~coordinax.representations.PointGeometry-flavoured rep and a concrete
location on the manifold.
:type data: :sphinx_autodoc_typehints_type:\:py\:class\:\dict`\ \[:py:class:`str`, :py:class:`~typing.TypeVar`\ \(``V``, bound= :py:class:`~coordinax.vectors._src.custom_types.HasShape`)] :param data: Mapping from chart component name to scalar value. :type chart: :sphinx_autodoc_typehints_type::py:class:`~typing.TypeVar`\ \(``ChartT``, bound= :py:class:`~coordinax._src.base.charts.AbstractChart`\ \[:py:data:`~typing.Any`, :py:data:`~typing.Any`, :py:data:`~typing.Any`]) :param chart: A chart instance (e.g.cxc.cart3d) that defines the coordinate system. :type basis: :sphinx_autodoc_typehints_type::py:class:`~typing.TypeVar`\ \(``BasisT``, bound= :py:class:`~coordinax.representations._src.basis.AbstractLinearBasis`) :param basis: The linear basis in which the tangent components are expressed. :type semantic: :sphinx_autodoc_typehints_type::py:class:`~typing.TypeVar`\ \(``SemanticT``, bound= :py:class:`~coordinax.representations._src.semantics.AbstractTangentSemanticKind`) :param semantic: The semantic kind of the tangent vector (velocity, displacement, etc.). :type frame: :sphinx_autodoc_typehints_type::py:data:`~typing.Any``
:param frame: The reference frame. Defaults to cxf.noframe.
:param Construct a coordinate-basis velocity in Cartesian 3D:
:param >>> import coordinax.main as cx:
:param >>> import coordinax.charts as cxc:
:param >>> import coordinax.representations as cxr:
:param >>> import unxt as u:
:param >>> v = cx.Tangent.from_(:
:param β¦ {βxβ:
:type β¦ {βxβ: u.Q(1.0, βm/sβ), βyβ: u.Q(2.0, βm/sβ), βzβ: u.Q(3.0, βm/sβ)},
:param β¦ cxc.cart3d:
:param cxr.coord_basis:
:param cxr.vel:
:param :
:param β¦ ):
:param >>> v.rep == cxr.coord_vel:
:param True:
.. py:attribute:: Tangent.data :module: coordinax.vectors :type: dict[str, ~coordinax.vectors._src.tangent.V]
The data for each component.
.. py:attribute:: Tangent.chart :module: coordinax.vectors :type: ~coordinax.vectors._src.tangent.ChartT
The chart of the vector, e.g. `cxc.cart3d`.
.. py:attribute:: Tangent.basis :module: coordinax.vectors :type: ~coordinax.vectors._src.tangent.BasisT
The linear basis for tangent components.
.. py:attribute:: Tangent.semantic :module: coordinax.vectors :type: ~coordinax.vectors._src.tangent.SemanticT
The semantic kind of the tangent vector.
.. py:attribute:: Tangent.frame :module: coordinax.vectors :type: ~coordinax.frames._src.base.AbstractReferenceFrame :value: NoFrame()
The reference frame. Defaults to ``cxf.noframe``.
.. py:property:: Tangent.rep :module: coordinax.vectors :type: ~coordinax.representations._src.rep.Representation
The representation, computed from basis and semantic.
.. py:property:: Tangent.M :module: coordinax.vectors :type: ~coordinax._src.base.manifold.AbstractManifold
The manifold of the vector, from the chart.
.. py:method:: Tangent.astype(dtype: ~typing.Any, /, **kwargs: ~typing.Any) :module: coordinax.vectors
Cast the vector to a new dtype.
.. rubric:: Examples
>>> import quaxed.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
We can cast a vector to a new dtype:
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec.astype(jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
>>> print(jnp.astype(vec, jnp.float32))
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
:type dtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param dtype:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: Tangent.cconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Represent the vector as another type.
This forwards to `coordinax.representations.cconvert`.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> print(vec.cconvert(cx.sph3d))
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. py:method:: Tangent.copy() :module: coordinax.vectors
Return a copy of the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m")
>>> print(vec.copy())
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:property:: Tangent.dtype :module: coordinax.vectors
.. py:method:: Tangent.flatten() :module: coordinax.vectors
Flatten the vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Tangent.from_(cls: type[~coordinax.vectors._src.base.AbstractVector], *args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors :classmethod:
Create a vector-like object from arguments.
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point.
>>> import coordinax.main as cx
>>> vec1 = cx.Point.from_([1, 2, 3], "m")
>>> vec2 = cx.Point.from_(vec1)
>>> print(vec2)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a vector from an object, and chart and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and chart info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, and rep info.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = {"x": u.Q([1, 2], "m"), "y": u.Q([3, 4], "m"), "z": u.Q([5, 6], "m")}
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 3 5]
[2 4 6]]>
>>> xs = u.Q(jnp.array([[1, 2, 3], [4, 5, 6]]), "m")
>>> vec = cx.Point.from_(xs, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, /) -> Any
:noindex:
Construct a point from an object.
Note that this is a pretty limited constructor since it often lacks the
necessary information to do a proper construction.
>>> import jax.numpy as jnp
>>> import unxt as u
>>> import coordinax.main as cx
>>> xs = {"x": u.Q(1, "m"), "y": u.Q(2, "m"), "z": u.Q(3, "m")}
>>> vec = cx.Point.from_(xs)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> vec = cx.Point.from_(u.Q([1, 2, 3], "m"))
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> Any
:noindex:
Construct a cartesian vector from an array and unit.
The ``ArrayLike[Any, (*#batch, N), "..."]`` is expected to have the
components as the last dimension.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "meter")
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> Any
:noindex:
Construct a vector from an array, unit, and chart.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> Any
:noindex:
Construct a vector from an array, unit, chart, and rep.
>>> import jax.numpy as jnp
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[1 2 3]>
>>> xs = jnp.array([[1, 2, 3], [4, 5, 6]])
>>> vec = cx.Point.from_(xs, "m", cx.cart3d, cx.point)
>>> print(vec)
<Point: chart=Cart3D (x, y, z) [m]
[[1 2 3]
[4 5 6]]>
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: coordinax.vectors._src.point.Point, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from another point, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km")
>>> p2 = cx.Point.from_(p, cxf.alice)
>>> p2.frame
Alice()
>>> # Replace an existing frame
>>> p3 = cx.Point.from_(p2, cxf.noframe)
>>> p3.frame == cxf.noframe
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from any object with a frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> p = cx.Point.from_(
... {"x": u.Q(1, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")},
... cxf.alice,
... )
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an object, chart, representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")}
>>> p = cx.Point.from_(d, cxc.cart3d, cxr.point, cxf.alice)
>>> p.chart
Cart3D(M=Rn(3))
>>> p.rep
point
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct a point from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 0, 0], "km", cxf.alice)
>>> p.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent (identity / fast path).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v)
>>> v2 is v
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel)
>>> v.chart
Cart3D(M=Rn(3))
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and a tangent Representation.
Extracts ``basis`` and ``semantic`` from the representation. Raises
``TypeError`` if the representation's geometry kind is not
``TangentGeometry``.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
>>> v.semantic == cxr.vel
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data and chart (rep inferred from data).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data alone (chart and rep inferred).
>>> import coordinax.main as cx
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array and unit (chart inferred).
>>> import coordinax.main as cx
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s")
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and chart.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d)
>>> isinstance(v, cx.Tangent)
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, and Representation.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel)
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, rep: coordinax.representations._src.rep.Representation, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, chart, Representation, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_vel, cxf.alice
... )
>>> v.basis == cxr.coord_basis
True
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from array, unit, chart, basis, and semantic.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> v = cx.Tangent.from_(
... [1.0, 2.0, 3.0], "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: unxt._src.quantity.base.AbstractQuantity, unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from a Quantity, unit, chart, basis, and semantic.
The Quantity is converted to the given unit before construction.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import unxt as u
>>> v = cx.Tangent.from_(
... u.Q([1.0, 2.0, 3.0], "m/s"), "m/s", cxc.cart3d, cxr.coord_basis, cxr.vel
... )
>>> v.basis == cxr.coord_basis
True
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: coordinax.vectors._src.tangent.Tangent, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from another Tangent, replacing its frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> v = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")},
... cxc.cart3d, cxr.coord_basis, cxr.vel,
... )
>>> v2 = cx.Tangent.from_(v, cxf.alice)
>>> v2.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data with a frame (chart and rep inferred).
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, and frame (basis/semantic inferred).
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Any, chart: coordinax._src.base.charts.AbstractChart, basis: coordinax.representations._src.basis.AbstractLinearBasis, semantic: coordinax.representations._src.semantics.AbstractTangentSemanticKind, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from data, chart, basis, semantic, and frame.
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> import coordinax.frames as cxf
>>> import unxt as u
>>> d = {"x": u.Q(1.0, "m/s"), "y": u.Q(2.0, "m/s"), "z": u.Q(3.0, "m/s")}
>>> v = cx.Tangent.from_(d, cxc.cart3d, cxr.coord_basis, cxr.vel, cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.tangent.Tangent], obj: Union[ArrayLike, list[Any]], unit: astropy.units.core.Unit | astropy.units.core.UnitBase | astropy.units.core.CompositeUnit | str, frame: coordinax.frames._src.base.AbstractReferenceFrame, /) -> coordinax.vectors._src.tangent.Tangent
:noindex:
Construct a Tangent from an array, unit, and frame.
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> v = cx.Tangent.from_([1.0, 2.0, 3.0], "m/s", cxf.alice)
>>> v.frame
Alice()
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], pv: coordinax.vectors._src.bundle.Coordinate, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Identity: return the same Coordinate unchanged.
>>> import coordinax.main as cx
>>> pv = cx.Coordinate(point=cx.Point.from_([1.0, 2.0, 3.0], "m"))
>>> cx.Coordinate.from_(pv) is pv
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], p: coordinax.vectors._src.point.Point, /) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Wrap a single ``Point`` as a point-only bundle (no field vectors).
>>> import coordinax.main as cx
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> pv = cx.Coordinate.from_(p)
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.bundle.Coordinate], data: collections.abc.Mapping[str, typing.Any], /, *, point: coordinax.vectors._src.point.Point | None = None) -> coordinax.vectors._src.bundle.Coordinate
:noindex:
Create a ``Coordinate`` from a mapping of named objects.
The mapping may contain a ``"point"`` key for the base; the explicit
``point`` keyword argument takes precedence if both are supplied.
>>> import unxt as u
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
>>> import coordinax.representations as cxr
>>> p = cx.Point.from_([1.0, 2.0, 3.0], "m")
>>> vel = cx.Tangent.from_(
... {"x": u.Q(1.0, "m/s"), "y": u.Q(0.0, "m/s"), "z": u.Q(0.0, "m/s")},
... cxc.cart3d, cxr.coord_vel)
>>> pv = cx.Coordinate.from_({"point": p, "velocity": vel})
>>> pv.point is p
True
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cartesian.CartesianRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CartesianRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CartesianRepresentation
>>> vec = CartesianRepresentation(1, 2, 3, unit="km")
>>> cxv.Point.from_(vec)
Point({'x': Q(1., 'km'), 'y': Q(2., 'km'), 'z': Q(3., 'km')}, chart=Cart3D(M=Rn(3)))
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.cylindrical.CylindricalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy CylindricalRepresentation.
>>> import astropy.units as apyu
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import CylindricalRepresentation
>>> vec = CylindricalRepresentation(rho=1 * apyu.km, phi=90 * apyu.deg,
... z=3 * apyu.km)
>>> cxv.Point.from_(vec)
Point(
{'rho': Q(1., 'km'), 'phi': Q(90., 'deg'), 'z': Q(3., 'km')},
chart=Cylindrical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.PhysicsSphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy PhysicsSphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import PhysicsSphericalRepresentation
>>> import astropy.units as apyu
>>> vec = PhysicsSphericalRepresentation(
... r=1 * apyu.kpc, theta=45 * apyu.deg, phi=90 * apyu.deg)
>>> cxv.Point.from_(vec)
Point(
{'r': Q(1., 'kpc'), 'theta': Q(45., 'deg'), 'phi': Q(90., 'deg')},
chart=Spherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.representation.spherical.SphericalRepresentation, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SphericalRepresentation.
>>> import coordinax.vectors as cxv
>>> from astropy.coordinates import SphericalRepresentation
>>> import astropy.units as apyu
>>> vec = SphericalRepresentation(
... lon=90 * apyu.deg, lat=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3))
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.baseframe.BaseCoordinateFrame, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy frame with data.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.ICRS(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = apyc.Galactocentric(
... x=1 * apyu.kpc, y=2 * apyu.kpc, z=3 * apyu.kpc
... )
>>> cxv.Point.from_(vec)
Point(
{'x': Q(1., 'kpc'), 'y': Q(2., 'kpc'), 'z': Q(3., 'kpc')},
chart=Cart3D(M=Rn(3)), frame=Galactocentric(...)
)
.. py:function:: from_(cls: type[coordinax.vectors._src.point.Point], obj: astropy.coordinates.sky_coordinate.SkyCoord, /) -> coordinax.vectors._src.point.Point
:noindex:
Construct Point from Astropy SkyCoord.
>>> import astropy.units as apyu
>>> import astropy.coordinates as apyc
>>> import coordinax.vectors as cxv
>>> vec = apyc.SkyCoord(ra=90 * apyu.deg, dec=45 * apyu.deg, distance=1 * apyu.kpc)
>>> cxv.Point.from_(vec)
Point(
{'lon': Q(90., 'deg'), 'lat': Q(45., 'deg'), 'distance': Q(1., 'kpc')},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
)
>>> vec = vec.transform_to(apyc.Galactocentric())
>>> cxv.Point.from_(vec)
Point(
{'x': Q(-9.08123957, 'kpc'), 'y': Q(0.21365468, 'kpc'), 'z': Q(0.2056243, 'kpc')},
chart=Cart3D(M=Rn(3)),
frame=Galactocentric(
galcen=Point(
{ 'lon': Q(266.4051, 'deg'), 'lat': Q(-28.936175, 'deg'),
'distance': Q(8.122, 'kpc')
},
chart=LonLatSpherical3D(M=Rn(3)), frame=ICRS()
),
roll=Angle(0., 'deg'),
z_sun=Q(20.8, 'pc')
)
)
:type cls: :sphinx_autodoc_typehints_type:`\:py\:class\:\`type\`\\ \\\[\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\`\]`
:param cls:
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. py:method:: Tangent.is_like(obj: ~typing.Any, /) :module: coordinax.vectors :classmethod:
Check if the object is a `AbstractVector` object.
.. rubric:: Examples
>>> import coordinax.vectors as cxv
>>> vec = cxv.Point.from_([1, 2, 3], "m")
>>> cxv.AbstractVector.is_like(vec)
True
>>> cxv.AbstractVector.is_like(42)
False
:type obj: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param obj:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.TypeIs\`\\ \\\[\:py\:class\:\`\~typing.Self\`\]`
.. py:property:: Tangent.ndim :module: coordinax.vectors
.. py:method:: Tangent.norm(*args: ~coordinax.vectors._src.base.AbstractVector) :module: coordinax.vectors
:type args: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
:param args:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.base.AbstractQuantity\``
.. py:method:: Tangent.ravel() :module: coordinax.vectors
Return a flattened vector.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Tangent.represent_as(target: ~typing.Any, *args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Represent the vector as another type.
This just forwards to `coordinax.cconvert`.
:param target: The representation type to convert to, e.g. `cxc.sph3d`.
:type target: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:type \*args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param \*args: Extra arguments. These are passed to `coordinax.cconvert` and might
be used, depending on the dispatched method. E.g. for transforming a
velocity or acceleration vector, generally the first argument is the
position vector at which the differential 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.
:type \*\*kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param \*\*kwargs: Extra arguments. These are passed to `coordinax.cconvert` and might
be used, depending on the dispatched method. E.g. for transforming a
velocity or acceleration vector, generally the first argument is the
position vector at which the differential 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.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.charts as cxc
Transforming a Position:
>>> q_cart = cx.Point.from_([1, 2, 3], "m")
>>> q_sph = q_cart.represent_as(cxc.sph3d)
>>> print(q_sph)
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
.. py:method:: Tangent.reshape(*shape: int) :module: coordinax.vectors
Return a reshaped vector.
:type shape: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param shape:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Tangent.round(decimals: int = 0) :module: coordinax.vectors
Return a rounded vector.
:type decimals: :sphinx_autodoc_typehints_type:`\:py\:class\:\`int\``
:param decimals:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:property:: Tangent.size :module: coordinax.vectors
.. py:method:: Tangent.to_cartesian() :module: coordinax.vectors
Return the vector in a Cartesian chart.
This just forwards to `coordinax.cartesian_chart` and `cconvert`.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "m").cconvert(cx.sph3d)
>>> print(vec)
<Point: chart=Spherical3D (r[m], theta[rad], phi[rad])
[3.742 0.641 1.107]>
>>> print(vec.to_cartesian())
<Point: chart=Cart3D (x, y, z) [m]
[1. 2. 3.]>
.. py:method:: Tangent.to_device(device: None | ~jaxlib._jax.Device = None) :module: coordinax.vectors
Move the vector to a new device.
:type device: :sphinx_autodoc_typehints_type:`\:py\:obj\:\`None\` \| \:py\:class\:\`\~jaxlib.\_jax.Device\``
:param device:
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~typing.Self\``
.. py:method:: Tangent.to_frame(toframe: ~coordinax.frames._src.base.AbstractReferenceFrame, /, t: ~unxt._src.quantity.quantity.Quantity | None = None) :module: coordinax.vectors
Transform the vector to a specified reference frame.
:param toframe: The target reference frame.
:type toframe: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.frames.\_src.base.AbstractReferenceFrame\``
:param t: The evolution parameter (e.g. time). Defaults to 0 s.
:type t: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~unxt.\_src.quantity.quantity.Quantity\` \| \:py\:obj\:\`None\``
:returns: New vector with the data transformed into ``toframe`` and
``frame=toframe``.
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.vectors.\_src.base.AbstractVector\``
.. rubric:: Examples
>>> import coordinax.main as cx
>>> import coordinax.frames as cxf
>>> p = cx.Point.from_([1, 2, 3], "kpc", cxf.alice)
>>> p.to_frame(cxf.alice) is p
True
.. py:method:: Tangent.uconvert(*args: ~typing.Any, **kwargs: ~typing.Any) :module: coordinax.vectors
Convert the vector to the given units.
This just forwards to `unxt.uconvert`, reversing the order of the
arguments to match the `unxt` API.
.. rubric:: Examples
>>> import coordinax.main as cx
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert({"length": "km"}))
<Point: chart=Cart3D (x, y, z) [km]
[1 2 3]>
.. py:function:: uconvert(self, usys: unxt._src.unitsystems.base.AbstractUnitSystem, /) -> Any
:noindex:
Convert the vector to the given units.
:param usys: The units to convert to according to the physical type of the
components. This is passed to [`unxt.unitsystem`][].
:rtype: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
.. rubric:: Examples
>>> import unxt as u
>>> import coordinax.main as cx
>>> usys = u.unitsystem("m", "s", "kg", "rad")
>>> vec = cx.Point.from_([1, 2, 3], "km")
>>> print(vec.uconvert(usys))
<Point: chart=Cart3D (x, y, z) [m]
[1000. 2000. 3000.]>
>>> print(vec.uconvert("galactic"))
<Point: chart=Cart3D (x, y, z) [kpc]
[3.241e-17 6.482e-17 9.722e-17]>
:type args: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param args:
:type kwargs: :sphinx_autodoc_typehints_type:`\:py\:data\:\`\~typing.Any\``
:param kwargs:
.. py:property:: Tangent.shape :module: coordinax.vectors :type: tuple[int, β¦]
Return the batch shape of the vector.
.. py:class:: ToUnitsOptions(*values) :module: coordinax.vectors :final: :canonical: coordinax.vectors._src.register_unxt.ToUnitsOptions
Bases: :py:class:~enum.Enum
Options for the units argument of uconvert.
This enum provides named conversion behaviors that are accepted by
Point.uconvert.
.. rubric:: Examples
Point.uconvert with consistent:
import unxt as u import coordinax.main as cx
vec = cx.Point.from_({βxβ: u.Q(1, βmβ), βyβ: u.Q(2, βkmβ)}, cx.cart2d) print(vec.uconvert(cx.ToUnitsOptions.consistent)) <Point: chart=Cart2D (x, y) [m] [1.e+00 2.e+03]>
.. py:attribute:: ToUnitsOptions.consistent :module: coordinax.vectors :value: βconsistentβ
Convert to consistent units.