agentMET4FOF metrologically enabled streams¶
-
class
agentMET4FOF.metrological_streams.MetrologicalDataStreamMET4FOF[source]¶ Abstract class for creating datastreams with metrological information. Inherits from the
DataStreamMET4FOFclassTo create a new
MetrologicalDataStreamMET4FOFclass, inherit this class and callset_metadata()in the constructor. Choose one of two types of datastreams to be created:- from dataset file (
set_data_source()), or - a waveform generator function (
set_generator_function()).
Alternatively, override the
next_sample()function if neither option suits the application. For generator functions,sfreqis a required variable to be set on init which sets the sampling frequency and the time-step which occurs whennext_sample()is called.For an example implementation of using generator function, see the built-in
MetrologicalSineGeneratorclass. See tutorials for more implementations.-
_generator_function_unc¶ A generator function for the time and quantity uncertainties which takes in at least one argument
timewhich will be used innext_sample(). The return value must be a 2-tuple of time and value uncertainties each of one of the three types:- np.ndarray
- pandas DataFrame
- list
Type: Callable
-
_uncertainty_parameters¶ Any additional keyword arguments to be supplied to the generator function. Both the calls of the value generator function and of the uncertainty generator function will be supplied with the
**_uncertainty_parameters.Type: Dict
-
_next_sample_generator(batch_size: int = 1) → numpy.ndarray[source]¶ Internal method for generating a batch of samples from the generator function. Overrides
DataStreamMET4FOF._next_sample_generator(). Adds time uncertaintyutand measurement uncertaintyuvto sample
-
default_uncertainty_generator(_)[source]¶ Default uncertainty generator function
Parameters: _ (Any) – unused parameters in place of the normally required time parameter Returns: constant (zero) time and amplitude uncertainties Return type: Tuple[float, float]
-
set_generator_function(generator_function: Callable = None, uncertainty_generator: Callable = None, sfreq: int = None, **kwargs)[source]¶ Set value and uncertainty generators based on user-defined functions. By default, this function resorts to a sine wave generator function and a constant (zero) uncertainty. Initialisation of the generator’s parameters should be done here such as setting the sampling frequency and wave frequency. For setting it with a dataset instead, see
set_data_source(). Overwrites the defaultDataStreamMET4FOF.set_generator_function()method.Parameters: - generator_function (callable) – A generator function which takes in at least one argument
timewhich will be used innext_sample(). - uncertainty_generator (callable) – An uncertainty generator function which takes in at least one argument
timewhich will be used innext_sample(). - sfreq (int) – Sampling frequency.
- **kwargs (Optional[Dict[str, Any]]) – Any additional keyword arguments to be supplied to the generator function.
The
**kwargswill be saved as_uncertainty_parameters. Both the calls of the value generator function and of the uncertainty generator function will be supplied with the**uncertainty_parameters.
- generator_function (callable) – A generator function which takes in at least one argument
- from dataset file (
-
class
agentMET4FOF.metrological_streams.MetrologicalSineGenerator(sfreq: int = 500, sine_freq: float = 50, device_id: str = 'SineGenerator', time_name: str = 'time', time_unit: str = 's', quantity_names: Union[str, Tuple[str, ...]] = 'Voltage', quantity_units: Union[str, Tuple[str, ...]] = 'V', misc: Optional[Any] = 'Simple sine wave generator', value_unc: Union[float, Iterable[float]] = 0.5, time_unc: Union[float, Iterable[float]] = 0)[source]¶ Built-in class of sine wave generator
Parameters: - sfreq (int, optional) – Sampling frequency which determines the time step when
next_sample()is called. Defaults to 500. - sine_freq (float, optional) – Frequency of the wave function. Defaults to 50.
- device_id (str, optional) – Name of the represented generator. Defaults to ‘SineGenerator’.
- time_name (str, optional) – Name for the time dimension. Defaults to ‘time’.
- time_unit (str, optional) – Unit for the time. Defaults to ‘s’.
- quantity_names (iterable of str or str, optional) – An iterable of names of the represented quantities’ values. Defaults to (‘Voltage’)
- quantity_units (iterable of str or str, optional) – An iterable of units for the quantities’ values. Defaults to (‘V’)
- misc (Any, optional) – This parameter can take any additional metadata which will be handed over to
the corresponding attribute of the created
Metadataobject. Defaults to ‘Simple sine wave generator’. - value_unc (iterable of floats or float, optional) – standard uncertainty(ies) of the quantity values. Defaults to 0.5.
- time_unc (iterable of floats or float, optional) – standard uncertainty of the time stamps. Defaults to 0.
- sfreq (int, optional) – Sampling frequency which determines the time step when