GenericDifferential¶
- class interpolated_coordinates.utils.generic_representation.GenericDifferential(*args, **kwargs)[source]¶
Bases:
BaseDifferential
,GenericRepresentationOrDifferential
A base class representing differentials of representations.
These represent differences or derivatives along each component. E.g., for physics spherical coordinates, these would be \(\delta r, \delta \theta, \delta \phi\).
- Parameters:
- d_q1, d_q2, d_q3
Quantity
or subclass The components of the 3D differentials. The names are the keys and the subclasses the values of the
attr_classes
attribute.- copybool, optional
If
True
(default), arrays will be copied. IfFalse
, arrays will be references, though possibly broadcast to ensure matching shapes.
- d_q1, d_q2, d_q3
Attributes Summary
Return an instance with the data transposed.
A tuple with the in-order names of the coordinate components.
Component 'd_q1' of the Differential.
Component 'd_q2' of the Differential.
Component 'd_q3' of the Differential.
Container for meta information like name, description, format.
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.
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_name
()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, 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 differential 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 = {'d_q1': <class 'astropy.units.quantity.Quantity'>, 'd_q2': <class 'astropy.units.quantity.Quantity'>, 'd_q3': <class 'astropy.units.quantity.Quantity'>}¶
- components¶
A tuple with the in-order names of the coordinate components.
- d_q1¶
Component ‘d_q1’ of the Differential.
- d_q2¶
Component ‘d_q2’ of the Differential.
- d_q3¶
Component ‘d_q3’ 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¶
- 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 thereshape
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).
- 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)¶
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_representation
if needed.
- Returns:
BaseDifferential
subclass 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
BaseRepresentation
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.
- representation
- classmethod get_name()¶
Name of the representation or differential.
In lower case, with any trailing ‘representation’ or ‘differential’ removed. (E.g., ‘spherical’ for
SphericalRepresentation
orSphericalDifferential
.)
- 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
BaseRepresentation
subclass 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)¶
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:
CartesianDifferential
This object, converted.
- transform(matrix, base, transformed_base)¶
Transform differential 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.
- baseinstance of
cls.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
.- transformed_baseinstance of
cls.base_representation
Base relative to which the transformed differentials are defined. If the other class is a differential representation, the base will be converted to its
base_representation
.
- 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.