devctrl.data.data.Data#
- class Data(data_path: str, file_mode: str = '', metadata: dict | None = None)[source]#
Bases:
objectGeneral purpose data class parent.
The idea is to flexible in the data storage, by not hard-coding indices but instead using data columns that refer to the columnd of a 2D-numpy array. Each column should then have a simple key. By defining a dictionary called _COLUMN_DATA, you can define extra stuff for each column, for example the label and unit it should have in a csv or plot. For example when plotting with latex expression support, you can easily get a nice axis label by then calling
data.get_column_tex_label_with_unit("<key of your column>"). Pre-defined data keys are:label: Plain-text label
unit: Plain-text unit
label-tex: Latex label
unit-tex: Latex unit
scale: Scaling for plots
Methods
Attributes
Absolute path to the data file or directory
Absolute path to the data directory
Name of the data directory
- _EQUALITY_CHECKS = {'endswith': <function Data.<lambda>>, 'equal': <function Data.<lambda>>, 'startswith': <function Data.<lambda>>}#
- __annotations__ = {'dir_name': 'str', 'dir_path': 'str'}#
- __dict__ = mappingproxy({'__module__': 'devctrl.data.data', '__firstlineno__': 41, '__doc__': 'General purpose data class parent.\n\nThe idea is to flexible in the data storage, by not hard-coding indices but instead using data columns that refer to the columnd of a 2D-numpy array.\nEach column should then have a simple key.\nBy defining a dictionary called _COLUMN_DATA, you can define extra stuff for each column, for example the label and unit it should have in a csv or plot.\nFor example when plotting with latex expression support, you can easily get a nice axis label by then calling ``data.get_column_tex_label_with_unit("<key of your column>")``.\nPre-defined data keys are:\n\n- label: Plain-text label\n- unit: Plain-text unit\n- label-tex: Latex label\n- unit-tex: Latex unit\n- scale: Scaling for plots\n', '__init__': <function Data.__init__>, '_subclasses': {'TimeData': <class 'devctrl.data.time.data.TimeData'>, 'PrsData': <class 'prsctrl.data.prsdata.PrsData'>}, '__init_subclass__': <classmethod(<function Data.__init_subclass__>)>, '_get_column_data': <classmethod(<function Data._get_column_data>)>, '_EQUALITY_CHECKS': {'equal': <function Data.<lambda>>, 'startswith': <function Data.<lambda>>, 'endswith': <function Data.<lambda>>}, '_get_column_key': <classmethod(<function Data._get_column_key>)>, 'get_column_label': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_unit': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_label_with_unit': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_tex_label': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_tex_unit': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_tex_label_with_unit': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_scale': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_color': <devctrl.data.data.ClassOrInstanceMethod object>, 'get_column_tex_label_with_unit_and_scale': <devctrl.data.data.ClassOrInstanceMethod object>, '_assert_write_mode': <function Data._assert_write_mode>, '_assert_read_mode': <function Data._assert_read_mode>, '__static_attributes__': ('_read_mode', '_write_mode', 'data_path', 'dir_name', 'dir_path', 'file_mode', 'metadata'), '__dict__': <attribute '__dict__' of 'Data' objects>, '__weakref__': <attribute '__weakref__' of 'Data' objects>, '__annotations__': {'dir_path': 'str', 'dir_name': 'str'}})#
- __firstlineno__ = 41#
- __module__ = 'devctrl.data.data'#
- __static_attributes__ = ('_read_mode', '_write_mode', 'data_path', 'dir_name', 'dir_path', 'file_mode', 'metadata')#
- __weakref__#
list of weak references to the object
- classmethod _get_column_data(key, column, default=None, mode='*', check_other_cls=True, instance=None)[source]#
Search for column data in _COLUMN_DATA hierarchy
Searches for the specified key and column in the _COLUMN_DATA dictionary following a priority order: specific mode → wildcard mode → other subclasses → default.
- Parameters:
key – Data key (e.g., ‘label’)
column – Column key to retrieve
default – Default value to return if no data is found
mode – Optional data mode to search in
check_other_cls – Whether to check other Data subclasses before returning default
instance – Optional Data subclass instance to auto-determine mode from .mode attribute
- Returns:
The found column data or default value
- classmethod _get_column_key(key, value, default=None, mode='*', check_other_modes=True, check_other_cls=True, equality_check='equal')[source]#
Reverse search of column data: returns the column key for the given data key and value. First checks the calling class, then all other subclasses.
- Parameters:
key – data key, e.g. ‘label’
value – the value of _COLUMN_DATA[mode][key][column] for which the column is returned
default – a default value to return of no value is found
mode – optional data mode
check_other_modes – whether to check if another mode in _COLUMN_DATA has the column data
check_other_cls – whether to check if other subclasses have the column data before returning the default
equality_check – How to check equality: ‘equal’, ‘startswith’ or ‘endswith’. The latter check if the searched value starts with the column data value
- Returns:
The column key to given value from _COLUMN_DATA
- _subclasses = {'PrsData': <class 'prsctrl.data.prsdata.PrsData'>, 'TimeData': <class 'devctrl.data.time.data.TimeData'>}#
- data_path#
Absolute path to the data file or directory
- dir_name: str#
Name of the data directory
- dir_path: str#
Absolute path to the data directory