#! /bin/tcsh -f # # standard procedure for tuning up the 8.x.x beamlines -James Holton 12-13-14 # # make sure we execute files in the same directory as this script set path = ( `dirname $0` $path ) set flux = "" if($?QUERY_STRING) setenv CGI set br = "" if($?CGI) then # we are running as CGI #echo "Content-Type: text/html\n" set path = ( `pwd` $path ) set br = "
" endif # decide how to print output test -t 1 if($status) set AUTO if($?CGI) set AUTO if(! $?beamline) then # default to beamline this computer belongs to setenv beamline `beamline.com` if($status) then echo "ERROR: $beamline" exit 9 endif endif #if(! $?beamline) setenv beamline 831 foreach arg ( $* ) if("$arg" == "ifneeded") set ifneeded if("$arg" == "auto") setenv AUTO if("$arg" == "hurry") setenv HURRY if("$arg" == "force") setenv FORCE end set test = `blmotor.com Hutch PSS Status | awk '{print $NF+0}'` if("$test" == "0" && ! $?FORCE) then set BAD = "photons are off at the hutch" goto exit endif set shift = ( 0 0 -1 ) if( "$beamline" =~ 82? ) set shift = ( 0 0.3 -0.3 ) if( "$beamline" == 1231 ) set shift = ( 0 0 1 ) #if( "$beamline" != 831 ) setenv HURRY # make sure we don't do this while collection is running pause.com set area = `divergence.com | awk '{printf "%d", 100 * $NF * $(NF-1) / (3*0.4)}'` if($area < 2) then echo "WARNING: Slits are closed! " echo "opening them to standard operating conditions." divergence.com 2 0.35 endif # don't confirm if this is a non-interactive run if(! $?AUTO) then # echo "Please make sure your sample is out of the x-ray beam " # echo 'Moving the "Z-axis" motor by -300 will usually do the trick. ' # echo "" # echo 'press "Enter" when you have done this:' # set nutn = ( $< ) else setenv plot "#" endif echo "moving crystal to a safe location..." set start = `sample.com | awk '{print $5,$6,$7}'` sample.com $shift onintr break stage.com up diode.com in shutter.com open attenuator.com Al out attenuator.com Cu out attenuator.com Se out if ("$beamline" == "1231") then attenuator.com Au out attenuator.com Zn out endif sleep 1 autoscale.com if($status) then set BAD = "no beam" goto break endif set flux = `flux.com | awk '/^Flux/{print "Flux =",$6,"photons/s,";dr=$(NF-1)} /^beam/{print $4,$5,$6,"(",dr,"Gy/s)"}'` echo "$flux" set test = `echo $flux | awk '{print ($5>400)}'` if(0 && $test && $?ifneeded) then echo "no need to tune up beam" shutter.com close diode.com out goto exit endif set energy = `blmotor.com Mono eV | awk '{print $NF}'` blmotor.com Mono eV with z $energy set using_feedback = `feedback.com | awk '/is on/{status=1} END{print status+0}'` if ( $using_feedback ) then echo "disabling feedback system..." feedback.com off endif tune_rock.com flux.com | awk '/^Flux/{print $1,$2,$6,"photons/s,"} /^beam/{print $4,$5,$6}' tune_M2.com flux.com | awk '/^Flux/{print $1,$2,$6,"photons/s,"} /^beam/{print $4,$5,$6}' tune_chi2.com set flux = `flux.com | awk '/^Flux/{print "Flux =",$6,"photons/s,";dr=$(NF-1)} /^beam/{print $4,$5,$6,"(",dr,"Gy/s)"}'` break: onintr shutter.com close diode.com out # make sure feedback is on from now on set using_feedback = 1 if ( $using_feedback ) then echo "updating feedback system..." sleep 2 feedback.com keep if($status) then set BAD = "cannot enable feedback" goto exit endif endif exit: if($?start) then echo "restoring old crystal position..." sample.com to $start endif echo "" echo "" echo "$flux" if($?BAD) then echo "something is wrong... $BAD" # page.com Holton "$BAD" exit 9 endif echo "you may now resume collecting data! "