Пример #1
0
 def close(self):
     '''closing instruments:
     '''
     AWG.Abort_Gen(self.awgsess)
     AWG.close(self.awgsess)
     PSGA.rfoutput(self.saga, action=['Set', 0])
     PSGA.close(self.saga, False)
     MXA.close(self.mxa, False)
                        and OPT.IQparams[3] - OPT.IQparams[4] > 180):
                print("phase skew Q-I:\n %s" %
                      (OPT.IQparams[4] - OPT.IQparams[3]))

            if (OPT.IQparams[2] > -1.0) and (OPT.IQparams[2] < 1.0):
                Iamp = 1
                Qamp = Iamp * OPT.IQparams[2]
            else:
                Qamp = 1
                Iamp = Qamp / OPT.IQparams[2]

            print("Ioffset:\n %s" % OPT.IQparams[0])
            print("Qoffset:\n %s" % OPT.IQparams[1])
            print("Iamp:\n %s" % Iamp)
            print("Qamp:\n %s" % Qamp)
            print("Iphase:\n %s" % OPT.IQparams[3])
            print("Qphase:\n %s" % OPT.IQparams[4])

            break

    curve(T, LO, 'LO Leakage vs time', 'T(#)', 'DLO(dB)')
    curve(T, Mirror, 'Mirror Image vs time', 'T(#)', 'DMirror(dB)')

# closing instruments:
ans = input("Press any keys to close AWG, PSGA and RSA-5 ")
AWG.Abort_Gen(awgsess)
AWG.close(awgsess)
PSGA.rfoutput(saga, action=['Set', 0])
PSGA.close(saga, False)
MXA.close(mxa, False)
Пример #3
0
def test():

    LO_0 = float((MXA.fpower(mxa, str(5.5) + 'GHz')).split('dBm')[0])
    Mirror_0 = float((MXA.fpower(mxa, str(5.475) + 'GHz')).split('dBm')[0])
    Initial = [0., 0., 1., 0., 0.]
    time = 0
    OPT = IQ_Cal()
    OPT.IQparams = array(Initial, dtype=float64)  #overwrite initial values
    result = OPT.nelder_mead(time=time)
    prev = result[0]
    no_improv, no_improv_thr, no_improv_break = 0, 1e-5, 4
    LO, Mirror, T = [], [], []
    while True:
        time += 1
        if time % 2: OPT = IQ_Cal('MR', result[0], ratio=time)
        else: OPT = IQ_Cal('LO', result[0], ratio=time)
        result = OPT.nelder_mead(time=time)
        # if len(result) == 3:
        #     print("Optimized IQ parameters:\n %s" %result)
        #     break
        LO.append(
            float((MXA.fpower(mxa,
                              str(5.5) + 'GHz')).split('dBm')[0]) - LO_0)
        Mirror.append(
            float((MXA.fpower(mxa,
                              str(5.475) + 'GHz')).split('dBm')[0]) - Mirror_0)
        print(Back.BLUE + Fore.WHITE +
              "Mirror has been suppressed for %s from %s" %
              (Mirror[-1], Mirror_0))
        T.append(time)
        ssq = sum((result[0] - prev)**2)
        if ssq > no_improv_thr:
            no_improv = 0
            prev = result[0]
        else:
            no_improv += 1

        if no_improv >= no_improv_break:
            AWG_Sinewave(25, OPT.IQparams)
            print(type(OPT.IQparams))
            print("Optimized IQ parameters:\n %s" % result)
            print("Amplitude Imbalance:\n %s" % OPT.IQparams[2])
            if OPT.IQparams[3] > OPT.IQparams[
                    4] and OPT.IQparams[3] - OPT.IQparams[4] < 180:
                print("phase skew I-Q:\n %s" %
                      (OPT.IQparams[3] - OPT.IQparams[4]))
            if OPT.IQparams[3] > OPT.IQparams[
                    4] and OPT.IQparams[3] - OPT.IQparams[4] > 180:
                print("phase skew Q-I:\n %s" %
                      (360 - (OPT.IQparams[3] - OPT.IQparams[4])))
            if (OPT.IQparams[4] > OPT.IQparams[3]
                    and OPT.IQparams[4] - OPT.IQparams[3] < 180) or (
                        OPT.IQparams[3] > OPT.IQparams[4]
                        and OPT.IQparams[3] - OPT.IQparams[4] > 180):
                print("phase skew Q-I:\n %s" %
                      (OPT.IQparams[4] - OPT.IQparams[3]))

            if (OPT.IQparams[2] > -1.0) and (OPT.IQparams[2] < 1.0):
                Iamp = 1
                Qamp = Iamp * OPT.IQparams[2]
            else:
                Qamp = 1
                Iamp = Qamp / OPT.IQparams[2]

            print("Ioffset:\n %s" % OPT.IQparams[0])
            print("Qoffset:\n %s" % OPT.IQparams[1])
            print("Iamp:\n %s" % Iamp)
            print("Qamp:\n %s" % Qamp)
            print("Iphase:\n %s" % OPT.IQparams[3])
            print("Qphase:\n %s" % OPT.IQparams[4])

            break

    curve(T, LO, 'LO Leakage vs time', 'T(#)', 'DLO(dB)')
    curve(T, Mirror, 'Mirror Image vs time', 'T(#)', 'DMirror(dB)')

    # closing instruments:
    ans = input("Press any keys to close AWG, PSGA and RSA-5 ")
    AWG.Abort_Gen(awgsess)
    AWG.close(awgsess)
    PSGA.rfoutput(saga, action=['Set', 0])
    PSGA.close(saga, False)
    MXA.close(mxa, False)