Beispiel #1
0
def fermat(x_motor,
           y_motor,
           x_range,
           y_range,
           dr,
           factor,
           time=None,
           *,
           tilt=0.0,
           per_step=None,
           md=None):
    '''Relative fermat spiral scan

    Parameters
    ----------
    x_motor : object
        any 'setable' object (motor, temp controller, etc.)
    y_motor : object
        any 'setable' object (motor, temp controller, etc.)
    x_range : float
        x range of spiral
    y_range : float
        y range of spiral
    dr : float
        delta radius
    factor : float
        radius gets divided by this
    time : float, optional
        applied to any detectors that have a `count_time` setting
    tilt : float, optional
        Tilt angle in radians, default 0.0
    per_step : callable, optional
        hook for cutomizing action of inner loop (messages per step)
        See docstring of bluesky.plans.one_nd_step (the default) for
        details.
    md : dict, optional
        metadata

    See Also
    --------
    `bluesky.spec_api.afermat`
    `bluesky.spec_api.aspiral`
    `bluesky.spec_api.spiral`
    '''
    _md = {'plan_name': 'fermat'}
    _md.update(md or {})
    plan = afermat(x_motor,
                   y_motor,
                   x_motor.position,
                   y_motor.position,
                   x_range,
                   y_range,
                   dr,
                   factor,
                   time=time,
                   tilt=tilt,
                   per_step=per_step,
                   md=_md)
    plan = plans.reset_positions_wrapper(plan)  # return motors to starting pos
    return (yield from plan)
def test_reset_positions_no_position_attr(fresh_RE):
    motor = DummyMover('motor')
    motor.set(5)

    msgs = []

    def accumulator(msg):
        msgs.append(msg)

    fresh_RE.msg_hook = accumulator

    def plan():
        yield from (m for m in [Msg('set', motor, 8)])

    fresh_RE(reset_positions_wrapper(plan()))

    expected = [
        Msg('read', motor),
        Msg('set', motor, 8),
        Msg('set', motor, 5),
        Msg('wait')
    ]

    for msg in msgs:
        msg.kwargs.pop('group', None)

    assert msgs == expected
Beispiel #3
0
def spiral(x_motor,
           y_motor,
           x_range,
           y_range,
           dr,
           nth,
           time=None,
           *,
           tilt=0.0,
           per_step=None,
           md=None):
    '''Relative spiral scan

    Parameters
    ----------
    x_motor : object
        any 'setable' object (motor, temp controller, etc.)
    y_motor : object
        any 'setable' object (motor, temp controller, etc.)
    x_range : float
        X range, in engineering units
    y_range : float
        Y range, in engineering units
    dr : float
        Delta radius, in engineering units
    nth : float
        Number of theta steps
    time : float, optional
        applied to any detectors that have a `count_time` setting
    tilt : float, optional
        Tilt angle in radians, default 0.0
    per_step : callable, optional
        hook for cutomizing action of inner loop (messages per step)
        See docstring of bluesky.plans.one_nd_step (the default) for
        details.
    md : dict, optional
        metadata

    See Also
    --------
    `bluesky.spec_api.fermat`
    `bluesky.spec_api.afermat`
    `bluesky.spec_api.aspiral`
    '''
    _md = {'plan_name': 'spiral'}
    _md.update(md or {})
    plan = aspiral(x_motor,
                   y_motor,
                   x_motor.position,
                   y_motor.position,
                   x_range,
                   y_range,
                   dr,
                   nth,
                   time=time,
                   tilt=tilt,
                   per_step=per_step,
                   md=_md)
    plan = plans.reset_positions_wrapper(plan)  # return to starting pos
    return (yield from plan)
Beispiel #4
0
def spiral(x_motor, y_motor, x_range, y_range, dr, nth, time=None, *,
           tilt=0.0, per_step=None, md=None):
    '''Relative spiral scan

    Parameters
    ----------
    x_motor : object
        any 'setable' object (motor, temp controller, etc.)
    y_motor : object
        any 'setable' object (motor, temp controller, etc.)
    x_range : float
        X range, in engineering units
    y_range : float
        Y range, in engineering units
    dr : float
        Delta radius, in engineering units
    nth : float
        Number of theta steps
    time : float, optional
        applied to any detectors that have a `count_time` setting
    tilt : float, optional
        Tilt angle in radians, default 0.0
    per_step : callable, optional
        hook for cutomizing action of inner loop (messages per step)
        See docstring of bluesky.plans.one_nd_step (the default) for
        details.
    md : dict, optional
        metadata

    See Also
    --------
    `bluesky.spec_api.fermat`
    `bluesky.spec_api.afermat`
    `bluesky.spec_api.aspiral`
    '''
    if md is None:
        md = {}
    md = ChainMap(md, {'plan_name': 'spiral'})
    plan = aspiral(x_motor, y_motor, x_motor.position, y_motor.position,
                   x_range, y_range, dr, nth, time=time, tilt=tilt,
                   per_step=per_step, md=md)
    plan = plans.reset_positions_wrapper(plan)  # return to starting pos
    return (yield from plan)
