convolution_detection
ConvolutionDetection
Bases: RotorDetection
KERNELS = {'nabla_2x2': np.array([[-1, 1], [0, 0]]), 'nabla_3x3': np.array([[-1, 0, 1], [-1, 0, 1], [0, 0, 0]]), 'sobel_3x3': np.array([[-1 / 2, 0, 1 / 2], [-1, 0, 1], [-1 / 2, 0, 1 / 2]]), 'sobel_5x5': np.array([[-1 / 4, -1 / 5, 0, 1 / 5, 1 / 4], [-2 / 5, -1 / 2, 0, 1 / 2, 2 / 5], [-1 / 2, -1, 0, 1, 1 / 2], [-2 / 5, -1 / 2, 0, 1 / 2, 2 / 5], [-1 / 4, -1 / 5, 0, 1 / 5, 1 / 4]])}
class-attribute
instance-attribute
kernel = self.KERNELS['nabla_3x3']
instance-attribute
tc_threshold = 0.95
instance-attribute
__init__(phase_maps)
Initialize the ConvolutionDetection class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase_maps |
ndarray[T, N, M]
|
T phases maps with shape (N, M). |
required |
calc_rotors(topocharge, direction)
calc_topocharge()
Calculate topological charge via 2D matrix convolution with kernels.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray[T, N, M]: Topological charge array. |
convolve(x, kernel)
Compute convolution of data using a certain kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
ndarray
|
Input array to be convoluted with arbitrary ndim. |
required |
kernel |
ndarray
|
Convolution kernel with dimension ndim-1. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Convoluted array with same shape as input array. |
detect()
Calculate (t_ind, node_ind, direction) of rotor centers.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Dataframe containing ['t_ind', 'x_ind', 'y_ind', 'direction']. |
set_kernel(kernel_name)
Set convolution kernel. Kernel: 'nabla_3x3'
set_tc_threshold(tc_threshold)
Threshold value for detecting rotor. Default: 0.95
unwrap_period(phases)
Keep every phase difference in [-pi, pi] range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phases |
ndarray
|
Array of phases. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of phases in range [-pi, pi] where every phase is restricted to its 2pi counterpart where needed. |