![]() |
kdotpy
|
Public Member Functions | |
__init__ (self, *val, astype=None, deg=None) | |
len (self, square=False) | |
__abs__ (self) | |
x (self) | |
y (self) | |
z (self) | |
xy (self) | |
xyz (self) | |
pm (self) | |
pmz (self) | |
polar (self, deg=True, fold=True) | |
cylindrical (self, deg=True, fold=True) | |
spherical (self, deg=True, fold=True) | |
component (self, comp, prefix='') | |
components (self, prefix='') | |
to_dict (self, prefix='', all_components=False) | |
get_pname_pval (self, prefix='') | |
set_component (self, comp, val=None, prefix='', inplace=True) | |
astype (self, astype, inplace=False, deg=None, fold=True, force=False) | |
reflect (self, axis=None, inplace=False, deg=None, fold=True) | |
__neg__ (self) | |
diff (self, other, square=False) | |
__sub__ (self, other) | |
equal (self, other, acc=1e-9) | |
zero (self, acc=1e-9) | |
__eq__ (self, other) | |
__ne__ (self, other) | |
identical (self, other, acc=1e-9) | |
parallel (self, other, acc=1e-9) | |
perpendicular (self, other, acc=1e-9) | |
__str__ (self, formatstr='%6.3f') | |
__repr__ (self) | |
xmlattr (self, prefix='') | |
to_tuple (self) | |
Public Attributes | |
tuple | degrees = None |
tuple | value = val |
str | vtype = astype |
tuple | aunit = None if self.degrees is None else pi / 180. if self.degrees else 1.0 |
Vector object Attributes: value Float or tuple. The vector component(s). vtype String. The vector type, which defines the parametrization of the vector. Is one of: 'x', 'y', 'z', 'xy', 'xyz', 'pol', 'cyl', 'sph'. degrees True, False or None. Whether angular units are degrees (True) or radians (False). None means unknown or undefined. aunit Float or None. Multiplier for angular coordinates. This is pi/180 for degrees, 1 for radians, and None if the angular unit is unkwown.
kdotpy.momentum.Vector.__init__ | ( | self, | |
* | val, | ||
astype = None, | |||
deg = None ) |
kdotpy.momentum.Vector.__abs__ | ( | self | ) |
kdotpy.momentum.Vector.__eq__ | ( | self, | |
other ) |
Test equality with other Vector instance or zero.
kdotpy.momentum.Vector.__ne__ | ( | self, | |
other ) |
Test inequality with other Vector instance or zero.
kdotpy.momentum.Vector.__neg__ | ( | self | ) |
Unary minus. The same as self.reflect('xyz').
kdotpy.momentum.Vector.__repr__ | ( | self | ) |
kdotpy.momentum.Vector.__str__ | ( | self, | |
formatstr = '%6.3f' ) |
String representation
kdotpy.momentum.Vector.__sub__ | ( | self, | |
other ) |
Alias for vector difference, |v1 - v2|
kdotpy.momentum.Vector.astype | ( | self, | |
astype, | |||
inplace = False, | |||
deg = None, | |||
fold = True, | |||
force = False ) |
Convert Vector to the given vector type. Arguments: astype String. Target vector type. inplace True or False. If True, return the present Vector instance. If False, return a new instance. deg True, False, or None. Whether the values of the angles in the target vector should be in degrees (True) or radians (False). If None, use the default. fold True or False. Whether to use folding for angular vector types. force True or False. If True, generate a new vector even if the target vector type is the same as that of the present instance. For angular types, this may involve folding or unfolding. If False, return the same vector if the vector types are the same. Returns: The present or a new Vector instance.
kdotpy.momentum.Vector.component | ( | self, | |
comp, | |||
prefix = '' ) |
Get component value. Argument: comp String. Which component to return. prefix String that matches the first part of the input comp, for example comp = 'kphi', prefix = 'k' is a valid input. Returns: A float. The value of the component.
kdotpy.momentum.Vector.components | ( | self, | |
prefix = '' ) |
Get natural components depending on vector type. Argument: prefix String that is prepended to the return value. Returns: List of strings.
kdotpy.momentum.Vector.cylindrical | ( | self, | |
deg = True, | |||
fold = True ) |
Get cylindrical coordinates r, phi and z (as tuple) Arguments: deg True or False. Whether the return value of phi should be in degrees (True) or radians (False). fold True or False. Whether to use folding. See polar_fold(). Returns: r, phi, z Floats. Cylindrical coordinates
kdotpy.momentum.Vector.diff | ( | self, | |
other, | |||
square = False ) |
Distance between two vectors |v1 - v2|. Arguments: other Vector instance or zero (0 or 0.0). The second vector. Zero means the zero vector. square True or False. If True, return |v1 - v2|^2 instead. Returns: A float.
kdotpy.momentum.Vector.equal | ( | self, | |
other, | |||
acc = 1e-9 ) |
Test vector equality v1 == v2. Equality means that the two instances refer to the same point in (1-, 2-, or 3-dimensional) space. The representations (vector types and values) need not be identical. Arguments: other Vector instance or zero (0 or 0.0). The second vector. Zero means the zero vector. acc Float. The maximum Euclidean difference for the vectors to be considered equal. Default value is 1e-9. Returns: True or False.
kdotpy.momentum.Vector.get_pname_pval | ( | self, | |
prefix = '' ) |
Return variable name and value for plot parameter text Either a single component like 'kx = 0.1' or a tuple for multiple components like '(kx, ky) = (0.1, 0.2)'.
kdotpy.momentum.Vector.identical | ( | self, | |
other, | |||
acc = 1e-9 ) |
Test vector identity v1 === v2. Identity means that the two instances have the same vector type and have the same values. Arguments: other Vector instance. The second vector. acc Float. The maximum absolute for the values to be considered equal. Default value is 1e-9. Returns: True or False.
kdotpy.momentum.Vector.len | ( | self, | |
square = False ) |
Length (magnitude) of the vector. Argument: square True or False. If True, return the squared value.
kdotpy.momentum.Vector.parallel | ( | self, | |
other, | |||
acc = 1e-9 ) |
Test whether two vectors are parallel. Do so by calculation the cross product. This is equal to zero if and only if the vectors are parallel. Arguments: other Vector instance or zero. The second vector. If zero, interpret as the zero vector. Then the result is always True. acc Float. The maximum length difference of the cross product for it to be considered zero. Default value is 1e-9. Returns: True or False.
kdotpy.momentum.Vector.perpendicular | ( | self, | |
other, | |||
acc = 1e-9 ) |
Test whether two vectors are perpendicular. Do so by calculation the inner product. This is equal to zero if and only if the vectors are perpendicular. Arguments: other Vector instance or zero. The second vector. If zero, interpret as the zero vector. Then the result is always True. acc Float. The maximum length difference of the cross product for it to be considered zero. Default value is 1e-9. Returns: True or False.
kdotpy.momentum.Vector.pm | ( | self | ) |
Get x + i y and x - i y (as tuple)
kdotpy.momentum.Vector.pmz | ( | self | ) |
Get x + i y, x - i y, and z (as tuple)
kdotpy.momentum.Vector.polar | ( | self, | |
deg = True, | |||
fold = True ) |
Get polar coordinates r and phi (as tuple) Arguments: deg True or False. Whether the return value of phi should be in degrees (True) or radians (False). fold True or False. Whether to use folding. See polar_fold(). Returns: r, phi Floats. Polar coordinates
kdotpy.momentum.Vector.reflect | ( | self, | |
axis = None, | |||
inplace = False, | |||
deg = None, | |||
fold = True ) |
Reflect Vector to the given vector type. Arguments: axis String or None. The axis/axes along which to reflect; one of '', 'x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz'. The empty string is equivalent to the identity transformation. None is equivalent to 'xyz', which is an overall sign flip. inplace True or False. If True, return the present Vector instance. If False, return a new instance. deg True, False, or None. Whether the values of the angles in the target vector should be in degrees (True) or radians (False). If None, use the default. fold True or False. Whether to use folding for angular vector types. Returns: The present or a new Vector instance.
kdotpy.momentum.Vector.set_component | ( | self, | |
comp, | |||
val = None, | |||
prefix = '', | |||
inplace = True ) |
Set specific labelled component(s). Arguments: comp, val Component and value. Can be one of the following combinations. If None, None, do nothing. If comp is a dict and val is None, set values according to the dict. (This must be of the form {component: value}, where component is a string, like 'x' and value a number. If comp is a string and val a number, set that component to that value. If comp is a list/tuple of strings and val is a list/tuple of number, set the components to the respective values. prefix Prefix for vector components, e.g., 'k'. inplace True or False. If True, return the present Vector instance. If False, return a new instance. Returns: The present or a new Vector instance.
kdotpy.momentum.Vector.spherical | ( | self, | |
deg = True, | |||
fold = True ) |
Get spherical coordinates r, theta and phi (as tuple) Arguments: deg True or False. Whether the return value of phi should be in degrees (True) or radians (False). fold True or False. Whether to use folding. See spherical_fold(). Returns: r, theta, phi Floats. Spherical coordinates.
kdotpy.momentum.Vector.to_dict | ( | self, | |
prefix = '', | |||
all_components = False ) |
Return a dict with components and values Argument: prefix String that is prepended to the return value. all_components True or False. If True, give all components x, y, z, phi, and theta, as well as len and abs. If False, give the appropriate components for the vtype only. Returns: vdict A dict instance, with vector components as keys.
kdotpy.momentum.Vector.to_tuple | ( | self | ) |
kdotpy.momentum.Vector.x | ( | self | ) |
Get the x component
kdotpy.momentum.Vector.xmlattr | ( | self, | |
prefix = '' ) |
XML output (attributes and values) Attributes: prefix String that is prepended to the vector components to form the attributes. Returns: A dict of the form {attribute: value, ...}, where attribute is the XML attribute for an XML <vector> tag or similar.
kdotpy.momentum.Vector.xy | ( | self | ) |
Get the x and y component (as tuple)
kdotpy.momentum.Vector.xyz | ( | self | ) |
Get the x, y, and z component (as tuple)
kdotpy.momentum.Vector.y | ( | self | ) |
Get the y component
kdotpy.momentum.Vector.z | ( | self | ) |
Get the z component
kdotpy.momentum.Vector.zero | ( | self, | |
acc = 1e-9 ) |
Test whether vector equals zero vector. Arguments: acc Float. The maximum length for the vector to be considered zero. Default value is 1e-9. Returns: True or False.
tuple kdotpy.momentum.Vector.aunit = None if self.degrees is None else pi / 180. if self.degrees else 1.0 |
tuple kdotpy.momentum.Vector.degrees = None |
kdotpy.momentum.Vector.value = val |
kdotpy.momentum.Vector.vtype = astype |