esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

#%TITLE% HKLEXTRA.MAC
#
#%NAME%
#  Additional macros for scans in the reciprocal space.
#
#%OVERVIEW%
#  These macros complement the standard %B%spec%B% macros for scanning in
#  the reciprocal space. They include:
#%UL%
#%LI% Delta scans (%B%dhklscan%B%, %B%dhscan%B%, %B%dkscan%B%, %B%dlscan%B%)
#%LI% Radial scans in HK, HL and KL planes. These macros deal properly with
#     the geometry of the reciprocal unit cell.
#%XUL%
#
#%EXAMPLE%
#
#  %DL%
#  %DT%dlscan -.5 .5 20 1
#  %DD%Scans the diffractometer in the L direction. The scan range is one 
#      reciprocal lattice unit around the current position (from L-.5 to L+.5).
#      When the scan finishes or if the user stops the scan, the diffractometer
#      is moved back to the initial position in the same way that
#      %B%dscan%B% does for single motor scans. 
#  %DT%hkradscan .9 1.1 30 2
#  %DD%Scan in a radial direction contained in the HK plane. The radius varies
#      from .9 to 1.1 reciprocal lattice units. The direction is defined by 
#      the current position in reciprocal space.
#  %XDL%

#%UU% <Hstart> <Hfinish> <Kstart> <Kfinish> <Lstart> <Lfinish> <interv.> <time>
#%MDESC%
#  Scan in the reciprocal space analogous to a %B%hklscan%B% but the
#  diffractometer is moved back to the initial position when the scan is
#  finished or interrupted.
#
def dhklscan '
   if ($# != 8) {
      print \
"Usage:  dhklscan Hstart Hfinish Kstart Kfinish Lstart Lfinish intervals time"
      exit
   } 
   waitall; get_angles; calcHKL
   _7 = H; _8 = K; _9 = L

   def cleanup \'
      def _cleanup2 ""
      undef cleanup
   \'
   def _cleanup2 \'
      rdef _cleanup2 ""
      printf("\nReturning to HKL = (%g, %g, %g)\n", _7, _8, _9)
      onp; offt
         printf("\nbr %g %g %g\n", _7, _8, _9)
      offp; ont
      waitmove; get_angles; 
      H=_7; K=_8; L=_9
      calcA
      move_em
      printf("\n")
   \'
   hklscan _7+($1) _7+($2) _8+($3) _8+($4) _9+($5) _9+($6) $7 $8
   _cleanup2
'

#%UU% <start> <finish> <intervals> <time>
#%MDESC%
#  Scan in the reciprocal space analogous to a standard %B%hscan%B% but the
#  diffractometer is moved back to the initial position when the scan is
#  finished or interrupted.
#
def dhscan '
   if ($# != 4) {
      print "Usage:  dhscan start finish intervals time"
      exit
   } 
   waitall; get_angles; calcHKL
   dhklscan $1 $2 0 0 0 0 $3 $4
'

#%UU% <start> <finish> <intervals> <time>
#%MDESC%
#  Scan in the reciprocal space analogous to a standard %B%kscan%B% but the
#  diffractometer is moved back to the initial position when the scan is
#  finished or interrupted.
#
def dkscan '
   if ($# != 4) {
      print "Usage:  dkscan start finish intervals time"
      exit
   } 
   waitall; get_angles; calcHKL
   dhklscan 0 0 $1 $2 0 0 $3 $4
'

#%UU% <start> <finish> <intervals> <time>
#%MDESC%
#  Scan in the reciprocal space analogous to a standard %B%lscan%B% but the
#  diffractometer is moved back to the initial position when the scan is
#  finished or interrupted.
#
def dlscan '
   if ($# != 4) {
      print "Usage:  dlscan start finish intervals time"
      exit
   } 
   waitall; get_angles; calcHKL
   dhklscan 0 0 0 0 $1 $2 $3 $4
'

#%UU% <Rstart> <Rfinish> <intervals> <time> [L=<expression>]
#%MDESC%
#  Radial scan in the HK plane. The radius of the projection on the HK plane
#  in made to vary from <Rstart> to <Rfinish> in reciprocal lattice units.
#  The direction of the scan is determined by the current position of the
#  diffractometer in the reciprocal space.%BR%
#  By default the L value is constant unless <expression> is specified. If so,
#  it is evaluated at each scan point and L is corrected accordingly.
#
def hkradscan '_hklradscan $0 H K g_ga_s $*'

