open_viewmin.filter_tree_plot.utilities.calculations#
General calculation utilities.
Attributes#
Functions#
Create a callable that defines a new dataset on a given mesh from a |
|
|
Create callable that will apply a calculation to a scalar dataset. |
|
Create callable that will apply a calculation to a dataset of |
|
Create a callable that defines a new dataset on a given mesh from a |
|
Create callable that will apply a calculation to a vector dataset. |
|
Gradient |
|
Hessian |
|
Increase flexibility of numpy.einsum, for convenience in calculating |
|
Unflatten a list of values so that the first three dimensions of the |
Compute matrix product $A A^T$ for a matrix $A$. |
|
|
take inverse $x rightarrow 1/x$ but with $0 rightarrow 0$ |
Compute matrix product $A^T A$ for a matrix $A$. |
|
|
Partially flatten an array from shape (Lx, Ly, Lz, ...) to |
Module Contents#
- calculate_from_one_vector_field_and_one_scalar_field(plotter, vector_field_name, scalar_field_name, operation_string, mesh_name='fullmesh')#
Create a callable that defines a new dataset on a given mesh from a named operation on one vector field and one scalar field already defined on that mesh.
- Parameters:
plotter (
FilterTreePlot
)vector_field_name (str)
scalar_field_name (str)
operation_string (str) – Must be “scale”
mesh_name (str)
- Return type:
callable()
- calculate_from_scalar_field(plotter, scalar_field_name, operation_string, mesh_name='fullmesh')#
Create callable that will apply a calculation to a scalar dataset.
- Parameters:
plotter (
FilterTreePlot
)scalar_field_name (str) – Name of scalar dataset
operation_string (str) – String key for calculation; must be one of: “gradient” or “Laplacian”
- mesh_namestr, optional
Name of mesh from which to extract dataset
- Return type:
callable()
- calculate_from_tensor_field(plotter, tensor_field_name, operation_string, mesh_name='fullmesh')#
Create callable that will apply a calculation to a dataset of Hermitian, rank-2 tensors.
- Parameters:
plotter (
FilterTreePlot
)tensor_field_name (str) – Name of tensor dataset
operation_string (str) – String key for calculation; must be ‘eigvalsh’ or ‘eigh’
mesh_name (str, optional) – Name of mesh from which to extract dataset
- Return type:
callable()
- calculate_from_two_vector_fields(plotter, vector_field1_name, vector_field2_name, operation_string, mesh_name='fullmesh')#
Create a callable that defines a new dataset on a given mesh from a named operation on two vector fields already defined on that mesh.
- Parameters:
plotter (
FilterTreePlot
)vector_field1_name (str)
vector_field2_name (str)
operation_string (str) – Must be “cross” or “dot”
mesh_name (str)
- Return type:
callable()
- calculate_from_vector_field(plotter, vector_field_name, operation_string, mesh_name='fullmesh')#
Create callable that will apply a calculation to a vector dataset.
- Parameters:
plotter (
FilterTreePlot
)vector_field_name (str) – Name of vector dataset
operation_string (str) – String key for calculation; must be one of: ‘x’, ‘y’, ‘z’, ‘|x|’, ‘|y|’, ‘|z|’, ‘div’, or ‘curl’
mesh_name (str, optional) – Name of mesh from which to extract dataset
- Return type:
callable()
- di(arr, array_dims, flatten=False, component=None, data_stride=1)#
Gradient
- Parameters:
arr (
np.ndarray
)array_dims (tuple(int))
flatten (bool)
component (int or None)
data_stride (int)
- Return type:
np.ndarray
- dij(arr, array_dims, flatten=False, data_stride=1)#
Hessian
- Parameters:
arr (
np.ndarray
)array_dims (tuple(int))
flatten (bool)
data_stride (int)
- Return type:
np.ndarray
- einstein_sum(sum_str, *arrays, reshape=True)#
Increase flexibility of numpy.einsum, for convenience in calculating datasets
- Parameters:
sum_str (str)
arrays (tuple(
np.ndarray
))reshape (bool)
- Return type:
np.ndarray
- list_to_xyzmat(arr, dims)#
Unflatten a list of values so that the first three dimensions of the returned array correspond to the spatial grid.
- Parameters:
arr (
np.ndarray
)dims (tuple(int))
- Return type:
np.ndarray
- matrix_times_transpose(arr)#
Compute matrix product \(A A^T\) for a matrix \(A\).
- Parameters:
arr (
np.ndarray
)- Return type:
np.ndarray
- safe_inverse(arr)#
take inverse \(x \rightarrow 1/x\) but with \(0 \rightarrow 0\)
- Parameters:
arr (
np.ndarray
)- Return type:
np.ndarray
- transpose_times_matrix(arr)#
Compute matrix product \(A^T A\) for a matrix \(A\).
- Parameters:
arr (
np.ndarray
)- Return type:
np.ndarray
- xyzmat_to_list(arr)#
Partially flatten an array from shape (Lx, Ly, Lz, …) to (Lx * Ly * Lz, …).
- Parameters:
arr (
np.ndarray
)- Return type:
np.ndarray
- levi_civita#