## An example of how uncertainties combine

This post discusses one aspect of an uncertainty calculation for a radio frequency (RF) power measurement. It builds on the earlier post Formulating uncertainty (3) in which a simple voltmeter model was described.

We consider a measurement setup that is often used in calibration laboratories. A signal is applied to the input to a power splitter (see lazy about differentiation) and a pair of power sensors are connected to the two output ports.

The sensors convert the RF signal into a voltage that is measured with a voltmeter (not shown).

To measure the power at one port, two voltage measurements are required: one with the power switched on, the other with the power off. The port power is then
$P_\mathrm{sens} = \frac{(V_\mathrm{off}-V_\mathrm{on})(V_\mathrm{off}+V_\mathrm{on})} {R_\mathrm{std}}$
where $$R_\mathrm{std}$$ is the resistance of a precision standard resistor inside the power sensor circuit. $$P_\mathrm{sens}$$ is the power registered by the sensor.1

However, the ratio of port powers has to be calculated to benefit from using a splitter. So we are interested in
$R_\mathrm{sens} = \frac{P_\mathrm{sens \cdot 1}}{P_\mathrm{sens \cdot 2}} \;.$
Assuming different sensor electronics (and hence different resistors) at each port
$R_\mathrm{sens} = \frac{R_\mathrm{std\cdot 2}}{R_\mathrm{std\cdot 1}} \frac{(V_\mathrm{off\cdot 1}-V_\mathrm{on\cdot 1})(V_\mathrm{off\cdot 1}+V_\mathrm{on\cdot 1})}{(V_\mathrm{off\cdot 2}-V_\mathrm{on\cdot 2})(V_\mathrm{off\cdot 2}+V_\mathrm{on\cdot 2})} \;.$
So, what is the uncertainty in the power ratio?

### Reusing a model

The voltmeter model developed earlier will serve us here too. But a class for power sensors will by keeping an uncertain number for the precision resistor and defining the power calculation.
class Sensor(object):
def __init__(self,R,u_R,tag=None):
"""Initialise a new sensor object"""
label = "R"
if tag is not None: label += "_%s" % tag
self.R = ureal(R,u_R,label=label)

def power(self,v_off,v_on):
"""Return an estimate of power"""
return (v_off-v_on)*(v_off+v_on)/self.R

Using this class and the Meter class defined here, we can proceed as follows.

First define objects for a voltmeter and two sensors
m = Meter(u_e_gain=3E-6,u_e_zero=1E-6,u_e_ran=1E-7,tag='m1')
s1 = Sensor(R=200,u_R=2E-4,tag='1')
s2 = Sensor(R=200,u_R=2E-4,tag='2')

Then convert raw voltage readings into uncertain numbers, obtain power estimates at each port and finally calculate the power ratio
V1, V2, = m.voltage(2.6,tag='1'), m.voltage(2.4,tag='2')
V3, V4, = m.voltage(2.55,tag='3'), m.voltage(2.41,tag='4')

P1 = s1.power(V1,V2)
P2 = s2.power(V3,V4)

X = P1/P2



### The results

First, the uncertainty budget of the power ratio
print summary(X)
for cpt in rp.budget(X,trim=0):
print "%s: %G" % cpt

The output is
1.4400922, u=4.9E-06, df=inf
e_ran_3: 2.69706E-06
e_ran_4: 2.40904E-06
e_ran_1: 1.947E-06
e_ran_2: 1.65899E-06
R_1: 1.44009E-06
R_2: 1.44009E-06
e_zero_m1: 4.64546E-09
e_gain_m1: 5.0822E-21

Random errors associated with the voltage measurements dominate this estimate.

A different picture emerges if we look at just one of the power estimates
print summary(P1)
for cpt in rp.budget(P1,trim=0):
print "%s: %G" % cpt

The output is dominated by uncertainty in the residual meter gain error
0.005000000, u=3.2E-08, df=inf
e_gain_m1: 3E-08
e_ran_1: 6.76E-09
e_ran_2: 5.76E-09
R_1: 5E-09
e_zero_m1: 2E-09

print summary(V1)
for cpt in rp.budget(V1,trim=0):
print "%s: %G" % cpt

We see that the random errors were dominated by both the residual meter gain and offset uncertainties.
2.6000000, u=7.9E-06, df=inf
e_gain_m1: 7.8E-06
e_zero_m1: 1E-06
e_ran_1: 2.6E-07


### In conclusion

One of the advantages of object-oriented programming is that code written in one context can often be reused in another. GTC can capture the benefits from this. In this post we have reused the Meter class definition.

This post has also illustrated how to combine classes of objects in data processing: a Meter object was used here to create uncertain numbers for the four voltage estimates and these uncertain numbers were then directly used to obtain estimates of power by the two Sensor objects. The use of classes makes data processing code easier to read, understand and maintain.

Finally, the way in which different sources of uncertainty propagate into the power ratio is not simple. A full analysis using calculus would be quite a lot more work than the GTC calculation here. With GTC, if we want to, we can track the relative importance of influence quantities through the calculation, from one intermediate step to the next. However, there is no need to audit all these details. GTC ensures that uncertainties are correctly propagated.

1. There are other factors that need to be considered to estimate the signal generator power. In this post, we are only interested in the power level registered by the sensor