"SS_AutoCal_CP: Automatic Calibration of Pulse Widths and CP Using CP Detection "

"      This macro requires the Solids sequences tancpx.c and onepul.c, the      " 
"      setup macros tancpx and onepul, the parameter file Settancpx.par and     "
"      BioPack macros BPsvf, BPpage, BPsetparams and BPgetdate. The optional    "
"      parameter MASdev stores the allowed spin rate deviation and BPplot stores" 
"      the plottting status 'plot' or 'on'. The probe file must use the template" 
"      SS_AutoCal_probe.template.                                               "

"      This macro calls SS_1_DP, SS_2_DP, SS_3_DP and SS_4_DP in sequence       "
"      Current regions: ('13C','alpha') peptide alpha region                    "
"                       ('13C','carbonyl') peptide carbonyl region              "
"                       ('15N','amide') peptide amide region                    "
"                       ('15N','amine') glycine amine region                    "
"      G Gray, D Rice 02/16/09                                                  "

Macro Actions: 

SS_AutoCal_CP

1.  Ask for plotting. If the parameter BPplot exists and BPplot='on' or BPplot='plot' 
    then calibration spectra will be plotted. Otherwise plotting is suppressed. 

2.  Initialize the workspace with Settancpx.par from first: the user or second: 
    the system. 

3.  Obtain the spin rate as an average of 10 trials. Abort if the spin rate is less
    than 500 Hz. Compare the deviation of the spin rate with the parameter MASdev 
    if it exists and abort if the deviation is greater than MASdev. Remove the files
    generated in the spin-rate measurement. Set srate to the measured value. 

4.  Create the directory ~/vnmrsys/AutoTripRes to store calibration data and the log 
    file. Create the logfile in the AutoTripRes directory and initialize it with the 
    nucleus, the region, temp and srate. 

5.  If BPplot = 'on' or 'plot' print the SSpreface manual file. 

6.  Get the referenced lock frequency and solvent from the probe file.  SS_AutoCal_DP 
    sets this value automatically, otherwise the probe file should be updated manually
    with the desire lockfreq and solvent.  

7.  Get a full set of parameters for the nucleus and region from the probe file.  These
    parameters are set automatically with SS_AutoCal_DP for the label _HC, these need 
    to be copied to the approiate region or the probe file should be updated manually. 

    The parameters are: (H1) aHspinal, pwHspinal, phHspinal, pwH90 (_hp), aH90 (_hp), 
    aHhx, bHX, dHX, tHX,  (X) pwX90, aX90, and aXhx. SPINAL decoupling is always used 
    but aHtppm, pwHtppm and phHtppm are copied from SPINAL. 

8.  Set the ppm regions for analysis: 
       'C13' ->  tn='C13', dn='H1' and dn2='N15' with ampmode='dppp', ad=4.0, rd=4.0, ddrtc=8.0
          'alpha' -> sp = 45p wp = 30p - setoffset(60)
          'carbonyl' -> sp = 165p wp = 20p - setoffset(175)
        sw=100000, at=0.01, lb=50 sb=at/2.0 (av mode)
       'N15' ->  tn='CN5', dn='H1' and dn2='C13' with ampmode='dppp', ad=4.0, rd=16.0, ddrtc=20.0
          'amide' -> sp = 90p wp = 50p - setoffset(115)
          'amine' -> sp = 15p wp = 40p - setoffset(35)
        sw=50000, at=0.1, lb=50 sb=at/2.0 (av mode)
        run getsolidsprobedata to set tpwr, dpwr, and dpwr2. Other values are obtained form the 
        probefile. 
       
8.  Get pwH90 (_mp), aH90 (_mp), reset aH90 and construct a nutation array of pwH90 
    50 steps of stepsize pwH90/10.0.  Reset a 10% linear ramp (bHX=10000 produces a 
    linear ramp). The array should span 1.25 cycles by default. 

9   Set wnt to produce av mode with a noise level of 1 mm and a dssh array and set au
    to start.   

SS_1_CP:

1.  Analyze the H1 mediuum power nutation array in av mode.  Obtain first values for pw90 (max), 
    pw180 (min), pw270 (max) and pw360 (min).  To be set a maximum it must be follwed by a
    height 25% lower and to set a minimum it must be followed by a height 25% higher.  Not
    all the values may be set. The calibration can proceed with only pw90. The value of F 
    is the number of minima nad maxima used. Minima and maxixma are refined with a parabolic
    fit, using the macro SS_AutoCal_minmaxfit, using 2 points on either side of the selected 
    point.  

2.  Phase and plot the data - but plot in absolute value mode. 

3.  Update the lock frequency in the probe file and write it to the log. 

4.  Save the nutation curve as "H1_nutation_mp" with nucleus and region appended. 

