# NDCartesianDifferential¶

class gala.dynamics.representation_nd.NDCartesianDifferential(d_x, unit=None, copy=True)[source]

Bases: gala.dynamics.representation_nd.NDMixin, astropy.coordinates.CartesianDifferential

Differentials in of points in ND cartesian coordinates.

Parameters
*d_xQuantity or array

The Cartesian coordinates of the differentials. If not quantity, unit should be set.

unitUnit or str

If given, the differentials will be converted to this unit (or taken to be in this unit if not given.

copybool, optional

If True (default), arrays will be copied rather than referenced.

Attributes Summary

 T Return an instance with the data transposed. attr_classes components A tuple with the in-order names of the coordinate components. d_x Component ‘d_x’ of the Differential. d_xyz Return a vector array of the x, y, and z coordinates. d_y Component ‘d_y’ of the Differential. d_z Component ‘d_z’ of the Differential. 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.

Methods Summary

 copy(*args, **kwargs) Return an instance containing copies of the internal data. diagonal(*args, **kwargs) Return an instance with the specified diagonals. flatten(*args, **kwargs) Return a copy with the array collapsed into one dimension. from_cartesian(other[, base]) Convert the differential from 3D rectangular cartesian coordinates to the desired class. from_representation(representation, base) Create a new instance of this representation from another one. get_d_xyz([xyz_axis]) Return a vector array of the x, y, and z coordinates. Name of the representation or differential. norm([base]) Vector norm. ravel(*args, **kwargs) Return an instance with the array collapsed into one dimension. represent_as(other_class, base) Convert coordinates to another representation. reshape(*args, **kwargs) Returns an instance containing the same data with a new shape. squeeze(*args, **kwargs) Return an instance with single-dimensional shape entries removed swapaxes(*args, **kwargs) Return an instance with the given axes interchanged. take(indices[, axis, mode]) Return a new instance formed from the elements at the given indices. to_cartesian([base]) Convert the differential to 3D rectangular cartesian coordinates. transpose(*args, **kwargs) Return an instance with the data transposed.

Attributes Documentation

T

Return an instance with the data transposed.

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

attr_classes = {}
components

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

d_x

Component ‘d_x’ of the Differential.

d_xyz

Return a vector array of the x, y, and z coordinates.

Parameters
xyz_axisint, optional

The axis in the final array along which the x, y, z components should be stored (default: 0).

Returns
d_xsQuantity

With dimension 3 along xyz_axis.

d_y

Component ‘d_y’ of the Differential.

d_z

Component ‘d_z’ of the Differential.

isscalar
ndim

The number of dimensions of the instance and underlying arrays.

shape

The shape of the instance and underlying arrays.

Like 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
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).

size

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

Methods Documentation

copy(*args, **kwargs)

Return an instance containing copies of the internal data.

Parameters are as for copy().

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.

flatten(*args, **kwargs)

Return a copy with the array collapsed into one dimension.

Parameters are as for flatten().

classmethod from_cartesian(other, base=None)

Convert the differential from 3D rectangular cartesian coordinates to the desired class.

Parameters
other :

The object to convert into this differential.

baseinstance of self.base_representation

The points for which the differentials are to be converted: each of the components is multiplied by its unit vectors and scale factors.

Returns
A new differential object that is this class’ type.
classmethod from_representation(representation, base)

Create a new instance of this representation from another one.

Parameters
representationBaseRepresentation instance

The presentation that should be converted to this class.

baseinstance of cls.base_representation

The base relative to which the differentials will be defined. If the representation is a differential itself, the base will be converted to its base_representation to help convert it.

get_d_xyz(xyz_axis=0)[source]

Return a vector array of the x, y, and z coordinates.

Parameters
xyz_axisint, optional

The axis in the final array along which the x, y, z components should be stored (default: 0).

Returns
d_xsQuantity

With dimension 3 along xyz_axis.

classmethod get_name()

Name of the representation or differential.

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

norm(base=None)

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.

Parameters
baseinstance of self.base_representation

Base relative to which the differentials are defined. This is required to calculate the physical size of the differential for all but cartesian differentials.

Returns
normastropy.units.Quantity

Vector norm, with the same shape as the representation.

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, base)

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.

Parameters
other_classBaseRepresentation subclass

The type of representation to turn the coordinates into.

baseinstance of self.base_representation, optional

Base relative to which the differentials are defined. If the other class is a differential representation, the base will be converted to its base_representation.

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 ShapedLikeNDArray).

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.

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, 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(base=None)

Convert the differential to 3D rectangular cartesian coordinates.

Parameters
baseinstance of self.base_representation

The points for which the differentials are to be converted: each of the components is multiplied by its unit vectors and scale factors.

Returns
This object as a CartesianDifferential
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.