rta_reconstruction.utils.coordinates.PlanarRepresentation

class rta_reconstruction.utils.coordinates.PlanarRepresentation(x, y, copy=True, **kwargs)[source]

Bases: BaseRepresentation

Representation of a point in a 2D plane. This is essentially a copy of the Cartesian representation used in astropy.

Parameters:
  • x (~astropy.units.Quantity) – The x and y coordinates of the point(s). If x and ``y``have different shapes, they should be broadcastable.

  • y (~astropy.units.Quantity) – The x and y coordinates of the point(s). If x and ``y``have different shapes, they should be broadcastable.

  • copy (bool, optional) – If True arrays will be copied rather than referenced.

__init__(x, y, copy=True, **kwargs)[source]

Methods

__init__(x, y[, copy])

copy(*args, **kwargs)

Return an instance containing copies of the internal data.

cross(other)

Vector cross product of two representations.

diagonal(*args, **kwargs)

Return an instance with the specified diagonals.

dot(other)

Dot product of two representations.

flatten(*args, **kwargs)

Return a copy with the array collapsed into one dimension.

from_cartesian(cartesian)

Create a representation of this class from a supplied Cartesian one.

from_representation(representation)

Create a new instance of this representation from another one.

get_name()

Name of the representation or differential.

mean(*args, **kwargs)

Vector mean.

norm()

Vector norm.

ravel(*args, **kwargs)

Return an instance with the array collapsed into one dimension.

represent_as(other_class[, differential_class])

Convert coordinates to another representation.

reshape(*args, **kwargs)

Returns an instance containing the same data with a new shape.

scale_factors()

Scale factors for each component's direction.

squeeze(*args, **kwargs)

Return an instance with single-dimensional shape entries removed.

sum(*args, **kwargs)

Vector sum.

swapaxes(*args, **kwargs)

Return an instance with the given axes interchanged.

take(indices[, axis, out, mode])

Return a new instance formed from the elements at the given indices.

to_cartesian()

Convert the representation to its Cartesian form.

transform(matrix)

Transform coordinates using a 3x3 matrix in a Cartesian basis.

transpose(*args, **kwargs)

Return an instance with the data transposed.

unit_vectors()

Cartesian unit vectors in the direction of each component.

with_differentials(differentials)

Create a new representation with the same positions as this representation, but with these new differentials.

without_differentials()

Return a copy of the representation without attached differentials.

Attributes

T

Return an instance with the data transposed.

attr_classes

components

A tuple with the in-order names of the coordinate components.

differentials

A dictionary of differential class instances.

info

isscalar

ndim

The number of dimensions of the instance and underlying arrays.

shape

The shape of the instance and underlying arrays.

size

The size of the object, as calculated from its shape.

x

The x component of the point(s).

xy

y

The y component of the point(s).

property T

Return an instance with the data transposed.

Parameters are as for T. All internal data are views of the data of the original.

property components

A tuple with the in-order names of the coordinate components.

copy(*args, **kwargs)

Return an instance containing copies of the internal data.

Parameters are as for copy().

cross(other)

Vector cross product of two representations.

The calculation is done by converting both self and other to ~astropy.coordinates.CartesianRepresentation, and converting the result back to the type of representation of self.

Parameters:

other (~astropy.coordinates.BaseRepresentation subclass instance) – The representation to take the cross product with.

Returns:

cross_product – With vectors perpendicular to both self and other, in the same type of representation as self.

Return type:

~astropy.coordinates.BaseRepresentation subclass instance

diagonal(*args, **kwargs)

Return an instance with the specified diagonals.

Parameters are as for diagonal(). All internal data are views of the data of the original.

property differentials

A dictionary of differential class instances.

The keys of this dictionary must be a string representation of the SI unit with which the differential (derivative) is taken. For example, for a velocity differential on a positional representation, the key would be 's' for seconds, indicating that the derivative is a time derivative.

dot(other)

Dot product of two representations.

The calculation is done by converting both self and other to ~astropy.coordinates.CartesianRepresentation.

Note that any associated differentials will be dropped during this operation.

Parameters:

other (~astropy.coordinates.BaseRepresentation) – The representation to take the dot product with.

Returns:

dot_product – The sum of the product of the x, y, and z components of the cartesian representations of self and other.

Return type:

~astropy.units.Quantity

flatten(*args, **kwargs)

Return a copy with the array collapsed into one dimension.

Parameters are as for flatten().

classmethod from_cartesian(cartesian)[source]

Create a representation of this class from a supplied Cartesian one.

Parameters:

other (~astropy.coordinates.CartesianRepresentation) – The representation to turn into this class

Returns:

representation – A new representation of this class’s type.

Return type:

~astropy.coordinates.BaseRepresentation subclass instance

classmethod from_representation(representation)

Create a new instance of this representation from another one.

Parameters:

representation (~astropy.coordinates.BaseRepresentation instance) – The presentation that should be converted to this class.

classmethod get_name()

Name of the representation or differential.

In lower case, with any trailing ‘representation’ or ‘differential’ removed. (E.g., ‘spherical’ for ~astropy.coordinates.SphericalRepresentation or ~astropy.coordinates.SphericalDifferential.)

info
mean(*args, **kwargs)

Vector mean.

Averaging is done by converting the representation to cartesian, and taking the mean of the x, y, and z components. The result is converted back to the same representation as the input.

Refer to ~numpy.mean for full documentation of the arguments, noting that axis is the entry in the shape of the representation, and that the out argument cannot be used.

Returns:

mean – Vector mean, in the same representation as that of the input.

Return type:

~astropy.coordinates.BaseRepresentation subclass instance

property ndim

The number of dimensions of the instance and underlying arrays.

norm()

Vector norm.

