Dataset handling

Measurement datasets are a central part in model validation and therefore we designed the Dataset class that offer a number of useful methods to deal with them.

A typical workflow consists in casting your log-data into Signal objects and then use the created Signals to instantiate a Dataset object.

Signals

Signal are used to represent real-world signals.

Dymoval Signals are Typeddict with the following keys

Keys

Signal.name

Signal name.

Signal.values()

Signal.signal_unit

Signal unit.

Signal.sampling_period

Signal sampling period.

Signal.time_unit

Signal sampling period.

Functions

Dymoval offers few function for dealing with Signals. Such functions are the following

validate_signals(*signals)

Perform a number of checks to verify that the passed list of Signals can be used to create a Dataset.

plot_signals(*signals)

Plot Signals.

Dataset class

The Dataset class is used to store and manipulate datasets.

Since to validate a model you need a datasets, objects of this class are used also to instantiate ValidationSession objects, and the passed Dataset object becomes an attribute of the newly created ValidationSession object.

A Dataset object can be instantiated in two ways

  1. Through a list of dymoval Signals (see validate_signals() )

  2. Through a pandas DataFrame with a specific structure (see validate_dataframe())

Constructor

Dataset(name, signal_list, u_names, y_names)

The Dataset class stores the candidate signals to be used as a dataset and it provides methods for analyzing and manipulating them.

Attributes

Dataset.name

Dataset.dataset

Dataset.coverage

Dataset.information_level

Manipulation methods

Dataset.add_input(*signals)

Add input signals to the Dataset object.

Dataset.add_output(*signals)

Add output signals to the Dataset object.

Dataset.remove_signals(*signals)

Remove signals from the Dataset.

Dataset.remove_means(*signals)

Remove the mean value to the specified signals.

Dataset.remove_offset(*signals_values)

Remove specified offsets to the specified signals.

Dataset.remove_NaNs(**kwargs)

Replace NaN:s values in the Dataset.

Dataset.apply(*signal_function, **kwargs)

Apply a function to specified signals and change their unit.

Dataset.low_pass_filter(*signals_values)

Low-pass filter a list of specified signals.

Dataset.fft(*signals)

Return the FFT of the dataset as pandas DataFrame.

Dataset.trim(*signals[, tin, tout, verbosity])

Trim the Dataset Dataset object.

Plotting methods

Dataset.plot(*signals[, overlap, ...])

Plot the Dataset.

Dataset.plotxy(*signal_pairs[, layout, ...])

Plot a signal against another signal in a plane (XY-plot).

Dataset.plot_coverage(*signals[, nbins, ...])

Plot the dataset Dataset coverage in histograms.

Dataset.plot_spectrum(*signals[, kind, ...])

Plot the spectrum of the specified signals in the dataset in different format.

change_axes_layout(fig, nrows, ncols)

Change Axes layout of an existing Matplotlib Figure.

Other methods

Dataset.dump_to_signals()

Dump a Dataset object into a list of Signals objects.

Dataset.dataset_values()

Return the dataset values as a tuple (t,u,y) of numpy ndarrays.

Dataset.export_to_mat(filename)

Write the dataset in a .mat file.

Dataset.dataset_values()

Return the dataset values as a tuple (t,u,y) of numpy ndarrays.

Dataset.signal_list()

Return the list of signals in form (["INPUT" | "OUTPUT"], name, unit)

validate_dataframe(df)

Check if a pandas DataFrame is suitable for instantiating a Dataset object.

compare_datasets(*datasets[, kind, layout, ...])

Compare different Datasets graphically by overlapping them.