コード例 #1
0
    def ratioerror(self, shuntv, xv, yv, shunt, comr, nomexcitation, full_scale):
        """
        Calculates the measured ratio error. All parameters are lists of data from

        :param shuntv: shuntv: voltage measured across the shunt on the secondary monitoring the primary current
        :param xv: xv: real part of voltage across the common resistor
        :param yv: imaginary part of the voltage across the common resistor
        :param shunt: value of the secondary shunt
        :param comr: value of the common resistor
        :param nomexcitation: nominal excitation list, e.g. 10%, 20% ... 120%
        :return: a list of errors, a list of actual excitation levels and a list of the matching nominal excitations
        """

        # TODO consider a 'swap' flag for where the nominal reference ratio was actually on the UUT side
        e = []  # list of error e1 at each excitation level
        excite = []  # matching list of fractional excitation level
        nom_excite = []  # matched nominal excitation level
        for i in range(len(xv)):
            xvolt = xv[i] * gtc.ureal(1.0, self.sr830, self.df_sr830, label = 'sr830 '+ repr(xv[i]))  #type B
            xvolt = xvolt + gtc.ureal(0.0, self.cmnmode, self.df_cmnmode, label = 'common mode ' + repr(xvolt.x))
            yvolt = yv[i] * gtc.ureal(1.0, self.sr830, self.df_sr830, label='sr830 '+ repr(yv[i]))  # type B
            yvolt = yvolt + gtc.ureal(0.0, self.cmnmode, self.df_cmnmode, label='common mode '+ repr(yvolt.x))
            ecurrent = (xvolt + 1j * yvolt) / comr[i]  # difference current measured by SR830
            current = shuntv[i] / shunt[i]  # primary =  secondary current
            e_answer =  gtc.result((ecurrent/current), 'my label')  # key intermiediate result? decide later
            e.append(e_answer)
            excite.append(current / full_scale * 100)  # note this is a ureal
            nom_excite.append(
                min(nomexcitation, key=lambda x: abs(x - excite[i].x)))  # finds closest nominal excitation level
        return e, excite, nom_excite
コード例 #2
0
import GTC as gtc
x = gtc.ureal(0.0, 0.1, 5)
y = gtc.ureal(0.0, 0.2, 10)
a = x * y
print(a.u)
b = gtc.function.mul2(x, y)
print(b)

ab = gtc.result(a * b, label='result')
print(ab.label, ab)