agentMET4FOF metrologically enabled streamsĀ¶
-
class
agentMET4FOF.metrological_streams.
MetrologicalDataStreamMET4FOF
(value_unc: Optional[float] = 0.0, time_unc: Optional[float] = 0.0, exp_unc: Optional[float] = None, cov_factor: Optional[float] = 1.0)[source]Ā¶ Abstract class for creating datastreams with metrological information. Inherits from the
DataStreamMET4FOF
classTo create a new
MetrologicalDataStreamMET4FOF
class, 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,sfreq
is 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
MetrologicalSineGenerator
class. See tutorials for more implementations.-
_generator_function_unc
Ā¶ A generator function for the time and quantity uncertainties which takes in at least one argument
time
which 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
-
_default_uncertainty_generator
(time: Union[List[T], pandas.core.frame.DataFrame, numpy.ndarray], values: Union[List[T], pandas.core.frame.DataFrame, numpy.ndarray]) → Tuple[numpy.ndarray, numpy.ndarray][source]Ā¶ Default (standard) uncertainty generator function
Parameters: - time (Union[List, DataFrame, np.ndarray]) ā timestamps
- values (Union[List, DataFrame, np.ndarray]) ā values corresponding to timestamps
Returns: constant time and value uncertainties each of the same shape as
time
Return type: Tuple[np.ndarray, np.ndarray]
-
_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 uncertaintyut
and measurement uncertaintyuv
to sample
-
set_generator_function
(generator_function: Callable = None, uncertainty_generator: Callable = None, sfreq: int = None, **kwargs) → Callable[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
time
which will be used innext_sample()
. - uncertainty_generator (callable) ā An uncertainty generator function which takes in at least one argument
time
which 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
**kwargs
will 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
.
Returns: The uncertainty generator function
Return type: Callable
- generator_function (callable) ā A generator function which takes in at least one argument
-
time_unc
Ā¶ uncertainties associated with timestamps
Type: Union[float, Iterable[float]]
-
value_unc
Ā¶ uncertainties associated with the values
Type: Union[float, Iterable[float]]
- from dataset file (
-
class
agentMET4FOF.metrological_streams.
MetrologicalMultiWaveGenerator
(sfreq: int = 500, freq_arr: numpy.array = array([50]), ampl_arr: numpy.array = array([1]), phase_ini_arr: numpy.array = array([0]), intercept: float = 0, device_id: str = 'MultiWaveDataGenerator', time_name: str = 'time', time_unit: str = 's', quantity_names: Union[str, Tuple[str, ...]] = ('Length', 'Mass'), quantity_units: Union[str, Tuple[str, ...]] = ('m', 'kg'), misc: Optional[Any] = ' Generator for a linear sum of cosines', value_unc: Union[float, Iterable[float]] = 0.1, time_unc: Union[float, Iterable[float]] = 0, noisy: bool = True)[source]Ā¶ Class to generate data as a sum of cosine wave and additional Gaussian noise.
Values with associated uncertainty are returned.
Parameters: - sfreq (float) ā sampling frequency which determines the time step when next_sample is called.
- intercept (float) ā constant intercept of the signal
- freq_arr (np.ndarray of float) ā array with frequencies of components included in the signal
- ampl_arr (np.ndarray of float) ā array with amplitudes of components included in the signal
- phase_ini_arr (np.ndarray of float) ā array with initial phases of components included in the signal
- noisy (bool) ā boolean to determine whether the generated signal should be noisy or ācleanā defaults to True
-
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: float = 0.1, time_unc: 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
Metadata
object. Defaults to āSimple sine wave generatorā. - value_unc (iterable of floats or float, optional) ā standard uncertainty(ies) of the quantity values. Defaults to 0.1.
- 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