// Set wpmlgX

if ((qXwpmlg > -3.0) and (qXwpmlg < 3.0)) then qXwpmlg = -3 endif
$qXwpmlg = qXwpmlg 
if ($qXwpmlg < 0.0) then $qXwpmlg = -$qXwpmlg endif 

aXwpmlg = aX90
$pwXwpmlg = sqrt(2.0/3.0)*4.0*pwX90
pwXwpmlg = 0.0125*$qXwpmlg*trunc($pwXwpmlg/($qXwpmlg*0.0125) + 0.5)

// Reset the amplitude to match the rounded 2pi pulse.

$aXwpmlg = ($pwXwpmlg/pwXwpmlg)*aXwpmlg
aXwpmlg = trunc($aXwpmlg + 0.5)

// set tau to add a 2-step window or 4 us (whichever is greater)

tauXwpmlg = 0.0125*trunc(2.0*pwXwpmlg*($qXwpmlg+1)/($qXwpmlg*0.0125) + 0.5)
if (tauXwpmlg < 2.0*pwXwpmlg + 4.0) then tauXwpmlg = 2.0*pwXwpmlg + 4.0 endif
sw = 1/(tauXwpmlg*1e-6)
if (npaXwpmlg < 10) then npaXwpmlg = 10 endif

// Reset the prep pulses

aXprep1 = aX90
pw1Xprep1 = pwX90
pw2Xprep1 = pwX90*54.7/90.0
phXprep1 = 0.0 





