diff --git a/script/sete.py b/script/sete.py index e69de29..009375e 100644 --- a/script/sete.py +++ b/script/sete.py @@ -0,0 +1,89 @@ +def error(msg): + caput(beam_err, (msg[:40]) if len(msg) > 40 else msg) + raise Exception (msg) + +#def sete(e, all=True, wavelengt=False): +e = 0 +all = False +wavelengt = False + +beam_err = BEAMLINE_XNAME + '-ES-DAQ:BEAM-ERROR' +beam_set = BEAMLINE_XNAME + '-ES-DAQ:BEAM-SET' +ring_current_cutoff = 300.0 + +if wavelength: + e = 12.39842/e +if e < 4.7 or e > 17.5: + error('ERROR:Energy out of range: 4.7 to 17.5 keV') + +print time.strftime('%X %x') +print '... Setting energy to '+ str(e) +' keV.' +msg = 'Working... (aiming @ '+ str(e) +' keV)' +caput(beam_err, (msg[:40]) if len(msg) > 40 else msg) + +if caget('ALIRF-GUN:CUR-LOWLIM', 'd') < ring_current_cutoff: + error('ERROR:Current is too low: < ' + str(ring_current_cutoff) + 'mA') + +if caget('X06DA-FE-AB1:CLOSE_EPS') == 'CLOSE': + error('ERROR:ABSORBER closed; aborting...') + +if caget('X06DA-FE-PH1:OPEN_EPS') != "OPEN": + error('ERROR:FE Shutter closed; aborting...') + + +e0 = get_energy(False); +dE = abs(e-e0) + +print '... started to move monochromator motors' +print '... alignment will take some minutes ' +act = 0 + +# do a setenergy to move theta 1 and 2 to calculated position in case they are not synchronized. +theta1 = caget('X06DA-OP-MO1:ROX1.RBV', 'd') +etheta1 = A2E(abs(theta1),1,1,1,True) +theta2 = caget('X06DA-OP-MO1:ROX2.RBV', 'd') +etheta2 = A2E(ABS(theta2),1,1,1,True) +if abs (etheta1-etheta2) > 0.01: + set_energy(e) + + +while abs(e-e0) > 3e-5/tan(angle(e)): + set_energy(e) + e0 = get_energy(False) + + + +#----- correcting theta2 if intensity is low or if the encoder ----- +#----- differs by more than rocking curve width from theory -------- + + +# -------- for sete, /all, remove all filters +if all: + caput('X06DA-ES-FI1:SET',0) + caput('X06DA-ES-FI2:SET',0) + caput('X06DA-ES-FI3:SET',0) + caput('X06DA-ES-FI4:SET',0) + time.sleep(0.5) + +#-------- rock FIRST crystal until its peak is reached ------------- +ff = 1 +while ff: +def rock(axis = th1, ffail = False, tt = 0.2, seti0 = False, dx = None, noref = False): + rock() #TODO: #ROCK,1,dt = (dE>1.)*4e-2/e,ffail=ff + +# finer final rock +time.sleep(1.0) +print 'FINER FINAL ROCK' +rock() + + +e0 = get_energy() +caput('X06DA-OP-MO:E-GET',e0) +print e0 +print '' +print caget('X06DA-OP-MO:E-GET') + +caput(beam_err, 'Finito') +caput(beam_set, 'DONE') + +print 'sete_done' \ No newline at end of file