PhysicsSphericalVectorField¶
- class discO.utils.PhysicsSphericalVectorField(points: BaseRepresentation, vf_phi, vf_theta=None, vf_r=None, frame: CoordinateFrame | SkyCoord | str | None = None, copy: bool = False)[source]¶
Bases:
BaseVectorField
PhysicsSpherical Vector Field.
Attributes Summary
Return an instance with the data transposed.
A tuple with the in-order names of the coordinate components.
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.
Component 'vf_phi' of the VectorField.
Component 'vf_r' of the VectorField.
Component 'vf_theta' of the VectorField.
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)Convert field from 3D Cartesian coordinates to the desired class.
from_field
(vectorfield)Create a new instance of this vectorfield from another one.
get_name
()Name of the representation or differential.
norm
()Vector norm.
ravel
(*args, **kwargs)Return an instance with the array collapsed into one dimension.
represent_as
(other_class)Convert coordinates to another representation.
reshape
(*args, **kwargs)Returns an instance containing the same data with a new shape.
Scale factors for each component's direction.
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.
Convert the field to 3D rectangular cartesian coordinates.
transpose
(*args, **kwargs)Return an instance with the data transposed.
Cartesian unit vectors in the direction of each component.
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 = {'vf_phi': <class 'astropy.units.quantity.Quantity'>, 'vf_r': <class 'astropy.units.quantity.Quantity'>, 'vf_theta': <class 'astropy.units.quantity.Quantity'>}¶
- components¶
A tuple with the in-order names of the coordinate components.
- frame¶
- 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.
- phi¶
- points¶
- r¶
- 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.
- theta¶
- vf_phi¶
Component ‘vf_phi’ of the VectorField.
- vf_r¶
Component ‘vf_r’ of the VectorField.
- vf_theta¶
Component ‘vf_theta’ of the VectorField.
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)¶
Convert field from 3D Cartesian coordinates to the desired class.
- Parameters:
- other
CartesianVectorField
The object to convert into this vector field.
- other
- Returns:
BaseVectorField
A new Vector Field object that is this class’ type.
- classmethod from_field(vectorfield)¶
Create a new instance of this vectorfield from another one.
- Parameters:
- vectorfield
BaseVectorField
instance The presentation that should be converted to this class.
- vectorfield
- 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() Quantity ¶
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
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)¶
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
BaseVectorField
subclass The type of representation to turn the coordinates into.
- 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
).
- scale_factors() Dict[str, Quantity] ¶
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\).
- 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()¶
Convert the field to 3D rectangular cartesian coordinates.
- Returns:
CartesianVectorField
This object, converted
- 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() Dict[str, BaseRepresentation] ¶
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
dict
ofCartesianRepresentation
The keys are the component names.
- unit_vectors