def newcapsp(self, ypg, z, r2, z2, uut_ratio): """ Calculates the parallel error minus the series error for a set of primary windings due to the change in potential distribution across the distributed capacitance from the primary windings to the screen. This version of the formula differs from the original published version. It also caclualtes the series/ parallel - series error when k=4. This error is set to 0 if k does not equal 4. :param ypg: ypg is complex admittance from series primary to primary screen :param z: is the leakage impedance of the primary when all the sections are connected in parallel :param r2: the secondary burden impedance :param z2: leakage impedance of the secondary winding :param uut_ratio: [k, m, n] is the ratio windings of the uut :return: (parallel-series) error, (series/parallel - series) erro """ k = uut_ratio[0] m = uut_ratio[1] n = uut_ratio[2] s_p_error = ypg / 3 *(k**2 - 1) * ((r2 + z2) * (m/n) ** 2 + z) s_p_error = s_p_error * gtc.ureal(1.0, self.sp_cap, self.df_sp_cap, label='sp_cap') # type B factor if k == 4: # 4 sections in series/parallel possible, note relies on exact integer ... isclose() needed? g = 2 sp_s_error = ypg / 3 * (k ** 2 - g**2) * ((r2 + z2) * (m / n) ** 2 + z) sp_s_error = sp_s_error * gtc.ureal(1.0, self.sp_cap, self.df_sp_cap, label='sp_s_cap') # type B factor else: sp_s_error =0 return s_p_error, sp_s_error
def get_correction(self, meas): """ Read calibration parameters from 'Calibrations' table determined by the measurement data in meas. :param meas: (Measurement obj) - single measurement data. :return: (Calibration obj) - Includes GTC.ureals of correction-factor and offset, calibration date and report no. """ equip = self.equip_id quant = meas.quantity date = meas.timestamp line = self.readrow_from_calibration_table(equip, quant, 'factor', date) val_fact = line['Value'] unc_fact = line['Uncert'] dof_fact = line['DoF'] cal_date = line['Date'] rep_no = line['Report No'] fact = GTC.ureal(val_fact, unc_fact, dof_fact) line = self.readrow_from_calibration_table(equip, quant, 'offset', date) val_offs = line['Value'] unc_offs = line['Uncert'] dof_offs = line['DoF'] offs = GTC.ureal(val_offs, unc_offs, dof_offs) cal = Calibration(date=cal_date, rep_no=rep_no, factor=fact, offset=offs) return cal
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
def fit_ureals(self, coeffs, cov, dof, label): """ Takes the coefficients, *coeffs*, and covariances, *cov*, together with degrees of freedom, *dof*, in the array output from *fit* and returns a list of function coefficients as correlated GTC ureals. The ureal is named with *label*. If one of the uncertainties is zero, a set of unlinked ureals is created. This should only occur if a transformer has had all errors set to zero (e.g. no VT) or the input data has been fabricated to be a perfect fit. """ uncert = [] for i in range(len(coeffs)): uncert.append(np.sqrt(cov[i, i])) flag = 1 #assume no zero uncertainties for x in uncert: if x == 0.0: flag = 0 if flag == 1: a = gtc.multiple_ureal(coeffs, uncert, dof, label) # and now set the correlations between all coefficients for i in range(len(coeffs)): for j in range(i): gtc.set_correlation(cov[i, j]/np.sqrt(cov[i, i]*cov[j, j]), a[j], a[i]) else: #have a zero uncertainty so create separate ureals print 'A fit has returned zero uncertainty for a function coefficient. This should only occur if input data has been purposely set to a perfect fit.' a = [] for i in range(len(coeffs)): a.append(gtc.ureal(coeffs[i], uncert[i], dof, label[i])) return a
def calculate_temp_from_Wr_unc(W, verbose=False): W = float2GTC(W) # constants for temperature calculation range -259.3467 C to 0 C B = [ 0.183324722, # B0 0.240975303, # B1 0.209108771, # B2 0.190439972, # B3 0.142648498, # B4 0.077993465, # B5 0.012475611, # B6 -0.032267127, # B7 -0.075291522, # B8 -0.056470670, # B9 0.076201285, # B10 0.123893204, # B11 -0.029201193, # B12 -0.091173542, # B13 0.001317696, # B14 0.026025526 ] # B15 # constants for temperature calculation range 0 C to 961.78 C D = [ 439.932854, # D0 472.418020, # D1 37.684494, # D2 7.472018, # D3 2.920828, # D4 0.005184, # D5 -0.963864, # D6 -0.188732, # D7 0.191203, # D8 0.049025 ] # D9 temp_k = 0 if W.x <= 1: for i in range(16): if i == 0: sum = B[0] else: sum = sum + B[i] * GTC.pow( (GTC.pow(W, 1 / 6) - 0.65) / 0.35, i) temp_k = 273.16 * sum else: for i in range(10): if i == 0: sum = 0 else: sum = sum + D[i] * GTC.pow((W - 2.64) / 1.64, i) temp_k = 273.15 + D[0] + sum temp_C = conv_kelvin2celsius(temp_k) if verbose: # print("W({})={}".format(temp_c, W)) print("T({}, unc std:{})={}, unc std:{}".format( W.x, W.u, temp_C.x, temp_C.u)) return temp_C
def coreZgtc(self, excite, frequency): """ 'excite' is the excitation level in % returns a complex impedance based on empirical fits...this works wit ureal for x """ x = excite inductance = (self.a1*GTC.log(x)+self.a2*x+self.a3)*1e-3 resistance = self.a4*GTC.log(x)+self.a5*x**2+self.a6/GTC.sqrt(x) return resistance + 1j*2*math.pi*frequency*inductance
def Calculate_Wr(temp_C): # constants for temperature range -259.3467 C to 0 C A = [ -2.13534729, #A0 3.18324720, #A1 -1.80143597, #A2 0.71727204, #A3 0.50344027, #A4 -0.61899395, #A5 -0.05332322, #A6 0.28021362, #A7 0.10715224, #A8 -0.29302865, #A9 0.04459872, #A10 0.11868632, #A11 -0.05248134 ] #A12 # constants for temperature range 0 C to 961.78 C C = [ 2.78157254, #C0 1.64650916, #C1 -0.13714390, #C2 -0.00649767, #C3 -0.00234444, #C4 0.00511868, #C5 0.00187982, #C6 -0.00204472, #C7 -0.00046122, #C8 0.00045724 ] #C9 temp_K = Conv_celsius2kelvin(float(temp_C)) Wr = 1 if (temp_C >= -259.3467) and (temp_C < 0): for i in range(13): if i == 0: sum = A[0] else: sum = sum + A[i] * GTC.pow( (GTC.log(temp_K / 273.16) + 1.5) / 1.5, i) Wr = GTC.exp(sum) elif (temp_C >= 0) and (temp_C <= 961.78): for i in range(10): if i == 0: sum = C[0] else: sum = sum + C[i] * GTC.pow((temp_K - 754.15) / 481, i) Wr = sum else: print("temperature out of range") print("Wr({})={}".format(temp_C, Wr)) return Wr
def burdenVAgtc(self,VA,pf,Isec): """ calculates the complex impedance of a burden from its VA, PF and secondary current """ if pf >= 0: #check sign convention for PF, '-'for capacitive multiplier = 1.0 else: multiplier = -1.0 magZ = VA/Isec**2 phi = GTC.acos(pf) Z = magZ*GTC.cos(phi)+ multiplier*1j*magZ*GTC.sin(phi) return Z
def get_test_result(self, a): """ :param a: first row of test :return: list of (ultimately ureals) [complex error 1, complex error 2, resistance] """ # first get relevant resistor resistor = self.perturbr[str( self.getblock([a + 1, a + 3, 12, 13])[0][0])] multiplier = float(self.getblock([a, a + 1, 7, 8])[0][0]) errors = self.getblock([a, a + 2, 10, 12]) error1 = self.tuple_to_complex(errors[0]) u_resolutionR = gtc.ureal( 0, self.arnie.resolutionR(error1.real, multiplier), 12, 'resR' + repr(error1.real)) u_correctionR = gtc.ureal(0, self.arnie.corrnR(error1.real, multiplier), 12, 'corrnR' + repr(error1.real)) u_resolutionM = gtc.ureal( 0, self.arnie.resolutionM(error1.imag, multiplier), 12, 'resM' + repr(error1.imag)) u_correctionM = gtc.ureal(0, self.arnie.corrnM(error1.imag, multiplier), 12, 'corrnM' + repr(error1.imag)) error = error1.real + u_resolutionR + u_correctionR + 1j * ( error1.imag + u_resolutionM + u_correctionM) error1 = error error2 = self.tuple_to_complex(errors[1]) u_resolutionR = gtc.ureal( 0, self.arnie.resolutionR(error2.real, multiplier), 12, 'resR' + repr(error2.real)) u_correctionR = gtc.ureal(0, self.arnie.corrnR(error2.real, multiplier), 12, 'corrnR' + repr(error2.real)) u_resolutionM = gtc.ureal( 0, self.arnie.resolutionM(error2.imag, multiplier), 12, 'resM' + repr(error2.imag)) u_correctionM = gtc.ureal(0, self.arnie.corrnM(error2.imag, multiplier), 12, 'corrnM' + repr(error2.imag)) error = error2.real + u_resolutionR + u_correctionR + 1j * ( error2.imag + u_resolutionM + u_correctionM) error2 = error the_burden = self.burdenZ(error1, error2, resistor) frequency_factor = gtc.ureal(0, self.maxfreq / 3.0, 50, label='frequency') the_burden = the_burden + 1j * the_burden.imag * frequency_factor # the addition is nominally zero return the_burden
def burdenZgtc(self,Z,Isec): """ returns a burden in the form of VA and PF based on its impedance uses GTC functions to cope if Z is a GTC ucomplex """ if Z.imag >= 0: #check sign convention for PF, '-'for capacitive multiplier = 1.0 else: multiplier = -1.0 phase = GTC.phase(Z) # phi = cmath.phase(Z) PF = GTC.cos(phase)*multiplier magZ = GTC.magnitude(Z) VA = magZ*Isec**2 return (VA, PF)
def calculate_Wr(temp_C, verbose=False): """ Function calculate reference function Wr for temperature t as numpy :param temp_C: :param verbose: :return: """ # constants for temperature range -259.3467 C to 0 C A = [ -2.13534729, # A0 3.18324720, # A1 -1.80143597, # A2 0.71727204, # A3 0.50344027, # A4 -0.61899395, # A5 -0.05332322, # A6 0.28021362, # A7 0.10715224, # A8 -0.29302865, # A9 0.04459872, # A10 0.11868632, # A11 -0.05248134 ] # A12 # constants for temperature range 0 C to 961.78 C C = [ 2.78157254, # C0 1.64650916, # C1 -0.13714390, # C2 -0.00649767, # C3 -0.00234444, # C4 0.00511868, # C5 0.00187982, # C6 -0.00204472, # C7 -0.00046122, # C8 0.00045724 ] # C9 temp_K = temp_C + 273.15 Wr = 1 if (temp_C >= -259.3467) and (temp_C < 0): for i in range(13): if i == 0: sum = A[0] else: sum = sum + A[i] * pow( (math.log(temp_K / 273.16) + 1.5) / 1.5, i) Wr = GTC.exp(sum) elif (temp_C >= 0) and (temp_C <= 961.78): for i in range(10): if i == 0: sum = C[0] else: sum = sum + C[i] * pow((temp_K - 754.15) / 481, i) Wr = sum else: print("temperature out of range") if verbose: print("Wr({}, unc std:{})={}, unc std:{}".format( temp_C.x, temp_C.u, Wr.x, Wr.u)) return Wr
def magnetic_coupling(self, block1, block2, uut_ratio, Rs, rls, target_i2, individual): """ Calculates the series error - parallel error for a set of primary windings. This method processes the data and calls on internal methods ishare, couple and magneticsp :param block1: the data block for calculating current sharing :param block2: the data block with coupling measurements :param uut_ratio: [k, m, n] ratio windings of the uut :param Rs: secondary burden resistance :param rls: secondary leakage impedance :param target_i2: the i2 value used to normalise the volt drops, usually 1, i.e. 5 A through 0.2 ohm :param individual: boolean when set to True the vdrops are measured across each individual winding :return: same as magneticsp, a complex error with no scaling """ N = uut_ratio[2]/(uut_ratio[0] * uut_ratio[1]) # the ratio in series connection vdrop = [] # measured volt drop i2 = [] # measured secondary current voltage for x in block1: vdrop.append(x[2]) i2.append(x[0]) proportions = self.ishare(uut_ratio, Rs, rls, vdrop, i2, 1, individual) # data is label, shunt volts, X V, Y V, Sh V sd/100, X stdev V, Y stdev V, CT ratio, Shunt, Com R # k = len(block2) + 1 # one fewer measurements than sections # create lists of data shuntv = [] # gtc values xv = [] # gtc values yv = [] # gtc values ctratio = [] # duplicates of a constant? shunt = [] # secondary shunt duplicates of a fixed value comr = [] # common resistance duplicates of a fixed value for x in block2: shuntv.append(gtc.ureal(x[1], x[4], 100, label='shuntv ' + repr(x[0]))) xv.append(gtc.ureal(x[2], x[5], 100, label='X V ' + repr(x[0]))) yv.append(gtc.ureal(x[3], x[6], 100, label='Y V ' + repr(x[0]))) ctratio.append(x[7]) shunt.append(x[8]) comr.append(x[9]) # calculation of coupling coupling = self.couple(shuntv, xv, yv, ctratio, shunt, comr, uut_ratio) return self.magneticsp(coupling, proportions, uut_ratio)
def magneticsp(self, couple, share, uut_ratio): """ Calculates the series error minus the parallel error for a set of primary windings due to magnetic coupling differences between the windings. Note that the way coupling was measured forces the first couple element to be zero. :param couple: list of k-1 mutual couplings for k primary windings :param share: list of fractional share of current for k primary windings in parallel :param uut_ratio: list [k, m, n] of windings for transformer :return: two complex errors, no scaling to % or ppm """ assert len(share) - len(couple) == 1, "sharing list should be one longer than coupling list" k = len(share) N = uut_ratio[2]/(uut_ratio[0] * uut_ratio[1]) if k == 4: # series/parallel available on Ta primaries x = (2-(share[0]+share[1]))/2 # x is offset required to make first two add to 2.0 y = (2-(share[2]+share[3]))/2 # y is offset required to make last two add to 2.0 sp_share = [] sp_share.append(share[0] + x) sp_share.append(share[1] + x) sp_share.append(share[2] + y) sp_share.append(share[3] + y) sp_merror = 0 # summation for the serie/parallel magnetic error for i in range(1, k): # the first element of share would have been multiplied by zero, so not needed sp_merror = couple[i - 1] * (sp_share[i]-1) + sp_merror sp_merror = N * sp_merror # the sign of this is as derived in section A3 of E056.005, relies on aj defn sp_merror = sp_merror * gtc.ureal(1.0, self.sp_mag, self.df_sp_mag, label='s_sp_mag') # type B factor else: sp_merror = 0 #i.e. there is no series/paralle connection merror = 0 for i in range(1, k): # the first element of share would have been multiplied by zero, so not needed merror = couple[i - 1] * (share[i] - 1) + merror merror = N * merror #the sign of this is as derived in section A3 of E056.005 and depends on aj measurement merror = merror * gtc.ureal(1.0, self.sp_mag, self.df_sp_mag, label='sp_mag') # type B factor return merror, sp_merror
def main(): bpm = BPM(sys.argv[1]) gtc = GTC(sys.argv[2], bpm.normID) outPath = sys.argv[3] useManifest = False ### Parse sample name from input gtc file name sampleName = sys.argv[2].split("/") sampleName = sampleName[len(sampleName) - 1] sampleName = sampleName.split(".")[0] out = [sampleName, sampleName, "0", "0", "-9", "-9"] #output holder in python list; have no sample information so use "0" and "-9" for mid, pid, gender, case/control status for i in range(gtc.getTotalSNPs()): if useManifest: alleleA = bpm.A[i] alleleB = bpm.B[i] else: alleleA = "A" alleleB = "B" origCall = gtc.genotypes[i] if origCall == 1: ## AA is original call out.append(alleleA) out.append(alleleA) elif origCall == 2: ## AB is original call out.append(alleleA) out.append(alleleB) elif origCall == 3: ## BB is original call out.append(alleleB) out.append(alleleB) else: ## NC is original call out.append("0") out.append("0") ## Output to std out the new calls in PED format outFile = open(outPath, 'a') # append to existing file outFile.write(" ".join(out)+"\n") outFile.close()
def oldcapsp(self, ypg, k, z4, r2, z2, uut_ratio): """ Calculates the series error minus the parallel error for a set of primary windings due to the change in potential distribution on the capacitance from the windings to screen. INCORRECT old formula. :param ypg: ypg is complex admittance from series primary to primary screen :param k: the number of sections connected in series :param z4: the leakage impedance of the primary winding :param r2: the secondary burden impedance :param z2: leakage impedance of the secondary winding :param uut_ratio: [k, n, m] transformer ratio :return: error; should be a GTC ucomplex if inputs are experimental values """ n = uut_ratio[2]/(uut_ratio[0] * uut_ratio[1]) s_p_error = ypg / 6 * 1 / (k ** 2 - 1) * (z4 + (r2 + z2) / n ** 2) s_p_error = s_p_error * gtc.ureal(1.0, self.sp_cap, self.df_sp_cap, label = 'sp_cap') # type B factor return s_p_error
def urealext(value_list, unc_list=0.0, k=2, array_label='X', df=GTC.inf): # INPUT variables: # for value_list are: # <class 'list'> # <class 'numpy.ndarray'> # <class 'int'> # <class 'float'> # for unc_list are: # <class 'list'> # <class 'numpy.ndarray'> # <class 'int'> # <class 'float'> # for k are: # <class 'int'> # <class 'float'> # for value_name are: # <class 'string'> if isinstance(value_list, int) or isinstance(value_list, float): # check if list is single value value_list = [[value_list]] n_rows = 1 n_cols = 1 else: # find size of value_list n_rows = len(value_list) n_cols = len(value_list[0]) if df == 'N': df = n_rows * n_cols - 1 realnumber_list = [[0 for x in range(n_cols)] for x in range(n_rows)] for i in range(n_rows): for j in range(n_cols): label = array_label + str(i) + '_' + str(j) if isinstance(unc_list, int) or isinstance(unc_list, float): unc_std = unc_list / k else: unc_std = unc_list[i][j] / k realnumber_list[i][j] = GTC.ureal(x=value_list[i][j], u=unc_std, label=label, df=df) unc_array = GTC.la.uarray(realnumber_list) return unc_array
def ctcompare(self, datablock, fullscale, targetexcitation, settings): """ Takes a set of CT error measurements as a block and returns the calculated ratio errors. Older spread sheets did not include gain and reserve settings for the SR830, hence the boolean settings :param datablock: shunt Volts, X V, Y V, Sh V sd/100, X stdev V, Y stdev, blank, Shunt, Gain, Reserve, Com R. :param fullscale: the value of current, A, that equates to 100% excitation :param targetexcitation: the set of nominal % excitation levels at which measurements were made :param settings: a boolean set to True if gain and reserve colunmns available :return: a list of errors, a list of actual excitation levels and a list of the matching nominal excitations """ assert settings in [True, False], "settings must be True for range and gain information, otherwise False" shuntv = [] # gtc values xv = [] # gtc values yv = [] # gtc values shunt = [] # secondary shunt duplicates of a fixed value gain = [] # SR830 range reserve = [] # reserve, 1 for on? comr = [] # common resistance, list will likely be duplicates of a fixed value for x in datablock: if settings == False: shunt.append(x[7]) comr.append(x[8]) shuntv.append( gtc.ureal(x[0], x[3], 100, label='shuntv ' + str(x[0] / x[7] / fullscale))) # use current as label xv.append(gtc.ureal(x[1], x[4], 100, label='X V ' + str(x[0] / x[7] / fullscale))) yv.append(gtc.ureal(x[2], x[5], 100, label='Y V ' + str(x[0] / x[7] / fullscale))) elif settings == True: gain.append(x[6]) reserve.append(x[7]) shunt.append(x[8]) comr.append(x[9]) shuntv.append( gtc.ureal(x[0], x[3], 100, label='shuntv ' + str(x[0] / x[8] / fullscale))) # use current as label xv.append(gtc.ureal(x[1], x[4], 100, label='X V ' + str(x[0] / x[8] / fullscale))) yv.append(gtc.ureal(x[2], x[5], 100, label='Y V ' + str(x[0] / x[8] / fullscale))) e, excite, nom_excite = self.ratioerror(shuntv, xv, yv, shunt, comr, targetexcitation, fullscale) return e, excite, nom_excite
print("Rs=",Rs) print("Rs shape=",Rs.shape) N=len(UR) print("N=",N) print("type:",type(R)) print(dir(R)) print(R.shape[1]) #T=np.array([1,2,3,4,5]) T2=GTC.pow(T,2) T3=(T-100)*GTC.pow(T,3) #T3=GTC.pow(T,3) print("T=",T) print("T2=",T2) print("T3=",T3) Ts=np.vstack((T,T2,T3)).transpose() print("Ts=",Ts) print(Ts.shape) W=psolve(Ts,Rs) print("\nw=",W) A=W[0,0] B=W[1,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)
def float2GTC(value): if isGTC(value): return value else: return GTC.ureal(value, 0)
print "specify GTC file path with -G" sys.exit() if options.thresholds == None: print "specify thresholds.txt file with -T" sys.exit() ### Parse sample name from input gtc file name sampleName = options.gtc.split("/") sampleName = sampleName[len(sampleName) - 1] sampleName = sampleName.split(".")[0] ### Initialize GTC and BPM file classes bpm = BPM(options.bpm) egt = EGT(options.egt) gtc = GTC(options.gtc, bpm.normID) ### Get Number of SNPs numSNPs = gtc.numSNPs ### Parse thresholds thresholdsX = [] thresholdsY = [] for line in open(options.thresholds, 'r'): line = line.replace("\n", "") if line.find("Tx") != -1: continue else: fields = line.split("\t") snp = fields[0]
max_sd = 0.00007754 return sd * reading def auxP(self, reading): """ uncertainty in the correction factor for auxiliary phase """ max_sd = 0.0003270 return sd * reading if __name__ == "__main__": print 'Testing that the module works as intended.' arnie = ARNOLD('a', 'b') #in GTC terms we add the corrections res_corrn_e = GTC.ureal(0, arnie.resolutionR(-0.682, 1), 5, 'swire_resolution').u scale_corrn_e = GTC.ureal(0, arnie.corrnR(-0.682, 1), 5, 'swire_correction').u res_corrn_p = GTC.ureal(0, arnie.resolutionM(0.032, 0.1), 5, 'mutual_resolution').u scale_corrn_p = GTC.ureal(0, arnie.corrnM(0.032, 0.1), 5, 'mutual_correction').u print res_corrn_e, '%' print scale_corrn_e, '%' print res_corrn_p, 'crad' print scale_corrn_p, 'crad' """ >pythonw -u "arnold.py" Testing that the module works as intended. 0.001 %
coeff=GTC.la.matmul(invA,B) print('\ncoeff=',coeff) a=coeff[0][0] b=coeff[1][0] c=coeff[2][0] print('\nCalculated coefficients:\n') print('a coeff=',a.x,'u=',a.u) print('b coeff=',b.x,'u=',b.u) print('c coeff=',c.x,'u=',c.u) #### STEP 3- TEMPERATURE CALCULATION FROM RESISTANCE MEASURED #resistancec from measurement R0=GTC.ureal(100,0.000002,label='R0') #Triple point of water resistance Ri=[102,189,300] # measured resistances R=GTCext.urealext(value_list=Ri, unc_list=0.0005, k=2, array_label='R', df=GTC.inf) print('\nR0=',R0) print('\nR=',R) Wt=R/R0 # calculating reference function for measured resistances print('\nW(t)=',Wt) Wt1=GTCext.python_list_transposition(Wt-1) pow2=lambda #Wt2=GTC.pow(Wt1,2) #Wt3=GTC.pow(Wt1,3)
frequency = 53.0 # Hz, the frequency of calibration capacitance = 197.39e-12 # farad, capacitance from 20 turn primary to screen ypg_admit = 1j * 2 * math.pi * frequency * capacitance k = 4 # number of sections on the primary # z4 has not been measured and is instead estimated as being P1 resistance value divided by 5, but a retain high full leakage impedance z4 = ( 0.374 / 5.0 + 1j * 0.035 ) / k # ohm, primary leakage impedance from Y51, Z51 of 'Calc 50 Hz' in CTCAL2 z3 = 0.2699 + 1j * 0.0021 # ohm, secondary leakage impedance from Z19, AA51 of 'Calc 50 Hz' in CTCAL2 r2 = 0.2 # ohm, secondary burden impedance ratio = [4, 5, 100] # 100 / 25 # ratio of series connection cap_error2a, cap_error2a_sp = build.calrun.newcapsp( ypg_admit, z4, r2, z3, ratio) print('capacitance error2a = ', cap_error2a) cap2a = gtc.ucomplex(0 + 0j, (abs(cap_error2a.real), abs(cap_error2a.imag)), label='cap2a') # use this estimate as an uncertainty # Note that there is a factor of 5 difference in the nominal excitation levels of Tc and Ta # Use simple 2-point extrapolation and interpolation to get the 0.2% to 25% values for P2ap P2ap_fifth = build.calrun.one_fifth( t3, target_excitation) # interpolated P2ap at one fifth excitation P2as_fifth = [] for x in P2ap_fifth: P2as_fifth.append( x - cap2a - magnetic2a ) # corrects each point e_series = e_par - cap_sp - mag_sp # finally assign error to the 5:1 transformer e6 = [] # this will be the final Tc error for i in range(len(e6_53)): e6.append(
print('magnetic2a ', magnetic2a) frequency = 53.0 # Hz, the frequency of calibration capacitance = 197.39e-12 # farad, capacitance from 20 turn primary to screen ypg_admit = 1j * 2 * math.pi * frequency * capacitance k = 4 # number of sections on the primary # z4 has not been measured and is instead estimated as being P1 resistance value divided by 5, but a retain high full leakage impedance z4 = ( 0.374 / 5.0 + 1j * 0.035 ) / k # ohm, primary leakage impedance from Y51, Z51 of 'Calc 50 Hz' in CTCAL2 z3 = 0.2699 + 1j * 0.0021 # ohm, secondary leakage impedance from Z19, AA51 of 'Calc 50 Hz' in CTCAL2 r2 = 0.2 # ohm, secondary burden impedance ratio = [4, 5, 100] # 100 / 25 # ratio of series connection cap_error2a, cap_error2a_sp = build.calrun.newcapsp(ypg_admit, z4, r2, z3, ratio) print('capacitance error2a = ', cap_error2a, cap_error2a_sp) cap2a = gtc.ucomplex(0 + 0j, (abs(cap_error2a.real), abs(cap_error2a.imag)), label='cap2a') # use this estimate as an uncertainty # Note that there is a factor of 5 difference in the nominal excitation levels of Tc and Ta # Use simple 2-point extrapolation and interpolation to get the 0.2% to 25% values for P2ap P2ap_fifth = build.calrun.one_fifth( t3, target_excitation) # interpolated P2ap at one fifth excitation P2as_fifth = [] for x in P2ap_fifth: P2as_fifth.append( x - cap2a - magnetic2a) # corrects each point e_series = e_par - cap_sp - mag_sp # finally assign error to the 5:1 transformer e6 = [] # this will be the final Tc error for i in range(len(e6_53)): e6.append( P2as_fifth[i] -