coordinax.transforms#
The coordinax.transforms module (commonly imported as cxfm) provides transform operators, transform composition APIs, and transformation-group marker classes.
Overview#
coordinax.transforms is the canonical transform namespace. coordinax.frames depends on it to build frame-transition operators.
Quick Start#
import coordinax.frames as cxf
import coordinax.transforms as cxfm
import coordinax.main as cx
import unxt as u
op = cxfm.Rotate.from_euler("z", u.Q(90, "deg"))
v = cx.Point.from_([1, 0, 0], "m")
rotated = cxfm.act(op, None, v)
# frame transitions still come from coordinax.frames
frame_op = cxf.frame_transition(cxf.alice, cxf.alex)
out = cxfm.act(frame_op, None, v)
Functional API#
act(transform, tau, x): apply a transform to datasimplify(transform): simplify transform structurecompose(*transforms): compose transforms intoComposedmaterialize_transform(transform, tau): materialize time-dependent transform parameters
Transform Types#
AbstractTransform: base class for transformsIdentity: null transformTranslate: pure displacementRotate: pure rotationReflect: Householder hyperplane reflectionScale: Cartesian linear scalingShear: Cartesian linear shearComposed: ordered transform compositionidentity: convenience instance ofIdentity
Transformation Group Classes (Markers)#
Used for classification and dispatch; not instantiated directly:
AbstractTransformGroupIdentityGroupDiffeomorphismGroupAffineGroupEuclideanGroupOrthogonalGroupSpecialOrthogonalGroupLorentzGroupProperOrthochronousLorentzGroupPoincareGroup
Transform operators and transformation-group markers.
Examples
>>> import unxt as u
>>> import coordinax.transforms as cxfm
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg"))
>>> op
Rotate(f64[3,3](jax))
- coordinax.transforms.act(*args: Any, **kwargs: Any)#
Apply a transform action to coordinates.
This is the core dispatch function for transform application. Each transform type registers its own implementation via multiple dispatch. Transforms act on various input types (Array, Quantity, Vector, CDict) according to their semantics.
Mathematical Definition:
For a transform $mathcal{T}$ parameterized by $tau$, this computes:
$$ x’ = mathcal{T}(tau)(x) $$
For tau-independent transforms, $tau$ is ignored. For composite transforms (e.g.,
Composed), the component transforms are applied sequentially.- Parameters:
op (AbstractTransform) –
The transform to apply. This can be any transform type:
Translate: Spatial translation (point geometry)Rotate: Spatial rotationIdentity: No-opComposed: Sequential composition
tau (Any) – Parameter for tau-dependent transforms. Pass
Nonefor tau-independent transforms.x (Any) –
The input to transform. Supported types depend on the transform:
Array/ArrayLike: Interpreted as Cartesian point dataQuantity: Unitful array, treated as Cartesian pointVector: Role-aware transformation with chart preservationCDict: Low-level component dict
*args (
Any) – Additional positional/keyword arguments passed to concrete dispatches, e.g.chart,rep,usys.**kwargs (
Any) – Additional positional/keyword arguments passed to concrete dispatches, e.g.chart,rep,usys.
- Returns:
The transformed input, same type as
x.- Return type:
- Raises:
NotImplementedError – If no dispatch is registered for the given
(transform, input)types.
Notes
Transform.__call__: The
__call__method of transforms delegates to this function:op(tau, x)is equivalent toact(op, tau, x).Chart inference: When no chart is provided and the input is an Array or Quantity, the chart is inferred via
coordinax.charts.guess_chart.Composite transforms: For
Composed, the component transforms are applied in sequence (left-to-right).
See also
coordinax.transforms.actConcrete dispatch entrypoint used in practice
coordinax.frames.composeCompose two transforms into one
coordinax.frames.simplifySimplify a transform to canonical form
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
Apply a rotation to a Quantity:
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> q = u.Q([1, 0, 0], "km") >>> cxfm.act(op, None, q).round(3) Q([0., 1., 0.], 'km')
Apply a translation to a Quantity (usys required):
>>> import jax.numpy as jnp >>> op = cxfm.Translate.from_([1, 0, 0], "km") >>> x = jnp.asarray([1.0, 0.0, 0.0]) # metres (dimensionless array) >>> cxfm.act(op, None, x, usys=u.unitsystems.si).round(3) Array([1001., 0., 0.], dtype=float64)
Composite transform:
>>> R = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> T = cxfm.Translate.from_([1, 0, 0], "km") >>> op = R | T # rotate then translate >>> cxfm.act(op, None, q).round(3) Q([1., 1., 0.], 'km')
- coordinax.transforms.act(op: Identity, tau: Any, x: Any, /, *args: Any, **kw: Any) Any
Identity operator - returns input unchanged.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.identity
>>> q = [1, 2, 3] >>> cxfm.act(op, None, q) is q True
>>> q = u.Q([1, 2, 3], "km") >>> cxfm.act(op, None, q) is q True
>>> data = {"x": u.Q(1, "km"), "y": u.Q(2, "km"), "z": u.Q(3, "km")} >>> cxfm.act(op, None, data) is data True
>>> v = cx.Point.from_(u.Q([1, 2, 3], "m")) >>> cxfm.act(op, None, v) is v True
- coordinax.transforms.act(op: Composed, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, **kw: object) Array
Apply Composed to an ArrayLike by sequentially applying each transform.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm >>> import coordinax.representations as cxr
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> rot = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> pipe = cxfm.Composed((shift,)) >>> x = jnp.array([0.0, 0.0, 0.0]) >>> usys = u.unitsystems.si >>> cxfm.act(pipe, None, x, cxc.cart3d, cxr.point, usys=usys) Array([1000., 2000., 3000.], dtype=float64)
- coordinax.transforms.act(op: Composed, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, **kw: object) dict[str, Any]
Apply Composed to a CDict by sequentially applying each transform.
>>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm >>> import coordinax.representations as cxr
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> pipe = cxfm.Composed((shift,)) >>> data = {"x": u.Q(0, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")} >>> cxfm.act(pipe, None, data, cxc.cart3d, cxr.point) {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}
- coordinax.transforms.act(op: Composed, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, **kw: object) AbstractQuantity
Apply Composed to a Quantity by sequentially applying each transform.
>>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm >>> import coordinax.representations as cxr
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> pipe = cxfm.Composed((shift,)) >>> q = u.Q([0, 0, 0], "km") >>> cxfm.act(pipe, None, q, cxc.cart3d, cxr.point) Q([1, 2, 3], 'km')
- coordinax.transforms.act(op: Composed, tau: Any, x: AbstractQuantity, /, **kw: object) AbstractQuantity
Apply Composed to a Quantity by sequentially applying each transform.
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> pipe = cxfm.Composed((shift,)) >>> q = u.Q([0, 0, 0], "km") >>> cxfm.act(pipe, None, q) Q([1, 2, 3], 'km')
- coordinax.transforms.act(op: Boost, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Boost to a component dictionary.
A Boost only affects velocity vectors; it is the identity for points, displacements, and accelerations.
Examples
>>> import jax.numpy as jnp >>> import coordinax.charts as cxc >>> import coordinax.representations as cxr >>> import coordinax.transforms as cxfm
Boost acts on velocity (shifts components):
>>> boost = cxfm.Boost( ... {"x": jnp.array(1.0), "y": jnp.array(0.0), "z": jnp.array(0.0)}, ... chart=cxc.cart3d, ... ) >>> v = {"x": jnp.array(2.0), "y": jnp.array(3.0), "z": jnp.array(0.0)} >>> cxfm.act(boost, None, v, cxc.cart3d, cxr.coord_vel) {'x': Array(3., dtype=float64, ...), 'y': Array(3., dtype=float64, ...), 'z': Array(0., dtype=float64, ...)}
Boost is identity for positions:
>>> p = {"x": jnp.array(1.0), "y": jnp.array(2.0), "z": jnp.array(3.0)} >>> cxfm.act(boost, None, p, cxc.cart3d, cxr.point) {'x': Array(1., dtype=float64, ...), 'y': Array(2., dtype=float64, ...), 'z': Array(3., dtype=float64, ...)}
- coordinax.transforms.act(op: Reflect, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, **kw: Any) Array
Apply Reflect to an Array(like) object.
- coordinax.transforms.act(op: Reflect, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, **kw: Any) AbstractQuantity
Apply Reflect to a PointGeometry-roled Quantity.
- coordinax.transforms.act(op: Reflect, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Reflect to a coordinate dictionary.
- coordinax.transforms.act(op: Reflect, tau: Any, x: dict[str, Any], chart: AbstractChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a hyperplane reflection to a Point-valued coordinate dictionary.
- coordinax.transforms.act(op: Reflect, tau: Any, x: dict[str, Any], chart: AbstractCartesianProductChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a reflection factorwise on Cartesian-product charts.
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: ArrayLike, /, **kw: Any) Array
Apply an operator to an Array(like) object.
The Array is interpreted as equivalent to the data for a
Vectorwith a Cartesian chart (e.g. coordinax.charts.Cartesian3D) and coordinax.representations.PointGeometry geometry.>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm
>>> usys = u.unitsystems.si >>> x = jnp.asarray([1, 0, 0]) # [m]
>>> T = cxfm.Translate.from_([1, 0, 0], "km") >>> cxfm.act(T, None, x, usys=usys).round(3) # needs usys Array([1001., 0., 0.], dtype=float64)
>>> R = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> cxfm.act(R, None, x).round(3) # no usys required Array([0., 1., 0.], dtype=float64)
>>> op = R | T # rotate then translate >>> cxfm.act(op, None, x, usys=usys).round(3) Array([1000., 1., 0.], dtype=float64)
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: ArrayLike, chart: AbstractChart, /, **kw: Any) Array
Apply an operator to an Array(like) object.
The Array is interpreted as equivalent to the data for a
Vectorwith a Cartesian chart (e.g. coordinax.charts.Cartesian3D) and coordinax.representations.PointGeometry geometry.>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.main as cx
>>> usys = u.unitsystems.si >>> x = jnp.asarray([1, 0, 0]) # [m]
>>> T = cx.Translate.from_([1, 0, 0], "km") >>> cx.act(T, None, x, cxc.cart3d, usys=usys).round(3) # needs usys Array([1001., 0., 0.], dtype=float64)
>>> R = cx.Rotate.from_euler("z", u.Q(90, "deg")) >>> cx.act(R, None, x, cx.cart3d).round(3) # no usys required Array([0., 1., 0.], dtype=float64)
>>> op = R | T # rotate then translate >>> cx.act(op, None, x, cx.cart3d, usys=usys).round(3) Array([1000., 1., 0.], dtype=float64)
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, **kw: Any) Array
Apply an operator to an Array(like) object.
The Array is interpreted as equivalent to the data for a
Vectorwith a Cartesian chart (e.g. coordinax.charts.Cartesian3D) and coordinax.representations.PointGeometry geometry.>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.main as cx
>>> op = cx.Rotate.from_euler("z", u.Q(90, "deg")) >>> q = u.Q([1, 0, 0], "km") >>> cx.act(op, None, q, cx.cart3d, cx.point).round(3) Q([0., 1., 0.], 'km')
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: AbstractQuantity, /, **kw: Any) AbstractQuantity
Apply an operator to a Quantity.
The Quantity is interpreted as equivalent to the data for a coordinax.Point with a Cartesian chart (e.g. coordinax.charts.Cartesian3D) and coordinax.representations.PointGeometry geometry.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.main as cx
>>> op = cx.Rotate.from_euler("z", u.Q(90, "deg")) >>> q = u.Q([1, 0, 0], "km") >>> cx.act(op, None, q).round(3) Q([0., 1., 0.], 'km')
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: AbstractQuantity, chart: AbstractChart, /, **kw: Any) AbstractQuantity
Apply operator, routing through dictionary-based implementation.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> q = u.Q([1, 0, 0], "km")
Directly access this registered method, bypassing more efficient methods.
>>> func = cxfm.act.invoke(cxfm.Rotate, None, u.Q, cxc.Cart3D) >>> func(op, None, q, cxc.cart3d).round(3) Q([0., 1., 0.], 'km')
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, **kw: Any) AbstractQuantity
Apply operator, routing through dictionary-based implementation.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm >>> import coordinax.representations as cxr
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> q = u.Q([1, 0, 0], "km")
Directly access this registered method, bypassing more efficient methods.
>>> func = cxfm.act.invoke(cxfm.Rotate, None, u.Q, cxc.Cart3D, cxr.Representation) >>> func(op, None, q, cxc.cart3d, cxr.point).round(3) Q([0., 1., 0.], 'km')
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: QMatrix, /, **kw: Any) QMatrix
Apply an operator to a
QMatrix.The chart is inferred from the matrix size and the representation defaults to
point.>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> from coordinax.internal import QMatrix
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> qm = QMatrix( ... jnp.array([1.0, 0.0, 0.0]), ... unit=(u.unit("km"), u.unit("km"), u.unit("km")), ... ) >>> result = cxfm.act(op, None, qm) >>> result.value.round(3) Array([0., 1., 0.], dtype=float64)
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: QMatrix, chart: AbstractChart, /, **kw: Any) QMatrix
Apply an operator to a
QMatrixwith explicit chart.>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm >>> from coordinax.internal import QMatrix
>>> qm = QMatrix( ... jnp.array([1.0, 0.0, 0.0]), ... unit=("km", "km", "km"), ... )
>>> op = cxfm.Translate.from_([1, 0, 0], "km") >>> result = cxfm.act(op, None, qm, cxc.cart3d) >>> result.value.round(3) Array([2., 0., 0.], dtype=float64)
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> result = cxfm.act(op, None, qm, cxc.cart3d) >>> result.value.round(3) Array([0., 1., 0.], dtype=float64)
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: QMatrix, chart: AbstractChart, rep: Representation, /, **kw: Any) QMatrix
Apply an operator to a
QMatrixwith explicit chart and rep.Routes through the CDict-based implementation, then repacks the result into a
QMatrix.>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm >>> import coordinax.representations as cxr >>> from coordinax.internal import QMatrix
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> qm = QMatrix( ... jnp.array([1.0, 0.0, 0.0]), ... unit=("km", "km", "km"), ... ) >>> result = cxfm.act(op, None, qm, cxc.cart3d, cxr.point) >>> result.value.round(3) Array([0., 1., 0.], dtype=float64)
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: dict[str, Any], /, **kw: Any) dict[str, Any]
Apply operator to a CDict representation of a vector.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Rotate([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) >>> data = {"x": u.Q(1, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")} >>> cxfm.act(op, None, data) {'x': Q(0, 'km'), 'y': Q(1, 'km'), 'z': Q(0, 'km')}
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: dict[str, Any], chart: AbstractChart, /, **kw: Any) dict[str, Any]
Apply operator to a CDict representation of a vector.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> import coordinax.charts as cxc
>>> op = cxfm.Rotate([[0, 1, 0], [1, 0, 0], [0, 0, 1]]) >>> data = {"x": u.Q(1, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")} >>> cxfm.act(op, None, data, cxc.cart3d) {'x': Q(0, 'km'), 'y': Q(1, 'km'), 'z': Q(0, 'km')}
- coordinax.transforms.act(op: Rotate, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, **kw: Any) Array
Apply Rotate to an Array(like) object.
- coordinax.transforms.act(op: Rotate, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, **kw: Any) AbstractQuantity
Apply Rotate to a PointGeometry-roled Quantity.
- coordinax.transforms.act(op: Rotate, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
- coordinax.transforms.act(op: Rotate, tau: Any, x: dict[str, Any], chart: AbstractChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a spatial rotation to a Point-valued coordinate dictionary.
The point is rotated by converting to the chart’s canonical Cartesian chart, applying the rotation in Cartesian components, then converting back.
Notes
This dispatch is for non-product charts; Cartesian-product charts have a separate dispatch that rotates only matching spatial factors.
The rotation matrix must be square and its dimension must match the canonical Cartesian chart dimension.
Units are handled by packing Cartesian components into a common unit before rotation and restoring that unit afterward.
- coordinax.transforms.act(op: Rotate, tau: Any, x: dict[str, Any], chart: AbstractChart, geom: TangentGeometry, rep: Representation, /, *, at: dict[str, Any] | None = None, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a spatial rotation to a TangentGeometry coordinate dictionary.
Rotation acts on tangent vectors via the Jacobian pushforward, not as a direct coordinate substitution. The algorithm is:
Push
xto the chart’s canonical Cartesian chart via the Jacobian.Pack Cartesian components to a common unit.
Apply
Rviaeinsumin a batch-safe way.Pull the result back to the original chart via the inverse Jacobian evaluated at the rotated base point.
For Cartesian charts the Jacobian is the identity, so steps 1 and 4 are no-ops and
atis not required. For all other charts (e.g. spherical)atmust be supplied: it is the base point (in the original chart) at which the Jacobian is evaluated.Examples
Rotate a Cartesian velocity vector by +90 degrees about
z:>>> import quaxed.numpy as jnp >>> import unxt as u >>> import coordinax.charts as cxc >>> import coordinax.representations as cxr >>> import coordinax.transforms as cxfm
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> x = {"x": u.Q(1, "m/s"), "y": u.Q(0, "m/s"), "z": u.Q(0, "m/s")} >>> out = cxfm.act(op, None, x, cxc.cart3d, cxr.tangent_geom, cxr.coord_vel) >>> jnp.stack([out[c].to_value("m/s") for c in ("x", "y", "z")]).round(3) Array([0., 1., 0.], dtype=float64)
Rotate a spherical velocity at a given base point:
>>> import jax.numpy as jnp >>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> x = {"r": u.Q(1, "m/s"), "theta": u.Q(0, "rad/s"), "phi": u.Q(0, "rad/s")} >>> at = {"r": u.Q(1, "m"), "theta": u.Q(jnp.pi / 2, "rad"), "phi": u.Q(0, "rad")} >>> out = cxfm.act(op, None, x, cxc.sph3d, cxr.tangent_geom, cxr.coord_vel, at=at) >>> round(float(out["r"].to_value("m/s")), 3) # radial component preserved 1.0
- coordinax.transforms.act(op: Rotate, tau: Any, x: dict[str, Any], chart: AbstractCartesianProductChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a spatial rotation to a coordinate dictionary.
For Cartesian-product charts, this applies the rotation factorwise: each factor is rotated in its canonical Cartesian chart iff that Cartesian chart’s dimension matches the rotation matrix. Factors that do not match (e.g. Time1D) are left unchanged.
Notes
The rotation matrix must be square.
Units are handled by packing Cartesian components into a shared unit before rotation and restoring that unit afterward.
Kwarg requirements depend on role; eg. Points do not require an anchoring base-point.
- coordinax.transforms.act(op: Scale, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, **kw: Any) Array
Apply Scale to an Array(like) object.
- coordinax.transforms.act(op: Scale, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, **kw: Any) AbstractQuantity
Apply Scale to a PointGeometry-roled Quantity.
- coordinax.transforms.act(op: Scale, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Scale to a coordinate dictionary.
- coordinax.transforms.act(op: Scale, tau: Any, x: dict[str, Any], chart: AbstractChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Scale to a Point-valued coordinate dictionary.
- coordinax.transforms.act(op: Scale, tau: Any, x: dict[str, Any], chart: AbstractCartesianProductChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a scaling factorwise on Cartesian-product charts.
- coordinax.transforms.act(op: Shear, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, **kw: Any) Array
Apply Shear to an Array(like) object.
- coordinax.transforms.act(op: Shear, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, **kw: Any) AbstractQuantity
Apply Shear to a PointGeometry-roled Quantity.
- coordinax.transforms.act(op: Shear, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Shear to a coordinate dictionary.
- coordinax.transforms.act(op: Shear, tau: Any, x: dict[str, Any], chart: AbstractChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Shear to a Point-valued coordinate dictionary.
- coordinax.transforms.act(op: Shear, tau: Any, x: dict[str, Any], chart: AbstractCartesianProductChart, geom: PointGeometry, rep: Representation, /, *, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply a shear factorwise on Cartesian-product charts.
- coordinax.transforms.act(op: Translate, tau: Any, x: ArrayLike, chart: AbstractChart, rep: Representation, /, usys: AbstractUnitSystem | None = None, **kw: Any) Array
Apply Translate to an ArrayLike.
The array is interpreted as Cartesian coordinates. The delta is converted to the same unit system to perform the addition.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> x = jnp.array([0.0, 0.0, 0.0]) >>> usys = u.unitsystems.si >>> cxfm.act(shift, None, x, cxc.cart3d, cxr.point, usys=usys) Array([1000., 2000., 3000.], dtype=float64)
Velocity-semantic translate is identity on point arrays:
>>> import coordinax.representations as cxr >>> from dataclassish import replace >>> vel_shift = replace(shift, semantic_kind=cxr.vel) >>> cxfm.act(vel_shift, None, x, cxc.cart3d, cxr.point, usys=usys) Array([0., 0., 0.], dtype=float64)
- coordinax.transforms.act(op: Translate, tau: Any, x: AbstractQuantity, chart: AbstractChart, rep: Representation, /, usys: AbstractUnitSystem | None = None, **kw: Any) AbstractQuantity
Apply Translate to a Quantity.
The array is interpreted as Cartesian coordinates. The delta is converted to the same unit system to perform the addition.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> import coordinax.representations as cxr >>> from dataclassish import replace >>> import unxt as u
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> x = u.Q([0.0, 0.0, 0.0], "m") >>> cxfm.act(shift, None, x, cxc.cart3d, cxr.point) Q([1000., 2000., 3000.], 'm')
Velocity-semantic translate is identity on point quantities:
>>> vel_shift = replace(shift, semantic_kind=cxr.vel) >>> cxfm.act(vel_shift, None, x, cxc.cart3d, cxr.point) Q([0., 0., 0.], 'm')
- coordinax.transforms.act(op: Translate, tau: Any, x: dict[str, Any], chart: AbstractChart, rep: Representation, /, usys: AbstractUnitSystem | None = None, **kw: Any) dict[str, Any]
Apply Translate to a Point-valued component dictionary.
Dispatches on
op.semantic_kindto determine which representations are shifted.>>> import coordinax.transforms as cxfm >>> import unxt as u
Default (displacement-semantic) translate shifts points:
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> x = {"x": u.Q(0, "km"), "y": u.Q(0, "km"), "z": u.Q(0, "km")} >>> cxfm.act(shift, None, x, cxc.cart3d, cxr.point) {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: coordinax.vectors._src.tangent.Tangent, /, **kw: Any) coordinax.vectors._src.tangent.Tangent
Act a frame transform on a tangent Tangent.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.main as cx >>> import coordinax.frames as cxf
>>> Rz = jnp.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) >>> op = cx.Rotate(Rz) >>> 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")}, ... cx.cart3d, cx.coord_vel, ... ) >>> transformed = cx.act(op, None, v) >>> print(transformed) <Tangent: chart=Cart3D (x, y, z) [m / s] [0. 1. 0.]>
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: coordinax.vectors._src.point.Point, /, **kw: Any) coordinax.vectors._src.point.Point
Act a frame transform on a Point.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.main as cx
>>> Rz = jnp.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) >>> op = cx.Rotate(Rz) >>> q = u.Q([1, 0, 0], "km") >>> vec = cx.Point.from_(q) >>> print(vec) <Point: chart=Cart3D (x, y, z) [km] [1 0 0]>
>>> transformed_vec = cx.act(op, None, vec) >>> print(transformed_vec) <Point: chart=Cart3D (x, y, z) [km] [0 1 0]>
- coordinax.transforms.act(op: AbstractTransform, tau: Any, x: coordinax.vectors._src.bundle.Coordinate, /, **kw: Any) coordinax.vectors._src.bundle.Coordinate
Act a frame transform on a Coordinate (point + all fibres).
>>> import coordinax.main as cx >>> import coordinax.frames as cxf >>> import coordinax.charts as cxc >>> import coordinax.representations as cxr >>> import unxt as u
>>> point = cx.Point.from_([1.0, 0.0, 0.0], "m", cxf.alice) >>> vel = cx.Tangent( ... {"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, frame=cxf.alice, ... ) >>> pv = cx.Coordinate(point=point, velocity=vel) >>> pv_alex = pv.to_frame(cxf.alex) >>> pv_alex.frame Alex() >>> pv_alex["velocity"].frame Alex()
- coordinax.transforms.simplify(*args: Any, **kwargs: Any)#
Simplify a transform to a canonical form.
This function takes a transform and attempts to simplify it, returning a new, potentially simpler transform. For example, a
Translatewith zero delta simplifies toIdentity.Notes
In general this cannot be called in a JIT’ed context because it generally requires inspecting values to determine if simplifications are possible.
This function uses multiple dispatch. Each operator type registers its own simplification rules.
To see all available dispatches:
>>> import coordinax.transforms as cxfm >>> cxfm.simplify.methods List of 7 method(s): [0] simplify(...)
Examples
>>> import coordinax.transforms as cxfm
Identity (already simple):
>>> op = cxfm.Identity() >>> cxfm.simplify(op) is op True
Translate with zero delta:
>>> op = cxfm.Translate.from_([0, 0, 0], "m") >>> cxfm.simplify(op) Identity()
Translate with non-zero delta (no simplification):
>>> op = cxfm.Translate.from_([1, 2, 3], "m") >>> simplified = cxfm.simplify(op) >>> type(simplified).__name__ 'Translate'
Rotate with identity matrix:
>>> import unxt as u >>> op = cxfm.Rotate.from_euler("z", u.Q(0, "deg")) >>> cxfm.simplify(op) Identity()
Simplify a {class}`coordinax.transforms.Identity` operator.
The coordinax.transforms.Identity operator is the simplest operator and cannot be simplified further:
>>> import coordinax.transforms as cxfm
>>> op = cxfm.identity >>> cxfm.simplify(op) is op True
- coordinax.transforms.simplify(op: Composed, /) AbstractTransform
Simplify a Composed transform.
>>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> identity = cxfm.Identity() >>> pipe = cxfm.Composed((shift, identity)) >>> pipe Composed(( Translate(...), Identity() ))
>>> cxfm.simplify(pipe) Translate(...)
- coordinax.transforms.simplify(op: coordinax.transforms._src.actions.add.AbstractAdd, /, **kw: Any) coordinax.transforms._src.actions.add.AbstractAdd | Identity
Simplify a AbstractAdd operator.
A translation with zero delta simplifies to Identity.
>>> import coordinax.transforms as cxfm
>>> op = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.simplify(op) Translate(...)
>>> op = cxfm.Translate.from_([0, 0, 0], "km") >>> cxfm.simplify(op) Identity()
- coordinax.transforms.simplify(op: Reflect, /, **kw: Any) AbstractTransform
Simplify a reflection, collapsing the identity matrix when present.
- coordinax.transforms.simplify(op: Rotate, /, **kw: Any) AbstractTransform
Simplify the Galilean rotation operator.
>>> import quaxed.numpy as jnp >>> import coordinax.main as cx
An operator with a non-identity rotation matrix is not simplified:
>>> Rz = jnp.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) >>> op = cxfm.Rotate(Rz) >>> cxfm.simplify(op) Rotate(i64[3,3](jax))
An operator with an identity rotation matrix is simplified:
>>> op = cxfm.Rotate(jnp.eye(3)) >>> cxfm.simplify(op) Identity()
When two rotations are combined that cancel each other out, the result simplifies to an {class}`coordinax.ops.Identity`:
>>> op = ( cxfm.Rotate.from_euler("z", u.Q(45, "deg")) ... @ cxfm.Rotate.from_euler("z", u.Q(-45, "deg"))) >>> cxfm.simplify(op) Identity()
- coordinax.transforms.simplify(op: Scale, /, **kw: Any) AbstractTransform
Simplify a scaling transform to identity when matrix is identity.
- coordinax.transforms.simplify(op: Shear, /, **kw: Any) AbstractTransform
Simplify a shear transform to identity when matrix is identity.
- coordinax.transforms.compose(*args: Any, **kwargs: Any)#
Compose two frame transforms into a single transform.
Examples
>>> import coordinax.transforms as cxfm >>> import unxt as u
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> rotate = cxfm.Rotate.from_euler("z", u.Q(90, "deg"))
>>> cxfm.compose(shift, rotate) Composed(( Translate(...), Rotate(...) ))
- coordinax.transforms.compose(*transforms: AbstractTransform) Composed
Compose multiple transforms into a Composed transform.
>>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> rotate = cxfm.Rotate.from_euler("z", u.Q(90, "deg"))
>>> pipe = cxfm.compose(shift, rotate) >>> pipe Composed(( Translate(...), Rotate(...) ))
- coordinax.transforms.materialize_transform(op: OpT, tau: Any, /)#
Evaluate time-dependent parameters of an operator at a given time.
This function materializes an operator by evaluating all callable (time-dependent) parameters at the specified time
tau, returning a new operator instance of the same type with purely numeric parameters.Mathematically, if an operator $mathrm{Op}$ has parameters that depend on an affine parameter $tau$, then:
$$ mathrm{materialize_transform}(mathrm{Op}, tau) to mathrm{Op}_tau $$
where $mathrm{Op}_tau$ is the operator with all time-dependent parameters evaluated at $tau$.
- Parameters:
- Returns:
A new operator of the same type with all time-dependent parameters evaluated at
tau. If the operator has no time-dependent parameters, returns a copy with equivalent parameters.- Return type:
TypeVar(OpT, bound=HasDataclassFields)
Notes
This function is:
Pure: No side effects, safe for JAX tracing
Structure-preserving: Returns same operator type
Pytree-compatible: Uses
equinox.partition/equinox.combine
The implementation:
Partitions operator fields into callable (dynamic) and static
Evaluates dynamic fields at
tauviajax.tree_util.tree_mapRecombines into a new operator instance
Examples
>>> import unxt as u >>> import coordinax.main as cx >>> import coordinax.charts as cxc >>> import coordinax.transforms as cxfm
Time-dependent operator:
>>> op = cxfm.Translate(lambda t: cx.cdict(u.Q([t.ustrip("s"), 0, 0], "km")), ... chart=cxc.cart3d) >>> tau = u.Q(5.0, "s") >>> op_eval = cxfm.materialize_transform(op, tau) >>> op_eval.delta["x"] Q(5., 'km')
Static operator (no change):
>>> op_static = cxfm.Translate(cx.cdict(u.Q([1, 2, 3], "km")), chart=cxc.cart3d) >>> op_eval_static = cxfm.materialize_transform(op_static, tau) >>> op_eval_static.delta["x"] Q(1, 'km')
Identity operator:
>>> identity = cxfm.Identity() >>> cxfm.materialize_transform(identity, tau) Identity()
See also
actApply an operator to an input (calls
materialize_transforminternally)
- class coordinax.transforms.AbstractTransformGroup(*_, **__)#
Bases:
objectAbstract base class for transformation-group kinds.
A transformation group is a group whose elements are maps acting on a space, typically preserving some chosen structure such as smooth, affine, or metric structure. Concrete subclasses represent named group kinds used for classification and dispatch.
This class is not instantiated directly.
- class coordinax.transforms.IdentityGroup(*_, **__)#
Bases:
AbstractTransformGroupThe trivial group containing only the identity map.
This is the one-element group whose sole transformation leaves every point fixed.
- class coordinax.transforms.DiffeomorphismGroup(*_, **__)#
Bases:
AbstractTransformGroupThe group of smooth invertible self-maps of a manifold.
Its elements are diffeomorphisms: smooth maps with smooth inverses. This is the largest natural transformation group associated with a smooth manifold.
- class coordinax.transforms.AffineGroup(*_, **__)#
Bases:
DiffeomorphismGroupThe group of affine transformations of an affine space.
An affine transformation preserves affine combinations and may be written in coordinates as
x \mapsto A x + bwithAinvertible.
- class coordinax.transforms.EuclideanGroup(*_, **__)#
Bases:
AffineGroupThe group of Euclidean isometries of Euclidean space.
Its elements preserve the Euclidean metric, and equivalently preserve distances. In coordinates these are rigid motions: rotations, reflections, and translations.
- class coordinax.transforms.OrthogonalGroup(*_, **__)#
Bases:
EuclideanGroupThe group of orthogonal linear transformations.
Its elements preserve a positive-definite inner product and fix the origin. In matrix form they satisfy
Q^T Q = I.
- class coordinax.transforms.SpecialOrthogonalGroup(*_, **__)#
Bases:
OrthogonalGroupThe group of orientation-preserving orthogonal transformations.
This is the subgroup of the orthogonal group with determinant
+1. In Euclidean space its elements are rotations.
- class coordinax.transforms.PoincareGroup(*_, **__)#
Bases:
DiffeomorphismGroupThe group of isometries of Minkowski spacetime.
It is the semidirect product of spacetime translations with the Lorentz group. Its elements preserve the Minkowski metric.
- class coordinax.transforms.LorentzGroup(*_, **__)#
Bases:
OrthogonalGroupThe group of linear isometries of Minkowski spacetime.
Its elements preserve the Minkowski bilinear form and fix the origin. It is the indefinite-orthogonal group associated with spacetime signature.
- class coordinax.transforms.ProperOrthochronousLorentzGroup(*_, **__)#
Bases:
LorentzGroupThe identity component of the Lorentz group.
Its elements preserve both spatial orientation and time orientation. This is the subgroup of Lorentz transformations continuously connected to the identity.
- class coordinax.transforms.AbstractTransform#
Bases:
ModuleAbstract base class for operators on coordinates.
An operator is an object that defines a transformation on coordinates. It can be applied to a set of coordinates to produce a new set of coordinates. Operators can be composed together to form a sequence of transformations.
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- abstract property inverse: AbstractTransform#
The inverse of the operator.
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- class coordinax.transforms.AbstractCompositeTransform#
Bases:
AbstractTransformAbstract Composite Operator.
This is the base class for all composite operations.
See also
{class}`coordinax.transforms.Composed` GalileanOp
- transforms: AbstractVar[tuple[AbstractTransform, ...]]#
The sequence of operators in the composite operator.
- property inverse: Composed#
The inverse of the operator.
This is the sequence of the inverse of each operator in reverse order.
Examples
>>> import coordinax.transforms as cxfm >>> import unxt as u
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> rotate = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> pipe = cxfm.Composed((shift, rotate)) >>> pipe.inverse Composed((...)) :type self: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.transforms.\_src.actions.composite.AbstractCompositeTransform\`` :param self:
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- final class coordinax.transforms.Boost(delta: dict[str, Any] | Callable[[Any], Any], chart: AbstractChart, *, right_add: bool = True)#
Bases:
AbstractAddOperator for boosting velocities (Galilean velocity offset).
A Boost operator adds a constant velocity offset \(\Delta v\) to the velocity components of a phase-space point. It acts trivially on position (point) data, displacement data, and acceleration data.
Formally, in a Cartesian chart: \(B_{\Delta v}:\; \dot{x} \mapsto \dot{x} + \Delta v\).
- Parameters:
Examples
>>> import jax.numpy as jnp >>> import coordinax.charts as cxc >>> import coordinax.representations as cxr >>> import coordinax.transforms as cxfm
Create a boost operator:
>>> delta_v = {"x": jnp.array(1.0), "y": jnp.array(0.0), "z": jnp.array(0.0)} >>> boost = cxfm.Boost(delta_v, chart=cxc.cart3d) >>> boost Boost({'x': 1.0, 'y': 0.0, 'z': 0.0}, chart=Cart3D(M=Rn(3)))
The inverse negates the velocity offset:
>>> boost.inverse Boost({'x': -1.0, 'y': -0.0, 'z': -0.0}, chart=Cart3D(M=Rn(3)))
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- property inverse: AbstractAdd#
The inverse operator (negated offset).
Examples
>>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> shift.inverse Translate( {'x': Q(-1, 'km'), 'y': Q(-2, 'km'), 'z': Q(-3, 'km')}, chart=Cart3D(M=Rn(3)) )
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- delta: dict[str, Any] | Callable[[Any], Any]#
The additive offset (displacement for Translate, velocity for Boost).
- chart: AbstractChart#
Chart in which the offset is expressed.
- final class coordinax.transforms.Identity#
Bases:
AbstractTransformIdentity operation.
This is the identity operation, which does nothing to the input.
Examples
>>> import coordinax.main as cx >>> import coordinax.transforms as cxfm >>> import unxt as u
>>> op = cxfm.Identity() >>> op Identity()
For example, applying the Identity operator to a unxt.Quantity:
>>> q = u.Q([1, 2, 3], "km") >>> op(q) is q True
We apply it to a {class}`coordinax.Cart3D` instance:
>>> vec = cx.Point.from_(q) >>> op(vec) is vec True
Actually, the Identity operator works for any vector or quantity:
1D:
>>> q = u.Q([1], "km") >>> vec = cx.Point.from_(q) >>> op(vec) is vec and op(q) is q True
2D:
>>> q = u.Q([1, 2], "km") >>> vec = cx.Point.from_(q) >>> op(vec) is vec and op(q) is q True
3D: (using a spherical chart):
>>> q = u.Q([1, 2, 3], "km") >>> vec = cx.Point.from_(q).cconvert(cx.sph3d) >>> op(vec) is vec and op(q) is q True
Lastly, many operators are time dependent and support a time argument. The Identity operator will also work with a time argument:
>>> tau = u.Q(0, "Gyr") >>> op(tau, vec) Point( {'r': Q(3.74165739, 'km'), 'theta': Q(0.64052231, 'rad'), 'phi': Q(1.10714872, 'rad')}, chart=Spherical3D(M=Rn(3)) )
>>> op(tau, q) Q([1, 2, 3], 'km')
- property inverse: Identity#
The inverse of the map is the map itself.
Examples
>>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.inverse is op True
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- final class coordinax.transforms.Composed(transforms: Any)#
Bases:
AbstractCompositeTransform,Generic[Unpack[Ts]]Composition of Transforms.
Piping refers to a process in which the output of one operation is directly passed as the input to another. This is a composite operator that represents a sequence of operations to be applied in order.
Composed transformations can be created using the ‘pipe’ syntax op1 | op2. A Composed transformation created as
FG = F | G, when evaluated, is equivalent to evaluating $g circ f = g(f(x))$. Note the order of the transformations!The | operator works differently from the functional composition operator $circ$, which is sadly not supported in Python. The | operator is like the Unix Shell pipe operator, where output is passed left-to-right. This order can be seen in the indexing of the transformations in the Composed object.
- Parameters:
transforms (
Any) – The sequence of transformations to apply.
Examples
>>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> rotate = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> pipe = cxfm.Composed((shift, rotate)) >>> pipe Composed(( Translate(...), Rotate(...) ))
A pipe can also be constructed by
|:>>> pipe2 = shift | rotate >>> pipe2 Composed(( Translate(...), Rotate(...) ))
The pipe can be simplified. For this example, we add an identity operator to the sequence and simplify, which will remove the identity operator.
>>> pipe3 = pipe2 | cxfm.Identity() >>> pipe3 Composed(( Translate(...), Rotate(...), Identity() ))
>>> cxfm.simplify(pipe3) Composed(( Translate(...), Rotate(...) ))
- groups()#
Return the least common supergroup of the component transforms.
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- property inverse: Composed#
The inverse of the operator.
This is the sequence of the inverse of each operator in reverse order.
Examples
>>> import coordinax.transforms as cxfm >>> import unxt as u
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> rotate = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> pipe = cxfm.Composed((shift, rotate)) >>> pipe.inverse Composed((...)) :type self: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~coordinax.transforms.\_src.actions.composite.AbstractCompositeTransform\`` :param self:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- final class coordinax.transforms.Translate(delta: dict[str, Any] | Callable[[Any], Any], chart: AbstractChart, semantic_kind: AbstractTangentSemanticKind = dpl, *, right_add: bool = True)#
Bases:
AbstractAddOperator for translating points.
A Translate operator represents addition of a constant displacement $Delta$ in the ambient Euclidean space (or in a chart whose metric is Euclidean and whose canonical Cartesian chart exists).
Think of $Delta$ as a displacement vector field that is constant in space and time (unless explicitly time-dependent).
Formally, in a Cartesian chart on $mathbb{R}^n$: $T_Delta:; x mapsto x+Delta$.
Its differential (pushforward) is the identity: $(dT_Delta)_x = I$.
- Parameters:
delta (
dict[str,Any] |Callable[[Any],Any]) – The displacement to apply. Must have length dimension. If callable, will be evaluated at the time parametertau.chart (AbstractChart)
semantic_kind (AbstractTangentSemanticKind)
right_add (bool)
Notes
Only applicable to
Pointrole vectorsRaises
TypeErrorwhen applied to other roles (e.g.,PhysVel)The
deltais interpreted as aPhysDisp-role displacement internally
Examples
>>> import unxt as u >>> import coordinax.main as cx >>> import coordinax.transforms as cxfm >>> import wadler_lindig as wl
Create a translation operator:
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> shift Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
The inverse negates the displacement:
>>> shift.inverse Translate( {'x': Q(-1, 'km'), 'y': Q(-2, 'km'), 'z': Q(-3, 'km')}, chart=Cart3D(M=Rn(3)) )
Time-dependent translation:
>>> delta = lambda t: {"x": u.Q(t.ustrip("s"), "m"), "y": u.Q(0, "m"), ... "z": u.Q(0, "m")} >>> moving = cxfm.Translate(delta, chart=cxc.cart3d) >>> moving Translate(<function <lambda>>, chart=Cart3D(M=Rn(3)))
>>> t = u.Q(10, "s") >>> x = cx.cdict(u.Q([0, 0, 0], "m")) >>> wl.pprint(moving(t, x), short_arrays='compact', named_units=False) {'x': Quantity(10, unit='m'), 'y': Quantity(0, unit='m'), 'z': Quantity(0, unit='m')}
- Parameters:
chart (
AbstractChart)semantic_kind (
AbstractTangentSemanticKind)right_add (
bool)
- semantic_kind: AbstractTangentSemanticKind = dpl#
Displacement.
- Type:
Semantic kind of tangent data this operator acts on. Default
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- property inverse: AbstractAdd#
The inverse operator (negated offset).
Examples
>>> import coordinax.transforms as cxfm
>>> shift = cxfm.Translate.from_([1, 2, 3], "km") >>> shift.inverse Translate( {'x': Q(-1, 'km'), 'y': Q(-2, 'km'), 'z': Q(-3, 'km')}, chart=Cart3D(M=Rn(3)) )
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- delta: dict[str, Any] | Callable[[Any], Any]#
The additive offset (displacement for Translate, velocity for Boost).
- chart: AbstractChart#
Chart in which the offset is expressed.
- final class coordinax.transforms.Rotate(R: Any)#
Bases:
AbstractTransformOperator for Galilean rotations.
The coordinate transform is given by:
$$#
(t,mathbf{x}) mapsto (t, R mathbf{x})
where $R$ is the rotation matrix. Note this is intrinsically time dependent.
- param rotation:
The rotation matrix.
- type rotation:
Array[float, (3, 3)]
- raises ValueError:
If the rotation matrix is not orthogonal.
Notes
The Galilean rotation is intrinsically a time-dependent transformation. This is part of the inhomogeneous Galilean group, which is the group of transformations that leave the space-time interval invariant.
Examples
We start with the required imports:
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.main as cx >>> import coordinax.transforms as cxfm >>> import wadler_lindig as wl
We can then create a rotation operator:
>>> Rz = jnp.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) >>> op = cxfm.Rotate(Rz) >>> op Rotate(i64[3,3](jax))
Rotation operators can be applied to {class}`~coordinax.Point` and other higher-level objects, with behavior depending on the role:
>>> v = cx.Point.from_([1, 0, 0], "m") # A cxr.Point vector >>> t = u.Q(1, "s")
>>> print(op(t, v)) # equivalent to `cx.act(op, t, v)` <Point: chart=Cart3D (x, y, z) [m] [0 1 0]>
This also works for a batch of vectors (as a note, it is more efficient to jax.vmap over the `jax.jit`ted operator):
>>> v = cx.Point.from_([[1, 0, 0], [0, 1, 0]], "m") # A Point vector >>> print(op(t, v)) <Point: chart=Cart3D (x, y, z) [m] [[ 0 1 0] [-1 0 0]]>
Rotations can also be applied to low-level coordinate dictionaries:
>>> q = {"x": u.Q(1, "m"), "y": u.Q(0, "m"), "z": u.Q(0, "m")} >>> nq = op(t, q) # inferred chart & rep -> cxr.Point >>> wl.pprint(nq, short_arrays="compact", use_short_name=True) {'x': Q(0, unit='m'), 'y': Q(1, unit='m'), 'z': Q(0, unit='m')}
In addition to the standard low-level objects, Rotation operators can be applied to {class}`~unxt.Quantity` and Array-like objects, taken to represent a Cartesian vectors. For Quantity, the role is inferred from the units, while Arrays are always points:
>>> q = u.Q([1, 0, 0], "m") >>> t = u.Q(1, "s") >>> op(t, q) Q([0, 1, 0], 'm')
This also works for a batch of vectors:
>>> q = u.Q([[1, 0, 0], [0, 1, 0]], "m") >>> op(t, q) Q([[ 0, 1, 0], [-1, 0, 0]], 'm')
You can make the rotation matrix time-dependent:
>>> from jaxtyping import Array, Real >>> def R_func(t) -> Real[Array, "3 3"]: ... theta = (jnp.pi / 4) * t.to_value("s") ... st, ct = jnp.sin(theta), jnp.cos(theta) ... return jnp.array([[ct, -st, 0], [st, ct, 0], [0, 0, 1]])
>>> R_op = cxfm.Rotate.from_(R_func) >>> R_op Rotate(<function R_func>)
>>> t = u.Q(4, "s") # R_func -> 180 degrees rotation >>> R_op(t, q).round(3) Q([[-1., 0., 0.], [-0., -1., 0.]], 'm')
- type R:
- param R:
- classmethod from_euler(seq: str, angles: Quantity[PhysicalType('angle')] | Angle, /)#
Initialize from Euler angles.
See jax.scipy.spatial.transform.Rotation.from_euler. XYZ are intrinsic rotations, xyz are extrinsic rotations.
Examples
>>> import unxt as u >>> import coordinax.main as cx
>>> op = cxfm.Rotate.from_euler("z", u.Q(90, "deg")) >>> op.R.round(2) Array([[ 0., -1., 0.], [ 1., 0., 0.], [ 0., 0., 1.]], dtype=float64)
- property inverse: Rotate#
The inverse of the operator.
Examples
>>> import quaxed.numpy as jnp >>> import coordinax.main as cx
>>> Rz = jnp.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) >>> op = cxfm.Rotate(Rz) >>> op.inverse Rotate(i64[3,3](jax))
>>> jnp.allclose(op.R, op.inverse.R.T) Array(True, dtype=bool)
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- final class coordinax.transforms.Reflect(H: Any)#
Bases:
AbstractTransformOperator for Euclidean hyperplane reflections.
A reflection across the hyperplane orthogonal to a nonzero normal vector $n$ acts on Cartesian coordinates by the Householder matrix
$$ H_n = I - 2hat{n}hat{n}^T, $$
where $ hat{n} = n / lVert n rVert $.
Examples
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Reflect.from_normal([1.0, 0.0, 0.0]) >>> op.H Array([[-1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]], dtype=float64)
>>> q = u.Q([1.0, 2.0, 3.0], "km") >>> cxfm.act(op, None, q) Q([-1., 2., 3.], 'km')
- Parameters:
H (
Any)
- classmethod from_normal(normal: Any, /)#
Construct a Householder reflection from a hyperplane normal.
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- final class coordinax.transforms.Scale(S: Any)#
Bases:
AbstractTransformOperator for Cartesian linear scaling.
A scaling transform applies
$$ x mapsto Sx, $$
where
Sis an invertible scaling matrix. The common case is diagonal anisotropic scaling with per-axis factors.- Parameters:
S (
Any)
- classmethod from_factors(factors: Any, /)#
Construct a diagonal scaling transform from axis factors.
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()
- final class coordinax.transforms.Shear(H: Any)#
Bases:
AbstractTransformOperator for Cartesian linear shear.
A shear transform applies
$$ x mapsto Hx, $$
where
His an invertible shear matrix.- Parameters:
H (
Any)
- classmethod from_(cls: type[AbstractTransform], *args: object, **kwargs: object)#
Construct from a set of arguments.
- from_(cls: type[AbstractTransform], *args: object, **kwargs: object) AbstractTransform
- Parameters:
- Return type:
Construct from a set of arguments.
This is a low-priority dispatch that will be called if no other dispatch is found. It just tries to pass the arguments to the constructor.
- from_(cls: type[AbstractTransform], obj: Mapping[str, Any], /) AbstractTransform
- Parameters:
- Return type:
Construct from a mapping.
>>> import coordinax.transforms as cxfm >>> cxfm.Composed.from_({"transforms": (cxfm.Identity(), cxfm.Identity())}) Composed((Identity(), Identity()))
- from_(cls: type[AbstractTransform], x: ArrayLike | list[float | int], unit: str, /) AbstractTransform
- Parameters:
- Return type:
Construct from a Quantity’s value and unit.
>>> import coordinax.transforms as cxfm >>> op = cxfm.Translate.from_([1, 1, 1], "km") >>> print(op) Translate( {'x': Q(1, 'km'), 'y': Q(1, 'km'), 'z': Q(1, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[AbstractTransform], obj: AbstractTransform, /) AbstractTransform
- Parameters:
- Return type:
Construct an operator from another operator.
- Raises:
TypeError – If the input object is not a subclass of the target class.
- Parameters:
- Return type:
Examples
>>> import coordinax.main as cx
If the object is the same type, it should return the object itself.
>>> op = cxfm.Identity() >>> cxfm.Identity.from_(op) is op True
If the object is a different type, it will error.
>>> try: ... cxfm.Translate.from_(op) ... except TypeError as e: ... print(e) Cannot construct <class '...Translate'> from <class '...Identity'>.
Unless the object is a subclass of the target class.
>>> class MyOperator(cxfm.Identity): ... pass
>>> op = MyOperator() >>> op MyOperator()
>>> newop = cxfm.Identity.from_(op) >>> newop is op, isinstance(newop, cxfm.Identity) (False, True)
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], obj: coordinax.transforms._src.actions.add.AbstractAdd, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct a AbstractAdd from another AbstractAdd.
>>> import coordinax.main as cx >>> shift1 = cxfm.Translate.from_([1, 2, 3], "km") >>> cxfm.Translate.from_(shift1) is shift1 True
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], q: AbstractQuantity, /) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an AbstractAdd subclass from a Quantity.
>>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_(u.Q([1, 2, 3], "km")) Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
- from_(cls: type[coordinax.transforms._src.actions.add.AbstractAdd], x: ArrayLike, unit: str) coordinax.transforms._src.actions.add.AbstractAdd
- Parameters:
- Return type:
Construct an Add operator from an array-like offset and unit.
>>> import coordinax.transforms as cxfm >>> cxfm.Translate.from_([1, 2, 3], "km") Translate( {'x': Q(1, 'km'), 'y': Q(2, 'km'), 'z': Q(3, 'km')}, chart=Cart3D(M=Rn(3)) )
Construct a Reflect from another Reflect.
- from_(cls: type[Reflect], obj: AbstractQuantity, /) Reflect
- Parameters:
- Return type:
Construct a Reflect from a dimensionless quantity matrix.
Construct a Reflect from an array matrix.
Construct a Rotate from another Rotate.
>>> import quaxed.numpy as jnp >>> import coordinax.transforms as cxfm >>> R = cxfm.Rotate(jnp.eye(3)) >>> cxfm.Rotate.from_(R) is R True
Construct a Rotate from a callable.
The callable must have a return type annotation with shape ending in NxN (a square matrix).
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> from jaxtyping import Array, Real
>>> def R_func(t) -> Real[Array, "3 3"]: ... return jnp.eye(3)
>>> R = cxfm.Rotate.from_(R_func) >>> R Rotate(<function R_func>)
- from_(cls: type[Rotate], obj: AbstractQuantity, /) Rotate
- Parameters:
- Return type:
Construct a Rotate from a Quantity.
>>> import jax.numpy as jnp >>> import unxt as u >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(u.Q(jnp.eye(3), "")) Rotate(f64[3,3](jax))
Construct a Rotate from an Array.
>>> import jax.numpy as jnp >>> import coordinax.transforms as cxfm >>> cxfm.Rotate.from_(jnp.eye(3)) Rotate(f64[3,3](jax))
Initialize from a jax.scipy.spatial.transform.Rotation.
>>> import jax.numpy as jnp >>> from jax.scipy.spatial.transform import Rotation >>> import coordinax.main as cx
>>> R = Rotation.from_euler("z", 90, degrees=True) >>> op = cxfm.Rotate.from_(R)
>>> jnp.allclose(op.R, R.as_matrix()) Array(True, dtype=bool)
Construct a Scale from another Scale.
- from_(cls: type[Scale], obj: AbstractQuantity, /) Scale
- Parameters:
- Return type:
Construct a Scale from a dimensionless quantity matrix.
Construct a Scale from an array matrix.
Construct a Shear from another Shear.
- from_(cls: type[Shear], obj: AbstractQuantity, /) Shear
- Parameters:
- Return type:
Construct a Shear from a dimensionless quantity matrix.
Construct a Shear from an array matrix.
- Parameters:
cls (
type[AbstractTransform])args (
object)kwargs (
object)
- Return type:
- simplify()#
Simplify the operator.
This method calls coordinax.ops.simplify to simplify the operator.
- Return type:
Examples
>>> import unxt as u >>> import coordinax.transforms as cxfm
>>> op = cxfm.Identity() >>> op.simplify() is op True
>>> pipe = cxfm.Composed((cxfm.Identity(), cxfm.Identity())) >>> pipe Composed((Identity(), Identity())) >>> pipe.simplify() Identity()