Measurements 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 measurement data into dymoval Signal objects and then use the created Signals to instantiate a Dataset object.

Signals

Dymoval Signal are used to represent real-world signals.

Dymoval Signals are Typeddict with the following keys

Keys

Signal.name

Signal name.

Signal.samples

Signal samples.

Signal.signal_unit

Signal samples unit.

Signal.sampling_period

Signal sampling period.

Signal.time_unit

Signal time unit.

Functions

Dymoval offers few function for dealing with Signals:

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 measurement datasets.

Since to validate a model you need some measurement 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 measurements datasets and it provides methods for analyzing and manipulating them.

Attributes

Dataset.name

Measurements dataset name.

Dataset.dataset

Measurements dataset values.

Dataset.coverage

Measurements dataset coverage.

Dataset.sampling_period

Measurements dataset sampling period.

Dataset.excluded_signals

Excluded signals during the re-sampling process.

Manipulation methods

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

Trim the Dataset Dataset object.

Dataset.fft(*signals)

Return the FFT of the dataset as pandas DataFrame.

Dataset.remove_means(*signals)

Remove the mean value to the specified signals.

Dataset.detrend(*signals)

Linearly detrend the specified signals.

Dataset.remove_offset(*signals_values)

Remove specified offsets to the specified signals.

Dataset.low_pass_filter(*signals_cutoffs)

Low-pass filter a list of specified signals.

Dataset.apply(*signal_function, **kwargs)

Apply a function to specified signals and change their unit.

Dataset.remove_NaNs(**kwargs)

Replace NaN:s values in the Dataset.

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.

Plotting methods

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

Plot the measurements 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.

plot_signals(*signals)

Plot Signals.

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.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.

validate_signals(*signals)

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

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

Compare different measurements Datasets graphically by overlapping them.