NDCartesianDifferential#
- class gala.dynamics.representation_nd.NDCartesianDifferential(d_x, unit=None, copy=True)[source]#
Bases:
NDMixin,CartesianDifferentialDifferentials in of points in ND cartesian coordinates.
- Parameters:
- *d_x
Quantityorarray The Cartesian coordinates of the differentials. If not quantity,
unitshould be set.- unit
Unitorstr 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.
- *d_x
Attributes Summary
Return an instance with the data transposed.
A tuple with the in-order names of the coordinate components.
Component 'd_x' of the Differential.
Return a vector array of the x, y, and z coordinates.
Component 'd_y' of the Differential.
Component 'd_z' of the Differential.
Container for meta information like name, description, format.
The combined mask of all components.
Whether or not the instance uses masked values.
Name of the representation or differential.
The number of dimensions of the instance and underlying arrays.
The shape of the instance and underlying arrays.
The size of the object, as calculated from its shape.
Get an instance without the mask.
Methods Summary
copy(*args, **kwargs)Return an instance containing copies of the internal data.
diagonal(*args, **kwargs)Return an instance with the specified diagonals.
filled(fill_value)Get a copy of the underlying data, with masked values filled in.
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.
get_mask(*attrs)Calculate the mask, by combining masks from the given attributes.
get_name()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, out, mode])Return a new instance formed from the elements at the given indices.
to_cartesian([base])Convert the differential to 3D rectangular cartesian coordinates.
transform(matrix[, base, transformed_base])Transform differentials using a 3x3 matrix in a Cartesian basis.
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.
- d_y#
Component ‘d_y’ of the Differential.
- d_z#
Component ‘d_z’ of the Differential.
- info#
Container for meta information like name, description, format. This is required when the object is used as a mixin column within a table, but can be used as a general way to store meta information.
- isscalar#
- mask#
The combined mask of all components.
- masked#
- name: ClassVar[str] = 'ndcartesian'#
Name of the representation or differential.
When a subclass is defined, by default, the name is the lower-cased name of the class with with any trailing ‘representation’ or ‘differential’ removed. (E.g., ‘spherical’ for
SphericalRepresentationorSphericalDifferential.)This can be customized when defining a subclass by setting the class attribute.
- 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 thereshapemethod.- Raises:
ValueErrorIf the new shape has the wrong total number of elements.
AttributeErrorIf the shape of any of the components cannot be changed without the arrays being copied. For these cases, use the
reshapemethod (which copies any arrays that cannot be reshaped in-place).
- size#
The size of the object, as calculated from its shape.
- unmasked#
Get an instance without the mask.
Note that while one gets a new instance, the underlying data will be shared.
See also
filledget a copy of the underlying data, with masked values filled in.
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.
- filled(fill_value)#
Get a copy of the underlying data, with masked values filled in.
- Parameters:
- fill_value
object Value to replace masked values with.
- fill_value
- Returns:
- filledinstance
Copy of
selfwith masked items replaced byfill_value.
See also
unmaskedget an instance without the mask.
- 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.
- base
BaseRepresentation The points for which the differentials are to be converted: each of the components is multiplied by its unit vectors and scale factors. Will be converted to
cls.base_representationif needed.
- Returns:
BaseDifferentialsubclass instanceA new differential object that is this class’ type.
- classmethod from_representation(representation, base)#
Create a new instance of this representation from another one.
- Parameters:
- representation
BaseRepresentationinstance 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_representationto help convert it.
- representation
- get_mask(*attrs)#
Calculate the mask, by combining masks from the given attributes.
- classmethod get_name()#
Deprecated since version v7.1: The get_name method is deprecated and may be removed in a future version. Use name instead.
Name of the representation or differential.
Returns the
.nameattribute.
- 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 or radial differentials.
- baseinstance of
- Returns:
- norm
astropy.units.Quantity Vector norm, with the same shape as the representation.
- norm
- 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_class
BaseRepresentationsubclass The type of representation to turn the coordinates into.
- baseinstance of
self.base_representation 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.
- other_class
- 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 (seereshape()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 usingNDArrayShapeMethods).
- 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, 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(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.
- baseinstance of
- Returns:
CartesianDifferentialThis object, converted.
- transform(matrix, base=None, transformed_base=None)#
Transform differentials using a 3x3 matrix in a Cartesian basis.
This returns a new differential and does not modify the original one.
- Parameters:
- matrix(3,3) array_like
A 3x3 (or stack thereof) matrix, such as a rotation matrix.
- base, transformed_base
CartesianRepresentationorNone, optional Not used in the Cartesian transformation.
- 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.