time-series-metadata - metadata scheme for time-series with measurement uncertainties

time-series-metadata is a Python software package developed jointly by software developers and researchers from Physikalisch-Technische Bundesanstalt (Germany) and Institute for Manufacturing (UK) as part of the joint European Research Project EMPIR 17IND12 Met4FoF and the German research project FAMOUS.

For the time-series-metadata homepage go to GitHub.

time-series-metadata is written in Python 3 and strives to run with all Python versions with upstream support. Currently it is tested to work with Python 3.7 to 3.10.

time-series-metadata

https://circleci.com/gh/PTB-M4D/time-series-metadata.svg?style=shieldCircleCI https://readthedocs.org/projects/time-series-metadata/badge/?version=latestDocumentation Status https://zenodo.org/badge/DOI/10.5281/zenodo.3935860.svgDOI

A metrologically enabled time-series metadata scheme

time-series-metadata is a Python implementation of a metadata scheme for time-series with measurement uncertainties. It is developed jointly by software developers and researchers from Physikalisch-Technische Bundesanstalt (Germany) and Institute for Manufacturing (UK) as part of the joint European Research Project EMPIR 17IND12 Met4FoF and the German research project FAMOUS.

time-series-metadata is written in Python 3 and strives to run with all Python versions with upstream support. Currently, it is tested to work with Python 3.8 to 3.11.

Scheme

The following image illustrates an abstract representation of a time series:

https://user-images.githubusercontent.com/50821607/80489031-8dac5000-895f-11ea-9b99-2add88c21d4b.pngtime-series metadata scheme illustration

The scheme contains all metadata to interpret the actual time and quantity values.

It consists of a dictionary containing the following keys with (default) values of the specified type:

metadata = {
    "device_id": string (default: ""),
    "time_name": string (default: "time"),
    "time_unit": string (default: "om:second"),
    "quantity_names": string or list of strings (default: ""),
    "quantity_units": string or list of strings (default: ""),
    "misc": optional, any other data you want to provide (default: None),
}

Example use

We illustrate the use of the scheme assuming you already have a project set up.

Installation

First you need to install the scheme with the usual command into your project’s Python virtual environment:

pip install time-series-metadata

Import scheme

Inside your project’s code import the scheme at the top of your module.

from time_series_metadata.scheme import MetaData

Assign initial values

After importing the package you can make use of it and assign initial values.

vs_description = MetaData(
    device_id="my_virtual_sensor",
    time_name="time",
    time_unit="s",
    quantity_names=("pressure_1", "pressure_2"),
    quantity_units=("Pa","mPa"),
    misc="additional information"
)

Read out metadata

You can access the metadata as a whole or time and quantity metadata separately. Quantity metadata can be either accessed for all quantities at once or individually via index or name. If you do not specify name or index, the first’s quantity metadata is returned. This might be especially convenient, if there is only one quantity.

>>> vs_description.metadata
{"device_id": "my_virtual_sensor", "time_name": "time", "time_unit": "s", "quantity_names": ["pressure_1", "pressure_2"], "quantity_units": ["Pa", "mPa"], "misc": None}
>>> vs_description.time
{'time_name': 'time', 'time_unit': 's'}
>>> vs_description.quantities
{'quantity_names': ('pressure_1', 'pressure_2'), 'quantity_units': ('Pa', 'mPa')}
>>> vs_description.get_quantity(1)
{'quantity_names': 'pressure_2', 'quantity_units': 'mPa'}
>>> vs_description.get_quantity(name="pressure_1")
{'quantity_names': 'pressure_1', 'quantity_units': 'Pa'}
>>> vs_description.get_quantity()
{'quantity_names': 'pressure_1', 'quantity_units': 'Pa'}

Maintainers

The package is developed and maintained at the “Physikalisch-Technische Bundesanstalt” by Maximilian Gruber and Björn Ludwig.

MetaData - the metrologically enabled time-series metadata scheme

The module time_series_metadata.scheme contains the main class of the package. It provides the Python implementation of the scheme.

This module contains the following class:

  • MetaData: Wrapper class for metrologically enabled time-series metadata

MetaData

class time_series_metadata.scheme.MetaData(device_id: str = '', time_name: str = 'time', time_unit: str = 'om:second', quantity_names: Union[str, Tuple[str, ...]] = '', quantity_units: Union[str, Tuple[str, ...]] = '', misc: Optional[Any] = None)[source]
get_quantity(index: int = 0, name: str = None) → Dict[KT, VT][source]

Return the metadata for one of the quantities

Parameters:
  • index (int, optional) – Index of the quantity in the initial tuple (default = 0). If name is set, index is ignored.
  • name (str, optional) – Name of the quantity. If name is set, index is ignored.
Returns:

metadata – the metadata for the specified quantity

Return type:

dict

metadata

Return the metadata as a whole

Returns:metadata – the metadata dictionary as a whole
Return type:Dict
misc

Return the additionally provided metadata

Returns:metadata – all misc metadata key value pairs
Return type:dict
quantities

Return all quantities metadata

Returns:metadata – all quantity metadata key value pairs
Return type:dict
time

Return the time metadata

Returns:metadata – all time metadata key value pairs
Return type:dict

Indices and tables