src.helpers.parsers.ErgFileReader module

This module is responsible for reading erg files from CarMaker.

It builds on the cmerg package from PyPI and https://github.com/danielhrisca/cmerg, which parses an erg file efficiently using regular expressions. This module extends the capabilities by adding further methods such as extracting only a subset of the quantities and returning them as an array. This satisfies the conventions of the DataFileReader parent class.

This module includes a main class called ErgFileReader. See details in its documentation. It requires two files with the extensions .erg and .erg.info. The former contains the data, the latter the meta-data.

Contact person: Stefan Riedmaier Creation date: 23.06.2020 Python version: 3.8

class src.helpers.parsers.ErgFileReader.ErgFileReader

Bases: DataFileReader

This child class is responsible for reading erg files from CarMaker.

It is based on the cmerg package and its regular expressions.

It includes basic functions for reading erg files, extracting quantities and returning different data structures. See the respective methods for more details.

get_quantity_array()

This function creates a 2d array of the previously selected quantities.

The array has one row per desired quantity and one column per time step.

Returns:

array of quantity values

Return type:

np.ndarray

get_units()

This function returns the units of the desired quantities.

Returns:

units of the desired quantities

Return type:

list[str]

read_data_file(erg_file_path)

This function parses an erg file, extracts the quantity values and adds them to a dictionary.

The function calls the function get_erg_quantity_names internally to get the quantity names.

Parameters:

erg_file_path (str) – path to the erg file

Returns:

ordered dictionary of all erg quantity objects with names, data types and values

Return type:

OrderedDict

select_quantities(quantity_name_list=None)

This function selects and prepares the desired quantities.

The order matches the list of desired quantities. In case no list is provided, all measured quantities are returned.

Parameters:

quantity_name_list (list[str]) – list of quantity names

Returns:

dict of selected quantity objects

Return type:

dict[Signal]