// 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.1*$qXwpmlg)*trunc(($pwXwpmlg/($qXwpmlg*0.1)) + 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

if ($qXwpmlg >= 5) then scalesw = 1/0.425 endif
if ($qXwpmlg >= 20) then scalesw = 1.0/.4375 endif 
if ($qXwpmlg >= 20) then scalesw = 1.0/.450 endif

// Reset the prep pulses

aXprep = aX90
pwXprep = pwX90
phXprep = 0.0 