The norm is the standard Frobenius norm, i.e., the square root of the sum of the squares of all components with non-angular units.

Note that any associated differentials will be dropped during this operation.

Returns:

norm – Vector norm, with the same shape as the representation.

Return type:

astropy.units.Quantity

ravel(*args, **kwargs)

Return an instance with the array collapsed into one dimension.

Parameters are as for ravel(). Note that it is not always possible to unravel an array without copying the data. If you want an error to be raise if the data is copied, you should should assign shape (-1,) to the shape attribute.

represent_as(other_class, differential_class=None)

Convert coordinates to another representation.

If the instance is of the requested class, it is returned unmodified. By default, conversion is done via Cartesian coordinates. Also note that orientation information at the origin is not preserved by conversions through Cartesian coordinates. See the docstring for to_cartesian() for an example.

Parameters:
  • other_class (~astropy.coordinates.BaseRepresentation subclass) – The type of representation to turn the coordinates into.

  • differential_class (dict of ~astropy.coordinates.BaseDifferential, optional) – Classes in which the differentials should be represented. Can be a single class if only a single differential is attached, otherwise it should be a dict keyed by the same keys as the differentials.

reshape(*args, **kwargs)

Returns an instance containing the same data with a new shape.

Parameters are as for reshape(). Note that it is not always possible to change the shape of an array without copying the data (see reshape() documentation). If you want an error to be raise if the data is copied, you should assign the new shape to the shape attribute (note: this may not be implemented for all classes using NDArrayShapeMethods).

scale_factors()

Scale factors for each component’s direction.

Given unit vectors \(\hat{e}_c\) and scale factors \(f_c\), a change in one component of \(\delta c\) corresponds to a change in representation of \(\delta c \times f_c \times \hat{e}_c\).

Returns:

scale_factors – The keys are the component names.

Return type:

dict of ~astropy.units.Quantity

property shape

The shape of the instance and underlying arrays.

Like ~numpy.ndarray.shape, can be set to a new shape by assigning a tuple. Note that if different instances share some but not all underlying data, setting the shape of one instance can make the other instance unusable. Hence, it is strongly recommended to get new, reshaped instances with the reshape method.

Raises:
  • ValueError – If the new shape has the wrong total number of elements.

  • AttributeError – If the shape of any of the components cannot be changed without the arrays being copied. For these cases, use the reshape method (which copies any arrays that cannot be reshaped in-place).

property size

The size of the object, as calculated from its shape.

squeeze(*args, **kwargs)

Return an instance with single-dimensional shape entries removed.

Parameters are as for squeeze(). All internal data are views of the data of the original.

sum(*args, **kwargs)

Vector sum.

Adding is done by converting the representation to cartesian, and summing the x, y, and z components. The result is converted back to the same representation as the input.

Refer to ~numpy.sum for full documentation of the arguments, noting that axis is the entry in the shape of the representation, and that the out argument cannot be used.

Returns:

sum – Vector sum, in the same representation as that of the input.

Return type:

~astropy.coordinates.BaseRepresentation subclass instance

swapaxes(*args, **kwargs)

Return an instance with the given axes interchanged.

Parameters are as for swapaxes(): axis1, axis2. All internal data are views of the data of the original.

take(indices, axis=None, out=None, mode='raise')

Return a new instance formed from the elements at the given indices.

Parameters are as for take(), except that, obviously, no output array can be given.

to_cartesian()[source]

Convert the representation to its Cartesian form.

Note that any differentials get dropped. Also note that orientation information at the origin is not preserved by conversions through Cartesian coordinates. For example, transforming an angular position defined at distance=0 through cartesian coordinates and back will lose the original angular coordinates:

>>> import astropy.units as u
>>> import astropy.coordinates as coord
>>> rep = coord.SphericalRepresentation(
...     lon=15*u.deg,
...     lat=-11*u.deg,
...     distance=0*u.pc)
>>> rep.to_cartesian().represent_as(coord.SphericalRepresentation)
<SphericalRepresentation (lon, lat, distance) in (rad, rad, pc)
    (0., 0., 0.)>
Returns:

cartrepr – The representation in Cartesian form.

Return type:

~astropy.coordinates.CartesianRepresentation

transform(matrix)

Transform coordinates using a 3x3 matrix in a Cartesian basis.

This returns a new representation and does not modify the original one. Any differentials attached to this representation will also be transformed.

Parameters:

matrix ((3,3) array-like) – A 3x3 (or stack thereof) matrix, such as a rotation matrix.

transpose(*args, **kwargs)

Return an instance with the data transposed.

Parameters are as for transpose(). All internal data are views of the data of the original.

unit_vectors()

Cartesian unit vectors in the direction of each component.

Given unit vectors \(\hat{e}_c\) and scale factors \(f_c\), a change in one component of \(\delta c\) corresponds to a change in representation of \(\delta c \times f_c \times \hat{e}_c\).

Returns:

unit_vectors – The keys are the component names.

Return type:

dict of ~astropy.coordinates.CartesianRepresentation

with_differentials(differentials)

Create a new representation with the same positions as this representation, but with these new differentials.

Differential keys that already exist in this object’s differential dict are overwritten.

Parameters:

differentials (sequence of ~astropy.coordinates.BaseDifferential subclass instance) – The differentials for the new representation to have.

Returns:

A copy of this representation, but with the differentials as its differentials.

Return type:

~astropy.coordinates.BaseRepresentation subclass instance

without_differentials()

Return a copy of the representation without attached differentials.

Returns:

A shallow copy of this representation, without any differentials. If no differentials were present, no copy is made.

Return type:

~astropy.coordinates.BaseRepresentation subclass instance

property x

The x component of the point(s).

property y

The y component of the point(s).