Example #1
0
def check_fermat_plan(xrange, yrange, dr, factor):
    xmotor = nano_stage.sx
    ymotor = nano_stage.sy
    plot_raster_path(
        rel_spiral_fermat([], xmotor, ymotor, xrange, yrange, dr, factor),
        xmotor.name, ymotor.name)
    ax = plt.gca()
    line = ax.lines[0]
    print(f'The scan will have {len(line.get_xdata())} points.')
Example #2
0
def test_old_module_name(hw):
    det = hw.det
    motor = hw.motor
    motor1 = hw.motor1
    motor2 = hw.motor2
    from bluesky.plan_tools import (print_summary, print_summary_wrapper,
                                    plot_raster_path)
    with pytest.warns(UserWarning):
        print_summary(scan([det], motor, -1, 1, 10))
    with pytest.warns(UserWarning):
        list(print_summary_wrapper(scan([det], motor, -1, 1, 10)))
    with pytest.warns(UserWarning):
        plan = grid_scan([det], motor1, -5, 5, 10, motor2, -7, 7, 15, True)
        plot_raster_path(plan, 'motor1', 'motor2', probe_size=.3)
Example #3
0
def fermat_master_plan(*args, exp_time=None, **kwargs):
    # Synchronize exposure times
    sclr1.preset_time.put(exp_time)
    xs.external_trig.put(False)
    xs.settings.acquire_time.put(exp_time)
    merlin.cam.acquire_time.put(exp_time)
    merlin.cam.acquire_period.put(exp_time + 0.005)

    scan_md = {}
    get_stock_md(scan_md)
    scan_md['scan']['merlin'] = {
        'merlin_exp_time': exp_time,
        'merlin_exp_period': exp_time + 0.005
    }

    plan = bp.rel_spiral_fermat(*args, **kwargs)
    d = plot_raster_path(plan,
                         args[1].name,
                         args[2].name,
                         probe_size=.001,
                         lw=0.5)
    num_points = d['path'].get_path().vertices.shape[0]

    print(f"Number of points: {num_points}")
    xs.total_points.put(num_points)
    yield from bps.mv(merlin.total_points, num_points, merlin.hdf5.num_capture,
                      num_points)
    merlin.hdf5.stage_sigs['num_capture'] = num_points
    yield from rel_spiral_fermat(*args, **kwargs, md=scan_md)
Example #4
0
def plot_raster_path(plan, x_motor, y_motor, ax=None, probe_size=None, lw=2):
    """Plot the raster path for this plan

    Parameters
    ----------
    plan : iterable
       Must yield `Msg` objects and not be a co-routine

    x_motor, y_motor : str
       Names of the x and y motors

    ax : matplotlib.axes.Axes
       The axes to plot to, if none, make new figure + axes

    probe_size : float, optional
       If not None, use as radius of probe (in same units as motor positions)

    lw : float, optional
        Width of lines drawn between points
    """
    warn("The bluesky.plan_tools module is deprecated. Use "
         "bluesky.simulators instead.")
    return _bs.plot_raster_path(plan,
                                x_motor,
                                y_motor,
                                ax=ax,
                                probe_size=probe_size,
                                lw=lw)
Example #5
0
from bluesky.simulators import plot_raster_path
from ophyd.sim import motor1, motor2, det
from bluesky.plans import spiral

plan = spiral([det], motor1, motor2, x_start=0.0, y_start=0.0, x_range=1.,
              y_range=1.0, dr=0.1, nth=10)
plot_raster_path(plan, 'motor1', 'motor2', probe_size=.01)
Example #6
0
def test_plot_raster_path(hw):
    det = hw.det
    motor1 = hw.motor1
    motor2 = hw.motor2
    plan = grid_scan([det], motor1, -5, 5, 10, motor2, -7, 7, 15, True)
    plot_raster_path(plan, 'motor1', 'motor2', probe_size=.3)
from bluesky.simulators import plot_raster_path
from ophyd.sim import motor1, motor2, det
from bluesky.plans import grid_scan
import matplotlib.pyplot as plt

true_plan = grid_scan([det], motor1, -5, 5, 10, motor2, -7, 7, 15, True)
false_plan = grid_scan([det], motor1, -5, 5, 10, motor2, -7, 7, 15, False)

fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
plot_raster_path(true_plan, 'motor1', 'motor2', probe_size=.3, ax=ax1)
plot_raster_path(false_plan, 'motor1', 'motor2', probe_size=.3, ax=ax2)
ax1.set_title('True')
ax2.set_title('False')
ax1.set_xlim(-6, 6)
ax2.set_xlim(-6, 6)
Example #8
0
# Inspect plans
# -------------
#
# Use ``print_summary`` which translates the plan into a human-readable list
# of steps.

print_summary(count([det]))
print_summary(scan([det], motor, 1, 3, 3))
print_summary(
    outer_product_scan([det], motor1, 1, 3, 3, motor2, 1, 2, 2, False))

###############################################################################
# Use ``plot_raster_path`` to visualize a two-dimensional trajectory.

plot_raster_path(
    outer_product_scan([det], motor1, 1, 3, 3, motor2, 1, 2, 2, False),
    'motor1', 'motor2')

###############################################################################
# Note that ``print_summary`` cannot be used on plans the require feedback from
# the hardware, such as adaptively-spaced step scans.
#
# Rehearse plans
# --------------
#
# Simply execute the plan as usual --- ``RE(plan)`` --- but define that plan
# using the simulated motors and detectors from ``bluesky.examples`` instead of
# the variables that represent real hardware.

RE(count([det]))  # executes the plan, 'reading' the simulated detector