5.  Obtain the value R = pw360/(2.0*pw180) if all minima and maxima are present. 
    Calculate a projected "180" for the next test of $pwH90calc = (R-0.5)*pw180. 
    If only pw270 and pw360 are not available set $pwH90calc=pw180 and R=1.0, F=2. 
    If only pw90 is  available set $pwH90calc = 2*pwH90, R=1.0 and F=1. Update R and
    F in the probe file and write the nutation data in the log file. 

6.  Set pwH90 = $pwH90calc and find a value of aH90 ($aH90) that should produce a 
    "180-degree null at pwH90.  Array aH90 in 21, 4% steps from 1.4*$aH90 downward.  

7.  Set wnt to produce av mode with a noise level of 1 mm and a dssh array and set au
    to start.   

SS_1_CP (part1):

1.  Analyze the H1 180-degree null array in av mode. Obtain a rough minimum from the 
    minimum intensity spectrum.  The minimum is refined with a parabolic fit, using 
    macro SS_AutoCal_minmaxfit, using 5 to 2 points on either side of the selected 
    point.  The point number is lmited if the minimum is close to the edge of the 
    array. If the rough value is within 3 points of the array edges the macro will
    abort. Such an abort will result if the projected amplitude of the null is 
    calculated incorrectly. The most likely cause is amplifier compression. To
    proceed it will be necessary to replace the starting amplitude with a value 
    closer to the final result - as of now there is no automatic way to do this.  
    Outside of compression the analysis should not fail. 

2.  Recalculate the correct pwH90 ($pwH90) from the 180 degree null(now "pwH90) and R with 
    the expression $pwH90 = (R-0.5)*pwH90.  Save pwH90 (it should be unchanged) in 
    the probe file along with the calibrated aH90 that produces this value. Write
    these values in the log file. 

3.  Save the 180-degree-nulll array as H1_pwH180_null_mp with the nucleus and region
    appended. 

4.  Get pwH90 (_hp), aH90 (_hp), reset aH90 and construct a nutation array of pwH90 
    50 steps of stepsize pwH90/10.0.  The array should span 1.25 cycles by default. 

5   Set wnt to produce av mode with a noise level of 1 mm and a dssh array and set au
    to start.   

SS_2_CP

1. Analyze the H1 high power nutation array in av mode. The method is identical to that 
   of SS_1_CP. 

2. Setup for a 180 degree null array in av mode.  The method is identical to that 
   off SS_1_CP. 

SS_2_CP (part 1) 

1. Analyze the H1 180 degree null array in av mode.  The method is identical to that 
   of SS_1_CP (part 1). 

2. Update aHspinal, pwHspinal in the probe file using the high-power aH90 derived above. Set 
   phHspinal=10.0. 

3. Update aHtppm, pwHtppm in the probe file using the high-power aH90 derived above. Set 
   phHtppm=10.0

4. Use the macro tancpxflip to setup a X nutation with cross polarization. Get values for 
   pwX90, aX90 from the probe file and reset aX90. Construct a nutation array of pwX90 
   50 steps of stepsize pwX90/10.0.  Continue to use a 10% linear ramp. The array should 
   span 1.25 cycles by default. Note that for tancpxflip a 90 degree pulse produces a 
   "null value". 

5. Set wnt to produce av mode with a noise level of 1 mm and a dssh array and set au
   to start.   

SS_3_CP

1.  Analyze X nutation with cross polarization in av mode.  The method is similar to that 
    of SS_1_CP except that pw90 is a minimum, pw180 (max), pw270 (min) and pw360 (max). 

2.  Setup a "90-degree null" array for tancpxflip in av mode. The method is similar to that
    of SS_1_CP except that pwX90 is set as the calculated pw90 rather than the pw180. 

SS_3_CP (part 1) 

1.  Analyze the "90-degree null" array for tancpxflip in av mode.  The method is similar to 
    that of SS_1_CP (part 1). 

2.  Use the macro tancpx tp reset simple cross polarization. Set aXhx = aX90 and calculate 
    a Hartmann-Hahn match array of aHhx to determine the best match in the presence of spinning. 
    Use the calibrated value of aH90_mp as the center of the aHhx array and array +/- WR in 
    filed strength units of the amplitude. Use 41 steps to span the range. 

3.  Set wnt to produce av mode with a noise level of 1 mm and a dssh array and set au
    to start.  

SS_4_CP 

1.  Analyze the Hartmann-Hahn match array in absolute value mode. Simply select the spectrum 
    with the maximum intensity and record the amplitude array element as aHjx in the probe 
    file. There is no refinement. 

2.  Setup to obtain a 4-scan signal to noise measurement with calibrated parameters. Set d1 = 4. 
 
3.  Set wnt='' and wexp='' and set au to start. 

SS_4-CP (part 1) 

1.  Phase the Signal to noise spectrum and plot it in phased modes with sp = -50p and wp = 300p. 

 














