//creates the parameters for real-time pure shift HSQC experiments 
$kp_setpar=0
if ($#>0) then $kp_setpar=$1 else $kp_setpar=1 endif

if ($kp_setpar<>0) then seqfil='UoM_2d_rt_PS_gHSQC' endif

if (dn='') then dn='C13' dof=0 endif 
exists('pw','parameter'):$e
if $e=0 then create('pw','pulse') setlimit('pw',100,0,0.0125) pw=10 endif 
exists('tpwr','parameter'):$e
if $e=0 then create('tpwr','real') setlimit('tpwr',63,-16,1) tpwr=58 endif
exists('tpwrf','parameter'):$e
if $e=0 then create('tpwrf','real') setlimit('tpwrf',4095,0,1) tpwrf=4095 endif if ($kp_setpar<>0) then tpwrf=4095 endif

exists('pwx','parameter'):$e
if $e=0 then create('pwx','pulse') setlimit('pwx',100,0,0.0125) pwx=14 endif if ($kp_setpar<>0) then pwx=14 endif 
exists('pwxlvl','parameter'):$e
if $e=0 then create('pwxlvl','real') setlimit('pwxlvl',63,-16,1) pwxlvl=58 endif if ($kp_setpar<>0) then pwxlvl=58 endif 

exists('pw90','parameter'):$e
if $e=0 then create('pw90','pulse') setlimit('pw90',100,0,0.0125) pw90=pw endif if ($kp_setpar<>0) then pw90=pw endif
exists('ref_pw90','parameter'):$e
if $e=0 then create('ref_pw90','pulse') setlimit('ref_pw90',1000,0,0.0125) ref_pw90=pw90 endif if ($kp_setpar<>0) then ref_pw90=pw90 endif
exists('ref_pwr','parameter'):$e
if $e=0 then create('ref_pwr','real') setlimit('ref_pwr',63,-16,1) ref_pwr=tpwr endif if ($kp_setpar<>0) then ref_pwr=tpwr endif
exists('pp','parameter'):$e
if $e=0 then create('pp','pulse') setlimit('pp',200,0,0.0125) pp=2.0*pw endif if ($kp_setpar<>0) then pp=2.0*pw endif
exists('pplvl','parameter'):$e
if $e=0 then create('pplvl','real') setlimit('pplvl',63,-16,1) pplvl=tpwr endif if ($kp_setpar<>0) then pplvl=tpwr endif
exists('pplvlf','parameter'):$e
if $e=0 then create('pplvlf','real') setlimit('pplvlf',4095,0,1) pplvlf=tpwrf endif if ($kp_setpar<>0) then pplvlf=tpwrf endif
exists('pw180_a','parameter'):$e
if $e=0 then create('pw180_a','pulse') setlimit('pw180_a',500000,0,0.0125) pw180_a=18500 endif if ($kp_setpar<>0) then pw180_a=18500 endif
exists('pwr180_a','parameter'):$e
if $e=0 then create('pwr180_a','real') setlimit('pwr180_a',63,-16,1) pwr180_a=-16 endif if ($kp_setpar<>0) then pwr180_a=-16 endif
exists('shp_a','parameter'):$e
if $e=0 then create('shp_a','string') shp_a='kp_rtACQ_active' endif if ($kp_setpar<>0) then shp_a='kp_rtACQ_active' endif

exists('bw_a','parameter'):$e
if $e=0 then create('bw_a','real') setlimit('bw_a',10000,5,1) bw_a=100 setgroup('bw_a','processing')  endif if ($kp_setpar<>0) then bw_a=100 endif
exists('kp_beta_a','parameter'):$e
if $e=0 then create('kp_beta_a','real') setlimit('kp_beta_a',360,0,0.01) kp_beta_a=180 endif if ($kp_setpar<>0) then kp_beta_a=180 endif
exists('kp_phincr_a','parameter'):$e
if $e=0 then create('kp_phincr_a','real') setlimit('kp_phincr_a',180,-180,0.001) kp_phincr_a=0 endif if ($kp_setpar<>0) then kp_phincr_a=0 endif
exists('kp_stepsize_a','parameter'):$e
if $e=0 then create('kp_stepsize_a','real') setlimit('kp_stepsize_a',100,0.25,0.25) kp_stepsize_a=10 endif if ($kp_setpar<>0) then kp_stepsize_a=10 endif
exists('kp_wave_a','parameter'):$e
if $e=0 then create('kp_wave_a','string') kp_wave_a='rsnob' endif if ($kp_setpar<>0) then kp_wave_a='rsnob' endif
exists('offset','parameter'):$e
if $e=0 then create('offset','frequency') setlimit('offset',100000,-100000,0.1) offset=0 setgroup('offset','processing') endif if ($kp_setpar<>0) then offset=0 endif

exists('pw_HBIP','parameter'):$e
if $e=0 then create('pw_HBIP','pulse') setlimit('pw_HBIP',100,0,0.0125) pw_HBIP=2*pw endif if ($kp_setpar<>0) then pw_HBIP=2*pw endif
exists('pwr_HBIP','parameter'):$e
if $e=0 then create('pwr_HBIP','real') setlimit('pwr_HBIP',63,-16,1) pwr_HBIP=tpwr endif if ($kp_setpar<>0) then pwr_HBIP=tpwr endif
exists('shp_HBIP','parameter'):$e
if $e=0 then create('shp_HBIP','string') shp_HBIP='' endif if ($kp_setpar<>0) then shp_HBIP='' endif
exists('pw_XBIP','parameter'):$e
if $e=0 then create('pw_XBIP','pulse') setlimit('pw_XBIP',5000,0,0.0125) pw_XBIP=125 endif if ($kp_setpar<>0) then pw_XBIP=125 endif
exists('pwr_XBIP','parameter'):$e
if $e=0 then create('pwr_XBIP','real') setlimit('pwr_XBIP',63,-16,1) pwr_XBIP=pwxlvl endif if ($kp_setpar<>0) then pwr_XBIP=pwxlvl endif
exists('shp_XBIP','parameter'):$e
if $e=0 then create('shp_XBIP','string') shp_XBIP='kp_bip125' endif if ($kp_setpar<>0) then shp_XBIP='kp_bip125' endif

exists('tau_p','parameter'):$e
if $e=0 then create('tau_p','delay') setlimit('tau_p',8192,0,0.0000000125) tau_p=0.013 endif if ($kp_setpar<>0) then tau_p=0.013 endif
exists('j1xh','parameter'):$e
if $e=0 then create('j1xh','real') setlimit('j1xh',1000,10,1) j1xh=150 endif if ($kp_setpar<>0) then j1xh=150 endif
exists('multh','parameter'):$e
if $e=0 then create('multh','real') setlimit('multh',2,0,1) multh=2 endif if ($kp_setpar<>0) then multh=2 endif
exists('sw1','parameter'):$e
if $e=0 then par2D sw1=25000 phase=1,2 ni=128 ss=4 nt=2 axis='pd' endif

exists('offRes_DEC','parameter'):$e
if $e=0 then create('offRes_DEC','frequency') setlimit('offRes_DEC',1000000,-1000000,0.1) offRes_DEC=0 endif if ($kp_setpar<>0) then offRes_DEC=0 endif
exists('offRes_X180','parameter'):$e
if $e=0 then create('offRes_X180','frequency') setlimit('offRes_X180',1000000,-1000000,0.1) offRes_X180=0 endif if ($kp_setpar<>0) then offRes_X180=0 endif
exists('bw_d','parameter'):$e
if $e=0 then create('bw_d','real') setlimit('bw_d',100000,1000,1) bw_d=25000 setgroup('bw_d','processing')  endif if ($kp_setpar<>0) then bw_d=25000 endif
exists('kp_pw_d','parameter'):$e
if $e=0 then create('kp_pw_d','pulse') setlimit('kp_pw_d',10000,100,1) kp_pw_d=1200 setgroup('kp_pw_d','processing')  endif if ($kp_setpar<>0) then kp_pw_d=1200 endif
exists('kp_beta_d','parameter'):$e
if $e=0 then create('kp_beta_d','real') setlimit('kp_beta_d',360,0,0.01) kp_beta_d=180 endif if ($kp_setpar<>0) then kp_beta_d=180 endif
exists('kp_phincr_d','parameter'):$e
if $e=0 then create('kp_phincr_d','real') setlimit('kp_phincr_d',180,-180,0.001) kp_phincr_d=0 endif if ($kp_setpar<>0) then kp_phincr_d=0 endif
exists('kp_stepsize_d','parameter'):$e
if $e=0 then create('kp_stepsize_d','real') setlimit('kp_stepsize_d',100,0.25,0.25) kp_stepsize_d=1 endif if ($kp_setpar<>0) then kp_stepsize_d=1 endif
exists('kp_scyc_d','parameter'):$e
if $e=0 then create('kp_scyc_d','string') setenumeral('kp_scyc_d',10,'d','m4','m8','m16','t5','t7','t9','t5,m4','t7,m4','t9,m4')  kp_scyc_d='t5,m4' endif if ($kp_setpar<>0) then kp_scyc_d='t5,m4' endif
exists('kp_wave_d','parameter'):$e
if $e=0 then create('kp_wave_d','string') kp_wave_d='kp_WURST40' endif if ($kp_setpar<>0) then kp_wave_d='kp_WURST40' endif
exists('cal_pw','parameter'):$e
if $e=0 then create('cal_pw','pulse') setlimit('cal_pw',100,0,0.0125) cal_pw=pw endif 
exists('cal_pwlvl','parameter'):$e
if $e=0 then create('cal_pwlvl','real') setlimit('cal_pwlvl',63,-16,1) cal_pwlvl=tpwr endif
exists('cal_pwx','parameter'):$e
if $e=0 then create('cal_pwx','pulse') setlimit('cal_pwx',100,0,0.0125) cal_pwx=pwx endif 
exists('cal_pwxlvl','parameter'):$e
if $e=0 then create('cal_pwxlvl','real') setlimit('cal_pwxlvl',63,-16,1) cal_pwxlvl=pwxlvl endif
exists('calH','parameter'):$e
if $e=0 then create('calH','real') setlimit('calH',2,0,0.01) calH=1 endif
exists('calX','parameter'):$e
if $e=0 then create('calX','real') setlimit('calX',2,0,0.01) calX=1 endif
if ($kp_setpar<>0) then kp_nocal endif
exists('rof3','parameter'):$e
if $e=0 then create('rof3','pulse') setlimit('rof3',100,0,0.0125) rof3=2.0 endif if ($kp_setpar<>0) then rof3=2.0 endif
exists('ddrcr','parameter'):$e
if $e=0 then create('ddrcr','integer') setlimit('ddrcr',1000,2,1) ddrcr=2 endif if ($kp_setpar<>0) then ddrcr=2 endif

exists('rof1','parameter'):$e
if $e=0 then create('rof1','pulse') setlimit('rof1',100,0,0.0125) rof1=4.0 endif if ($kp_setpar<>0) then rof1=4.0 endif
exists('rof2','parameter'):$e
if $e=0 then create('rof2','pulse') setlimit('rof2',100,0,0.0125) rof2=10.0 endif if ($kp_setpar<>0) then rof2=10.0 endif
exists('alfa','parameter'):$e
if $e=0 then create('alfa','pulse') setlimit('alfa',1000,0,0.4) alfa=10.0 endif if ($kp_setpar<>0) then alfa=10.0 endif
exists('ddrtc','parameter'):$e
if $e=0 then create('ddrtc','pulse') setlimit('ddrtc',1000,0,0.4) ddrtc=10.0 endif if ($kp_setpar<>0) then ddrtc=10.0 endif
exists('ddrpm','parameter'):$e
if $e=0 then create('ddrpm','string') ddrpm='e' endif if ($kp_setpar<>0) then ddrpm='e' endif

if ($kp_setpar<>0) then setrc endif
setlimit('np',524288,64,2)

exists('sspul','parameter'):$e
if $e=0 then create('sspul','flag') setenumeral('sspul',2,'n','y') sspul='y' endif if ($kp_setpar<>0) then sspul='y' endif
exists('PFGflg','parameter'):$e
if $e=0 then create('PFGflg','flag') setenumeral('PFGflg',2,'n','y') PFGflg='y' endif if ($kp_setpar<>0) then PFGflg='y' endif
exists('nullflg','parameter'):$e
if $e=0 then create('nullflg','flag') setenumeral('nullflg',2,'n','y') nullflg='n' endif if ($kp_setpar<>0) then nullflg='n' endif
exists('lkgate_flg','parameter'):$e
if $e=0 then create('lkgate_flg','string') setenumeral('lkgate_flg',3,'n','y','k') lkgate_flg='y' endif if ($kp_setpar<>0) then lkgate_flg='y' endif
exists('kp_auto','parameter'):$e
if $e=0 then create('kp_auto','flag') setenumeral('kp_auto',2,'n','y') kp_auto='y' endif if ($kp_setpar<>0) then kp_auto='y' endif
exists('BIRDmode','parameter'):$e
if $e=0 then create('BIRDmode','flag') setenumeral('BIRDmode',4,'n','h','b','w') BIRDmode='b' endif if ($kp_setpar<>0) then BIRDmode='b' endif
exists('BIRD','parameter'):$e
if $e=0 then create('BIRD','flag') setenumeral('BIRD',2,'n','y') BIRD='y' endif if ($kp_setpar<>0) then BIRD='y' endif
exists('kp_hsqc','parameter'):$e
if $e=0 then create('kp_hsqc','flag') setenumeral('kp_hsqc',2,'n','y') kp_hsqc='y' endif if ($kp_setpar<>0) then kp_hsqc='y' endif
exists('gradaxis','parameter'):$e
if $e=0 then create('gradaxis','string') setenumeral('gradaxis',4,'z','x','y','t') gradaxis='z' endif if ($kp_setpar<>0) then gradaxis='z' endif
exists('hs_gradaxis','parameter'):$e
if $e=0 then create('hs_gradaxis','string') setenumeral('hs_gradaxis',4,'z','x','y','t') hs_gradaxis='z' endif if ($kp_setpar<>0) then hs_gradaxis='z' endif

exists('hsgt','parameter'):$e
if $e=0 then create('hsgt','delay') setlimit('hsgt',0.02,0,0.0000000125) hsgt=0.002 endif if ($kp_setpar<>0) then hsgt=0.002 endif
exists('hsglvl','parameter'):$e
if $e=0 then create('hsglvl','real') setlimit('hsglvl',32768,-32767,1) hsglvl=11177 endif if ($kp_setpar<>0) then hsglvl=11177 endif
exists('hsgstab','parameter'):$e
if $e=0 then create('hsgstab','delay') setlimit('hsgstab',0.1,0,0.0000000125) hsgstab=0.001 endif if ($kp_setpar<>0) then hsgstab=0.001 endif
exists('gtE','parameter'):$e
if $e=0 then create('gtE','delay') setlimit('gtE',0.005,0,0.0000000125) gtE=0.002 endif if ($kp_setpar<>0) then gtE=0.002 endif
exists('gzlvlE','parameter'):$e
if $e=0 then create('gzlvlE','real') setlimit('gzlvlE',32768,-32767,1) gzlvlE=16000 endif if ($kp_setpar<>0) then gzlvlE=16000 endif
exists('gtD','parameter'):$e
if $e=0 then create('gtD','delay') setlimit('gtD',0.005,0,0.0000000125) gtD=0.001 endif if ($kp_setpar<>0) then gtD=0.001 endif
exists('gzlvlD','parameter'):$e
if $e=0 then create('gzlvlD','real') setlimit('gzlvlD',32768,-32767,1) gzlvlD=8046 endif if ($kp_setpar<>0) then gzlvlD=8046 endif
exists('gstab','parameter'):$e
if $e=0 then create('gstab','delay') setlimit('gstab',0.1,0,0.0000000125) gstab=0.0005 endif if ($kp_setpar<>0) then gstab=0.0005 endif
exists('ACQ_gt1','parameter'):$e
if $e=0 then create('ACQ_gt1','delay') setlimit('ACQ_gt1',0.005,0,0.0000000125) ACQ_gt1=0.0005 endif if ($kp_setpar<>0) then ACQ_gt1=0.0005 endif
exists('ACQ_gzlvl1','parameter'):$e
if $e=0 then create('ACQ_gzlvl1','real') setlimit('ACQ_gzlvl1',32768,-32767,1) ACQ_gzlvl1=3079 endif if ($kp_setpar<>0) then ACQ_gzlvl1=3079 endif
exists('ACQ_gzlvl2','parameter'):$e
if $e=0 then create('ACQ_gzlvl2','real') setlimit('ACQ_gzlvl2',32768,-32767,1) ACQ_gzlvl2=4139 endif if ($kp_setpar<>0) then ACQ_gzlvl2=4139 endif
exists('ACQ_gzlvl3','parameter'):$e
if $e=0 then create('ACQ_gzlvl3','real') setlimit('ACQ_gzlvl3',32768,-32767,1) ACQ_gzlvl3=3547 endif if ($kp_setpar<>0) then ACQ_gzlvl3=3547 endif
exists('ACQ_gzlvl4','parameter'):$e
if $e=0 then create('ACQ_gzlvl4','real') setlimit('ACQ_gzlvl4',32768,-32767,1) ACQ_gzlvl4=4733 endif if ($kp_setpar<>0) then ACQ_gzlvl4=4733 endif
exists('ACQ_gstab','parameter'):$e
if $e=0 then create('ACQ_gstab','delay') setlimit('ACQ_gstab',0.1,0,0.0000000125) ACQ_gstab=0.0005 endif if ($kp_setpar<>0) then ACQ_gstab=0.0005 endif
exists('gzlvl7','parameter'):$e
if $e=0 then create('gzlvl7','real') setlimit('gzlvl7',8192,-8192,1) gzlvl7=0 endif if ($kp_setpar<>0) then gzlvl7=0 endif
exists('kp_pfgtc','parameter'):$e
if $e=0 then create('kp_pfgtc','pulse') setlimit('kp_pfgtc',1000,0,0.0125) kp_pfgtc=6.0 endif if ($kp_setpar<>0) then kp_pfgtc=6.0 endif

exists('droppts','parameter'):$e
if $e=1 then destroy('droppts') endif
exists('droppts1','parameter'):$e
if $e=0 then create('droppts1','real') setlimit('droppts1',16384,0,1) droppts1=2 endif if ($kp_setpar<>0) then droppts1=2 endif
exists('droppts2','parameter'):$e
if $e=0 then create('droppts2','real') setlimit('droppts2',16384,0,1) droppts2=2 endif if ($kp_setpar<>0) then droppts2=2 endif
exists('npoints','parameter'):$e
if $e=1 then destroy('npoints') endif
exists('kp_npoints','parameter'):$e
if $e=0 then create('kp_npoints','real') setlimit('kp_npoints',524288,0,2)  kp_npoints=256 endif if ($kp_setpar<>0) then kp_npoints=256 endif
exists('kp_cycles','parameter'):$e
if $e=0 then create('kp_cycles','real') setlimit('kp_cycles',1024,1,1) kp_cycles=16 endif if ($kp_setpar<>0) then kp_cycles=16 endif
exists('kp_scyc','parameter'):$e
if $e=0 then create('kp_scyc','string') setenumeral('kp_scyc',7,'n','m4','m16','t5','t7','t9','t4') kp_scyc='t7' endif if ($kp_setpar<>0) then kp_scyc='t7' endif

setprotect('droppts1','on',8) 
setprotect('droppts2','on',8)
setprotect('kp_npoints','on',8)
setprotect('kp_cycles','on',8)

exists('kpph','parameter'):$e
if $e=0 then create('kpph','integer') setlimit('kpph',32,-32,1) kpph=0 endif if ($kp_setpar<>0) then kpph=0 endif
exists('kp_chunkmode','parameter'):$e
if $e=0 then create('kp_chunkmode','integer') setlimit('kp_chunkmode',4,0,1) kp_chunkmode=1 endif if ($kp_setpar<>0) then kp_chunkmode=1 endif

f1coef = '1 0 1 0 0 1 0 -1'

if ($kp_setpar<>0) then
 nt=2 ss=2 bs=4 il='n' 
 sw=6250
 _kp_cycles
 wexp = 'ft UoM_proc_2d_rt wft2da dconi' 
 UoM_makePS9(6)
UoM_nowt fn=kp_npoints*kp_cycles*8 gf= kp_npoints*kp_cycles/sw/4 proc='ft' proc1='ft' gf1=ni/sw1/2 
rp=rp+180
 trace='f2' ph1 ph2 th=2 vs2d=200
 dm='nny'
endif


dps

