示例#1
0
def HN(MAS0, MAS, units):

    p90H = pul.GetPar('pH90', "")
    ampH = pul.GetPar('aH', units)
    SPH = pul.GetPar('sHhn', "")
    ampHCP = pul.GetPar('aHhn', units)
    avgH = 1.0

    p90X = pul.GetPar('pN90', "")
    ampX = pul.GetPar('aN', units)
    SPX = pul.GetPar('sNhn', "")
    ampXCP = pul.GetPar('aNhn', units)
    avgX = 1.0

    CNCT = pul.GetPar('pHN', "")

    params = TopCmds.INPUT_DIALOG("HN CP MAS adjustment", "Proton Nitrogen Cross Polarization", \
    ["Old MAS rate","New MAS rate","Old 1H power ("+pul.pulDict['aHhc']+")",\
    "Old 15N power ("+pul.pulDict['aNhn']+")","Contact Time ("+pul.pulDict['pHN']+")",\
    "H-Ramp ("+pul.pulDict['sHhc']+")","N-Ramp ("+pul.pulDict['sChc']+")"],\
    [str(MAS0),str(MAS),str(ampXCP),str(ampHCP),str(CNCT),SPH,SPX],\
    ["Hz","Hz",units,units,"us","",""],\
    ["1","1","1","1","1","1","1"],\
    ["Accept","Close"], [spc,ret], 10)

    if params == None: TopCmds.EXIT()

    if units == "W":
        params[2] = str(Setup.WtodB(float(params[2])))
        params[3] = str(Setup.WtodB(float(params[3])))
        ampH = Setup.WtodB(ampH)
        ampX = Setup.WtodB(ampX)

    if SPH != "None" and SPH != None and SPH != "Unused":
        avgH = IntShape.Integrate(SPH) / 100.
    if SPX != "None" and SPX != None and SPX != "Unused":
        avgX = IntShape.Integrate(SPX) / 100.

    pulses = p90H, ampH, p90X, ampX, avgH, avgX

    SelectorText="Adjust the HN CP parameters:","Calculate New Match for:",\
    ["Proton","Nitrogen","Maximum for Both"]

    ampHCP, ampXCP = FindMatch(params, pulses, SelectorText)

    if units == "W":
        ampXCP = Setup.dBtoW(ampXCP)
        ampHCP = Setup.dBtoW(ampHCP)

    value = TopCmds.SELECT("Adjusting the HN CP parameters:",\
    "This will set\n 1H power to:  " + str('%3.2f' %ampHCP)+ " "+units+"\n \
  15N power to:  "                     +str('%3.2f' %ampXCP) + " "+units,["Update", "Keep Previous"])

    if value != 1:
        pul.SetPar('aHhn', ampHCP, units)
        pul.SetPar('aNhn', ampXCP, units)
        pul.SetPar('pHN', CNCT, "")
        pul.SetPar('sHhn', SPH, "")
        pul.SetPar('sNhn', SPX, "")
