# 2D Conversion of Bruker Data:
# for multiple datasets
# written by mikey
# usage script <first exp number>  < final exp number>


@ index = $1
echo ok
while ( $index <= $2 )
        set inname = ./$index/
        set outname = ./noeprocessed

if ( -r $inname/ser.gz) then


zcat $index/ser.gz | bruk2pipe -swap -DMX -decim 16 -dspfvs 12 \
              -xN           1024    -yN          100 \
              -xT           512    -yT          50 \
              -xMODE         DQD    -yMODE  Echo-antiecho \
              -xSW      8389.26174496644    -ySW  1277.1799865 \
              -xOBS       600.13    -yOBS    60.8179 \
              -xCAR         4.64    -yCAR   118.5 \
              -xLAB           1H    -yLAB        15N \
              -ndim            2    -aq2D States-TPPI \
              -out $outname/mikeT2kayWG_$index.fid -verb -ov -nofs
#
# px2dxy.com: 2D Conversion of Varian Data
#

nmrPipe    -in $outname/mikeT2kayWG_$index.fid \
| nmrPipe  -fn SOL \
| nmrPipe  -fn SP -off 0.5 -end 0.95 -pow 2 -c 0.5 \
| nmrPipe  -fn ZF -auto  \
| nmrPipe  -fn FT \
| nmrPipe  -fn PS -p0 164.0 -p1 0.0 -di -verb 2 \
| nmrPipe  -fn EXT -x1 10ppm -xn 6.5ppm -sw \
| nmrPipe  -fn TP \
| nmrPipe  -fn LP -ps90-180 \
| nmrPipe  -fn SP -off 0.45 -end 0.98 -pow 2 -c 1.0 \
| nmrPipe  -fn ZF -auto \
| nmrPipe  -fn FT -auto \
| nmrPipe  -fn PS -p0 -90.0 -p1 180.0 -di -verb 2 \
| nmrPipe  -fn TP \
#| nmrPipe  -fn POLY -auto \
   -out $outname/spec_$index.DAT -verb 2 -ov

echo spec.DAT done
rm -r  $outname/mikeT2kayWG_$index.fid

pipe2xyz -nv -out $outname/new_$index.nv < $outname/spec_$index.DAT

 @ index ++
else
clear
echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo data for $inname/ser does not exist continuing to next dataset
echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo
@ index ++
endif

end