agentMFred: Python software agents for processing redundant measurement data

Some of the methods of the module MFred have been incorporated into a Redundancy Agent that can be used in the Met4FoF agent framework. The Redundancy Agent can be found in redundancyAgents1. It uses of a metrological datastream which can be found in metrological_streams_v2. The usage of the Redundancy Agent is illustrated with two examples contained in two tutorials.

In tutorial redundancyAgents_tutorial_1 four independent signals are generated and the Redundancy Agent calculates the best estimate with associated uncertainty, respecting the input uncertainties, and rejecting sensor values that may be erroneous. In this case the sensors directly measure the measurand.

In tutorial redundancyAgents_tutorial_2 a single signal containing redundant, correlated information is analyzed, and the best estimate with associated uncertainty, respecting all provided input uncertainties, and rejecting sensor values that may be erroneous. In this case the sensors do not directly measure the measurand, but the measurand is linked to the sensor values by means of four linear equations. The fact that there are four equations and not just one is the cause of the redundancy.

Details of the different modules are presented in the next sections.

Details of the module metrological_streams_v2

This module contains the definition of a metrological datastream that can be used to generate data for usage in the agentMET4FOF framework.

class Met4FoF_redundancy.agentMFred.metrological_streams_v2.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 = 'DataGenerator', 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 waves 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

Details of the module redundancyAgents1

This module defines a Redundancy Agent that can be used in the agentMET4FOF framework. It has two main data processing types: - lcs: best estimate calculation using Largest Consistent Subset method - lcss: best estimate calculation using Largest Consistent Subset of Sensor values method

class Met4FoF_redundancy.agentMFred.redundancyAgents1.MetrologicalMultiWaveGeneratorAgent(name='', host=None, serializer=None, transport=None, attributes=None, backend='osbrain', mesa_model=None)[source]

An agent streaming a signal composed of various sine and cosine components. Takes samples from the MultiWaveGenerator and pushes them sample by sample (or in batches) to connected agents via its output channel.

agent_loop()[source]

Model the agent’s behaviour On state Running the agent will extract sample by sample the input data streams content and push it via invoking AgentMET4FOF.send_output().

init_parameters(signal: Met4FoF_redundancy.agentMFred.metrological_streams_v2.MetrologicalMultiWaveGenerator = <Met4FoF_redundancy.agentMFred.metrological_streams_v2.MetrologicalMultiWaveGenerator object>, **kwargs)[source]

Initialize the input data Initialize the input data stream as an instance of the MultiWaveGenerator class

Parameters

signal (Signal) – the underlying signal for the generator

class Met4FoF_redundancy.agentMFred.redundancyAgents1.RedundancyAgent(name='', host=None, serializer=None, transport=None, attributes=None, backend='osbrain', mesa_model=None)[source]

This is the main Redundancy Agent class. Main calculation types are lcs() and lcss(), as defined in the module redundancy1.

agent_loop()[source]

Model the agent’s behaviour On state Running the agent will extract sample by sample the input data streams content and push it via invoking AgentMET4FOF.send_output().

init_parameters(input_data_maxlen=25, output_data_maxlen=25)[source]

Initialize the input data stream as an instance of the MultiWaveGenerator class.

Parameters

signal (Signal) – the underlying signal for the generator

init_parameters1(calc_type, sensor_key_list, n_pr, problim)[source]

Parameters used for both methods lcs() and lcss().

Parameters
  • calc_type (str) – calculation type: ‘lcs’ or ‘lcss’

  • sensor_key_list (list of strings) – list containing the names of the sensors that should feed data to the Redundancy Agent

  • n_pr (integer) – size of the batch of data that is handled at once by the Redundancy Agent

  • problim (float) – limit probability used for conistency evaluation

init_parameters2(fsam, f1, f2, ampl_ratio, phi1, phi2)[source]

Additional parameters used for this particular example in combination with the lcss() method. It provides the prior knowledge needed to make the information contained in the data redundant. This method sets up the vector a and matrix A for the system y = a + A * x.

Parameters
  • fsam (float) – sampling frequency

  • f1 (float) – first frequency of interest in signal

  • f2 (float) – second frequency of interest in signal

  • ampl_ratio (float) – ratio of the amplitudes of the two frequency components

  • phi1 (float) – initial phase of first frequency component

  • phi2 (float) – initial phase of second frequency component

on_received_message(message)[source]

Handles incoming data from ‘default’ channels. Stores ‘default’ data into an internal buffer

Parameters

message (dict) – Only acceptable channel value is ‘default’.

Details of the module redundancyAgents_tutorial_1

Example 1 of using a Redundancy Agent. Four signals are generated and data is supplied to the Redundancy Agent. The Redundancy Agent calculates the best consistent estimate taking into account the supplied uncertainties.

Met4FoF_redundancy_tutorials.redundancyAgents_tutorial_1.demonstrate_redundancy_agent_four_signals()[source]

At the start of the main module all important parameters are defined. Then the agents are defined and the network is started. The network and the calculated results can be monitored in a browser at the address http://127.0.0.1:8050/.

Details of the module redundancyAgents_tutorial_2

Example 2 of using a Redundancy Agent. A single signal is generated and supplied to the Redundancy Agent. The Redundancy Agent uses the redundancy in the data vector together with some prior knowledge in order to calculate the best consistent estimate taking into account the supplied uncertainties.

Met4FoF_redundancy_tutorials.redundancyAgents_tutorial_2.demonstrate_redundancy_agent_onesignal()[source]

At the start of the main module all important parameters are defined. Then the agents are defined and the network is started. The network and the calculated results can be monitored in a browser at the address http://127.0.0.1:8050/.