def CalS7purge():
  p90C=float(TopCmds.GETPAR("P 1"))
  ampC=float(TopCmds.GETPAR("PLdB 1"))
  
  MaxB1 = 1000000./4./p90C
  p90sC=float(TopCmds.GETPAR("P 7"))
  
  SPname=(TopCmds.GETPAR("SPNAM7"))
  if p90sC == 0: p90sC = 1500000./MAS
  SP=SPname
  if SP == "gauss" : SP = "3pi2SINC.wtf"
  offs = float(TopCmds.GETPAR("SPOFFS 7"))

  index = TopCmds.INPUT_DIALOG("ON-resonance 90 purge", "S7 soft 90", \
  ["Duration","Offset","Pulse Name (3pi/2 Sinc)"],\
  [str(p90sC),str(offs),SP],\
  ["us","Hz",""],\
  ["1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)
  
  p90sC=float(index[0])
  offs=float(index[1])
  SP=index[2]
  
  AvgAmp=IntShape.Integrate(SP)/100.
  
  adjust=20*math.log10(p90C/p90sC/AvgAmp)
  Power=ampC-adjust
  
  TopCmds.PUTPAR("PLdB 27",str('%3.2f' %Power))
  TopCmds.PUTPAR("SPNAM7",SP)
  TopCmds.PUTPAR("SPOFFS 7",str('%8.2f' %offs))
  TopCmds.PUTPAR("P 7",str('%3.2f' %p90sC))     
def S6purge():
  p90C=float(TopCmds.GETPAR("P 1"))
  ampC=float(TopCmds.GETPAR("PLdB 1"))
  MAS =float(TopCmds.GETPAR("CNST 31"))
  
  MaxB1 = 1000000./4./p90C
  p90sC=float(TopCmds.GETPAR("P 6"))
  
  SPname=(TopCmds.GETPAR2("SPNAM 6"))
  if p90sC == 0: p90sC = 1500000./MAS
  SP=SPname

  #Check for existence and default
  if SP == "gauss" or SP == "None" :
    #TopCmds.MSG("Please set spnam6")
    TopCmds.XCMD("spnam6")
    SP=(TopCmds.GETPAR2("SPNAM 6"))
    
  offs = float(TopCmds.GETPAR("SPOFFS 6"))
  ppm=CFrq.offs2ppm(offs)

  if ppm > 140.0 : ppm=55.0
  if ppm < -10.0 : ppm=55.0

  index = TopCmds.INPUT_DIALOG("CA 90 purge", "S6 soft 90", \
  ["Duration","Offset","Pulse Name (3pi/2 Sinc)"],\
  [str('%3.2f' %p90sC),str('%3.2f' %ppm),SP],\
  ["us","ppm",""],\
  ["1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)
  
  p90sC=float(index[0])
  ppm=float(index[1])
  SP=index[2]
  offs=CFrq.ppm2offs(ppm)
  
  AvgAmp=IntShape.Integrate(SP)/100.
  adjust=20*math.log10(p90C/p90sC/AvgAmp)
  Power=ampC-adjust
  
  PowerW=pwr.dBtoW(Power)
  
  confirm = TopCmds.SELECT("Adjusting the S6 purge pulse:",\
  "This will set\n \
  13C amp (pl26) to :" + str('%3.2f' %PowerW)+ " W\n \
  Pulse offset to   :" + str('%8.0f' %offs) + " Hz\n \
  Equivalent to     :" + str('%3.1f' %ppm ) + " ppm\n \
  p6 to             :" + str('%6.1f' %p90sC)+ " us\n "\
  ,["Update", "Keep Previous"])
  
  if confirm != 1:
    TopCmds.PUTPAR("PLdB 26",str('%3.2f' %Power))
    TopCmds.PUTPAR("SPNAM 6",SP)
    TopCmds.PUTPAR("SPOFFS 6",str('%8.2f' %offs))
    TopCmds.PUTPAR("P 6",str('%3.2f' %p90sC))
def CalS9refocus():
  p90C=float(TopCmds.GETPAR("P 1"))
  ampC=float(TopCmds.GETPAR("PLdB 1"))
  
  MaxB1 = 1000000./4./p90C
  p180sC=float(TopCmds.GETPAR("P 9"))
  
  SPname=(TopCmds.GETPAR("SPNAM9"))
  if p180sC == 0: p90sC = 1500000./MAS
  SP=SPname
  if SP == "gauss" : SP = "RSnob"
  offs = float(TopCmds.GETPAR("SPOFFS 9"))

  index = TopCmds.INPUT_DIALOG("OFF-resonance 180 Refocussing", "S9 soft 180", \
  ["Duration","Offset","Pulse Name (RSnob)"],\
  [str(p180sC),str(offs),SP],\
  ["us","Hz",""],\
  ["1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)
  p180sC=float(index[0])
  offs=float(index[1])
  SP=index[2]
  
  #TopCmds.MSG(str(p90sC)+' p90sC')
  AvgAmp=IntShape.Integrate(SP)/100.
  adjust=20*math.log10(2*p90C/p180sC/AvgAmp)
  #TopCmds.MSG(str(adjust)+'adjust')
  
  Power=ampC-adjust
  
  #TopCmds.MSG(str(Power))
  
  TopCmds.PUTPAR("PLdB 29",str('%3.2f' %Power))
  TopCmds.PUTPAR("SPNAM9",SP)
  TopCmds.PUTPAR("SPOFFS 9",str('%8.2f' %offs))
  TopCmds.PUTPAR("P 9",str('%3.2f' %p180sC))
示例#5
0
def CalC542_adb_TOBSY():
    p90C = pul.GetPar('pC90', "")
    ampC = pul.GetPar('aC', units)
    MAS = pul.GetPar('MAS', "")
    SP = pul.GetPar('sCabd', "")
    Loop = pul.GetPar('lTOBSY', "")
    AvgAmp = IntShape.Integrate(RAMP) / 100.

    if Loop == 0: Loop = 25

    if units == "W":
        ampC = WtodB(ampC)

    MaxB1 = 1000000. / 4. / p90C
    C542B1 = MAS * 0.8 / AvgAmp

    adjust = 20 * (math.log10(C542B1 / MaxB1))
    condition = ampC - adjust

    if units == "W":
        condition = dBtoW(condition)

    pul.SetPar('aCadb', condition, "units")
    Loop = pul.GetPar('lTOBSY', Loop, "")
示例#6
0
def HC(units):
    p90H = pul.GetPar('pH90', "")
    p90C = pul.GetPar('pC90', "")
    ampH = pul.GetPar('aH', units)
    ampC = pul.GetPar('aC', units)
    MAS = pul.GetPar('MAS', "")
    CNCT = pul.GetPar('pHC', "")
    SPH = pul.GetPar('sHhc', "")
    SPX = pul.GetPar('sChc', "")

    if units == "W":
        ampH = WtodB(ampH)
        ampC = WtodB(ampC)

    if CNCT <= 1.: CNCT = 1000.

    if SPH == "gauss" or SPH == "None" or SPH == "" or SPH == "0":
        pul.SetPar('sHhc', "ramp.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict['sHhc']))
        SPH = pul.GetPar('sHhc', "")

    if SPX == "gauss" or SPX == "None" or SPX == "" or SPX == "0":
        pul.SetPar('sChc', "square.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict['sChc']))
        SPX = pul.GetPar('sChc', "")

    MaxB1H = 1000000. / 4. / p90H
    MaxB1C = 1000000. / 4. / p90C

    #find the channel with the lowest B1
    if MaxB1C < MaxB1H:
        Ratio = int(math.floor(MaxB1C / MAS))
        CCond = (Ratio - 0.5) * MAS
        HCond = (Ratio + 0.5) * MAS

        if HCond > MaxB1H:
            Ratio = Ratio - 1
            CCond = (Ratio - 0.5) * MAS
            HCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            CCond = .25 * MAS
            HCond = .75 * MAS

    if MaxB1C >= MaxB1H:
        Ratio = int(math.floor(MaxB1H / MAS))
        HCond = (Ratio - 0.5) * MAS
        CCond = (Ratio + 0.5) * MAS

        if CCond > MaxB1C:
            Ratio = Ratio - 1
            HCond = (Ratio - 0.5) * MAS
            CCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            CCond = .75 * MAS
            HCond = .25 * MAS

    adjust = 20 * (math.log10(CCond / MaxB1C))
    Camp = ampC - adjust
    adjust = 20 * (math.log10(HCond / MaxB1H))
    Hamp = ampH - adjust

    index = TopCmds.INPUT_DIALOG("HC CP Input", "Proton Carbon Cross Polarization", \
    ["Proton B1 Field","H Ramp","Carbon B1 Field","C Ramp","Contact Time(P15)"],\
    [str(HCond),str(SPH),str(CCond),str(SPX),str(CNCT)],\
    ["Hz","","Hz","","us"],\
    ["1","1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1H))
    Hamp1 = ampH - adjust
    if SPH == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) / MaxB1C))
    Camp1 = ampC - adjust
    if SPX == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[3]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Camp = Camp1 - adjust

    CNCT = float(index[4])

    if units == "W":
        Hamp = dBtoW(Hamp)
        Camp = dBtoW(Camp)

    value = TopCmds.SELECT("Adjusting the HC CP parameters:",\
    "This will set\n 1H power to:  " + str('%3.2f' %Hamp)+" "+ units+"\n \
  13C power to:  "                     +str('%3.2f' %Camp) + " "+units,["Update", "Keep Previous"])

    if value != 1:
        pul.SetPar('aHhc', Hamp, units)
        pul.SetPar('aChc', Camp, units)
        pul.SetPar('pHC', CNCT, "")
        if SPH != "Unused":
            pul.SetPar('sHhc', index[1], "")
        if SPX != "Unused":
            pul.SetPar('sChc', index[3], "")
示例#7
0
["SPNAM #","points","%","%","%","steps","","","steps"],\
["1","1","1","1","1","1","1","1","1"],\
["Accept","Close"], ['a','c'], 10)

if dia == None: EXIT()
""" 
Let's check the scaling to make sure we don't change the condition, but we'll let it happen 
if that is what the user intends.
"""

SP=GETPAR2("SPNAM "+dia[0])
if SP == "gauss" or SP == "None" : Empty=1
  
Scale=float(dia[2])
if not Empty: 
  AvgAmp=IntShape.Integrate(SP)
  if math.fabs(AvgAmp-float(dia[2])) > 5.:
    value=SELECT("Scaling Error",\
    "The scaling and the previous power differs by more than 5%.\n\n"+\
    "This may effect the quality of the match condition, please choose how to proceed:",\
    ["Use Previous: " + str("%3.1f" %AvgAmp), "Use "+str("%3.1f" %Scale)])
  
    if not value: Scale=AvgAmp

#MSG(str(Scale)+ "  Scale")

"""
Another safety check so we don't go over 100 or under 0

"""
示例#8
0
def NCO(MAS0,MAS,units):

  p90X=float(TopCmds.GETPAR("P 1"))
  ampX=float(TopCmds.GETPAR("PL"+units+" 1"))
  ampXdB=float(TopCmds.GETPAR("PLdB 1"))
  
  ampXCP0=float(TopCmds.GETPAR("SP"+units+" 51"))
  ampXCP0dB=float(TopCmds.GETPAR("SPdB 51"))
  #ampXCP0=float(TopCmds.GETPAR("PL"+units+" 50"))
  #ampXCP0dB=float(TopCmds.GETPAR("PLdB 50"))
  SPX=TopCmds.GETPAR2("SPNAM 51")
  
  p90Y=float(TopCmds.GETPAR("P 21"))
  ampY=float(TopCmds.GETPAR("PL"+units+" 3"))
  ampYdB=float(TopCmds.GETPAR("PLdB 3"))
  
  ampYCP0=float(TopCmds.GETPAR("PL"+units+" 6"))
  ampYCP0dB=float(TopCmds.GETPAR("PLdB 6"))

  SPY="None"
  avgY0=1.  
  
  # Get the integration before possibly changing the shape.
  if SPX != "None" and SPX != None:
    avgX0=IntShape.Integrate(SPX)/100.
  if SPX == "None" or SPX == None:
    avgX0=1.

  CNCT=float(TopCmds.GETPAR("P 17"))


  #Interact with user about MAS and power levels, likely not needed
  params = TopCmds.INPUT_DIALOG("NCO CP MAS adjustment", "Nitrogen Carbonyl Cross Polarization", \
  ["Old MAS rate","New MAS rate","Old 13C power","Old 15N power","Contact Time(P16)","C-Ramp"],\
  [str(MAS0),str(MAS),str(ampXCP0),str(ampYCP0),str(CNCT),SPX],\
  ["kHz","kHz",units,units,"us",""],\
  ["1","1","1","1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)
  
  if params == None: TopCmds.EXIT()
  params.append(SPY)

  # Everything is written with dB, so we might have to convert
  if units == "W":
    params[2]=str(Setup.WtodB(float(params[2])))
    params[3]=str(Setup.WtodB(float(params[3])))

  if SPX != "None" and SPX != None:
    avgX0=IntShape.Integrate(SPX)/100.
  if SPX == "None" or SPX == None:
    avgX0=1.

  pulses=p90X,ampXdB,p90Y,ampYdB,avgX0,avgY0
  
  SelectorText="Adjust the NCA CP parameters:","Calculate New Power Level for:",\
  ["Carbon","Nitrogen","Both"]
  
  ampXCPdB, ampYCPdB = FindMatch(params,pulses,SelectorText)

  if units == "W":
    ampXCP=Setup.dBtoW(ampXCPdB)
    ampYCP=Setup.dBtoW(ampYCPdB)
  
  value = TopCmds.SELECT("Adjusting the NCO CP parameters:",\
  "This will set\n 13C power to:  " + str('%3.2f' %ampXCP)+ " "+units+"\n \
  15N power to:  " +str('%3.2f' %ampYCP) + " "+units,["Update", "Keep Previous"])
    
  if value != 1:
    TopCmds.PUTPAR("PLdB 51",str('%3.2f' %ampXCPdB))
    TopCmds.PUTPAR("SPdB 51",str('%3.2f' %ampXCPdB))
    TopCmds.PUTPAR("PLdB 6",str('%3.2f' %ampYCPdB))
    TopCmds.PUTPAR("P 17" ,str('%3.2f' %CNCT))
    TopCmds.PUTPAR("SPNAM 51",SPX)
示例#9
0
def HN(MAS0,MAS,units):

  p90H=float(TopCmds.GETPAR("P 3"))
  ampH=float(TopCmds.GETPAR("PL"+units+" 2"))
  ampHdB=float(TopCmds.GETPAR("PLdB 2"))
  
  ampHCP0=float(TopCmds.GETPAR("SP"+units+" 42"))
  ampHCP0dB=float(TopCmds.GETPAR("SPdB 42"))
  #ampHCP0=float(TopCmds.GETPAR("PL"+units+" 42"))
  #ampHCP0dB=float(TopCmds.GETPAR("PLdB 42"))
  SPH=TopCmds.GETPAR2("SPNAM 42")
  
  p90X=float(TopCmds.GETPAR("P 21"))
  ampX=float(TopCmds.GETPAR("PL"+units+" 3"))
  ampXdB=float(TopCmds.GETPAR("PLdB 3"))
  
  ampXCP0=float(TopCmds.GETPAR("SP"+units+" 43"))
  ampXCP0dB=float(TopCmds.GETPAR("SPdB 43"))
  #ampXCP0=float(TopCmds.GETPAR("PL"+units+" 43"))
  #ampXCP0dB=float(TopCmds.GETPAR("PLdB 43"))
  SPX=TopCmds.GETPAR2("SPNAM 43")
  CNCT=float(TopCmds.GETPAR("P 25"))
  
  #Interact with user about MAS and power levels, likely not needed
  params = TopCmds.INPUT_DIALOG("HN CP MAS adjustment", "Proton Nitrogen Cross Polarization", \
  ["Old MAS rate","New MAS rate","Old 15N power","Old 1H power","Contact Time(P15)","H-Ramp","N-Ramp"],\
  [str(MAS0),str(MAS),str(ampXCP0),str(ampHCP0),str(CNCT),SPH,SPX],\
  ["kHz","kHz",units,units,"us","",""],\
  ["1","1","1","1","1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)
  
  if params == None: TopCmds.EXIT()

  # Everything is written with dB, so we might have to convert
  if units == "W":
    params[2]=str(Setup.WtodB(float(params[2])))
    params[3]=str(Setup.WtodB(float(params[3])))

  if SPH != "None" and SPH != None:
    avgH0=1.
    avgH0=IntShape.Integrate(SPH)/100.
  if SPX != "None" and SPX != None:
    avgX0=1.
    avgX0=IntShape.Integrate(SPX)/100.
  
  pulses=p90H,ampHdB,p90X,ampXdB,avgH0,avgX0
  
  SelectorText="Adjust the HN CP parameters:","Calculate New Match for:",\
  ["Proton","Nitrogen","Maximum for Both"]
  
  ampHCPdB, ampXCPdB = FindMatch(params,pulses,SelectorText)

  if units == "W":
    ampXCP=Setup.dBtoW(ampXCPdB)
    ampHCP=Setup.dBtoW(ampHCPdB)
  
  value = TopCmds.SELECT("Adjusting the HN CP parameters:",\
  "This will set\n 1H power to:  " + str('%3.2f' %ampHCP)+ " "+units+"\n \
  15N power to:  " +str('%3.2f' %ampXCP) + " "+units,["Update", "Keep Previous"])
    
  if value != 1:
    TopCmds.PUTPAR("PLdB 42",str('%3.2f' %ampHCPdB))
    TopCmds.PUTPAR("SPdB 42",str('%3.2f' %ampHCPdB))
    TopCmds.PUTPAR("PLdB 43",str('%3.2f' %ampXCPdB))
    TopCmds.PUTPAR("SPdB 43",str('%3.2f' %ampXCPdB))
    TopCmds.PUTPAR("P 25" ,str('%3.2f' %CNCT))
    TopCmds.PUTPAR("SPNAM 42",SPH)
    TopCmds.PUTPAR("SPNAM 43",SPX)
示例#10
0
def HC(units):
    #44,45
    p90H = float(TopCmds.GETPAR("P 3"))
    ampH = float(TopCmds.GETPAR("PLdB 2"))
    p90C = float(TopCmds.GETPAR("P 1"))
    ampC = float(TopCmds.GETPAR("PLdB 1"))
    MAS = float(TopCmds.GETPAR("CNST 31"))

    SPH = TopCmds.GETPAR2("SPNAM 44")
    SPH0 = TopCmds.GETPAR2("SPNAM 40")

    CNCT = float(TopCmds.GETPAR("P 44"))
    CNCT0 = float(TopCmds.GETPAR("P 15"))

    MaxB1H = 1000000. / 4. / p90H
    MaxB1C = 1000000. / 4. / p90C

    if CNCT <= 1.00: CNCT = CNCT0

    if SPH == "gauss" or SPH == "None" or SPH == "":
        SPH = SPH0
        TopCmds.PUTPAR("SPNAM 44", SPH)
        TopCmds.XCMD("spnam44")
        SPH = (TopCmds.GETPAR2("SPNAM 44"))
        SPH.join()

    Hav = IntShape.Integrate(SPH)
    Hav0 = IntShape.Integrate(SPH0)
    Hint = 0.01 * ((Hav)**2) / Hav0
    #TopCmds.MSG("Hint "+str(Hint))

    Hamp0 = float(TopCmds.GETPAR("SPdB 40"))
    Camp0 = float(TopCmds.GETPAR("SPdB 41"))

    B1H = MaxB1H * Hint * math.pow(10, (ampH - Hamp0) / 20.)
    B1C = MaxB1C * math.pow(10, (ampC - Camp0) / 20.)

    index = TopCmds.INPUT_DIALOG("H-C CP", "Contact and Ramp", \
    ["Proton B1 Field","H Ramp","Carbon B1 Field","Contact Time(P44)"],\
    [str('%3.0f' %B1H),SPH,str('%3.0f' %B1C),str(CNCT)],\
    ["kHz","","kHz","us"],\
    ["1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    SP = index[1]
    CNCT = float(index[3])

    adjust = 20 * (math.log10(float(index[0]) / MaxB1H))
    Hamp1 = ampH - adjust
    AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) / MaxB1C))
    Camp = ampC - adjust

    if units == "W":
        Hamp = Setup.dBtoW(Hamp)
        Camp = Setup.dBtoW(Camp)

    value = TopCmds.SELECT("Adjusting the CH CP parameters:",\
    "This will set\n 1H power to:  " + str('%3.2f' %Hamp)+" "+units+"\n \
  13C power to:  "                     +str('%3.2f' %Camp) + units,["Update", "Keep Previous"])

    if value != 1:
        TopCmds.PUTPAR("SP" + units + " 44", str('%3.2f' % Hamp))
        TopCmds.PUTPAR("SP" + units + " 45", str('%3.2f' % Camp))
        TopCmds.PUTPAR("PL" + units + " 44", str('%3.2f' % Hamp))
        TopCmds.PUTPAR("PL" + units + " 45", str('%3.2f' % Camp))
        TopCmds.PUTPAR("P 44", str('%3.2f' % CNCT))
        TopCmds.PUTPAR("SPNAM 44", SP)
示例#11
0
def NCO(units):
    p90C = float(TopCmds.GETPAR("P 1"))
    ampC = float(TopCmds.GETPAR("PLdB 1"))
    p90N = float(TopCmds.GETPAR("P 21"))
    ampN = float(TopCmds.GETPAR("PLdB 3"))
    MAS = float(TopCmds.GETPAR("CNST 31"))
    SP = TopCmds.GETPAR2("SPNAM 51")
    CNCT = float(TopCmds.GETPAR("P 17"))

    if CNCT <= 1.: CNCT = 3500.
    if SP == "gauss" or SP == "None" or SP == "":
        #TopCmds.MSG("Please set spnam2")
        TopCmds.XCMD("spnam51")
        SP = (TopCmds.GETPAR2("SPNAM 51"))
        SP.join()

    MaxB1N = 1000000. / 4. / p90N
    MaxB1C = 1000000. / 4. / p90C
    #find the channel with the lowest B1
    NCond = (5. / 2.) * MAS
    CCond = (7. / 2.) * MAS

    while NCond > MaxB1N:
        NCond = NCond - MAS
        CCond = NCond + MAS

    while CCond > MaxB1C:
        NCond = NCond - MAS
        CCond = NCond + MAS

    if NCond < MAS:
        NCond = 0.25 * MAS
        CCond = 0.75 * MAS

    index = TopCmds.INPUT_DIALOG("NCO CP Input", "N-CO  SPECIFIC 7/2*C; 5/2*N", \
    ["Carbon B1 field","Nitrogen B1 field","Contact Time(P15)","Ramp Name"],\
    [str(CCond),str(NCond),str(CNCT),SP],\
    ["kHz","kHz","us",""],\
    ["1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1C))
    Camp = ampC - adjust
    adjust = 20 * (math.log10(float(index[1]) / MaxB1N))
    Namp = ampN - adjust
    #Insert ramp calibration here
    AvgAmp = IntShape.Integrate(SP) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Camp = Camp - adjust
    CNCT = float(index[2])

    if units == "W":
        Namp = dBtoW(Namp)
        Camp = dBtoW(Camp)

    value = TopCmds.SELECT("Adjusting the NC CP parameters:",\
    "This will set\n 13C power to:  " + str('%3.2f' %Camp)+" "+ units+"\n \
  15N power to:  "                     +str('%3.2f' %Namp) + units,["Update", "Keep Previous"])

    if value != 1:
        TopCmds.PUTPAR("PL" + units + " 6", str('%3.2f' % Namp))
        TopCmds.PUTPAR("PL" + units + " 51", str('%3.2f' % Camp))
        TopCmds.PUTPAR("SP" + units + " 51", str('%3.2f' % Camp))
        TopCmds.PUTPAR("P 17", str('%3.2f' % CNCT))
        TopCmds.PUTPAR("SPNAM 51", SP)
示例#12
0
def HC(units):
    p90H = float(TopCmds.GETPAR("P 3"))
    ampH = float(TopCmds.GETPAR("PLdB 2"))
    p90C = float(TopCmds.GETPAR("P 1"))
    ampC = float(TopCmds.GETPAR("PLdB 1"))
    MAS = float(TopCmds.GETPAR("CNST 31"))
    CNCT = float(TopCmds.GETPAR("P 15"))
    SPH = TopCmds.GETPAR2("SPNAM 40")
    SPX = TopCmds.GETPAR2("SPNAM 41")

    if CNCT <= 1.: CNCT = 1000.

    if SPH == "gauss" or SPH == "None" or SPH == "":
        #TopCmds.MSG("Please set spnam40")
        TopCmds.PUTPAR("SPNAM 40", "ramp.100")
        TopCmds.XCMD("spnam40")
        SPH = (TopCmds.GETPAR2("SPNAM 40"))
        SPH.join()

    if SPX == "gauss" or SPX == "None" or SPX == "":
        #TopCmds.MSG("Please set spnam10")
        TopCmds.PUTPAR("SPNAM 41", "square.100")
        TopCmds.XCMD("spnam41")
        SPX = (TopCmds.GETPAR2("SPNAM 41"))
        SPX.join()

    MaxB1H = 1000000. / 4. / p90H
    MaxB1C = 1000000. / 4. / p90C

    #find the channel with the lowest B1
    if MaxB1C < MaxB1H:
        Ratio = int(math.floor(MaxB1C / MAS))
        #TopCmds.MSG(str(Ratio))
        CCond = (Ratio - 0.5) * MAS
        HCond = (Ratio + 0.5) * MAS

        if HCond > MaxB1H:
            Ratio = Ratio - 1
            CCond = (Ratio - 0.5) * MAS
            HCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            CCond = .25 * MAS
            HCond = .75 * MAS

    if MaxB1C >= MaxB1H:
        Ratio = int(math.floor(MaxB1H / MAS))
        HCond = (Ratio - 0.5) * MAS
        CCond = (Ratio + 0.5) * MAS

        if CCond > MaxB1C:
            Ratio = Ratio - 1
            HCond = (Ratio - 0.5) * MAS
            CCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            CCond = .75 * MAS
            HCond = .25 * MAS

    adjust = 20 * (math.log10(CCond / MaxB1C))
    Camp = ampC - adjust
    adjust = 20 * (math.log10(HCond / MaxB1H))
    Hamp = ampH - adjust

    index = TopCmds.INPUT_DIALOG("HC CP Input", "Proton Carbon Cross Polarization", \
    ["Proton B1 Field","H Ramp","Carbon B1 Field","C Ramp","Contact Time(P15)"],\
    [str(HCond),SPH,str(CCond),SPX,str(CNCT)],\
    ["kHz","","kHz","","us"],\
    ["1","1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1H))
    Hamp1 = ampH - adjust
    AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) / MaxB1C))
    Camp1 = ampC - adjust
    #Ramp integration adjustment
    AvgAmp = IntShape.Integrate(index[3]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Camp = Camp1 - adjust

    CNCT = float(index[4])

    if units == "W":
        Hamp = dBtoW(Hamp)
        Camp = dBtoW(Camp)

    value = TopCmds.SELECT("Adjusting the HC CP parameters:",\
    "This will set\n 1H power to:  " + str('%3.2f' %Hamp)+" "+ units+"\n \
  13C power to:  "                     +str('%3.2f' %Camp) + units,["Update", "Keep Previous"])

    if value != 1:
        TopCmds.PUTPAR("SP" + units + " 40", str('%3.2f' % Hamp))
        TopCmds.PUTPAR("SP" + units + " 41", str('%3.2f' % Camp))
        TopCmds.PUTPAR("PL" + units + " 40", str('%3.2f' % Hamp))
        TopCmds.PUTPAR("PL" + units + " 41", str('%3.2f' % Camp))
        TopCmds.PUTPAR("P 15", str('%3.2f' % CNCT))
        TopCmds.PUTPAR("SPNAM 40", index[1])
        TopCmds.PUTPAR("SPNAM 41", index[3])
示例#13
0
def CalCP(p90H, p90L, ampH, ampL, ampD, Cnct, shH, shL, HXorXY, iGuess, units,
          In, Out):

    P90H = pul.GetPar(p90H, "")
    P90L = pul.GetPar(p90L, "")
    P90D = pul.GetPar('pH90', "")

    #Use Definitions to find hard pulse powers
    if p90H.find('H') >= 0: AmpH = pul.GetPar('aH', units)
    if p90H.find('C') >= 0: AmpH = pul.GetPar('aC', units)
    if p90H.find('N') >= 0: AmpH = pul.GetPar('aN', units)

    if p90L.find('H') >= 0: AmpL = pul.GetPar('aH', units)
    if p90L.find('C') >= 0: AmpL = pul.GetPar('aC', units)
    if p90L.find('N') >= 0: AmpL = pul.GetPar('aN', units)

    SPH = pul.GetPar(shH, "")
    SPL = pul.GetPar(shL, "")

    MAS = pul.GetPar('MAS', "")
    CNCT = pul.GetPar(Cnct, "")

    if CNCT <= 1.: CNCT = 1000.
    if CNCT >= 10000.: CNCT = 10000.

    MaxB1H = 1000000. / 4. / P90H
    MaxB1L = 1000000. / 4. / P90L
    MaxB1D = 1000000. / 4. / P90D

    #Set Decoupler if Appropriate
    if HXorXY == "XY":
        AmpD = pul.GetPar('aH', "dB")
        AmpD0 = pul.GetPar(ampD, "dB")

        B1_0 = MaxB1D * (math.pow(10, (AmpD - AmpD0) / 20.))
        if B1_0 > 100.: Dcond = '% .1f' % B1_0
        if B1_0 > MaxB1D: Dcond = '85000.0'
        if B1_0 <= 100.: Dcond = '85000.0'

    if units == "W":
        AmpH = WtodB(AmpH)
        AmpL = WtodB(AmpL)

    if pul.GetPar(shH,"") == "gauss" or pul.GetPar(shH,"") == "None" or \
    pul.GetPar(shH,"") == "" or pul.GetPar(shH,"") == "0" :
        pul.SetPar(shH, "ramp.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict[shH]))
        SPH = pul.GetPar(shH, "")

    if pul.GetPar(shL,"") == "gauss" or pul.GetPar(shL,"") == "None" or \
    pul.GetPar(shL,"") == "" or pul.GetPar(shL,"") == "0" :
        pul.SetPar(shL, "square.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict[shL]))
        SPH = pul.GetPar(shL, "")

    if iGuess == "Max":
        #find the channel with the lowest B1
        if MaxB1L < MaxB1H:
            Ratio = int(math.floor(MaxB1L / MAS))
            HCond = (Ratio + 0.5) * MAS
            LCond = (Ratio - 0.5) * MAS

        if MaxB1L >= MaxB1H:
            Ratio = int(math.floor(MaxB1H / MAS))
            HCond = (Ratio - 0.5) * MAS
            LCond = (Ratio + 0.5) * MAS

        while HCond > MaxB1H or LCond > MaxB1L:
            Ratio = Ratio - 1
            if MaxB1L < MaxB1H:
                HCond = (Ratio + 0.5) * MAS
                LCond = (Ratio - 0.5) * MAS
            if MaxB1L >= MaxB1H:
                HCond = (Ratio - 0.5) * MAS
                LCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio == 2:
            LCond = 0.75 * MAS
            HCond = 1.75 * MAS
        if Ratio <= 1 or HCond > MaxB1H or LCond > MaxB1L:
            LCond = .25 * MAS
            HCond = .75 * MAS

    else:
        LCond = (5. / 2.) * MAS
        if iGuess == "Low":
            HCond = (3. / 2.) * MAS
        else:
            #iGuess == "High":
            HCond = (7. / 2.) * MAS

        while LCond > MaxB1L:
            LCond = LCond - MAS
            CCond = LCond + MAS

        while HCond > MaxB1H:
            LCond = LCond - MAS
            CCond = LCond + MAS

        if LCond < MAS:
            LCond = 0.25 * MAS
            HCond = 0.75 * MAS

    adjust = 20 * (math.log10(LCond / MaxB1L))
    Lamp = AmpL - adjust
    adjust = 20 * (math.log10(HCond / MaxB1H))
    Hamp = AmpH - adjust

    if HXorXY == "HX":
        index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
          [str(HCond),str(SPH),str(LCond),str(SPL),str(CNCT)],\
          ["Hz","","Hz","","us"],\
          ["1","1","1","1","1"],\
          ["Accept","Close"], ['a','c'], 10)

    if HXorXY == "XY":
        index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
          [str(HCond),str(SPH),str(LCond),str(SPL),str(CNCT),str(Dcond)],\
          ["Hz","","Hz","","us","Hz"],\
          ["1","1","1","1","1","1"],\
          ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1H))
    Hamp1 = AmpH - adjust
    if SPH == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) / MaxB1L))
    Lamp1 = AmpL - adjust
    if SPL == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[3]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Lamp = Lamp1 - adjust

    CNCT = float(index[4])

    if HXorXY == "XY":
        adjust = 20 * (math.log10(float(index[5]) / MaxB1D))
        Damp = AmpD - adjust

    if units == "W":
        Hamp = dBtoW(Hamp)
        Lamp = dBtoW(Lamp)
        if HXorXY == "XY": Damp = dBtoW(Damp)

    if HXorXY == "HX":
        value = TopCmds.SELECT(Out[0],\
        "This will set\n "+\
        Out[1][0]+" power to:  " + str('%3.2f' %Hamp)+" "+ units+"\n"+\
        Out[1][1]+" power to:  " + str('%3.2f' %Lamp)+" "+ units,\
        ["Update", "Keep Previous"])

    if HXorXY == "XY":
        value = TopCmds.SELECT(Out[0],\
        "This will set\n "+\
        Out[1][0]+" power to:  " + str('%3.2f' %Hamp)+" "+ units+"\n"+\
        Out[1][1]+" power to:  " + str('%3.2f' %Lamp)+" "+ units+"\n"+\
        Out[1][2]+" power to:  " + str('%3.2f' %Damp)+" "+ units,\
        ["Update", "Keep Previous"])

    if value != 1:
        pul.SetPar(ampH, Hamp, units)
        pul.SetPar(ampL, Lamp, units)

        if HXorXY == "XY":
            pul.SetPar(ampD, Damp, units)
        pul.SetPar(Cnct, CNCT, "")
        if SPH != "Unused":
            pul.SetPar(shH, index[1], "")
        if SPL != "Unused":
            pul.SetPar(shL, index[3], "")

    return
示例#14
0
def HN(units):
    p90H = pul.GetPar('pH90', "")
    p90N = pul.GetPar('pN90', "")
    ampH = pul.GetPar('aH', units)
    ampN = pul.GetPar('aN', units)
    MAS = pul.GetPar('MAS', "")
    CNCT = pul.GetPar('pHN', "")
    SPH = pul.GetPar('sHhn', "")
    SPX = pul.GetPar('sNhn', "")

    if units == "W":
        ampH = WtodB(ampH)
        ampN = WtodB(ampN)

    if CNCT <= 1.: CNCT = 1000.

    if SPH == "gauss" or SPH == "None" or SPH == "" or SPH == "0":
        pul.SetPar('sHhn', "ramp.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict['sHhn']))
        SPH = pul.GetPar('sHhn', "")

    if SPX == "gauss" or SPX == "None" or SPX == "" or SPX == "0":
        pul.SetPar('sNhn', "square.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict['sNhn']))
        SPX = pul.GetPar('sNhn', "")

    MaxB1H = 1000000. / 4. / p90H
    MaxB1N = 1000000. / 4. / p90N

    #find the channel with the lowest B1
    if MaxB1N < MaxB1H:
        Ratio = int(math.floor(MaxB1N / MAS))
        NCond = (Ratio - 0.5) * MAS
        HCond = (Ratio + 0.5) * MAS

        if HCond > MaxB1H:
            Ratio = Ratio - 1
            NCond = (Ratio - 0.5) * MAS
            HCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            NCond = .25 * MAS
            HCond = .75 * MAS

    if MaxB1N >= MaxB1H:
        Ratio = int(math.floor(MaxB1H / MAS))
        HCond = (Ratio - 0.5) * MAS
        NCond = (Ratio + 0.5) * MAS

        if NCond > MaxB1N:
            Ratio = Ratio - 1
            HCond = (Ratio - 0.5) * MAS
            NCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            NCond = .25 * MAS
            HCond = .75 * MAS

    adjust = 20 * (math.log10(NCond / MaxB1N))
    Namp = ampN - adjust
    adjust = 20 * (math.log10(HCond / MaxB1H))
    Hamp = ampH - adjust

    index = TopCmds.INPUT_DIALOG("HN CP Input", "Proton Nitrogen Cross Polarization", \
    ["Proton B1 Field","H Ramp","Nitrogen B1 Field","N Ramp","Contact Time(P25)"],\
    [str(HCond),SPH,str(NCond),SPX,str(CNCT)],\
    ["Hz","","Hz","","us"],\
    ["1","1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1H))
    Hamp1 = ampH - adjust
    if SPH == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) / MaxB1N))
    Namp = ampN - adjust
    if SPX == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[3]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Namp = Namp - adjust

    CNCT = float(index[4])

    #TopCmds.MSG("Adjusting the HC CP parameters:\n Your Proton Amplitude is set to " + str('%3.2f' %Hamp)+ "dB\n Your Nitrogen Ammplitude is set to " +str('%3.2f' %Namp))

    if units == "W":
        Hamp = dBtoW(Hamp)
        Namp = dBtoW(Namp)

    value = TopCmds.SELECT("Adjusting the HN CP parameters:",\
    "This will set\n 1H power to:  " + str('%3.2f' %Hamp)+" "+ units+"\n \
  15N power to:  "                     +str('%3.2f' %Namp) + units,["Update", "Keep Previous"])

    if value != 1:
        pul.SetPar('aHhn', Hamp, units)
        pul.SetPar('aNhn', Namp, units)
        pul.SetPar('pHN', CNCT, "")
        if SPH != "Unused":
            pul.SetPar('sHhn', index[1], "")
        if SPX != "Unused":
            pul.SetPar('sNhn', index[3], "")
示例#15
0
def CalCP(p90H, p90L, ampH, ampL, ampD, Cnct, shH, shL, HXorXY, iGuess, units,
          offsCP, In, Out):
    """
  p90H/L: Dictionary Key for High/Low Gamma Nucleus 90 degree pulse
  ampH/L: dict key for High/Low G CP amp     
  ampD  : dict key for Decoupler (assumed to be 1H) or "empty"
  Cnct  : dict key for CP contact
  shH/L : dict key of CP shape files
  HXorXY: Determines whether decoupling is used
  iGuess: "Max", "High", "Low", "LG"
          Max  : determine highest allowed condition
          High : High G = 3/2 Wr Low G = 5/2 Wr
          Low  : High G = 7/2 Wr Low G = 5/2 Wr
          LG   : Use Max, but adjust for Lee-Goldburg
  units : Watts (W) or decibel (dB)
  offsCP: offset for CP in Hz (LG or off-resonance CP)
  In    : Title, Subtitle, and Label for Input Dialog
  Out   : Title and Label for Selection/Confirmation Window
  """
    P90H = pul.GetPar(p90H, "")
    P90L = pul.GetPar(p90L, "")
    P90D = pul.GetPar('pH90', "")

    #Use Dictionary Definitions to find hard pulse powers
    if p90H.find('H') >= 0: AmpH = pul.GetPar('aH', units)
    if p90H.find('C') >= 0: AmpH = pul.GetPar('aC', units)
    if p90H.find('N') >= 0: AmpH = pul.GetPar('aN', units)

    if p90L.find('H') >= 0: AmpL = pul.GetPar('aH', units)
    if p90L.find('C') >= 0: AmpL = pul.GetPar('aC', units)
    if p90L.find('N') >= 0: AmpL = pul.GetPar('aN', units)

    SPH = pul.GetPar(shH, "")
    SPL = pul.GetPar(shL, "")

    MAS = pul.GetPar('MAS', "")
    CNCT = pul.GetPar(Cnct, "")

    if CNCT <= 1.: CNCT = 1000.
    if CNCT >= 10000.: CNCT = 10000.

    MaxB1H = 1000000. / 4. / P90H
    MaxB1L = 1000000. / 4. / P90L
    MaxB1D = 1000000. / 4. / P90D

    #Set Decoupler if Appropriate
    if HXorXY == "XY":
        AmpD = pul.GetPar('aH', "dB")
        AmpD0 = pul.GetPar(ampD, "dB")

        B1_0 = MaxB1D * (math.pow(10, (AmpD - AmpD0) / 20.))
        if B1_0 > 100.: Dcond = '% .1f' % B1_0
        if B1_0 > MaxB1D: Dcond = '85000.0'
        if B1_0 <= 100.: Dcond = '85000.0'

    if units == "W":
        AmpH = WtodB(AmpH)
        AmpL = WtodB(AmpL)

    if pul.GetPar(shH,"") == "gauss" or pul.GetPar(shH,"") == "None" or \
    pul.GetPar(shH,"") == "" or pul.GetPar(shH,"") == "0" :
        pul.SetPar(shH, "ramp.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict[shH]))
        SPH = pul.GetPar(shH, "")

    if pul.GetPar(shL,"") == "gauss" or pul.GetPar(shL,"") == "None" or \
    pul.GetPar(shL,"") == "" or pul.GetPar(shL,"") == "0" :
        pul.SetPar(shL, "square.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict[shL]))
        SPH = pul.GetPar(shL, "")
    if iGuess == "LG":
        #Adjust MaxB1H for Lee-Goldburg
        MaxB1H = MaxB1H * math.sqrt(3.0 / 2.)
    if iGuess == "Max" or iGuess == "LG":
        #find the channel with the lowest B1
        if MaxB1L < MaxB1H:
            Ratio = int(math.floor(MaxB1L / MAS))
            HCond = (Ratio + 0.5) * MAS
            LCond = (Ratio - 0.5) * MAS

        if MaxB1L >= MaxB1H:
            Ratio = int(math.floor(MaxB1H / MAS))
            HCond = (Ratio - 0.5) * MAS
            LCond = (Ratio + 0.5) * MAS

        while HCond > MaxB1H or LCond > MaxB1L:
            Ratio = Ratio - 1
            if MaxB1L < MaxB1H:
                HCond = (Ratio + 0.5) * MAS
                LCond = (Ratio - 0.5) * MAS
            if MaxB1L >= MaxB1H:
                HCond = (Ratio - 0.5) * MAS
                LCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio == 2:
            LCond = 0.75 * MAS
            HCond = 1.75 * MAS
        if Ratio <= 1 or HCond > MaxB1H or LCond > MaxB1L:
            LCond = .25 * MAS
            HCond = .75 * MAS

    else:
        LCond = (5. / 2.) * MAS
        if iGuess == "Low":
            HCond = (3. / 2.) * MAS
        else:
            #iGuess == "High":
            HCond = (7. / 2.) * MAS

        while LCond > MaxB1L:
            LCond = LCond - MAS
            HCond = LCond + MAS

        while HCond > MaxB1H:
            LCond = LCond - MAS
            HCond = LCond + MAS

        if LCond < MAS:
            LCond = 0.25 * MAS
            HCond = 0.75 * MAS

    if iGuess == "LG":
        #Change MaxB1H back for proper conversion
        MaxB1H = 1000000. / 4. / P90H

    if HXorXY == "HX":
        index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
          [str('%.3f' %(HCond/1000.)),str(SPH),str('%.3f' %(LCond/1000.)),str(SPL),\
          str('%.3f' %(CNCT/1000.))],\
          ["kHz","","kHz","","ms"],\
          ["1","1","1","1","1"],\
          ["Accept","Close"], [spc,ret], 10)

    if HXorXY == "XY":
        index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
         [str('%.3f' %(HCond/1000.)),str(SPH),str('%.3f' %(LCond/1000.)),str(SPL),\
         str('%.3f' %(CNCT/1000.)),str('%.3f' %(float(Dcond)/1000.))],\
         ["kHz","","kHz","","ms","kHz"],\
         ["1","1","1","1","1","1"],\
         ["Accept","Close"], [spc,ret], 10)

    if index == None:
        TopCmds.EXIT()

    if iGuess == "LG":
        w1H = float(index[0]) * math.sqrt(2. / 3.)
        LGoffs = 1000 * float(index[0]) / math.sqrt(3.)
    else:
        w1H = float(index[0])

    #TopCmds.MSG("w1H "+str('%.2f' %(w1H*1000.))+" MaxB1H: "+str('%.2f' %(MaxB1H)))
    adjust = 20 * (math.log10(w1H * 1000. / MaxB1H))
    Hamp1 = AmpH - adjust

    if SPH == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) * 1000. / MaxB1L))
    Lamp1 = AmpL - adjust
    if SPL == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[3]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Lamp = Lamp1 - adjust

    CNCT = float(index[4]) * 1000.

    if HXorXY == "XY":
        #Decouple Safely
        Damp = DecSafely(1000. * float(index[5]), ampD, MaxB1D, 150000., AmpD,
                         units)

    if units == "W":
        Hamp = dBtoW(Hamp)
        Lamp = dBtoW(Lamp)
        if HXorXY == "XY": Damp = dBtoW(Damp)

    if HXorXY == "HX":
        if iGuess == "LG":
            value = TopCmds.SELECT(Out[0],\
            "This will set\n "+\
            Out[1][0]+" power ("+ pul.pulDict[ampH] +") to:  " + str('%3.2f' %Hamp)+" "+ units+"\n"+\
            Out[1][1]+" power ("+ pul.pulDict[ampL] +") to:  " + str('%3.2f' %Lamp)+" "+ units+"\n"+\
            "1H LG offset ("+ pul.pulDict[offsCP] +") to:  "+   str('%3.2f' %LGoffs)+ " Hz",\
            ["Update", "Keep Previous"],[spc,ret])
        else:
            value = TopCmds.SELECT(Out[0],\
            "This will set\n "+\
            Out[1][0]+" power ("+ pul.pulDict[ampH] +") to:  " + str('%3.2f' %Hamp)+" "+ units+"\n"+\
            Out[1][1]+" power ("+ pul.pulDict[ampL] +") to:  " + str('%3.2f' %Lamp)+" "+ units,\
            ["Update", "Keep Previous"],[spc,ret])

    if HXorXY == "XY":
        value = TopCmds.SELECT(Out[0],\
        "This will set\n "+\
        Out[1][0]+" power ("+ pul.pulDict[ampH] +") to:  " + str('%3.2f' %Hamp)+" "+ units+"\n"+\
        Out[1][1]+" power ("+ pul.pulDict[ampL] +") to:  " + str('%3.2f' %Lamp)+" "+ units+"\n"+\
        Out[1][2]+" power ("+ pul.pulDict[ampD] +") to:  " + str('%3.2f' %Damp)+" "+ units,\
        ["Update", "Keep Previous"],[spc,ret])

    if value != 1:
        pul.SetPar(ampH, Hamp, units)
        pul.SetPar(ampL, Lamp, units)
        pul.SetPar(Cnct, CNCT, "")

        if iGuess == "LG":
            pul.SetPar(offsCP, LGoffs, "")
        if HXorXY == "XY":
            pul.SetPar(ampD, Damp, units)
        if SPH != "Unused":
            pul.SetPar(shH, index[1], "")
        if SPL != "Unused":
            pul.SetPar(shL, index[3], "")

    return
示例#16
0
def NCO(MAS0, MAS, units):

    p90X = pul.GetPar('pC90', "")
    ampX = pul.GetPar('aC', units)
    ampXCP = pul.GetPar('aCnco', units)
    SPX = pul.GetPar('sCnco', "")
    avgX = 1.

    p90Y = pul.GetPar('pN90', "")
    ampY = pul.GetPar('aN', units)
    ampYCP = pul.GetPar('aNnco', units)
    SPY = pul.GetPar('sNnco', "")
    avgY = 1.

    CNCT = pul.GetPar('pNCO', "")

    # Get the integration before possibly changing the shape.
    if SPX != "None" and SPX != None and SPX != "Unused":
        avgX = IntShape.Integrate(SPX) / 100.
    if SPY == "None" or SPY == None and SPY != "Unused":
        avgY = IntShape.Integrate(SPY) / 100.

    #Interact with user about MAS and power levels, likely not needed
    params = TopCmds.INPUT_DIALOG("NCO CP MAS adjustment", "NCO", \
    ["Old MAS rate","New MAS rate","Old CO power ("+pul.pulDict['aCnco']+")",\
    "Old 15N power ("+pul.pulDict['aNnco']+")","Contact Time ("+pul.pulDict['pNCO']+")",\
    "CO-Ramp ("+pul.pulDict['sCnco']+")","N-Ramp ("+pul.pulDict['sNnco']+")"],\
    [str(MAS0),str(MAS),str(ampXCP),str(ampYCP),str(CNCT),SPX,SPY],\
    ["Hz","Hz",units,units,"us","",""],\
    ["1","1","1","1","1","1","1"],\
    ["Accept","Close"], [spc,ret], 10)

    if params == None: TopCmds.EXIT()

    # Everything is written with dB, so we might have to convert
    if units == "W":
        params[2] = str(Setup.WtodB(float(params[2])))
        params[3] = str(Setup.WtodB(float(params[3])))
        ampX = Setup.WtodB(ampX)
        ampY = Setup.WtodB(ampY)

    pulses = p90X, ampX, p90Y, ampY, avgX, avgY

    SelectorText="Adjust the NCO CP parameters:","Calculate New Power Level for:",\
    ["Carbon","Nitrogen","Both"]

    ampXCP, ampYCP = FindMatch(params, pulses, SelectorText)

    if units == "W":
        ampXCP = Setup.dBtoW(ampXCP)
        ampYCP = Setup.dBtoW(ampYCP)

    value = TopCmds.SELECT("Adjusting the NCO CP parameters:",\
    "This will set\n 13C power to:  " + str('%3.2f' %ampXCP)+ " "+units+"\n \
  15N power to:  "                     +str('%3.2f' %ampYCP) + " "+units,["Update", "Keep Previous"])

    if value != 1:
        pul.SetPar('aCnco', ampXCP, units)
        pul.SetPar('aNnco', ampYCP, units)
        pul.SetPar('pNCO', CNCT, "")
        pul.SetPar('sCnco', SPX, "")
        pul.SetPar('sNnco', SPY, "")
示例#17
0
def CalcSym(CorR, N, n, v, mult, p90, amp, Wave, time, dfltT, nuc, dec, units):
    """
  CorR    : Symmetry Element
  N       : Step Number
  n       : Space Winding Number
  v       : Spin Winding Number (not used here, yet)
  mult    : Mulitplier for Composite Pulses
  p90     : Dict key for Hard Pulse of Nucleus
  amp     : Dict key for recoupling Amplitude
  Wave    : Shaped pulse (None or Unused)
  nuc     : Recoupled Nucleus
  dec     : Dict key for Decoupler Nucleus
  dfltT   : Default Time or Loop
  """
    value = 0
    if pul.pulDict[time].find("D") >= 0:
        lblT = "Delay", "s"
    elif pul.pulDict[time].find("L") >= 0:
        lblT = "Loop", "cycles"
    elif pul.pulDict[time].find("P") >= 0:
        lblT = "Pulse", "us"

    #Use Dictionary Definitions to find hard pulse powers
    if p90.find('H') >= 0: Amp = pul.GetPar('aH', "dB")
    if p90.find('C') >= 0: Amp = pul.GetPar('aC', "dB")
    if p90.find('N') >= 0: Amp = pul.GetPar('aN', "dB")

    #Assume 1H decoupling if neccessary
    P90 = pul.GetPar(p90, "")
    P90D = pul.GetPar('pH90', "")
    MAS = pul.GetPar('MAS', "")

    Tau_r = 1. / float(MAS)
    MaxB1 = 1000000. / 4. / P90
    MaxB1D = 1000000. / 4. / P90D
    #Calculate the RF field
    if CorR == "C":
        Cond = mult * 1. * N * MAS / n
    if CorR == "R":
        Cond = mult * 2. * N * MAS / n

    #Set Decoupler if Appropriate
    if dec != "None":
        AmpD = pul.GetPar('aH', "dB")
        AmpD0 = pul.GetPar(dec, "dB")

        B1_0 = MaxB1D * (math.pow(10, (AmpD - AmpD0) / 20.))

        if B1_0 > 100.: Dcond = B1_0
        if B1_0 > MaxB1D: Dcond = 85000.0
        if B1_0 <= 100.: Dcond = 85000.0

    if Cond > MaxB1:
        TopCmds.MSG("The match condition for " + CorR+str(N)+unb+str(n)+crt+str(v)+" is "+\
        str('%.3f' %(Cond/1000.))+" kHz \n\nIt is greater than the Max B1 ("+ str('%.3f' %(MaxB1/1000.))+" kHz)\n\n"+\
        pul.pulDict[amp]+" will NOT be set  ")

        TopCmds.EXIT()
    else:
        if dec == "None":
            Title = "Adjusting " + nuc + " Power for Symmetry-Based Recoupling"
            Subtit = CorR + str(N) + unb + str(n) + crt + str(
                v) + "Symmetry Match"
            Label = [nuc + " Amplitude", lblT[0] + " " + pul.pulDict[time]]
            Values = [str('%.3f' % (Cond / 1000.)), str(dfltT)]
            Units = ["kHz", lblT[1]]
            Types = ["1", "1"]
            Buttons = ["Accept", "Cancel"]
            ShortCuts = [spc, ret]
            columns = 10

        else:
            Title = "Adjusting " + nuc + " Power for Symmetry-Based Recoupling"
            Subtit = CorR + str(N) + unb + str(n) + crt + str(
                v) + " Symmetry Match"
            Label = [nuc+" Amplitude",lblT[0]+" "+pul.pulDict[time],\
                     "1H decoupling field"]

            temp1 = Cond / 1000.
            temp2 = Dcond / 1000.
            Values = [str('%.3f' % temp1), str(dfltT), str('%.3f' % temp2)]
            Units = ["kHz", lblT[1], "kHz"]
            Types = ["1", "1", "1"]
            Buttons = ["Accept", "Cancel"]
            ShortCuts = [spc, ret]
            columns = 10

        index = TopCmds.INPUT_DIALOG(Title, Subtit, Label, Values, Units,
                                     Types, Buttons, ShortCuts, columns)

        if index == None:
            TopCmds.EXIT()
        if index != None:
            Cond = float(index[0]) * 1000.
            Time = str(index[1])
            if dec != "None":
                #Safety
                Damp = DecSafely(1000. * float(index[2]), dec, MaxB1D, 150000.,
                                 AmpD, units)

    #Calculate the power
    adjust = 20 * (math.log10(Cond / MaxB1))
    Condition = Amp - adjust

    #Calculate the Integration if shaped pulses are used
    if Wave != "None" and Wave != "Unused":

        if pul.GetPar(Wave,"") == "gauss" or pul.GetPar(Wave,"") == "None" or \
        pul.GetPar(Wave,"") == "" or pul.GetPar(Wave,"") == "0" :
            pul.SetPar(Wave, "square.100", "")
            TopCmds.XCMD(pul.xcmd_name(pul.pulDict[Wave]))
            SP = pul.GetPar(Wave, "")

        AvgAmp = IntShape.Integrate(SP) / 100.

        adjust = 20 * (math.log10(1. / AvgAmp))
        Condition = Condition - adjust

    if units == "W":
        Condition = dBtoW(Condition)
        if dec != "None": Damp = dBtoW(Damp)

    if dec == "None":
        Confirm = nuc + " Power for " + CorR + str(N) + "_" + str(
            n) + "^" + str(v) + "Symmetry Match"
        Power  ="Set\n "+ pul.pulDict[amp]+" to:  "+str('%3.2f' %Condition)+" "+ units+"\n"+\
                            pul.pulDict[time]+" "+lblT[1]+" to: "+index[1]
    else:
        Confirm = "Adjusting " + nuc + " and 1H Power for " + CorR + str(
            N) + "_" + str(n) + "^" + str(v) + "Symmetry Match"
        Power  ="Set\n "+ pul.pulDict[amp]+" to:  "+str('%3.2f' %Condition)+" "+ units+"\n"+\
                          pul.pulDict[dec]+" (Dec) power to:  "+str('%3.2f' %Damp)+" "+ units+"\n"+\
                          pul.pulDict[time]+" "+lblT[1]+" to: "+index[1]

    if Confirm == "None":
        value = 1
    else:
        value = TopCmds.SELECT(Confirm, Power, ["Update", "Keep Previous"],
                               [spc, ret])

    if value != 1:
        pul.SetPar(amp, Condition, units)
        pul.SetPar(time, index[1], "")
        if dec != "None": pul.SetPar(dec, Damp, units)
示例#18
0
def copyCP(aH,sH,aL,sL,pCP,aH0,sH0,aL0,sL0,pCP0,Input,Output,units):
  """
  aH/L(0)  : dict key for High/Low G CP amp (0 for default)
  pCP(0)   : dict key for CP contact (0 default)
  shH/L(0) : dict key of CP shape files
  units    : Watts (W) or decibel (dB)
  In       : Title, Subtitle, and Label for Input Dialog
  Out      : Title and Label for Selection/Confirmation Window
  """  

  #Use Dictionary Definitions to find hard pulse powers
  if aH.find('H') >= 0:AmpH=pul.GetPar('aH',"dB"); P90H=pul.GetPar('pH90',""); Hnuc="1H"
  if aH.find('C') >= 0:AmpH=pul.GetPar('aC',"dB"); P90H=pul.GetPar('pC90',""); Hnuc="13C"
  if aH.find('N') >= 0:AmpH=pul.GetPar('aN',"dB"); P90H=pul.GetPar('pN90',""); Hnuc="15N"

  if aL.find('H') >= 0:AmpL=pul.GetPar('aH',"dB"); P90L=pul.GetPar('pH90',""); Lnuc="1H"
  if aL.find('C') >= 0:AmpL=pul.GetPar('aC',"dB"); P90L=pul.GetPar('pC90',""); Lnuc="13C"
  if aL.find('N') >= 0:AmpL=pul.GetPar('aN',"dB"); P90L=pul.GetPar('pN90',""); Lnuc="15N"
  
  MaxB1H=1000000./4./P90H
  MaxB1L=1000000./4./P90L

  SPH =pul.GetPar(sH,"")
  SPL =pul.GetPar(sL,"")

  Hamp0=pul.GetPar(aH0,"dB")
  Lamp0=pul.GetPar(aL0,"dB")
  
  if pul.GetPar(pCP,"") <=   1.00  :
    pul.SetPar(pCP,pul.GetPar(pCP0,""),"")

  CNCT = pul.GetPar(pCP,"")/1000.

  if SPH == "gauss" or SPH == "None" or SPH == ""  or SPH == "0" :
    pul.SetPar(sH,pul.GetPar(sH0,""),"")
    TopCmds.XCMD(pul.xcmd_name(pul.pulDict[sH]))
    SPH = pul.GetPar(sH,"")

  if SPL == "gauss" or SPL == "None" or SPL == "" or SPL == "0":
    pul.SetPar(sL,pul.GetPar(sL0,""),"")
    TopCmds.XCMD(pul.xcmd_name(pul.pulDict[sL]))
    SPX=pul.GetPar(sL0,"")

  if SPH == "Unused":
    Hav  = 1.
    Hav0 = 1.
  else:
    Hav  = IntShape.Integrate(pul.GetPar(sH,""))/100.
    Hav0 = IntShape.Integrate(pul.GetPar(sH0,""))/100.
  
  if SPL == "Unused":
    Lav  = 1.
    Lav0 = 1.
  else:
    Lav  = IntShape.Integrate(pul.GetPar(sL,""))/100.
    Lav0 = IntShape.Integrate(pul.GetPar(sL0,""))/100.

  #This is the new integration times the change in new/old
  Hint = ((Hav)**2)/Hav0
  Lint = ((Lav)**2)/Lav0
  
  B1H = MaxB1H*Hint*math.pow(10,(AmpH-Hamp0)/20.)
  B1L = MaxB1L*Lint*math.pow(10,(AmpL-Lamp0)/20.)
  
  index=TopCmds.INPUT_DIALOG(Input[0],Input[1],Input[2],\
  [str('%.3f' %(B1H/1000.)),SPH,str('%.3f' %(B1L/1000.)),SPL,str(CNCT)],\
  ["kHz","","kHz","","ms"],\
  ["1","1","1","1","1",],\
  ["Accept","Close"], [spc,ret], 10)
  
  if index == None:TopCmds.EXIT()
  SPH=index[1]
  SPX=index[3]
  CNCT=1000*float(index[4])

  adjust=20*(math.log10(1000.*float(index[0])/MaxB1H))
  Hamp1 = AmpH-adjust
  if SPH == "Unused":
    AvgAmp=1.
  else:
    AvgAmp=IntShape.Integrate(index[1])/100.
  adjust=20*(math.log10(1./AvgAmp))
  Hamp = Hamp1-adjust

  adjust=20*(math.log10(1000.*float(index[2])/MaxB1L))
  Lamp = AmpL-adjust
  if SPL == "Unused":
    AvgAmp=1.
  else:
    AvgAmp=IntShape.Integrate(index[3])/100.
  adjust=20*(math.log10(1./AvgAmp))
  Lamp = Lamp-adjust

  if units == "W":
    Hamp=Setup.dBtoW(Hamp)
    Lamp=Setup.dBtoW(Lamp)

  value = TopCmds.SELECT(Output[0],\
  "This will set\n"+\
  Hnuc+" power to:  " + str('%3.2f' %Hamp)+" "+units+"\n"+ \
  Lnuc+" power to:  " +str('%3.2f' %Lamp) + units,\
  ["Update", "Keep Previous"],[spc,ret])
    
  if value != 1:
    pul.SetPar(aH,Hamp,units)
    pul.SetPar(aL,Lamp,units)
    pul.SetPar(pCP,CNCT,"")
    if SPH != "Unused":
      pul.SetPar(sH,index[1],"")
    if SPX != "Unused":
      pul.SetPar(sL,index[3],"")
示例#19
0
def NCO(units):
    p90H = pul.GetPar('pH90', "")
    p90C = pul.GetPar('pC90', "")
    p90N = pul.GetPar('pN90', "")
    ampH = pul.GetPar('aH', units)
    ampC = pul.GetPar('aC', units)
    ampN = pul.GetPar('aN', units)
    MAS = pul.GetPar('MAS', "")
    CNCT = pul.GetPar('pNCO', "")
    SPX = pul.GetPar('sCnco', "")
    SPY = pul.GetPar('sNnco', "")

    #TopCmds.MSG(str(CNCT))
    MaxB1H = 1000000. / 4. / p90H

    if units == "W":
        ampN = WtodB(ampN)
        ampC = WtodB(ampC)
        ampH = WtodB(ampH)

    if CNCT <= 1.: CNCT = 3500.
    if SPX == "gauss" or SPX == "None" or SPX == "" or SPX == "0":
        pul.SetPar('sCnco', "ramp.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict['sCnco']))
        SPX = pul.GetPar('sCnco', "")
    if SPY == "gauss" or SPY == "None" or SPY == "" or SPY == "0":
        pul.SetPar('sNnco', "ramp.100", "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict['sNnco']))
        SPY = pul.GetPar('sNnco', "")

    MaxB1N = 1000000. / 4. / p90N
    MaxB1C = 1000000. / 4. / p90C
    #find the channel with the lowest B1
    NCond = (5. / 2.) * MAS
    CCond = (7. / 2.) * MAS

    while NCond > MaxB1N:
        NCond = NCond - MAS
        CCond = NCond + MAS

    while CCond > MaxB1C:
        NCond = NCond - MAS
        CCond = NCond + MAS

    if NCond < MAS:
        NCond = 0.25 * MAS
        CCond = 0.75 * MAS

    index = TopCmds.INPUT_DIALOG("NCO CP Input", "N-CO  SPECIFIC 7/2*C; 5/2*N", \
    ["CO B1 field","N B1 field","H B1 decoupler","Contact Time","Carbon Ramp","Nitrogen Ramp"],\
    [str(CCond),str(NCond),"85000.0",str(CNCT),SPX,SPY],\
    ["Hz","Hz","Hz","us","",""],\
    ["1","1","1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1C))
    Camp = ampC - adjust
    adjust = 20 * (math.log10(float(index[1]) / MaxB1N))
    Namp = ampN - adjust
    adjust = 20 * (math.log10(float(index[2]) / MaxB1H))
    Hamp = ampH - adjust

    CNCT = float(index[3])

    #Insert ramp calibration here
    if SPX == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[4]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Camp = Camp - adjust

    if SPY == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(index[5]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Namp = Namp - adjust

    if units == "W":
        Namp = dBtoW(Namp)
        Camp = dBtoW(Camp)
        Hamp = dBtoW(Hamp)

    value = TopCmds.SELECT("Adjusting the NCO CP parameters:",\
    "This will set\n \
  13C power to:  "                     + str('%3.2f' %Camp) + " " + units +"\n \
  15N power to:  "                     + str('%3.2f' %Namp) + " " + units +"\n \
  1H power to:   "                     + str('%3.2f' %Hamp) + " " + units,["Update", "Keep Previous"])

    if value != 1:
        pul.SetPar('aNnco', Namp, units)
        pul.SetPar('aCnco', Camp, units)
        pul.SetPar('aHnco', Hamp, units)
        pul.SetPar('pNCO', CNCT, "")
        if SPX != "Unused":
            pul.SetPar('sCnco', index[4], "")
        if SPY != "Unused":
            pul.SetPar('sNnco', index[5], "")
示例#20
0
def CalNCO():
  p90C=float(TopCmds.GETPAR("P 1"))
  ampC=float(TopCmds.GETPAR("PLdB 1"))
  p90N=float(TopCmds.GETPAR("P 21"))
  ampN=float(TopCmds.GETPAR("PLdB 21"))
  MAS =float(TopCmds.GETPAR("CNST 31"))
  SP=TopCmds.GETPAR("SPNAM 3")
  CNCT=float(TopCmds.GETPAR("P 16"))

  if CNCT <= 1.: CNCT = 3500.
  if SP == "gauss" or SP == "None" :
    #TopCmds.MSG("Please set spnam3")
    TopCmds.XCMD("spnam3")
    SP=(TopCmds.GETPAR2("SPNAM 3"))

  MaxB1N = 1000000./4./p90N
  MaxB1C = 1000000./4./p90C
  Coffs=Cfrq.ppm2offs(170.0)

  NCond=(5./2.)*MAS
  CCond=(7./2.)*MAS

  while NCond > MaxB1N :
    NCond=NCond - MAS
    CCond=NCond + MAS

  while CCond > MaxB1C :
    NCond=NCond - MAS
    CCond=NCond + MAS

  if NCond < MAS :
    NCond= 0.25*MAS
    CCond= 0.75*MAS
 
  index = TopCmds.INPUT_DIALOG("NCO off-resonance CP Input",\
   "N-CO SPECIFIC-CP w1C=7/2*wr; w1N=5/2*wr", \
  ["Carbon B1 field","Carbon offset (170ppm)","Nitrogen B1 field","Contact Time(P16)","Ramp Name"],\
  [str(CCond),str(Coffs),str(NCond),str(CNCT),SP],\
  ["Hz","Hz","Hz","us",""],\
  ["1","1","1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)
  
  NCond=(float(index[2]))*MAS
  CCond=math.sqrt( (float(index[0]))**2 - (float(index[1]))**2))
  
  adjust=20*(math.log10(CCond/MaxB1C))
  Camp = ampC-adjust
  adjust=20*(math.log10(NCond/MaxB1N))
  Namp = ampN-adjust
  #Insert ramp calibration here
  AvgAmp=IntShape.Integrate(SP)/100.
  adjust=20*(math.log10(1./AvgAmp))
  Camp = Camp-adjust
  CNCT = float(index[3])
  
  CampW=pwr.dBtoW(Camp)
  NampW=pwr.dBtoW(Namp)
  
  value = TopCmds.SELECT("Adjusting the NC CP parameters:",\
  "This will set\n 13C power to:  " + str('%3.2f' %CampW)+ " W\n \
  15N power to:  " +str('%3.2f' %NampW) + " W",["Update", "Keep Previous"]) 
  if value != 1:
    TopCmds.PUTPAR("PLdB 17",str('%3.2f' %Namp))
    TopCmds.PUTPAR("PLdB 16",str('%3.2f' %Camp))
    TopCmds.PUTPAR("P 16",str('%3.2f' %CNCT))
    TopCmds.PUTPAR("SPNAM 3",SP)
      
      
def CalBSH(p90, ppm, amp, ampD, Cnct, shp, dfltramp, pflp, pflp2k, units, In,
           Out):
    """
  p90   : Dictionary Key for Nucleus 90 degree pulse; determines Nuc (Decoupling flag)
  ppm   : float of ppm difference
  amp   : dict key for CP amp
  ampD  : dict key for Decoupler (assumed to be 1H) or "empty"
  Cnct  : dict key for CP contact
  shp   : dict key of CP shape file
  dfltshp: Default pulse shape
  pflp  : dict key for trim pulse
  pflp2k: dict key for flip back pulse
  units : Watts (W) or decibel (dB)
  In    : Title, Subtitle, and Label for Input Dialog
  Out   : Title and Label for Selection/Confirmation Window
  """

    P90 = pul.GetPar(p90, "")
    P90D = pul.GetPar('pH90', "")

    if p90.find('H') >= 0:
        Amp = pul.GetPar('aH', units)
        nuc = "1H"
    if p90.find('C') >= 0:
        Amp = pul.GetPar('aC', units)
        nuc = "13C"
    if p90.find('N') >= 0:
        Amp = pul.GetPar('aN', units)
        nuc = "15N"
    frq = fq.fq(nuc, 1)

    AmpD = pul.GetPar('aH', units)

    i = 0
    Nucs = NUC.list()
    for label in Nucs:
        if label == nuc: frq = fq.fq(nuc, i + 1)
        i = i + 1

    SP = pul.GetPar(shp, "")
    MAS = pul.GetPar('MAS', "") / 1000.  #kHz not Hz
    CNCT = pul.GetPar(Cnct, "")

    ## Check that the values aren't stupid
    if CNCT <= 1.: CNCT = 1000.
    if CNCT >= 10000.: CNCT = 10000.

    MaxB1 = 1000000. / 4. / P90
    MaxB1D = 1000000. / 4. / P90D

    ##Set Decoupler if Appropriate
    if nuc != "1H":
        AmpD0 = pul.GetPar(ampD, "dB")
        B1_0 = MaxB1D * (math.pow(10, (AmpD - AmpD0) / 20.))

        if B1_0 > 100.: Dcond = '% .1f' % B1_0
        if B1_0 > MaxB1D: Dcond = '85000.0'
        if B1_0 <= 100.: Dcond = '85000.0'

    #Use a reasonable ramp name (passed in as dfltramp)
    if SP == "gauss" or SP == "None" or SP == "" or SP == "0":
        pul.SetPar(shp, dfltramp, "")
        TopCmds.XCMD(pul.xcmd_name(pul.pulDict[shp]))
        SP = pul.GetPar(shp, "")

    ## change everything into dB for calculations.
    if units == "W":
        Amp = Setup.WtodB(Amp)
        AmpD = Setup.WtodB(AmpD)

    bf = math.floor(float(frq.bf))
    ppm = float(str('%.0f' % ppm))
    changedPPM = 'y'

    while changedPPM == 'y':
        #TopCmds.MSG(str(ppm)+":ppm  bf:"+str(bf))
        DHz = (float(ppm) * bf) / 1000.
        bshkHz = round(float(((MAS * MAS) - ((DHz * DHz) / 4)) / MAS), 2)

        if nuc != "1H":
            index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
              [str('%.2f' %bshkHz),SP,str('%.0f' %ppm),\
              str('%.0f' %(CNCT/1000.)),str('%.2f' %(float(Dcond)/1000.))],\
              ["kHz","","ppm","ms","kHz"],\
              ["1","1","1","1","1"],\
              ["Accept","Close"], [spc,ret], 10)
            Dcond = float(index[4]) * 1000.

        if nuc == "1H":
            index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
              [str('%.2f' %bshkHz),str(SP),str('%.2f' %ppm),\
              str('%.0f' %(Cnct/1000.))],\
              ["kHz","","ppm","ms"],\
              ["1","1","1","1"],\
              ["Accept","Close"], [spc,ret], 10)

        bshkHz = float(index[0])
        SP = index[1]
        Cnct = float(index[3]) * 1000.

        if str('%.2f' % ppm) == str('%.2f' % float(index[2])): changedPPM = 'n'
        if str('%.2f' % ppm) != str('%.2f' % float(index[2])):
            changedPPM = 'y'
            ppm = float(index[2])

    DHz = (float(ppm) * bf) / 1000.

    flip = (math.atan(DHz / bshkHz) * 180) / 3.1415
    pflip = round(((P90 * flip) / 90.), 2)

    #TopCmds.MSG(str(P90)+" "+str(flip)+" "+str(pflip)+" "+str(DHz)+" "+str(bshkHz))
    flip2k = (DHz * DHz) / bshkHz
    pflip2k = round(((0.25 / flip2k) * 1000), 2)

    w1bsh = float(index[0])
    adjust = 20 * (math.log10(w1bsh * 1000 / MaxB1))
    AmpBsh = Amp - adjust

    # Adjust for the ramp.
    if SP == "Unused":
        AvgAmp = 1.
    else:
        AvgAmp = IntShape.Integrate(SP) / 100.
    AmpBsh = AmpBsh - 20 * (math.log10(1. / AvgAmp))

    # For the Decoupling
    if nuc != "1H":
        AmpDec = Setup.DecSafely(Dcond, ampD, MaxB1D, 150000., AmpD, units)

    # Convert to Watts, if wanted
    if units == "W":
        AmpBsh = Setup.dBtoW(AmpBsh)
        if nuc != "1H": Damp = Setup.dBtoW(AmpDec)

    if nuc == "1H":
        value = TopCmds.SELECT(Out[0],"This will set\n "+\
          Out[1]+" power ("+pul.pulDict[amp]+") to: " + str('%3.2f' %AmpBsh)+" "+ units+"\n"+\
          "With shape (" + pul.pulDict[shp] + ") of "+ str(SP) +"\n"\
          "Flip pulse (" + pul.pulDict[pflp] +  ") of "+ str(pflip) +"us\n"\
          "Flip pulse 2k(" + pul.pulDict[pflp2k] +  ") of "+ str(pflip2k) +"us\n",\
          ["Update", "Keep Previous"],[spc,ret])

    else:
        value = TopCmds.SELECT(Out[0],\
          "This will set\n "+\
          Out[1][0]+" power ("+pul.pulDict[amp]+") to: " + str('%3.2f' %AmpBsh)+" "+ units+"\n"+\
          Out[1][1]+" power ("+pul.pulDict[ampD]+") to: " + str('%3.2f' %AmpD)+" "+ units+"\n"+\
          "With shape (" + pul.pulDict[shp] + ") of "+ str(SP) +"\n"\
          "Flip pulse (" + pul.pulDict[pflp] +  ") of "+ str(pflip) +"us\n"\
          "Flip pulse 2k(" + pul.pulDict[pflp2k] +  ") of "+ str(pflip2k) +"us\n",\
          ["Update", "Keep Previous"],[spc,ret])

    if value != 1:
        pul.SetPar(amp, AmpBsh, units)
        pul.SetPar(shp, SP, units)
        pul.SetPar(pflp, pflip, units)
        pul.SetPar(pflp2k, pflip2k, units)
        if nuc == "1H":
            pul.SetPar(ampD, AmpD, units)

    return
示例#22
0
def HC(MAS0,MAS,units):
  p90H=float(TopCmds.GETPAR("P 3"))
  ampH=float(TopCmds.GETPAR("PL"+units+" 2"))
  ampHdB=float(TopCmds.GETPAR("PLdB 2"))
  
  ampHCP0=float(TopCmds.GETPAR("SP"+units+" 40"))
  ampHCP0dB=float(TopCmds.GETPAR("SPdB 40"))
  #ampHCP0=float(TopCmds.GETPAR("PL"+units+" 10"))
  #ampHCP0dB=float(TopCmds.GETPAR("PLdB 10"))
  SPH=TopCmds.GETPAR2("SPNAM 40")
  
  p90X=float(TopCmds.GETPAR("P 1"))
  ampX=float(TopCmds.GETPAR("PL"+units+" 1"))
  ampXdB=float(TopCmds.GETPAR("PLdB 1"))
  
  ampXCP0=float(TopCmds.GETPAR("SP"+units+" 41"))
  ampXCP0dB=float(TopCmds.GETPAR("SPdB 41"))
  #ampXCP0=float(TopCmds.GETPAR("PL"+units+" 20"))
  #ampXCP0dB=float(TopCmds.GETPAR("PLdB 20"))
  SPX=TopCmds.GETPAR2("SPNAM 41")
  
  CNCT=float(TopCmds.GETPAR("P 15"))

  params = TopCmds.INPUT_DIALOG("HC CP MAS adjustment", "Proton Carbon Cross Polarization", \
  ["Old MAS rate","New MAS rate","Old 13C power","Old 1H power","Contact Time(P15)","H-Ramp","C-Ramp"],\
  [str(MAS0),str(MAS),str(ampXCP0),str(ampHCP0),str(CNCT),SPH,SPX],\
  ["Hz","Hz",units,units,"us","",""],\
  ["1","1","1","1","1","1","1"],\
  ["Accept","Close"], ['a','c'], 10)

  if units == "W":
    params[2]=str(Setup.WtodB(float(params[2])))
    params[3]=str(Setup.WtodB(float(params[3])))

  if SPH != "None" and SPH != None:
    avgH0=IntShape.Integrate(SPH)/100.
  if SPX != "None" and SPX != None:
    avgX0=IntShape.Integrate(SPX)/100.
  
  pulses=p90H,ampHdB,p90X,ampXdB,avgH0,avgX0
  
  SelectorText="Adjust the HC CP parameters:","Calculate New Match for:",\
  ["Proton","Carbon","Maximum for Both"]
  
  ampHCPdB, ampXCPdB = FindMatch(params,pulses,SelectorText)

  if units == "W":
    ampXCP=Setup.dBtoW(ampXCPdB)
    ampHCP=Setup.dBtoW(ampHCPdB)
  
  value = TopCmds.SELECT("Adjusting the HC CP parameters:",\
  "This will set\n 1H power to:  " + str('%3.2f' %ampHCP)+ " "+units+"\n \
  13C power to:  " +str('%3.2f' %ampXCP) + " "+units,["Update", "Keep Previous"])
    
  if value != 1:
    TopCmds.PUTPAR("PLdB 40",str('%3.2f' %ampHCPdB))
    TopCmds.PUTPAR("SPdB 40",str('%3.2f' %ampHCPdB))
    TopCmds.PUTPAR("PLdB 41",str('%3.2f' %ampXCPdB))
    TopCmds.PUTPAR("SPdB 41",str('%3.2f' %ampXCPdB))
    TopCmds.PUTPAR("P 15" ,params[4])
    TopCmds.PUTPAR("SPNAM 40",params[5])
    TopCmds.PUTPAR("SPNAM 41",params[6])
示例#23
0
def HN(units):
    p90H = float(TopCmds.GETPAR("P 3"))
    ampH = float(TopCmds.GETPAR("PLdB 2"))
    p90N = float(TopCmds.GETPAR("P 21"))
    ampN = float(TopCmds.GETPAR("PLdB 3"))
    MAS = float(TopCmds.GETPAR("CNST 31"))
    CNCT = float(TopCmds.GETPAR("P 25"))
    SPH = TopCmds.GETPAR2("SPNAM 42")
    SPX = TopCmds.GETPAR2("SPNAM 43")

    if CNCT <= 1.: CNCT = 1000.

    if SPH == "gauss" or SPH == "None" or SPH == "":
        #TopCmds.MSG("Please set spnam1")
        TopCmds.PUTPAR("SPNAM 42", "ramp.100")
        TopCmds.XCMD("spnam42")
        SPH = (TopCmds.GETPAR2("SPNAM 42"))
        SPH.join()

    if SPX == "gauss" or SPX == "None" or SPX == "":
        #TopCmds.MSG("Please set spnam11")
        TopCmds.PUTPAR("SPNAM 43", "square.100")
        TopCmds.XCMD("spnam43")
        SPX = (TopCmds.GETPAR2("SPNAM 43"))
        SPX.join()

    MaxB1H = 1000000. / 4. / p90H
    MaxB1N = 1000000. / 4. / p90N

    #find the channel with the lowest B1
    if MaxB1N < MaxB1H:
        Ratio = int(math.floor(MaxB1N / MAS))
        NCond = (Ratio - 0.5) * MAS
        HCond = (Ratio + 0.5) * MAS

        if HCond > MaxB1H:
            Ratio = Ratio - 1
            NCond = (Ratio - 0.5) * MAS
            HCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            NCond = .25 * MAS
            HCond = .75 * MAS

    if MaxB1N >= MaxB1H:
        Ratio = int(math.floor(MaxB1H / MAS))
        HCond = (Ratio - 0.5) * MAS
        NCond = (Ratio + 0.5) * MAS

        if NCond > MaxB1N:
            Ratio = Ratio - 1
            HCond = (Ratio - 0.5) * MAS
            NCond = (Ratio + 0.5) * MAS

        # If spinning very fast or using weak B1s
        if Ratio <= 1:
            NCond = .25 * MAS
            HCond = .75 * MAS

    adjust = 20 * (math.log10(NCond / MaxB1N))
    Namp = ampN - adjust
    adjust = 20 * (math.log10(HCond / MaxB1H))
    Hamp = ampH - adjust

    index = TopCmds.INPUT_DIALOG("HN CP Input", "Proton Nitrogen Cross Polarization", \
    ["Proton B1 Field","H Ramp","Nitrogen B1 Field","N Ramp","Contact Time(P25)"],\
    [str(HCond),SPH,str(NCond),SPX,str(CNCT)],\
    ["kHz","","kHz","","us"],\
    ["1","1","1","1","1"],\
    ["Accept","Close"], ['a','c'], 10)

    adjust = 20 * (math.log10(float(index[0]) / MaxB1H))
    Hamp1 = ampH - adjust
    AvgAmp = IntShape.Integrate(index[1]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Hamp = Hamp1 - adjust

    adjust = 20 * (math.log10(float(index[2]) / MaxB1N))
    Namp = ampN - adjust
    #Ramp integration adjustment
    AvgAmp = IntShape.Integrate(index[3]) / 100.
    adjust = 20 * (math.log10(1. / AvgAmp))
    Namp = Namp - adjust

    CNCT = float(index[4])

    #TopCmds.MSG("Adjusting the HC CP parameters:\n Your Proton Amplitude is set to " + str('%3.2f' %Hamp)+ "dB\n Your Nitrogen Ammplitude is set to " +str('%3.2f' %Namp))

    if units == "W":
        Hamp = dBtoW(Hamp)
        Namp = dBtoW(Namp)

    value = TopCmds.SELECT("Adjusting the HN CP parameters:",\
    "This will set\n 1H power to:  " + str('%3.2f' %Hamp)+" "+ units+"\n \
  15N power to:  "                     +str('%3.2f' %Namp) + units,["Update", "Keep Previous"])

    if value != 1:
        TopCmds.PUTPAR("SP" + units + " 42", str('%3.2f' % Hamp))
        TopCmds.PUTPAR("SP" + units + " 43", str('%3.2f' % Namp))
        TopCmds.PUTPAR("PL" + units + " 42", str('%3.2f' % Hamp))
        TopCmds.PUTPAR("PL" + units + " 43", str('%3.2f' % Namp))
        TopCmds.PUTPAR("P 25", str('%.2f' % CNCT))
        TopCmds.PUTPAR("SPNAM 42", index[1])
        TopCmds.PUTPAR("SPNAM 43", index[3])
示例#24
0
def FindMatch(params,pulses,Dia):

  p90H,ampHdB,p90X,ampXdB,avgH0,avgX0=pulses

  MAS0 =float(params[0])
  MAS  =float(params[1])
  ampXCP0dB=float(params[2])
  ampHCP0dB=float(params[3])
  CNCT =float(params[4])
  SPH  =params[5]
  SPX  =params[6]

  avgH=1.
  avgX=1.

  if SPH != "None" and SPH != None:
    avgH=IntShape.Integrate(SPH)/100.
  if SPH == "None" or SPH == None:
    avgH=1.
    
  if SPX != "None" and SPX != None:
    avgX=IntShape.Integrate(SPX)/100.
  if SPX == "None" or SPX == None:
    avgX=1.
  
  MaxB1H = 1000000./4./p90H
  MaxB1X = 1000000./4./p90X
    
  HCPpw0=(p90H/avgH0)*(math.pow(10,((ampHCP0dB-ampHdB)/20.)))
  XCPpw0=(p90X/avgX0)*(math.pow(10,((ampXCP0dB-ampXdB)/20.)))
  
  HB1_0=1000000./HCPpw0/4.
  XB1_0=1000000./XCPpw0/4.
  
  HR0=HB1_0/MAS0
  XR0=XB1_0/MAS0
  
  ###   Choices for adjusting the match  ###

  value = TopCmds.SELECT(Dia[0],Dia[1],Dia[2])

  if value == 0:
    XB1=XB1_0
    if HB1_0 > XB1_0 :
      HB1=XB1_0+MAS
    if HB1_0 <= XB1_0 :
      HB1=XB1_0-MAS

    HR=HB1/MAS
    XR=XB1/MAS
    
  elif value == 1:
    HB1=HB1_0
    if HB1_0 > XB1_0 :
      XB1=HB1_0-MAS
    if HB1_0 <= XB1_0 :
      XB1=HB1_0+MAS

    HR=HB1/MAS
    XR=XB1/MAS
    
  elif value == 2:
    HB1=HR0*MAS
    XB1=XR0*MAS
    
    HR=HR0
    XR=XR0
    
    # If we are slowing down, keep CP levels similar to previous
    if MAS0 < MAS:
      if XB1 <= HB1:
        while XB1 <= XB1_0 :
          XR=XR+1
          XB1=XR*MAS
          HR=HR+1
      if XB1 >> HB1:
        while HB1 <= HB1_0 :
          HR=HR+1
          HB1=HR*MAS
          XR=XR+1
      XR=XR-1  #the above should always go one step too far
      HR=HR-1
      XB1=XR*MAS
      HB1=HR*MAS
  else:
    TopCmds.EXIT()
  
  #  Don't allow feilds higher than max
  
  while XB1 > MaxB1X :
    HR=HR-1
    XR=XR-1
    HB1=HR*MAS
    XB1=XR*MAS
  while HB1 > MaxB1H :
    HR=HR-1
    XR=XR-1
    HB1=HR*MAS
    XB1=XR*MAS

  adjust=20*(math.log10(HB1/HB1_0))
  ampHCPdB = ampHCP0dB-adjust
  adjust=20*(math.log10(avgH/avgH0))  #in case there is a Ramp change 
  ampHCPdB = ampHCP0dB-adjust
  
  adjust=20*(math.log10(XB1/XB1_0))
  ampXCPdB = ampXCP0dB-adjust
  adjust=20*(math.log10(avgX/avgX0))  #in case there is a Ramp change 
  ampXCPdB = ampXCP0dB-adjust
  
  return ampHCPdB, ampXCPdB
示例#25
0
def CalSP(nuc,units,para,dflt,limits,dia,conf,tip):
  """
  nuc     : Nucleus, 13C or 1H
  units   : Watts (W) or Decibels (dB)
  para    : Dict keys for soft pulse wave (time,amp,shape,offs)
  dflt    : Defaults (time,shape,offs(in ppm))
  limits  : ppm frequency limits (upper, lower)
  """
	
  if nuc=="13C":p90=pul.GetPar('pC90',""); amp=pul.GetPar('aC',units)
  if nuc=="1H": p90=pul.GetPar('pH90',""); amp=pul.GetPar('aH',units)
  MAS =pul.GetPar('MAS',"")
  
  if units == "W":
    amp=Setup.WtodB(amp)  

  MaxB1 = 1000000./4./p90
  pSft  = pul.GetPar(para[0],"")
  if pSft == 0: pSft = dflt[0]
  SP=pul.GetPar(para[2],"")
  offs0 = pul.GetPar(para[3],"")
  
  #Check for existence and default
  if SP == "gauss" or SP == "None" or SP == "0"  or SP == "" :
    pul.SetPar(para[2],dflt[1],"")
    TopCmds.XCMD(pul.xcmd_name(pul.pulDict[para[2]]))
    SP=pul.GetPar(para[2],"")
  
  if pul.pulDict['uoffs']=='ppm':
    ppm=offs0
    offs=Cfrq.ppm2offs(offs0)
  else:
    #offs0 is in Hz
    ppm=Cfrq.offs2ppm(offs0)
    offs=offs0
  
  if ppm > limits[0] : ppm=dflt[2]
  if ppm < limits[1] : ppm=dflt[2]

  index = TopCmds.INPUT_DIALOG(dia[0],dia[1],dia[2],\
  [str('%3.2f' %pSft),str('%3.2f' %ppm),SP],\
  dia[3],["1","1","1"],\
  ["Accept","Close"], [spc,ret], 10)

  if index == None:TopCmds.EXIT()

  pSft=float(index[0])
  ppm=float(index[1])
  SP=index[2]
  offs=Cfrq.ppm2offs(ppm)

  AvgAmp=IntShape.Integrate(SP)/100.
  adjust=20*math.log10((tip/90.)*p90/pSft/AvgAmp)
  Power =amp-adjust

  if units == "W":
    Power=Setup.dBtoW(Power)  

  confirm = TopCmds.SELECT(conf,\
  "This will set\n "+\
  nuc+" amp "+pul.pulDict[para[1]]+" to : " + str('%3.2f' %Power)+ " "+units+"\n \
  Pulse offset to   : " + str('%8.0f' %offs) + " Hz\n \
  Equivalent to     : " + str('%3.1f' %ppm ) + " ppm\n "+\
  pul.pulDict[para[0]]+" to     :" + str('%6.1f' %pSft)+ " us\n "\
  ,["Update", "Keep Previous"])
  
  if confirm != 1:
    pul.SetPar(para[0],pSft,"")
    pul.SetPar(para[1],Power,units)
    pul.SetPar(para[2],SP,"")

    if pul.pulDict['uoffs']=='ppm':
      pul.SetPar(para[3],ppm,"")
    elif pul.pulDict['uoffs']=='Hz':
      pul.SetPar(para[3],offs,"")
    else :
      pul.SetPar(para[3],ppm,"")
示例#26
0
def CalDREAM(p90,match,amp,ampD,Cnct,SP,dfltSP,shpdict,units,In,Out):
  """
  p90   : Dictionary Key for Nucleus 90 degree pulse; determines Nuc (Decoupling flag)
  match : float of precalculated match
  amp   : dict key for DREAM amp
  ampD  : dict key for Decoupler (assumed to be 1H) or "empty"
  Cnct  : dict key for DREAM contact
  shp   : dict key of DREAM shape file
  dfltSP: Default pulse shape
  shpdict:dict key for DREAM shape
  units : Watts (W) or decibel (dB)
  In    : Title, Subtitle, and Label for Input Dialog
  Out   : Title and Label for Selection/Confirmation Window
  """

  MAS=pul.GetPar('MAS',"")
  TauR=float(1000000/MAS)
  P90D=pul.GetPar('pH90',"")
  AmpD =pul.GetPar('aH',"dB")
  MaxB1D = 1000000./4./P90D

  if p90.find('H') >=0:MaxB1=1000000./4./(pul.GetPar('pH90',""));Amp=pul.GetPar('aH','dB')
  if p90.find('C') >=0:MaxB1=1000000./4./(pul.GetPar('pC90',""));Amp=pul.GetPar('aC','dB')

  CNCT=pul.GetPar(Cnct,"")

  if CNCT <= 1.    : CNCT =  1000.
  if CNCT >= 10000.: CNCT = 10000.

  if p90.find('H') <=0:
    AmpD0=pul.GetPar(ampD,'dB')
    B1_0 = MaxB1D*(math.pow(10,(AmpD-AmpD0)/20.))
    if B1_0 >  100.  : Dcond='% .1f' % B1_0
    if B1_0 >  MaxB1D: Dcond='85000.0'
    if B1_0 <= 100.  : Dcond='85000.0'
  
  if units == "W":
    Amp=WtodB(Amp)

  if SP == "gauss" or SP == "None" or SP=="" or SP == "0" :
    SP=dfltSP
    pul.SetPar(shpdict,SP,"")
    TopCmds.XCMD(pul.xcmd_name(pul.pulDict[shpdict]))
    SP=pul.GetPar(shp,"")

  if p90.find('H') >=0:
    index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
    [str('%.3f' %(match/1000.)),str(SP),str('%.3f' %(CNCT/1000.))],\
    ["kHz","","ms"],\
    ["1","1","1"],\
    ["Accept","Close"], [spc,ret], 10)
    if index== None: TopCmds.EXIT()
  else:
    index=TopCmds.INPUT_DIALOG(In[0],In[1],In[2],\
    [str('%.3f' %(match/1000.)),str(SP),str('%.3f' %(CNCT/1000.)),\
    str('%.3f' %(float(Dcond)/1000.))],\
    ["kHz","","ms","kHz"],\
    ["1","1","1","1"],\
    ["Accept","Close"], [spc,ret], 10)
    if index== None: TopCmds.EXIT()
    wD=float(index[3])

  w1=float(index[0])
  SP=index[1]
  CNCT=float(index[2])*1000.

  #Integrate Dream ramp
  adjust=20*(math.log10(w1*1000./MaxB1))
  Amp1 = Amp-adjust
  AvgAmp=(IntShape.Integrate(SP))/100.
  adjust=20*(math.log10(1./AvgAmp))
  AmpX = Amp1-adjust

  if units == "W": AmpX=dBtoW(AmpX)

  #TopCmds.MSG(str(Out))
  if p90.find('H') <=0:
    AmpD = Setup.DecSafely(1000.*wD,ampD,MaxB1D,150000.,AmpD,units)

    value = TopCmds.SELECT(Out[0],\
    "This will set\n "+\
    Out[1][1]+" power ("+ pul.pulDict[amp] +") to:  " + str('%3.2f' %AmpX)+" "+ units+"\n"+\
    Out[1][0]+" power ("+ pul.pulDict[ampD] +") to:  " + str('%3.2f' %AmpD)+" "+ units,\
    ["Update", "Keep Previous"],[spc,ret])
  else:
    value = TopCmds.SELECT(Out[0],\
    "This will set\n "+\
    Out[1][0]+" power ("+ pul.pulDict[amp] +") to:  " + str('%3.2f' %Hamp)+" "+ units+"\n"+\
    ["Update", "Keep Previous"],[spc,ret])

  if value != 1:
    pul.SetPar(amp,AmpX,units)
    pul.SetPar(Cnct,CNCT,"")

    if p90.find('H') <=0:
      pul.SetPar(ampD,AmpD,"dB")