MFred: Python functions for best estimate calculation in a sensor network in the presence of redundancy¶
In this section some method for analysing redundant measurement data is presented. Redundancy means that there is more than one way to derive the value of the measurand Y from the values of the sensor data X_i. Following main cases are considered in the module:
Redundant measurement of the measurand Y by independent sensors directly measuring Y
Redundant measurement of the measurand Y by correlated sensors directly measuring Y
Redundant measurement of the measurand Y by correlated sensors X_i indirectly measuring Y, with a linear relationship y = a + A * x between the vector x of sensor values and the vector y containing the various (redundant) estimates of the measurand Y, where a is a vector and A a matrix both of appropriate size.
Details of the different modules are presented in the next sections.
Details of the main module redundancy1
¶
The module redundancy1
implements methods for analysing redundant estimates provided by
redundant measurement data from a sensor network.
The main functions included in the file redundancy1.py are:
calc_consistent_estimates_no_corr()
: Calculation of n_rows of best estimates for n_rows of sets ofindependent estimates with associated standard uncertainty.
calc_best_estimate()
: Calculation of the best estimate for a given set of estimates with associated uncertaintymatrix.
calc_lcs()
: Calculation of the largest subset of consistent estimates of a measurand.calc_lcss()
: Calculation of the largest subset of sensor values that yield consistent estimates of a measurandlinked to the sensor values by a linear system of equations.
The scientific publication giving more information on this topic is:
G. Kok and P. Harris, “Uncertainty Evaluation for Metrologically Redundant Industrial Sensor Networks,” 2020 IEEE International Workshop on Metrology for Industry 4.0 & IoT, Roma, Italy, 2020, pp. 84-88, doi: 10.1109/MetroInd4.0IoT48571.2020.9138297.
- exception Met4FoF_redundancy.MFred.redundancy1.AllColumnsZeroSum[source]¶
Custom exception to handle the case when all columns have zero sum
- exception Met4FoF_redundancy.MFred.redundancy1.ColumnNotZeroError[source]¶
Custom exception to handle the case when a redundant column has not been reduced to zero
- exception Met4FoF_redundancy.MFred.redundancy1.SensorsNotLinearlyIndependentError[source]¶
Custom exception to handle the case when sensor results are not linearly independent
- exception Met4FoF_redundancy.MFred.redundancy1.SystemMatrixNotReducibleError[source]¶
Custom exception to handle the case when the system matrix A is not reducible
- Met4FoF_redundancy.MFred.redundancy1.calc_best_est_lin_sys(a_arr, a_arr2d, x_arr, vx_arr2d, problim)[source]¶
Function to calculate the best estimate of a linear system y = a + A * x and determines if the inputs are consistent in view of problim.
- Parameters
a_arr (np.ndarray of shape (n_estimates)) – vector a of linear system y = a + A * x
a_arr2d (np.ndarray of shape (n_estimates, n_sensors)) – matrix A of linear system y = a + A * x
x_arr (np.ndarray of shape (n_sensors)) – vector with sensor values vector x of linear system y = a + A * x
vx_arr2d (np.ndarray of shape (n_sensors, n_sensors)) – uncertainty matrix associated with vector x_arr
problim (float) – probability limit used for consistency evaluation. Typically 0.95.
- Returns
isconsist (bool) – indicator whether provided estimates are consistent in view of problim
ybest (float) – best estimate
uybest (float) – standard uncertainty of best estimate
chi2obs (float) – observed chi-squared value
- Met4FoF_redundancy.MFred.redundancy1.calc_best_estimate(y_arr, vy_arr2d, problim)[source]¶
Calculate the best estimate for a set of estimates with associated uncertainty matrix, and determine if the set of estimates are consistent using a provided limit probability.
- Parameters
y_arr (np.ndarray of shape (n)) – vector of estimates of a measurand Y
vy_arr2d (np.ndarray of shape (n, n)) – uncertainty matrix associated with y_arr
problim (float) – probability limit used for assessing the consistency of the estimates. Typically, problim equals 0.95.
- Returns
isconsist (bool) – indicator whether provided estimates are consistent in view of problim
ybest (float) – best estimate of measurand
uybest (float) – uncertainty associated with ybest
chi2obs (float) – observed value of chi-squared, used for consistency evaluation
- Met4FoF_redundancy.MFred.redundancy1.calc_consistent_estimates_no_corr(y_arr2d, uy_arr2d, prob_lim)[source]¶
Calculation of consistent estimate for n_sets of estimates y_ij (contained in y_arr2d) of a quantity Y, where each set contains n_estims estimates. The uncertainties are assumed to be independent and given in uy_arr2d. The consistency test is using limit probability limit prob_lim. For each set of estimates, the best estimate, uncertainty, observed chi-2 value and a flag if the provided estimates were consistent given the model are given as output.
- Parameters
y_arr2d (np.ndarray of size (n_rows, n_estimates)) – each row contains m=n_estimates independent estimates of a measurand
uy_arr2d (np.ndarray of size (n_rows, n_estimates)) – each row contains the standard uncertainty u(y_ij) of y_ij = y_arr2d[i,j]
prob_lim (limit probability used in consistency test. Typically 0.95.) –
- Returns
isconsist_arr (bool array of shape (n_rows)) – indicates for each row if the n_estimates are consistent or not
ybest_arr (np.ndarray of shape (n_rows)) – contains the best estimate for each row of individual estimates
uybest_arr (np.ndarray of shape (n_rows)) – contains the uncertainty associated with each best estimate for each row of y_arr2d
chi2obs_arr (observed chi-squared value for each row)
- Met4FoF_redundancy.MFred.redundancy1.calc_lcs(y_arr, vy_arr2d, problim)[source]¶
Function to calculate the best estimate of a measurand based on individual estimates of the measurand with associated uncertainty matrix.
- Parameters
y_arr (np.ndarray of shape (n)) – vector with estimates of the measurand
vy_arr2d (np.ndarray of shape (n, n)) – uncertainty matrix of the vector y_arr
problim (float) – limit probability used in the consistency evaluation. Typically 0.95.
- Met4FoF_redundancy.MFred.redundancy1.calc_lcss(a_arr, a_arr2d, x_arr, vx_arr2d, problim)[source]¶
Calculation of the largest consistent subset of sensor values and the implied best estimate.
- Parameters
x_arr (np.ndarray of shape (n_sensors)) –
vx_arr2d (np.ndarray of shape (n_sensors, n_sensors)) –
a_arr (np.ndarray of shape (n_estimates)) –
a_arr2d (np.ndarray of shape (n_estimates, n_sensors)) –
problim (float) –
a_arr – vector a of linear system y = a + A * x
a_arr2d – matrix A of linear system y = a + A * x
x_arr – vector with sensor values vector x of linear system y = a + A * x
vx_arr2d – uncertainty matrix associated with vector x_arr
problim – probability limit used for consistency evaluation. Typically 0.95.
- Returns
isconsist (bool) – indicator whether provided estimates are consistent in view of problim
ybest (float) – best estimate
uybest (float) – standard uncertainty of best estimate
chi2obs (float) – observed chi-squared value
- Met4FoF_redundancy.MFred.redundancy1.print_output_cbe(isconsist_arr, ybest_arr, uybest_arr, chi2obs_arr)[source]¶
Function to print the full output of calc_best_estimate.
- Parameters
isconsist_arr (bool array of shape (n_rows)) – indicates for each row if the n_estimates are consistent or not
ybest_arr (np.ndarray of shape (n_rows)) – contains the best estimate for each row of individual estimates
uybest_arr (np.ndarray of shape (n_rows)) – contains the uncertainty associated with each best estimate for each row of y_arr2d
chi2obs_arr (observed chi-squared value for each row) –
- Met4FoF_redundancy.MFred.redundancy1.print_output_lcs(n_sols, ybest, uybest, chi2obs, indkeep, y_arr)[source]¶
Method to print the output of the method
calc_lcs()
.- Parameters
n_sols (int) – number of best solutions
ybest (float or np.ndarray of shape (n_sols)) – best estimate or vector of best estimates
uybest (float or np.ndarray of shape (n_sols)) – standard uncertainty of best estimate or vector with standard uncertainty of best estimates
chi2obs (float) – observed chi-squared value of all best solutions
indkeep (np.ndarary of shape (n) or (n_sols, n)) – indices of retained estimates of y_arr for the calculation of the best estimate ybest
y_arr (np.ndarray of shape (n)) – individual estimates of measurand
- Met4FoF_redundancy.MFred.redundancy1.print_output_single(isconsist, ybest, uybest, chi2obs)[source]¶
Function to print the output of a single row of the calculate_best_estimate function.
- Parameters
isconsist (bool) – Indicates if provided estimates were consistent
ybest (float) – best estimate
uybest (float) – uncertainty of best estimate
chi2obs (float) – observed value of chi-squared
Details of the test module test1
¶
The module test_MFred.py
calls all test functions which are implemented in the
module redundancy1
. These test functions are:
- test_redundancy.test_MFred.test_calc_consistent_estimates_no_corr()[source]¶
Test function for calc_consistent_estimates_no_corr(), implementing two test cases.