def kscan(dev, start, step, numpoints, speed=None, *args, **kwargs): """Kinematic scan over device(s). The syntax is to give start, step and number of points: >>> kscan(dev, 3, 2, 4) # kinematic scan starting at 3 oscillate by 2 # 4 times with default speed >>> kscan(dev, 3, 2, 4, 1) # same scan as above with speed 1. oscillates between 3 and 5 during exposure for each interval of (3, 5) respectively (5, 3). """ def mkpos(starts, steps, numpoints): startpositions = [] endpositions = [] for i in range(numpoints): for start, step in zip(starts, steps): startpositions.append([start + (i % 2) * step]) endpositions.append([start + ((i + 1) % 2) * step]) return startpositions, endpositions scanargs = (start, step, numpoints) + args scanstr = _infostr('kscan', (dev, ) + scanargs, kwargs) devs, values, restargs = _fixTypeNPoints(dev, scanargs, mkpos) _preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(restargs, kwargs, scanstr) KScan(devs, values[0], values[1], speed, move, multistep, detlist, envlist, scaninfo).run()
def msingle(settings, *args, **kwargs): """Single MIEZE counting. First argument is a list of MIEZE settings or -1 to scan all setings. All other arguments are handled like for `count`. """ scanstr = _infostr('msingle', (settings, ) + args, kwargs) preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(args, kwargs, scanstr) MiezeScan(settings, [], [], move, multistep, detlist, envlist, preset, scaninfo).run()
def sscan(dev, *args, **kwargs): """Scan over device(s) and count detector(s). The general syntax is either to give start, step and end: >>> sscan(dev, 0, 1, 10) # scans from 0 to 10 in steps of 1. or a list of positions to scan: >>> sscan(dev, [0, 1, 2, 3, 7, 8, 9, 10]) # scans at the given positions. For floating point arguments, the length of the result is ``int(round((end - start) / step + 1)``. Because of floating point overflow, this rule may result in the last element being greater than ``end``, e.g. >>> sscan(dev, 30, .1, 30.19) # scans from 30 to 30.2 in steps of 0.1. """ def mkpos(starts, steps, ends): def mk(starts, steps, numpoints): return [[start + i * step for (start, step) in zip(starts, steps)] for i in range(numpoints)] # use round to handle floating point overflows numpoints = [ int(round((end - start) / step + 1)) for (start, step, end) in zip(starts, steps, ends) ] if all(n == numpoints[0] for n in numpoints): if numpoints[0] > 0: if numpoints[0] > 1: return mk(starts, steps, numpoints[0]) else: raise UsageError("invalid number of points. At least two " "points are necessary to define a range " "scan. Please check parameters.") else: raise UsageError("negative number of points. Please check " "parameters. Maybe step parameter has wrong" "sign.") else: raise UsageError("all entries must generate the same number of " "points") scanstr = _infostr("sscan", (dev, ) + args, kwargs) devs, values, restargs = _fixType(dev, args, mkpos) preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(restargs, kwargs, scanstr) Scan(devs, values, None, move, multistep, detlist, envlist, preset, scaninfo).run()
def walltimecount(numpoints, walltime, *args, **kwargs): """Count a number of times for the given amount of time on wall. "numpoints" can be -1 to scan for unlimited points (break using Ctrl-C or the GUI to quit). "walltime" provides the time in seconds Example: >>> walltimecount(500, 10) # counts 500 times, every count for 10 seconds A special "delay" argument is supported to allow time delays between two points: >>> walltimecount(500, 2, delay=5) """ scanstr = _infostr('walltimecount', ( numpoints, walltime, ) + args, kwargs) preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(args, kwargs, scanstr) # Get AMOR detector if not detlist: detlist = session.experiment.detectors detector = None for det in detlist: if isinstance(det, SinqDetector): detector = det if not detector: session.log.error('Detector not found in the detector list') # Set the beam threshold to 0 oldthreshold = detector.threshold # Complete the scan scan = WallTimeScan([], [], numpoints, walltime, move, multistep, detlist, envlist, preset, scaninfo) scan.run() # Reset the beam threshold to oldvalue detector.threshold = oldthreshold
def mscan(settings, dev, *args, **kwargs): """MIEZE scan over device(s). First argument is a list of MIEZE settings or -1 to scan all settings. All other arguments are handled like for `scan`. """ def mkpos(starts, steps, numsteps): return [[start + i * step for (start, step) in zip(starts, steps)] for i in range(numsteps)] scanstr = _infostr('mscan', (settings, dev) + args, kwargs) devs, values, restargs = _fixType(dev, args, mkpos) preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(restargs, kwargs, scanstr) MiezeScan(settings, devs, values, move, multistep, detlist, envlist, preset, scaninfo).run()
def atscan(time, *args, **kwargs): """A timescan that has an adjustable running time.""" time = parseDuration(time, 'atscan') scanstr = _infostr('vartimescan', (time, ) + args, kwargs) target = kwargs.pop('target', 'eta') preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(args, kwargs, scanstr) scan = VariableTimeScan([], [], move, multistep, detlist, envlist, preset, scaninfo, totaltime=time, target=target) scan.run()
def __init__(self, settings, args, kwargs): # pylint: disable=super-init-not-called scanstr = _infostr('mmanualscan', (settings, ) + args, kwargs) preset, scaninfo, detlist, envlist, move, multistep = \ _handleScanArgs(args, kwargs, scanstr) self.scan = MiezeManualScan(settings, move, multistep, detlist, envlist, preset, scaninfo)