/* VnmrJ/VNMR macro to process 3D data for SAPPHIRE modified by Pinelopi Moutzouri (08/11/2016) Developed By NMR Methodology Group School of Chemistry, University of Manchester United Kingdom This macro will use exp5 (or the one that was choosen by setting addsubexp) to create ni2 interferogram pure shift FIDs with diffrente first chunk duration (stored as an array) $1 optional argument to choose the number of increments for processing in the t1 dimension; default value: ni-1 $2 optional argument to choose the number of different J evolution increments; default value: ni2 */ $kp_exp_str='' jexp:$exp_num,$kp_exp_str $sw1=sw1 $sw2=sw2 $samplename=samplename if ($#<>2) then write('error','Two arguments should be used..') abort endif if ($#=2) then $kp_ni2=$2 $kp_ni=$1 else $kp_ni2=ni2 $kp_ni=ni endif if (lsfid>0) then $droppts=lsfid+1 else $droppts=1 ENDIF exists('droppts','parameter'):$ex IF $ex>0 then $droppts=droppts ENDIF cptmp('pureshift') clradd $ni=ni $ni2=$kp_ni2 $nfid=$kp_ni $npoint=trunc((sw/sw1)+0.5) $imag=0.0 $real=0.0 jexp:$exp,$expname $tmpfile=userdir+'/'+$expname+'/homodec_writefid' exists($tmpfile,'file'):$ex1 IF $ex1>0 then shell('rm',$tmpfile) ENDIF $tmpfile2=userdir+'/'+$expname+'/homodec_fid' exists($tmpfile2,'file'):$ex1 IF $ex1>0 then shell('rm',$tmpfile2) ENDIF beepoff $i=1 " increment tau1 evolution 0 .. ni2 " repeat $chunk1=$npoint*((1-($i-1)*0.125)) $j=1 " increment t1 evolution chunk 0 .. ni " rttmp('pureshift') repeat write('line3','increment %d 1st fid %d',$j,$i) write('line3','npoint %d chunk1 %d dev %d',$npoint,$chunk1,$npoint-$chunk1) $fid=1+($j-1)+($i-1)*ni " fid containing i'th chunk for j'th t2 value " exists($tmpfile,'file'):$ex1 IF $ex1>0 then shell('rm',$tmpfile) ENDIF writefid($tmpfile,$fid) lookup('file',$tmpfile) $k=1 repeat lookup('read'):$temp "read dummy points" lookup('read'):$temp "read dummy points" $k=$k+1 until $k>$droppts $l=1 IF ($j<2) THEN REPEAT lookup('read'):$imag[$l] lookup('read'):$real[$l] $l=$l+1 UNTIL ($l>($chunk1)) ELSEIF (($j>=2) and ($j<=$kp_ni)) THEN REPEAT lookup('read'):$imag[($j-2)*$npoint+$l+$chunk1] lookup('read'):$real[($j-2)*$npoint+$l+$chunk1] $l=$l+1 UNTIL ($l>($npoint)) ELSEIF ($j>$kp_ni) THEN REPEAT lookup('read'):$imag[($kp_ni-1)*$npoint+$l+$chunk1] lookup('read'):$real[($kp_ni-1)*$npoint+$l+$chunk1] $l=$l+1 UNTIL ($l>($npoint-$chunk1)) ENDIF $j=$j+1 until $j>ni write('line3','ni %d kp_ni %d nfid %d',$ni,$kp_ni,$nfid) $l=1 REPEAT write('file',$tmpfile2,'%s %s',$imag[$l],$real[$l]) $l=$l+1 UNTIL ($l>(($nfid-1)*$npoint+$chunk1+($npoint-$chunk1))) shell('rm ',curexp+'/acqfil/fid') shell('sleep 1') setvalue('np',2*($npoint*($nfid-1)+$chunk1+($npoint-$chunk1))) groupcopy('current','processed','acquisition') makefid($tmpfile2,'float') setvalue('np',2*($npoint*($nfid-1)+$chunk1+($npoint-$chunk1))) groupcopy('current','processed','acquisition') add('new') " add pure shift fid to exp5 " shell('rm',$tmpfile2) $i=$i+1 until $i>$kp_ni2 write('line3','kp_ni2 %d',$kp_ni2) rttmp('pureshift') exists('addsubexp','parameter'):$ex1 IF $ex1>0 THEN $addsubexp=addsubexp ELSE $addsubexp=5 ENDIF $addsubexp_str='' format($addsubexp,'lower'):$addsubexp_str exec('jexp'+$addsubexp_str) $ct=ct phase=phase2 phase2=0 sw1=$sw2 sw2=$sw1 ni2=0 ni=$kp_ni2 setvalue('ct',$ct) setvalue('celem',$kp_ni2) calcdim setvalue('np',2*($npoint*($nfid-1)+$chunk1+($npoint-$chunk1))) setvalue('at', 0.5*np/sw) fn=2*np ff rfl1=$sw2/2 rfp1=0 groupcopy('current','processed','acquisition') //nowt by KP lb='n'sb='n'gf='n'gfs='n'sbs='n' awc='n' setlimit('lb',1000,-1000,0) setlimit('sb',1000,-1000,0) setlimit('gf',1000,-1000,0) setlimit('gfs',1000,-1000,0) setlimit('sbs',1000,-1000,0) setlimit('awc',1000,-1000,0) exists('ni','parameter'):$e1 if ($e1=1) then lb1='n' sb1='n' gf1='n' gfs1='n' sbs1='n' awc1='n' setlimit('lb1',1000,-1000,0) setlimit('sb1',1000,-1000,0) setlimit('gf1',1000,-1000,0) setlimit('gfs1',1000,-1000,0) setlimit('sbs1',1000,-1000,0) setlimit('awc1',1000,-1000,0) endif exists('ni2','parameter'):$e2 if ($e2=1) then lb2='n' sb2='n' gf2='n' gfs2='n' sbs2='n' awc2='n' setlimit('lb2',1000,-1000,0) setlimit('sb2',1000,-1000,0) setlimit('gf2',1000,-1000,0) setlimit('gfs2',1000,-1000,0) setlimit('sbs2',1000,-1000,0) setlimit('awc2',1000,-1000,0) endif //end of nowt gf=at/2 gf1=ni/sw1/2 fn1=1k fn=np*8 ph ph1 ph2 if (fn>17000) then fn=16k endif rp1=0 sp1=-sw1/2 wp1=sw1 wft2d mt($exp,$addsubexp) samplename=$samplename+'-proc' vs2d=40 th=2 dcpn //edit and/or uncomment the lines below to queue experiments in automation mode; otherwise macro will leave VnmrJ in exp5 (or the one choosen by addsubexp); this part allow the user to save processed data and continue acquisition of other experiments based on the settings of "wexp" and "wdone" parameters; starting acquisition by "au" is needed to use this // kp_save //this line must be replaced by the user's own saving macro or any of the system defaults e.g. savefid in VJ40 or fidsave in VJ22 //exec('j'+$kp_exp_str)