Esempio n. 1
0
def make(input, name):
    import math
    amplitudes = []  #  normalized to 0...100
    phases = []  # in degrees

    pi = 3.14159265
    NomRF = float(input[0])
    MAS = float(input[1])
    steps = int(input[2])
    DUO_B = MAS * float(input[3])
    DUO_C = MAS * float(input[4])
    duration = 2.0e06 / MAS
    deltaT = duration / steps
    RFmax = 0

    for i in range(steps):
        ti = i * deltaT
        co = math.cos(2 * pi * DUO_C * ti * 1.0e-6)
        si = math.sin(2 * pi * DUO_C * ti * 1.0e-6)

        # Calculate RF portion
        rf1 = DUO_C
        rf2 = -1.0 * DUO_B * si

        rf = math.sqrt(rf1 * rf1 + rf2 * rf2)
        if rf > RFmax:
            RFmax = rf

    # Calculate Phase Portion
        phcor = -1 * DUO_B * si / DUO_C
        ph = (math.atan2(rf2, rf1) + phcor) * 180 / pi
        if ph >= 0.0:
            nph = int(ph / 360.0)
            phint = ph - (nph) * 360
        else:
            nph = int(ph / 360.0)
            phint = ph - (nph - 1) * 360
        if RFmax > (NomRF * 1000):
            TopCmds.ERRMSG(
                message="ERROR the maximum RF is above the nominal RF",
                title="WAVE ERROR")
    amplitudes.append(rf / NomRF / 10)
    phases.append(phint)
    TopCmds.SAVE_SHAPE(name, "Excitation", amplitudes, phases)
    return
Esempio n. 2
0
def make(input, Names):
    import math
    Iampl = []  #  normalized to 0...100
    Sampl = []  #  normalized to 0...100
    Iphases = []  # in degrees
    Sphases = []  # in degrees
    Names = []
    iph = []  # in degrees

    pi = 3.14159265
    NomRFI = float(input[0])
    NomRFS = float(input[1])
    MAS = float(input[2])
    steps = int(input[3])
    CF = MAS * float(input[4])
    BI = MAS * float(input[5])
    BS = MAS * float(input[6])
    Iphase = float(input[7])

    duration = 2.0e06 / MAS
    deltaT = duration / steps
    RFImax = 0
    RFSmax = 0
    h = 0 - 1

    for i in range(steps):
        j = i + 1
        k = 1 + math.fmod(j - 1, steps)
        if (k == 1): h = -1 * h

        ti = i * deltaT
        co = math.cos(2 * pi * CF * ti * 1.0e-6)
        si = math.sin(2 * pi * CF * ti * 1.0e-6)

        #RF part
        RFIx = CF * (h)
        RFIy = BI * co
        RFSx = CF * (h)
        RFSy = BS * co

        RFI = math.sqrt(RFIx * RFIx + RFIy * RFIy)
        RFS = math.sqrt(RFSx * RFSx + RFSy * RFSy)

        if RFI > RFImax:
            RFImax = RFI
        if RFS > RFSmax:
            RFSmax = RFS
        if RFImax > (NomRFI * 1000):
            TopCmds.ERRMSG(message="ERROR the maximum RF is above the nominal RF",\
            title="WAVE ERROR")

        if RFSmax > (NomRFS * 1000):
            TopCmds.ERRMSG(message="ERROR the maximum RF is above the nominal RF",\
            title="WAVE ERROR")

        #Phase Part

        Iphcor = Iphase + BI * h * (co - 1) / (CF)
        Sphcor = BS * h * (co - 1) / (CF)

        Iph = (Iphcor + math.atan2(RFIy, RFIx)) * 180 / pi
        Sph = (Sphcor + math.atan2(RFSy, RFSx)) * 180 / pi

        if (Iph >= 0.0):
            Inph = int(Iph / 360.0)
            Iph_int = Iph - (Inph) * 360
        else:
            Inph = int(Iph / 360.0)
            Iph_int = Iph - (Inph - 1) * 360

        if (Sph >= 0.0):
            Snph = int(Sph / 360.0)
            Sph_int = Sph - (Snph) * 360
        else:
            Snph = int(Sph / 360.0)
            Sph_int = Sph - (Snph - 1) * 360
        Iampl.append(RFI / NomRFI / 10)
        Sampl.append(RFS / NomRFS / 10)
        Iphases.append(Iph_int)
        Sphases.append(Sph_int)

    TopCmds.SAVE_SHAPE(Names[0], "Excitation", Iampl, Iphases)
    TopCmds.SAVE_SHAPE(Names[1], "Excitation", Sampl, Sphases)