#%UU% <Rstart> <Rfinish> <intervals> <time> [K=<expression>]
#%MDESC%
#  Radial scan in the HL plane. Analogous to %B%hkradscan%B%.
#
def hlradscan '_hklradscan $0 H L g_be_s $*'


#%UU% <Rstart> <Rfinish> <intervals> <time> [H=<expression>]
#%MDESC%
#  Radial scan in the KL plane. Analogous to %B%hkradscan%B%.
#
def klradscan '_hklradscan $0 K L g_al_s $*'

#%UU% <Rstart> <Rfinish> <intervals> <time> [L=<expression>]
#%MDESC%
#  Delta radial scan in the HK plane. It is analogous to %B%hkradscan%B% but
#  <Rstart> and <Rfinish> are specified as relative values with respect to
#  the current one. When the scan finishes or is interrupted, the
#  diffractometer moves back to the initial position.
#
def dhkradscan '_dhklradscan $0 H K g_ga_s $*'

#%UU% <Rstart> <Rfinish> <intervals> <time> [K=<expression>]
#%MDESC%
#  Delta radial scan in the HL plane. Analogous to %B%dhkradscan%B%.
#
def dhlradscan '_dhklradscan $0 H L g_be_s $*'

#%UU% <Rstart> <Rfinish> <intervals> <time> [H=<expression>]
#%MDESC%
#  Delta radial scan in the KL plane. Analogous to %B%dhkradscan%B%.
#
def dklradscan '_dhklradscan $0 K L g_al_s $*'

#%IU% 
#%MDESC%
#
def _hklradscan '{
   local qu qv qmod

   waitmove; get_angles; calcHKL
   qmod = sqrt($1*$1 + $2*$2 + 2*$1*$2*cos(rad($3)))
   qu = $1/qmod
   qv = $2/qmod
   def _hkl "
     $1 = \$1 * qu
     $2 = \$1 * qv
   "

   X_L = "$1$2radius"
   if ($4 < 0 || $5 < 0) {
      printf("Negative radius (from %g to %g). Aborting.\n", $4, $5)
   } else {
      _hklline 0 $4 $5 $6 $7 "$8"
   }
}'


#%IU% 
#%MDESC%
#
def _ahklradscan '{
   if ($# < 8 || $# > 9) {
      printf("Usage:  $1 start finish intervals time [%s=expression]\n",\
               ("$2$3"=="HK")?"L":("$2$3"=="HL")?"K":"H")
      exit
   } 
   HEADING = sprintf("$1 %g %g %g %g %g", $5,$6,$7,$8,"$9")
   _hklradscan $2 $3 $4 $5 $6 $7 $8 "$9"
}'


#%IU% 
#%MDESC%
#
def _dhklradscan '{
   if ($# < 8 || $# > 9) {
      printf("Usage:  $1 start finish intervals time [%s=expression]\n",\
               ("$2$3"=="HK")?"L":("$2$3"=="HL")?"K":"H")
      exit
   } 

   HEADING = sprintf("$1 %g %g %g %g %g", $5,$6,$7,$8,"$9")
   waitall; get_angles; calcHKL
   _7 = H; _8 = K; _9 = L

   def cleanup \'
      def _cleanup2 ""
      undef cleanup
   \'
   def _cleanup2 \'
      rdef _cleanup2 ""
      printf("\nReturning to HKL = (%g, %g, %g)\n", _7, _8, _9)
      onp; offt
      printf("\nbr %g %g %g\n", _7, _8, _9)
      offp; ont
      waitmove; get_angles; 
      br _7 _8 _9
      printf("\n")
   \'

   _hklradscan $2 $3 $4 qmod+($5) qmod+($6) $7 $8 "$9"
   _cleanup2
}'

#%MACROS%
#%IMACROS%
#
#%AUTHOR% P. Fajardo, (Original 12/96).
#  $Revision: 3.0 $ / $Date: 1999/03/17 10:08:18 $
#%TOC%