Beispiel #5
0
def scan_steps(dets, *args, time=None, per_step=None, md=None):
    '''
    Absolute scan over an arbitrary N-dimensional trajectory.

    Parameters
    ----------
    ``*args`` : {Positioner, list/sequence}
        Patterned like
            (``motor1, motor1_positions, ..., motorN, motorN_positions``)
        Where motorN_positions is a list/tuple/sequence of absolute positions
        for motorN to go to.
    time : float, optional
        applied to any detectors that have a `count_time` setting
    per_step : callable, optional
        hook for cutomizing action of inner loop (messages per step)
        See docstring of bluesky.plans.one_nd_step (the default) for
        details.
    md : dict, optional
        metadata
    '''
    if len(args) % 2 == 1:
        if time is not None:
            raise ValueError('Wrong number of positional arguments')
        args, time = args[:-1], args[-1]

    cyclers = [cycler(motor, steps) for motor, steps in chunked(args, 2)]
    cyc = sum(cyclers[1:], cyclers[0])
    total_points = len(cyc)

    if md is None:
        md = {}

    from collections import ChainMap

    md = ChainMap(md, {'plan_name': 'scan_steps'})

    plan = plans.scan_nd(dets, cyc, md=md, per_step=per_step)
    plan = plans.configure_count_time_wrapper(plan, time)

    yield from _pre_scan(dets, total_points=total_points, count_time=time)
    return (yield from plans.reset_positions_wrapper(plan))
def test_reset_positions(fresh_RE):
    motor = Mover('a', {'a': lambda x: x}, {'x': 0})
    motor.set(5)

    msgs = []

    def accumulator(msg):
        msgs.append(msg)

    fresh_RE.msg_hook = accumulator

    def plan():
        yield from (m for m in [Msg('set', motor, 8)])

    fresh_RE(reset_positions_wrapper(plan()))

    expected = [Msg('set', motor, 8), Msg('set', motor, 5), Msg('wait')]

    for msg in msgs:
        msg.kwargs.pop('group', None)

    assert msgs == expected
def test_reset_positions_no_position_attr(fresh_RE):
    motor = DummyMover("motor")
    motor.set(5)

    msgs = []

    def accumulator(msg):
        msgs.append(msg)

    fresh_RE.msg_hook = accumulator

    def plan():
        yield from (m for m in [Msg("set", motor, 8)])

    fresh_RE(reset_positions_wrapper(plan()))

    expected = [Msg("read", motor), Msg("set", motor, 8), Msg("set", motor, 5), Msg("wait")]

    for msg in msgs:
        msg.kwargs.pop("group", None)

    assert msgs == expected
def test_reset_positions(fresh_RE):
    motor = Mover("a", {"a": lambda x: x}, {"x": 0})
    motor.set(5)

    msgs = []

    def accumulator(msg):
        msgs.append(msg)

    fresh_RE.msg_hook = accumulator

    def plan():
        yield from (m for m in [Msg("set", motor, 8)])

    fresh_RE(reset_positions_wrapper(plan()))

    expected = [Msg("set", motor, 8), Msg("set", motor, 5), Msg("wait")]

    for msg in msgs:
        msg.kwargs.pop("group", None)

    assert msgs == expected
Beispiel #9
0
def test_reset_positions(fresh_RE):
    motor = Mover('a', {'a': lambda x: x}, {'x': 0})
    motor.set(5)

    msgs = []

    def accumulator(msg):
        msgs.append(msg)

    fresh_RE.msg_hook = accumulator

    def plan():
        yield from (m for m in [Msg('set', motor, 8)])

    fresh_RE(reset_positions_wrapper(plan()))

    expected = [Msg('set', motor, 8), Msg('set', motor, 5), Msg('wait')]

    for msg in msgs:
        msg.kwargs.pop('group', None)

    assert msgs == expected