#%TITLE% RICARDO.MAC
#
#%NAME%
# Macros used by Ricardo to do acquisition at MX beamlines
# including the use of laser
#
#%DESCRIPTION%
# For operating the laser you need also the macro id23_laser.mac
# Check the documentation of that macro for proper operation
#
#%END%
global LASER_DIR LASER_FALCON
LASER_FALCON = "id29/falcon/0"
LASER_DIR = "/buffer/lid2911/ricardo/2006_08_28"
#%UU% falcon-devname img-dir
#%MDESC%
# Set general parameters: falcon device name and directory where
# the images will be saved. Remember to create the directory first.
#
def ricardosetup '{
LASER_FALCON = "$1"
LASER_DIR = "$2"
}'
#%UU%
#%MDESC%
# Get a full range of images spaced by 5 degrees without laser
def getvisible '{
getrange visible $1 0 360 5
}'
#%UU%
#%MDESC%
# Get a full range of images spaced by 5 degrees with switchinf on/off laser
def getlaser '{
getrange laser $1 0 360 5
}'
#%UU% [visible|laser] imgprefix phi_start phi_end phi_step
#%MDESC%
# Get a range of images with selected parameters
def getrange '{
local i prefix start end step getimg imgfile cmd
local laser
if ($# != 5) {
printf("Usage: %s [visible|laser] imgprefix phi_start phi_end phi_step\n","$0")
exit
}
style = "$1"
prefix = "$2"
start = $3
end = $4
step = $5
getimg = "/users/blissadm/local/bin/getimg"
if (style == "laser") {
laser = 1
} else {
laser = 0
print "First get background image"
#getbckg $2
}
for (i=start;i<end;i+=step) {
printf(" - Phi at % 3deg \n", i)
mv phi i
printf(" * move done\n", i)
if (laser) {
laseron
imgfile = sprintf("%s/%s_laser_%03d.tif", LASER_DIR, prefix,i)
} else {
imgfile = sprintf("%s/%s_%03d.tif", LASER_DIR, prefix,i)
}
cmd = sprintf("%s %s %s", getimg, LASER_FALCON, imgfile)
unix(cmd)
if (laser) laseroff
printf(" * img saved to %s\n", imgfile)
}
}'
#%UU% get a background image
#%MDESC%
# You should get the sample manually out of the beam
def getbckg '{
devname = LASER_FALCON
prefix = "$1"
#print "moving sample out of view"
#A[phiy] = A[phiy] + 1.2
#move_em;waitmove
imgfile = sprintf("%s/%s_bckg.tif", LASER_DIR, prefix)
cmd = sprintf("getimg %s %s", LASER_FALCON, imgfile)
unix(cmd)
printf(" * img saved to %s\n", imgfile)
#print "moving sample back to view"
#A[phiy] = A[phiy] - 1.2
#move_em;waitmove
print "Ok.Ready."
}'
#%IU%
#%MDESC%
#
def getfullrange '{
if ( $# != 1 ) {
print "Usage: getfullrange file-prefix"
exit
}
mv phi 0
for (pos=0;pos<360;pos+=5) {
mv phi pos
getshot $1 pos
}
print "Disabling laser"
laseroff
}'
#%IU%
# Switch the laser on
def laseron '{
id23laserenable
}'
#%IU%
#%MDESC%
# Switch the laser off
def laseroff '{
id23laserdisable
}'
#%UU% filename current-phi-pos
#%MDESC%
# Get one single image and save it at current position
def getshot '{
filename = "$1"
pos = $2
laseron
filename = sprintf("%s_%03d.png",filename,pos)
falcon_save_image(filename)
laseroff
}'
#%IU%
#%MDESC%
# Saves an image
def falcon_save_image(filename) '{
cmd = sprintf("/users/blissadm/local/bin/getimg %s %s" ,LASER_FALCON, filename)
unix(cmd)
printf(" * img saved to %s\n", filename)
}'
#%MACROS%
#%IMACROS%
#%TOC%
#%AUTHOR% Ricardo Leal - BLISS group / 2006
#%DEPENDENCIES%
# This macro needs macrofile id23_laser.mac to be loaded
#
|