// dcpYXprobe - A macro to get or set calibrations from the probe
//              file for double cross polarization with AhYX. 

//             Argument 1 is:
//                        'set' loads values into the probe file. 
//                        'get' sets values into the workspace. 
//                        'init' creates a complete set of parameter entries. 
//             Argument 2 is the second nucleus, the recipient of polarization. The first
//                        polarizing nucleus is assumed to be 'N15'.                      
//             Argument 3 is the region: 
//                        'alpha' with code HCa (13C center 60 ppm, width 50 ppm).
//                        'carbonyl' with code HCO (13C center 170 ppm, width 20 ppm).
//                        'The 'N15' region is assumed to be amide. 
//             Argument 4 is a label: 
//                        '' is forced as the default, not used in this macro. 
//             Argument 5 (1) forces the observe spectral center and width as noted 
//                            for argument 3.  
//                        (0) uses the spectral center saved in the probe file. 
//             Parameters:                         
//                         chYX,shYX,toYX,frYX,aYyx,bYX,dYX,tYX,ofYX (region - N15)
//                         aXyx (region X - C13)
//                         

// Initialize CP Parameters in the Probe File

if (($#>0) and ($1='init')) then 

// Set the Region

   $reg='' $pwr='' $nuc='' $4=''
   $macroname = $0 + '(\'region\',$2,$3,$4,0):$reg,$pwr,$nuc'
   exec($macroname)
   $pwr=''

// Set the Double-CP Region-code for YX CP

   $reg2=''
   if ($reg = 'HCa') then 
      $reg2 = 'NCa'
   else
      $reg2 = 'NCO'
   endif  

// Initialize the Probe File with Standard DCP Parameters

   probeparamgroup('set',$reg2,'N15','YX','ch','sh','to','fr',
                                         'aY','b','d','t','of')
   probeparamgroup('set',$reg2,$nuc,'YX','aX')
endif

// Set CP Parameters to the Probe File

if (($#>0) and ($1='set')) then 

// Set the Region

   $reg='' $pwr='' $nuc='' $4=''
   $macroname = $0 + '(\'region\',$2,$3,$4,0):$reg,$pwr,$nuc'
   exec($macroname)
   $pwr=''

// Set the Double-CP Region-code for YX CP

   $reg2=''
   if ($reg = 'HCa') then 
      $reg2 = 'NCa'
   else
      $reg2 = 'NCO'
   endif 

// Set the Probe File with Standard CP and Decoupling Parameters

   probeparamgroup('set',$reg2,'N15','YX','ch','sh','to','fr',
                                         'aY','b','d','t','of') 
   probeparamgroup('set',$reg2,$nuc,'YX','aX')
endif

// Get CP Parameters from the Probe File

if (($#>0) and ($1='get')) then

// Set the Region

   $reg='' $pwr='' $nuc='' $4=''
   $macroname = $0 + '(\'region\',$2,$3,$4,0):$reg,$pwr,$nuc'
   exec($macroname)
   $pwr=''

// Set the Double-CP Region-code for YX CP

   $reg2=''
   if ($reg = 'HCa') then 
      $reg2 = 'NCa'
   else
      $reg2 = 'NCO'
   endif 

// Obtain Standard CP and Decoupling Parameters from Probe File

   probeparamgroup('get',$reg2,'N15','YX','ch','sh','to','fr',
                                         'aY','b','d','t','of') 
   probeparamgroup('get',$reg2,$nuc,'YX','aX')
endif

//-------------------
// The Region Macro
//-------------------

if (($# > 0) and ($1 = 'region')) then
   $nuc=$2
   $reg=''
   $pwr=$4
   if (($# > 4) and ($5 = 1)) then 
      if ($2='C13') then 
         tn='C13' dn='H1' dn2='N15' dn3=''   
         wc = 200 sc =10
         ad=4.0 rd=4.0 ddrtc=8.0 rp=0 lp=0 d1=2.0 nt=1 ss=2 bs=4
         sw=100000.0 at=0.01 fn=16.0*np sb=at/2.0 sb='y' sbs='n' lb=50 gain=30
         ofHX=0.0
         if ($3='alpha') then
            setref setoffset('C13',60):tof tof=0.1*trunc(tof/0.1 + 0.5) sp=35p wp=50p
            $reg='HCa'
         elseif ($3='carbonyl') then 
            setref setoffset('C13',175):tof tof=0.1*trunc(tof/0.1 + 0.5) sp=165p wp=20p
            $reg='HCO'
         elseif ($3='adam') then 
            setref setoffset('C13',38):tof tof=0.1*trunc(tof/0.1 + 0.5) sp=28p wp=20p
            $reg='HC'
         endif
      elseif ($2='N15') then 
         tn='N15' dn='H1' dn2='C13'  dn3=''   
         wc = 200 sc =10
         ad=16.0 rd=4.0 ddrtc=20.0 rp=0 lp=0 d1=2.0 nt=1 ss=2 bs=4
         sw=100000.0 at=0.01 fn=16.0*np sb=at/2.0 sb='y' sbs='n' lb=50 gain=30  
         ofHX=0.0
         if ($3='amide') then
            setref setoffset('N15',115):tof tof=0.1*trunc(tof/0.1 + 0.5) sp=90p wp=50p
            $reg='HNai'
         elseif ($3='amine') then 
            setref setoffset('N15',35):tof tof=0.1*trunc(tof/0.1 + 0.5) sp=15p wp=40p
            $reg='HNam'
         elseif ($3='amino') then 
            setref setoffset('N15',35):tof tof=0.1*trunc(tof/0.1 + 0.5) sp=15p wp=40p
            $reg='HN'
         endif
      endif
   else
      if ($2='C13') then 
         if ($3='alpha') then
            $reg='HCa'
         elseif ($3='carbonyl') then 
            $reg='HCO'
         elseif ($3='adam') then 
            $reg='HC'
         endif
      elseif ($2='N15') then 
         if ($3='amide') then
            $reg='HNai'
         elseif ($3='amine') then 
            $reg='HNam'
         elseif ($3='amino') then 
            $reg='HN'
         endif
      endif
   endif
   return($reg,$pwr,$nuc)
endif

