pylbo.utilities.toolbox
Module Contents
Functions
|
|
Retrieves the geometry of a given matplotlib axis. |
|
|
Determines which values to retrieve from an array. |
|
Makes a matplotlib artist pickable and adds a pickradius. |
|
Does a custom enumeration with a given stepsize. |
|
Transforms a given input argument obj to a list. If obj |
|
Transforms a given input argument obj to a numpy array. |
|
Solves a given cubic polynomial of the form |
|
Counts the number of zeroes of an array of complex eigenfunctions by looking at |
|
Finds the location of resonance for eigenmode solutions having a real part that |
- pylbo.utilities.toolbox.get_axis_geometry(ax)[source]
Retrieves the geometry of a given matplotlib axis.
- pylbo.utilities.toolbox.get_values(array, which_values)[source]
Determines which values to retrieve from an array.
- Parameters:
array (numpy.ndarray) – The array with values.
which_values (str) –
Can be one of the following:
”average”: returns the average of the array
”minimum”: returns the minimum of the array
”maximum”: returns the maximum of the array
If not supplied or equal to None, simply returns the array.
- Returns:
array – Numpy array with values depending on the argument provided.
- Return type:
- pylbo.utilities.toolbox.add_pickradius_to_item(item, pickradius)[source]
Makes a matplotlib artist pickable and adds a pickradius. We have to handle this separately, because for line2D items the method
set_picker()
is deprecated from version 3.3 onwards.
- pylbo.utilities.toolbox.custom_enumerate(iterable, start=0, step=1)[source]
Does a custom enumeration with a given stepsize.
- Parameters:
- Yields:
start (int) – The current index in iterable, incremented with step.
itr (~typing.Iterable) – The corresponding entry of iterable.
- pylbo.utilities.toolbox.transform_to_list(obj: any) list [source]
Transforms a given input argument obj to a list. If obj is a Numpy-array or tuple, a cast to list() is invoked.
- Parameters:
obj (any) – The object to transform.
- Returns:
The object converted to a list.
- Return type:
- pylbo.utilities.toolbox.transform_to_numpy(obj: any) numpy.ndarray [source]
Transforms a given input argument obj to a numpy array.
- Parameters:
obj (any) – The object to transform.
- Returns:
The object transformed to a numpy array.
- Return type:
- pylbo.utilities.toolbox.solve_cubic_exact(a, b, c, d)[source]
Solves a given cubic polynomial of the form \(ax^3 + bx^2 + cx + d = 0\) using the analytical cubic root formula instead of the general numpy.roots routine. From StackOverflow.
- Parameters:
- Returns:
roots – The three roots of the cubic polynomial as a Numpy array.
- Return type:
np.ndarray(ndim=3, dtype=complex)
- pylbo.utilities.toolbox.count_zeroes(eigfuncs)[source]
Counts the number of zeroes of an array of complex eigenfunctions by looking at sign changes of the real and imaginary part of the eigenfunctions. Doesn’t include the grid endpoints in the count, since the boundary conditions are automatically satisfied. This only becomes accurate for eigenfunctions with enough oscillations and is resolution dependent. Therefore, we take the minimum of the number of zeroes of the real and imaginary part.
- Parameters:
eigfuncs (numpy.ndarray) – Array of eigenfunction arrays of complex numbers.
- Returns:
nzeroes – Counter array containing the number of zeroes of the real or imaginary part of each input eigenfunction array.
- Return type:
np.ndarray(dtype=int)
- pylbo.utilities.toolbox.invert_continuum_array(cont, r_gauss, sigma)[source]
Finds the location of resonance for eigenmode solutions having a real part that might overlap with a continuum range.
- Parameters:
cont (numpy.ndarray) – Array containing the range of a specific continuum. Automatically has the same length as r_gauss, since it has the same shape as the equilibrium fields used to calculate the continua. Can be complex, but only the resonance with the real part is calculated.
r_gauss (numpy.ndarray) – Array containing the grid on which equilibrium fields are defined.
sigma (complex) – An eigenvalue solution of the generalized eigenvalue problem.
- Returns:
r_inv – The location where there is resonance between the eigenmode and the continuum. Returns None if there is no resonance with the specified continuum.
- Return type:
None, float