diff --git a/script/scans/6mom.py b/script/scans/6mom.py index 5a65159..8cc08e7 100644 --- a/script/scans/6mom.py +++ b/script/scans/6mom.py @@ -1,8 +1,8 @@ startphi=-10 -endphi=10 # for DACs the middle is 57 +endphi=0 # for DACs the middle is 57 time_step=1 step=0.5 # in degrees -#fname='testing' +passes = 1 fname='test6mom' # remember the run number @@ -10,7 +10,7 @@ fname='test6mom' # remember the run number startphi, endphi, time_step, step = float(startphi), float(endphi), float(time_step), float(step) #TODO: Should not move to startphi? scr.setSpeed (5.0) -scr.move(startphi) +scr.move(startphi, 60000) filt=caget("X04SA-ES2-FI:TRANSM",'d') *1000000000 caput("X04SA-ES2-PIL:cam1:FilterTransm",filt) @@ -35,50 +35,38 @@ det.acquirePeriod = time_step # Acquire period ### FORWARD ### # PLEASE NOTE THE FOLLOWING HAS NOT YET BEEN UPDATED FOR AUTOMATIC ANGLES -det.phiIncr = step + det.chi = 90 det.chiIncr = 0.0 det.omega = 57.05 # initial angle -det.startAngle = startphi # might be redundant det.omegaIncr = 0.0 # increment angle det.angleIncr = step # might be redundant det.kappa = -134.76 # kappa det.phi = 57.045 # phi -# PREPARE AND ACQUIRE -det.fileNumber = 1 # always start with image 1 -sleep (1.0) #TODO: Why needed if another sleep below -det.fileName =fname # filename -sleep (1.0) -scr.moveAsync(endphi) -det.start() -#scr.waitInPosition(endphi, int(tottime * 1000)) #TODO: Should sleep or wait end of move? or waiting Pilatus to finish: det.waitReady(int(tottime * 1000)) -scr.waitReady(int(tottime * 1000)) -#sleep(tottime) - - -### BACKWARD ### -# PLEASE NOTE THE FOLLOWING HAS NOT YET BEEN UPDATED FOR AUTOMATIC ANGLES -#det.phiIncr = $stepb -#det.chi = 90 -#det.chiIncr = 0.0 -#det.omega = 57.05 # initial angle -#det.startAngle = endphi # might be redundant -#det.omegaIncr = 0.0 # increment angle -#det.angleIncr = stepb # might be redundant -#det.kappa = -134.76 # kappa -#det.phi = 57.045 # phi - -## PREPARE AND ACQUIRE -#det.fileNumber = 1 # always start with image 1 -#sleep (1.0) -#det.fileName =fnameb # filename -#sleep (1.0) -#scr.move(startphi) # move the axis to ... -#det.start() -#sleep(tottime) +for p in range(passes): + if p % 2 == 0: + det.phiIncr = step + det.startAngle = startphi # might be redundant + scr.moveAsync(endphi) + det.fileName = (fname + str(p)) if (passes > 1) else fname # filename + else : + det.phiIncr = -step + det.startAngle = endphi # might be redundant + scr.moveAsync(startphi) + det.fileName =fname + str(p) # filename + det.fileNumber = 1 # always start with image 1 + sleep (1.0) + try: + det.start() + #sleep(tottime) + scr.waitReady(int(tottime * 1000)) + except: + scr.stop() + det.stop() + raise scr.setSpeed (5.0) scr.move(startphi, 30000) #timeout = 30.0s diff --git a/script/test/AlignDemo.py b/script/test/AlignDemo.py index e69de29..0a88d5f 100644 --- a/script/test/AlignDemo.py +++ b/script/test/AlignDemo.py @@ -0,0 +1,31 @@ +import mathutils +import plotutils + + +#ascan([scx, scy], [scd,], [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.1, 0.1], latency = 0.0, relative = False, zigzag = True) + + + +scy.move(0.0) +#r = lscan(scx, scd, scx.minValue, scx.maxValue, 0.1, latency = 0.0) +xdata = r.getPositions(0) +ydata = r.getReadable(0) + +maxy=max(ydata) +maxx=ydata.indexOf(maxy) +print "maxx =" , maxx +print "maxy =" , maxy + +#Fitting a gaussian +(normalization, mean_val, sigma) = mathutils.fit_gaussian(ydata, xdata) +print "fit mean = ", mean_val +#Plotting the gaussian +gaussian = mathutils.Gaussian(normalization, mean_val, sigma) +plotutils.plot_function(get_plots(None)[0], gaussian, "Fit", frange(scx.minValue, scx.maxValue, 0.01)) + + + + +r = bsearch([scx, scy], scd, [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.01, 0.01], maximum=True, strategy = "FullNeighborhood", latency = 0.01, title = "Binary Search") + +r = hsearch([scx, scy], scd, [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.2, 0.2], [0.01, 0.01], noise_filtering_steps = 3, relative = False, maximum=True, latency = 0.01, title = "Hill Climbing")