poreflow.utils
¶
apply_bessel_filter(x, sfreq, cutoff=1000, order=4)
¶
Applies a zero-phase Bessel low-pass filter.
apply_filter(x, sfreq, cutoff=False, verbose=False, method='bessel4')
¶
bhattacharyya_distance(mu_1, sigma_1, mu_2, sigma_2)
¶
Computes the Bhattacharyya distance between two multivariate Gaussians.
Supports array broadcasting for fast distance computations across multiple distirbutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu_1
|
ndarray
|
The mean of the first multivariate Gaussian. |
required |
sigma_1
|
ndarray
|
The covariance matrix of the first multivariate Gaussian. |
required |
mu_2
|
ndarray
|
The mean of the second multivariate Gaussian. |
required |
sigma_2
|
ndarray
|
The covariance matrix of the second multivariate Gaussian. |
required |
check_if_array_is_full_cycle(a, period)
¶
Checks if array contains data on half a cycle
Checks if array contains data on the full bias votlage cycle. In such an array each column contains the voltage/current data of a full bias votlage cycle. Each voltage has two columns, one for the up swing of the voltage cycle and one for the down swing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
ndarray
|
An array to check. |
required |
period
|
int
|
The period of the bias votlage cycle in samples. |
required |
check_if_array_is_half_cycle(a, period)
¶
Checks if array contains data on half a cycle
Checks if array contains data on half a bias votlage cycle. Such an array is referred to a 'long' matrix by Noakes et. al. (2019). In such an array, each row now corresponds to a single voltage, as opposed to a single phase point (each voltage point corresponds to two phase points, one for the up swing of the voltage cycle and one for the down swing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
ndarray
|
An array to check. |
required |
period
|
int
|
The period of the bias votlage cycle in samples. |
required |
fewer_ticks(ax, n_y=3, n_x=None)
¶
Makes a plot have fewer ticks
get_coef_cols(d)
¶
Gets the columns of the feature coefficients in a feature dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
An integer specifying the number of features. |
required |
get_cov_cols(d)
¶
Gets the columns of the covariance matrix in a feature dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
int
|
An integer specifying the number of features. |
required |
get_phase_from_fourier_component(fourier_component, period)
¶
Finds the phase in samples for a known complex fourier component.
The complex fourier component is assumed to be the component associated to
the frequency equivalent to period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fourier_component
|
complex128
|
A complex fourier component of frequency related to the period. |
required |
period
|
int
|
The period in samples. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The phase in samples of that complex component. |
get_phase_of_period(v_data, period, max_length_to_check=10000, min_amplitude=1, invert=True)
¶
Finds the phase of a frequency of a known period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_data
|
ndarray
|
A numpy array containing the time series of bias voltage. |
required |
period
|
int
|
The period in samples of the known bias frequency. |
required |
max_length_to_check
|
int
|
Maximum number of samples in which to find a period and phase. Defaults to 10,000 samples. Speeds up Fourier transform. |
10000
|
min_amplitude
|
float
|
The minimum amplitude in mV the bias frequency component should have. If this is not the case, the bias frequency is assumed to not be present and an error is raised. |
1
|
invert (bool): Whether to invert the phase. Defaults to True in which case the value returned is equivalent to a sample in the signal with zero phase shift. When set to False, the phase returned is the mathematical phase shift.
Returns:
| Type | Description |
|---|---|
int
|
An integer specifying the phase (offset) in samples of the bias |
int
|
frequency signal. |
Raises:
| Type | Description |
|---|---|
ValueError
|
This error is raised when no Fourier component of significant amplitude is found in the arrays. This might mean that no AC bias votlage was applied during the measurement. |
get_tu_delft_cmap()
¶
Gets a list of colors from the Delft University of Technology style guide
show_text(text)
¶
Displays styled text in a Jupyter notebook output cell.