scope.utils package
- scope.utils.plot.plot_emd_spectrum(emd_sp, cutoff_period, conf_period=None, conf_up=None, conf_down=None, conf_mean=None, fap=None)[source]
Plots the Empirical Mode Decomposition (EMD) energy spectrum along with optional confidence intervals and significant mode markers.
- Parameters:
emd_sp (dict) –
- Dictionary containing the EMD spectrum data with the following keys:
’period’: numpy array, periods of the EMD modes.
’energy’: numpy array, energy values of the EMD modes.
’period_err’: numpy array, uncertainties in the period values.
cutoff_period (float) – The cutoff period value, shown as a vertical dashed line on the plot.
conf_period (numpy array, optional) – Period values corresponding to the confidence intervals. If provided, confidence intervals are plotted.
conf_up (numpy array, optional) – Upper confidence boundary corresponding to conf_period.
conf_down (numpy array, optional) – Lower confidence boundary corresponding to conf_period.
conf_mean (numpy array, optional) – Mean confidence boundary corresponding to conf_period.
fap (float, optional) – False alarm probability. If provided, used to calculate the significance confidence level (e.g., 95% confidence corresponds to fap=0.05) and label the confidence interval.
- Returns:
This function does not return any values. It displays a log-log plot of the EMD spectrum.
- Return type:
None
Notes
The EMD spectrum is plotted as points with error bars for period uncertainties.
A vertical dashed line indicates the cutoff_period.
Confidence intervals (if provided) are plotted as red lines (upper and lower bounds) and a blue line (mean, if available).
Significant modes, determined by comparing emd_sp[‘energy’] against conf_up, are highlighted in green.
The x-axis (period) and y-axis (energy) are plotted on a logarithmic scale.
Gridlines and a legend enhance plot readability.
Example
‘period’: [0.5, 1.0, 2.0, 4.0], ‘energy’: [0.01, 0.1, 0.5, 2.0], ‘period_err’: [0.05, 0.1, 0.2, 0.4] }
cutoff_period = 1.5 conf_period = [0.5, 1.0, 2.0, 4.0] conf_up = [0.02, 0.15, 0.6, 2.5] conf_down = [0.005, 0.05, 0.4, 1.5] plot_emd_spectrum(emd_sp, cutoff_period, conf_period, conf_up, conf_down) ```
- scope.utils.plot.plot_fft_spectrum(fit_fft)[source]
Plots the FFT spectrum from fitting results, displaying the power, the model fit, and confidence limits.
- Parameters:
fit_fft (dict) –
- A dictionary containing the results of FFT fitting with the following keys:
- ’frequency’numpy array
Frequencies obtained from the FFT fitting.
- ’power’numpy array
Power spectrum values corresponding to each frequency.
- ’pl_index’float
Power-law index of the colored noise model.
- ’pl_index_stderr’float
Standard error of the power-law index.
- ’expectation_continuous’numpy array
Expected power values from the model fit to the data.
- ’confidence_limit’numpy array
Confidence limit values for the power spectrum.
- ’conf_prob’float
Confidence probability associated with the confidence limit.
- Returns:
This function does not return any values. It displays a log-log plot of the power spectrum, including the model fit and confidence limits.
- Return type:
None
Notes
The function plots the period (1/frequency) on the x-axis and the Fourier magnitude on the y-axis. It uses a log-log scale for both axes to better visualize the frequency spectrum over a wide range. The power-law index with its error is included in the legend, as well as the confidence probability of the confidence limits.
- scope.utils.plot.plot_modes(t, modes)[source]
Plots the modes obtained using Empirical Mode Decomposition (EMD) as a series of subplots, each representing one mode over time.
- Parameters:
t (numpy array) – Time values for each mode, used as the x-axis in each subplot.
modes (numpy array, shape (n_samples, n_modes)) – 2D array where each column represents a mode obtained from EMD, with n_samples time points and n_modes modes.
- Returns:
None
This function does not return any values. It displays a series of subplots,
with each subplot representing one mode as a function of time.
Notes
Each mode is plotted in its own subplot, aligned vertically in a single column. The x-axis represents time, while the y-axis shows the amplitude of each mode. The y-limits of each subplot are set based on the global minimum and maximum across all modes, ensuring consistent scaling.
- scope.utils.plot.plot_signal(t, x, title='Input signal', ax=None)[source]
Plots the input signal over time.
- Parameters:
t (numpy array) – Time values for the signal, used as the x-axis in the plot.
x (numpy array) – Signal values corresponding to each time point in t, used as the y-axis in the plot.
title (string) – Tittle of the plot
ax (matplotlib.axes.Axes) – Axis to align the plot with other plots
- Returns:
This function does not return any values. It displays a plot of the input signal as a function of time.
- Return type:
None
Notes
This function produces a simple 2D line plot, showing how the signal varies over time. The x-axis represents time, and the y-axis represents the signal magnitude.