qcodes.math_utils
The math_utils module contains math related utility functions and classes such as coordinate system mappings.
Classes:

A convenient class to keep track of vectors representing physical fields. 
 class qcodes.math_utils.FieldVector(x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None, r: Optional[float] = None, theta: Optional[float] = None, phi: Optional[float] = None, rho: Optional[float] = None)[source]
Bases:
object
A convenient class to keep track of vectors representing physical fields. The idea is that a vector instance stores a representation in Cartesian, spherical and cylindrical coordinates. All arguments are optional, however the user needs to provide one of the combinations of either (x, y, z) values or (rho, phi, z) values or (r, theta, phi) values at instantiation for a meaningful computation of the other representation, immediately.
 Parameters
x – represents the norm of the projection of the vector along the xaxis
y – represents the norm of the projection of the vector along the yaxis
z – represents the norm of the projection of the vector along the zaxis
r – represents the norm of the vector
theta – represents the angle of the vector with respect to the positive zaxis
rho – represents the norm of the projection of the vector on to the xyplane
phi – represents the angle of rho with respect to the positive xaxis
Attributes:
Methods:
copy
(other)Copy the properties of other vector to yourself.
set_vector
(**new_values)Reset the the values of the vector.
set_component
(**new_values)Set a single component of the vector to some new value.
get_components
(*names)Get field components by name.
is_equal
(other)Returns
True
ifother
is equivalent toself
,False
otherwise.norm
([ord])Returns the norm of this field vector.
distance
(other[, ord])from_homogeneous
(hvec) attributes = ['x', 'y', 'z', 'r', 'theta', 'phi', 'rho']
 repr_format = 'cartesian'
 set_vector(**new_values: float) None [source]
Reset the the values of the vector.
Examples
>>> f = FieldVector(x=0, y=2, z=6) >>> f.set_vector(x=9, y=3, z=1) >>> f.set_vector(r=1, theta=30.0, phi=10.0) # The following should raise a value error: # "Can only set vector with a complete value set" >>> f.set_vector(x=9, y=0) # Although mathematically it is possible to compute the complete # vector from the values given, this is too hard to implement with # generality (and not worth it), so the following will raise the # abovementioned ValueError too. >>> f.set_vector(x=9, y=0, r=3)
 set_component(**new_values: float) None [source]
Set a single component of the vector to some new value. It is disallowed for the user to set vector components manually as this can lead to inconsistencies (e.g. x and rho are not independent of each other, setting one has to effect the other).
Examples
>>> f = FieldVector(x=2, y=3, z=4) # Since r is part of the set (r, theta, phi) representing # spherical coordinates, setting r means that theta and phi are # kept constant and only r is changed. After changing r, # (x, y, z) values are recomputed, as is the rho coordinate. # Internally we arrange this by setting x, y, z and rho to None # and calling self._compute_unknowns(). >>> f.set_component(r=10)
 Parameters
new_values (dict) – Keys representing parameter names and values the values to be set.
 is_equal(other: FieldVector) bool [source]
Returns
True
ifother
is equivalent toself
,False
otherwise.