def abort(Home, Source, winfil): if winfil ==0 : TopCmds.SET_SELECTED_WIN(Source) TopCmds.CLOSEWIN(TopCmds.CURDATA()) TopCmds.SET_SELECTED_WIN(Home) TopCmds.EXIT() if winfil ==1 : TopCmds.RE(Source) TopCmds.CLOSEWIN(TopCmds.CURDATA()) TopCmds.RE(Home) TopCmds.EXIT()
def MAS(Home, Source, winfil, unit, qt): MAS = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source, "n") MAS0 = Get.MAS(unit) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home, "n") MAS1 = Get.MAS(unit) if MAS1 != MAS0: Put.MAS(MAS0, "") MAS = 1 return MAS
def Phases(Phase): pul.SetPar('PHC0', Phase[0], "") pul.SetPar('PHC1', Phase[1], "") #Reload so everything updates. TopCmds.SLEEP(0.05) TopCmds.RE(TopCmds.CURDATA()) TopCmds.SLEEP(0.05) return
def NH2(Home, Source, winfil, unit, qt): NH2 = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source, "n") CPcnct, aHcp, aXcp, SPH, SPX = Get.NH2(unit) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home, "n") CPcnct0, aHcp0, aXcp0, SPH0, SPX0 = Get.NH2(unit) if CPcnct != CPcnct0 or aHcp != aHcp0 or aXcp != aXcp0 or SPH != SPH0 or SPX != SPX0: Title = "UPDATE N-H CP (H-detect)" Header = "" Inputs=\ "Contact : "+str(CPcnct0)+" us ("+str(pul.pulDict['pNH2'])+")",\ "1H pwr : "+str(aHcp0)+" "+unit+" ("+str(pul.pulDict['aHnh2'])+")",\ "15N pwr : "+str(aXcp0)+" "+unit+" ("+str(pul.pulDict['aNnh2'])+")",\ "1H shape : "+str(SPH0)+" ("+str(pul.pulDict['sHnh2'])+")",\ "15N shape : "+str(SPX0)+" ("+str(pul.pulDict['sNnh2'])+")" Values = str(CPcnct), str(aHcp), str(aXcp), str(SPH), str(SPX) Comments = "us", unit, unit, "", "" Types = "1", "1", "1", "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 15 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: CPcnct, aHcp, aXcp, SPH, SPX = result NH2 = 1 Put.NH2(CPcnct, aHcp, aXcp, SPH, SPX, unit) else: abort(Home, Source, winfil) if qt != 0: NH2 = 1 Put.NH2(CPcnct, aHcp, aXcp, SPH, SPX, unit) return NH2
def NCO(Home, Source, winfil, unit, qt): NC = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source) CPcnct, aH, aX, aY, SPX, SPY = Get.NCO(unit) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home) CPcnct0, aH0, aX0, aY0, SPX0, SPY0 = Get.NCO(unit) if CPcnct != CPcnct0 or aH != aH0 or aX != aX0 or aY != aY0 or SP != SP0: Title = "UPDATE N-CO CP" Header = "" Inputs=\ "Contact : "+str(CPcnct0)+" us ("+str(pul.pulDict['pNCO'])+")",\ "1H dec pwr : "+str(aH0)+" "+unit+" ("+str(pul.pulDict['aHnco'])+")",\ "13C pwr : "+str(aX0)+" "+unit+" ("+str(pul.pulDict['aCnco'])+")",\ "15N pwr : "+str(aY0)+" "+unit+" ("+str(pul.pulDict['aNnco'])+")",\ "13C shape : "+str(SP0)+" ("+str(pul.pulDict['sCnco'])+")" "15N shape : " + str(SP0) + " (" + str(pul.pulDict['aNnco']) + ")" Values = str(CPcnct), str(aH), str(aX), str(aY), str(SPX), str(SPY) Comments = "us", unit, unit, unit, "", "" Types = "1", "1", "1", "1", "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 15 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: CPcnct, aH, aX, aY, SPX, SPY = result NC = 1 Put.NCO(CPcnct, aH, aX, aY, SPX, SPY, unit) else: abort(Home, Source, winfil) else: NCA = 1 Put.NCO(CPcnct, aH, aX, aY, SPX, SPY, unit) return NC
def Nhp(Home, Source, winfil, unit, qt): Nhp = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source, "n") p90, pamp = Get.NPul(unit) #TopCmds.MSG("From:\np90= "+str(p90)+"\npamp= "+str(pamp)) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home, "n") p90_0, pamp0 = Get.NPul(unit) #TopCmds.MSG("Home:\np90_0= "+str(p90_0)+"\npamp_0= "+str(pamp0)) if p90_0 != p90 or pamp != pamp0: Title = "Nitrogen Hard Pulse Merger" Header = "" Inputs=\ "15N 90"+deg+" pulse : "+str(p90_0)+" us ("+str(pul.pulDict['pN90'])+")",\ "15N 90"+deg+" pwr : "+str(pamp0)+unit+" ("+str(pul.pulDict['aN'])+")" Values = str(p90), str(pamp) Comments = "us", unit Types = "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 5 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: p90, pamp = result Nhp = 1 Put.NPul(p90, pamp, unit) else: abort(Home, Source, winfil) if qt != 0: Put.NPul(p90, pamp, unit) Nhp = 1 return Nhp
def COs180(Home, Source, winfil, unit, qt): done = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source, "n") PW, Amp, SP, Off = Get.CO_S180(unit) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home, "n") PW0, Amp0, SP0, Off0 = Get.CO_S180(unit) if CPcnct != CPcnct0 or aHcp != aHcp0 or aXcp != aXcp0 or SPH != SPH0 or SPX != SPX0: Title = "UPDATE CO soft 180 pulse" Header = "" Inputs=\ "Pulse : "+str(PW0)+" us ("+str(pul.pulDict['pCOr'])+")",\ "Ampl : "+str(Amp0)+" "+unit+" ("+str(pul.pulDict['aCOr'])+")",\ "Shape : "+str(SP0)+" ("+str(pul.pulDict['sCOr'])+")",\ "Offset : "+str(Off0)+" ("+str(pul.pulDict['oCOr'])+")" Values = str(PW), str(Amp), str(SP), str(Off) Comments = "us", unit, "", str(pul.pulDict['uoffs']) Types = "1", "1", "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 15 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: PW, Amp, SP, Off = result done = 1 Put.CO_S18(PW, Amp, SP, Off, unit) else: abort(Home, Source, winfil) if qt != 0: done = 1 Put.CO_S180(PW, Amp, SP, Off, unit) return done
def HDec(Home, Source, winfil, unit, qt): HDec = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source) cpd, pwname, pw, pampname, pamp = Get.HDec(unit) #TopCmds.MSG(cpd+pwname+str(pw)+pampname+str(pamp)) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home) cpd0, pw0name, pw0, pamp0name, pamp0 = Get.HDec(unit) #TopCmds.MSG(cpd0+pw0name+str(pw0)+pamp0name+str(pamp0)) if cpd0 != cpd or pamp != pamp0 or pw != pw0 or pwname != pw0name or pampname != pamp0name: Title = "UPDATE Proton Decoupling parameters" Header = "(pl12, pcpd2, cpdprg2 only)" Inputs=\ "Compound pulse : "+str(cpd0),\ pwname+" : "+str(pw0)+" us ",\ pampname+" : "+str(pamp0)+unit Values = str(cpd), str(pw), str(pamp) Comments = "", "us", unit Types = "1", "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 15 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: cpd, pw, pamp = result HDec = 1 Put.HDec(cpd, pwname, pw, pampname, pamp, unit) else: abort(Home, Source, winfil) if qt != 0: HDec = 1 Put.HDec(cpd, pwname, pw, pampname, pamp, unit) return HDec
def HN(Home,Source,winfil,unit,qt): HN=0 if winfil ==0 :TopCmds.SET_SELECTED_WIN(Source) if winfil ==1 :TopCmds.RE(Source,"n") CPcnct, aHcp, aXcp, SPH, SPX = Get.HN(unit) if winfil ==0 :TopCmds.SET_SELECTED_WIN(Home) if winfil ==1 :TopCmds.RE(Home,"n") CPcnct0, aHcp0, aXcp0, SPH0, SPX0 = Get.HN(unit) if CPcnct!=CPcnct0 or aHcp!=aHcp0 or aXcp!=aXcp0 or SPH!=SPH0 or SPX!=SPX0 : Title="UPDATE H-N CP" Header="" Inputs=\ "Contact : "+CPcnct0+" us ",\ "1H pwr : "+aHcp0+" "+unit,\ "13C pwr : "+aXcp0+" "+unit,\ "1H shape : "+SPH0,\ "13C shape : "+SPX0 Values=CPcnct,aHcp,aXcp,SPH,SPX Comments="us",unit,unit,"","" Types="1","1","1","1","1" Buttons="Accept","Cancel" ShortCuts='a','c' columns=15 if qt==0: result=TopCmds.INPUT_DIALOG(Title,Header,Inputs,Values,Comments,Types,Buttons,ShortCuts,columns) if result != None: CPcnct, aHcp, aXcp, SPH, SPX = result HN=1 Put.HN(CPcnct, aHcp, aXcp, SPH, SPX, unit) else: abort(Home,Source,winfil) else: HN=1 Put.HN(CPcnct, aHcp, aXcp, SPH, SPX, unit) return HN
def NCO(Home,Source,winfil,unit,qt): NCO=0 if winfil ==0 :TopCmds.SET_SELECTED_WIN(Source) if winfil ==1 :TopCmds.RE(Source) CPcnct, aH, aX, aY, SP = Get.NCO(unit) if winfil ==0 :TopCmds.SET_SELECTED_WIN(Home) if winfil ==1 :TopCmds.RE(Home) CPcnct0, aH0, aX0, aY0, SP0 = Get.NCO(unit) if CPcnct!=CPcnct0 or aH!=aH0 or aX!=aX0 or aY != aY0 or SP!=SP0 : Title="UPDATE N-CO CP" Header="" Inputs=\ "Contact : "+CPcnct0+" us ",\ "1H dec pwr : "+aH0+" "+unit,\ "13C pwr : "+aX0+" "+unit,\ "15N pwr : "+aY0+" "+unit,\ "13C shape : "+SP0 Values=CPcnct,aH,aX,aY,SP Comments="us",unit,unit,unit,"" Types="1","1","1","1","1" Buttons="Accept","Cancel" ShortCuts='a','c' columns=15 if qt==0: result=TopCmds.INPUT_DIALOG(Title,Header,Inputs,Values,Comments,Types,Buttons,ShortCuts,columns) if result != None: CPcnct, aH, aX, aY, SP = result NCO=1 Put.NCO(CPcnct, aH, aX, aY, SP, unit) else: abort(Home,Source,winfil) else: NCO=1 Put.NCO(CPcnct, aH, aX, aY, SP, unit) return NCO
def Phases(Home, Source, winfil, unit, qt): Phases = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source) Phase = Get.Phases() if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home) Phase0 = Get.Phases() if Phase != Phase0: Title = "UPDATE Phaseing" Header = "" Inputs=\ "PH0 : "+str(Phase0[0])+deg,\ "PH1 : "+str(Phase0[1])+deg Values = str(Phase[0]), str(Phase[1]) Comments = deg, deg Types = "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 8 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: Phase = result Put.Phases(Phase) Phases = 1 else: abort(Home, Source, winfil) if qt != 0: Phases = 1 Put.Phases(Phase) return Phases
def NH(Home,Source,winfil,unit,qt): NH=0 if winfil ==0 :TopCmds.SET_SELECTED_WIN(Source) if winfil ==1 :TopCmds.RE(Source) cnct, aH, aX, SP = Get.NH(unit) if winfil ==0 :TopCmds.SET_SELECTED_WIN(Home) if winfil ==1 :TopCmds.RE(Home) cnct0, aH0, aX0, SP0 = Get.NH(unit) if cnct!=cnct0 or aH!=aH0 or aX!=aX0 or SP!=SP0 : Title="UPDATE N->H CP for XhhC experiments" Header="" Inputs=\ "Contact : "+cnct0+" us ",\ "1H pwr : "+aH0+" "+unit,\ "15N pwr : "+aX0+" "+unit,\ "15N shape : "+SP0 Values=cnct,aH,aX,SP Comments="us",unit,unit,"" Types="1","1","1","1" Buttons="Accept","Cancel" ShortCuts='a','c' columns=15 if qt==0: result=TopCmds.INPUT_DIALOG(Title,Header,Inputs,Values,Comments,Types,Buttons,ShortCuts,columns) if result != None: CPcnct, aH, aX, SP = result NH=1 Put.NH(cnct, aH, aX, SP, unit) else: abort(Home,Source,winfil) else: NH=1 Put.NH(cnct, aH, aX, SP, unit) return NH
def Nhp(Home,Source,winfil,unit,qt): Nhp=0 if winfil ==0 :TopCmds.SET_SELECTED_WIN(Source) if winfil ==1 :TopCmds.RE(Source,"n") p90, pamp = Get.NPul(unit) if winfil ==0 :TopCmds.SET_SELECTED_WIN(Home) if winfil ==1 :TopCmds.RE(Home,"n") p90_0, pamp0 = Get.NPul(unit) if p90_0 != p90 or pamp != pamp0: Title="Nitrogen Hard Pulse Merger" Header="" Inputs=\ "15N 90"+deg+" pulse : "+p90_0+" us ",\ "15N 90"+deg+" pwr : "+pamp0+unit Values=p90,pamp Comments="us",unit Types="1","1" Buttons="Accept","Cancel" ShortCuts='a','c' columns=5 if qt==0: result=TopCmds.INPUT_DIALOG(Title,Header,Inputs,Values,Comments,Types,Buttons,ShortCuts,columns) if result != None: p90, pamp = result Nhp=1 Put.NPul(p90, pamp, unit) else: abort(Home,Source,winfil) else: Put.NPul(p90, pamp, unit) Nhp=1 return Nhp
def CX(Home, Source, winfil, unit, qt): CX = 0 if winfil == 0: TopCmds.SET_SELECTED_WIN(Source) if winfil == 1: TopCmds.RE(Source) p90, pamp = Get.CX(unit) if winfil == 0: TopCmds.SET_SELECTED_WIN(Home) if winfil == 1: TopCmds.RE(Home) p90_0, pamp0 = Get.CX(unit) if p90_0 != p90 or pamp != pamp0: Title = "Carbon DARR/PDSD/NOE Merger" Header = "" Inputs=\ "Spin Diffusion Mixing Time : "+str(p90_0)+" s ("+str(pul.pulDict['dDarr'])+")",\ "1H field during mixing : "+str(pamp0)+unit+" ("+str(pul.pulDict['aHdarr'])+")" Values = str(p90), str(pamp) Comments = "s", unit Types = "1", "1" Buttons = "Accept", "Cancel" ShortCuts = 'a', 'c' columns = 5 if qt == 0: result = TopCmds.INPUT_DIALOG(Title, Header, Inputs, Values, Comments, Types, Buttons, ShortCuts, columns) if result != None: p90, pamp = result CX = 1 Put.CX(p90, pamp, unit) else: abort(Home, Source, winfil) if qt != 0: CX = 1 Put.CX(p90, pamp, unit) return CX
def load_templt(templt, expname, stan_dir): """ Load Topspin parameter set from stand_dir and creates a new dataset. Args: templt: Name of topspin parameter set expname: Name of the new dataset stand_dir: Directory from where Topspin stores new data set """ try: TC.NEWDATASET([expname, '1', '1', stan_dir]) TC.RE([expname, '1', '1', stan_dir], 'y') TC.XCMD('rpar %s all' % templt) except: TC.MSG( '''You need to define the parameter set "%s" defining the correct routing to continue. First define the correct routing using edasp. Then save the parmeterset using: wpar %s all ''' % (templt, templt)) TC.EXIT()