elasticai.hw_measurements.plots#

Module Contents#

Functions#

get_plot_color

Getting the color string

get_font_size

Getting the font size for paper work

get_plot_marker

Getting the marker for plotting

save_figure

Saving figure in given format Args: fig: Matplot which will be saved path: Path for saving the figure name: Name of the plot formats: List with data formats for saving the figures Returns: None

scale_auto_value

Getting the scaling value and corresponding string notation for unit scaling in plots Args: data: Array or value for calculating the SI scaling value Returns: Tuple with [0] = scaling value and [1] = SI pre-unit

plot_transfer_function_norm

Function for plotting the transfer function

plot_transfer_function_metric

Function for plotting the metric, extracted from the transfer function

plot_spectrum_harmonic

Plotting the spectrum for analysing the total harmonic distortion

plot_fra_data

Plotting the data from Frequency Response Analysis (FRA) using R&S MXO44

plot_transient_data

Plotting content from transient measurements for extracting Total Harmonic Distortion (THD)

plot_transient_noise

Plotting content from transient measurements for extracting noise properties

plot_spectrum_noise

Plotting the noise amplitude spectral density from transient measurements for extracting noise properties

API#

elasticai.hw_measurements.plots.get_plot_color(idx: int) str[source]#

Getting the color string

elasticai.hw_measurements.plots.get_font_size() int[source]#

Getting the font size for paper work

elasticai.hw_measurements.plots.get_plot_marker(idx: int) str[source]#

Getting the marker for plotting

elasticai.hw_measurements.plots.save_figure(fig, path: str | pathlib.Path, name: str, formats: list = ('pdf', 'svg')) None[source]#

Saving figure in given format Args: fig: Matplot which will be saved path: Path for saving the figure name: Name of the plot formats: List with data formats for saving the figures Returns: None

elasticai.hw_measurements.plots.scale_auto_value(data: numpy.ndarray | float) [float, str][source]#

Getting the scaling value and corresponding string notation for unit scaling in plots Args: data: Array or value for calculating the SI scaling value Returns: Tuple with [0] = scaling value and [1] = SI pre-unit

elasticai.hw_measurements.plots.plot_transfer_function_norm(data: dict, path2save: str = '', xlabel: str = 'Stimulus Input', ylabel: str = 'Stimulus Output', title: str = 'Transfer Function', file_name: str = '', show_plot: bool = True) None[source]#

Function for plotting the transfer function

Parameters:
  • data – Dictionary with extracted values from measurement data

  • path2save – Path for saving the figure

  • xlabel – Text Label for x-axis

  • ylabel – Text Label for y-axis

  • title – Text Label for title

  • file_name – File name of the saved figure

  • show_plot – Boolean for showing the plot

Returns:

None

elasticai.hw_measurements.plots.plot_transfer_function_metric(data: dict, func: object, path2save: str = '', xlabel: str = 'Stimulus Input', ylabel: str = 'Stimulus Output', title: str = 'Transfer Function', file_name: str = '') None[source]#

Function for plotting the metric, extracted from the transfer function

Parameters:
  • data – Dictionary with pre-processed data from measurement with keys: [‘stim’, ‘ch’: {‘mean’, ‘std’}}

  • func – Function for calculating the metric

  • path2save – Path for saving the figure

  • xlabel – Text Label for x-axis

  • ylabel – Text Label for y-axis

  • title – Text Label for title

  • file_name – File name of the saved figure

Returns:

None

elasticai.hw_measurements.plots.plot_spectrum_harmonic(data: elasticai.hw_measurements.TransformSpectrum, N_harmonics: int = 6, file_name: str = '', path2save: str = '', delta_peaks: int = 20, show_peaks: bool = True, show_metric: bool = False, show_plot: bool = True, is_input_db: bool = True) None[source]#

Plotting the spectrum for analysing the total harmonic distortion

Parameters:
  • data – Dataclass TransformSpectrum with spectral data from measurement

  • N_harmonics – Number of harmonics for calculation and plot

  • file_name – File name of the saved figure

  • path2save – Path for saving the figure

  • delta_peaks – Number of positions around the peaks

  • show_peaks – Boolean for highlighting the harmonics

  • show_metric – Boolean for showing the THD metric

  • show_plot – Boolean for showing the plot

  • is_input_db – Boolean for whether the data is logarithmic [dB]

Returns:

None

elasticai.hw_measurements.plots.plot_fra_data(data: elasticai.hw_measurements.FrequencyResponse, num_pol: int = 1, file_name: str = '', path2save: str = '', show_plot: bool = True) None[source]#

Plotting the data from Frequency Response Analysis (FRA) using R&S MXO44

Parameters:
  • data – Dataclass with measured results from FRA analysis

  • num_pol – Integer with number of poles in transfer function, detecting slopes (each high-pass and low-pass)

  • file_name – File name of the saved figure

  • path2save – Path for saving the figure

  • show_plot – Boolean for showing the plot

elasticai.hw_measurements.plots.plot_transient_data(data: elasticai.hw_measurements.TransientData, file_name: str = '', path2save: str = '', show_plot: bool = False, xzoom: list = [0, -1]) None[source]#

Plotting content from transient measurements for extracting Total Harmonic Distortion (THD)

Parameters:
  • data – List with dataclass TransientData

  • file_name – String with file name of the saved figure

  • path2save – String with path for saving the figure

  • show_plot – Boolean for showing the plot

  • xzoom – List with xzoom values

Returns:

None

elasticai.hw_measurements.plots.plot_transient_noise(data: elasticai.hw_measurements.TransientData, offset: numpy.ndarray, scale: float = 1.0, xzoom: list = [0, -1], file_name: str = 'noise', path2save: str = '', show_plot: bool = False) None[source]#

Plotting content from transient measurements for extracting noise properties

Parameters:
  • data – List with dataclass TransientData

  • offset – Numpy array with offset, shape: (num_channels, )

  • scale – Floating value with y-scaling value [Default: 1.0 –> ADC output, else Voltage]

  • xzoom – List with xzoom values

  • file_name – String with file name of the saved figure

  • path2save – String with path for saving the figure

  • show_plot – Boolean for showing the plot

Returns:

None

elasticai.hw_measurements.plots.plot_spectrum_noise(data: elasticai.hw_measurements.TransientNoiseSpectrum, file_name: str = 'noise', path2save: str = '', show_plot: bool = False) None[source]#

Plotting the noise amplitude spectral density from transient measurements for extracting noise properties

Parameters:
  • data – List with dataclass TransientNoiseSpectrum

  • file_name – String with file name of the saved figure

  • path2save – String with path for saving the figure

  • show_plot – Boolean for showing the plot

Returns:

None