コード例 #1
0
ファイル: test_spec.py プロジェクト: ericdill/suitcase
def test_round_trip_from_run_engine():
    try:
        import bluesky
    except ImportError as ie:
        raise pytest.skip('ImportError: {0}'.format(ie))
    # generate a new specfile
    from bluesky.tests.utils import setup_test_run_engine
    from bluesky.examples import motor, det
    from bluesky.global_state import gs
    from bluesky.spec_api import dscan, ascan, ct
    RE = setup_test_run_engine()
    RE.ignore_callback_exceptions = False
    fname = tempfile.NamedTemporaryFile().name
    cb = DocumentToSpec(fname)
    RE.subscribe('all', cb)
    gs.DETS = [det]
    RE(dscan(motor, -1, 1, 10))
    RE(ascan(motor, -1, 1, 10))
    # add count to hit some lines in
    #   suitcase.spec:_get_motor_name
    #   suitcase.spec:_get_motor_position
    #   suitcase.spec:_get_plan_type
    RE(ct())

    sf = Specfile(fname)
    sf1 = _round_trip(sf)

    assert len(sf) == len(sf1)
コード例 #2
0
ファイル: test_spec.py プロジェクト: BCDA-APS/suitcase
def test_round_trip_from_run_engine(mds_all):
    try:
        import bluesky
    except ImportError as ie:
        raise pytest.skip('ImportError: {0}'.format(ie))
    # generate a new specfile
    from bluesky.tests.utils import setup_test_run_engine
    from bluesky.examples import motor, det, motor1
    from bluesky.global_state import gs
    from bluesky.spec_api import dscan, ascan, ct, a2scan
    RE = setup_test_run_engine()
    fname = tempfile.NamedTemporaryFile().name
    cb = spec.DocumentToSpec(fname)
    RE.subscribe('all', cb)
    gs.DETS = [det]
    RE(dscan(motor, -1, 1, 10))
    RE(ascan(motor, -1, 1, 10))
    # add count to hit some lines in
    #   suitcase.spec:_get_motor_name
    #   suitcase.spec:_get_motor_position
    #   suitcase.spec:_get_plan_type
    RE(ct())

    RE(a2scan(motor, -1, 1, motor1, -1, 1, 10))

    sf = spec.Specfile(fname)
    sf1 = _round_trip(sf, mds_all)

    # a2scan is not round trippable
    num_unconvertable_scans = 1

    assert len(sf) == (len(sf1) + num_unconvertable_scans)
コード例 #3
0
ファイル: test_simple_api.py プロジェクト: ericdill/bluesky
def test_basic_usage():
    try:
        import metadatastore
    except ImportError:
        raise nose.SkipTest
    from bluesky.global_state import gs
    from bluesky.spec_api import (ct, ascan, a2scan, a3scan, dscan, d2scan,
                                  d3scan, mesh, tscan, dtscan, th2th)
    gs.DETS = [det]
    with assert_raises(TraitError):
        gs.DETS = [det, det]  # no duplicate data keys
    gs.TEMP_CONTROLLER = motor
    gs.TH_MOTOR = motor1
    gs.TTH_MOTOR = motor2
    gs.RE.md['owner'] = 'test'
    gs.RE.md['group'] = 'test'
    gs.RE.md['beamline_id'] = 'test'
    gs.RE.md['config'] = {}
    # without count time specified
    ct()
    ct(num=3)  # passing kwargs through to scan
    ascan(motor, 1, 2, 2)
    a2scan(motor, 1, 2, 2)
    a3scan(motor, 1, 2, 2)
    dscan(motor, 1, 2, 2)
    d2scan(motor, 1, 2, 2)
    d3scan(motor, 1, 2, 2)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3)
    tscan(1, 2, 2)
    dtscan(1, 2, 2)
    th2th(1, 2, 2)
    # with count time specified as positional arg
    ct()
    ascan(motor, 1, 2, 2, 0.1)
    a2scan(motor, 1, 2, 2, 0.1)
    a3scan(motor, 1, 2, 2, 0.1)
    dscan(motor, 1, 2, 2, 0.1)
    d2scan(motor, 1, 2, 2, 0.1)
    d3scan(motor, 1, 2, 2, 0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, 0.1)
    tscan(1, 2, 2, 0.1)
    dtscan(1, 2, 2, 0.1)
    th2th(1, 2, 2, 0.1)
    # with count time specified as keyword arg
    ct()
    ascan(motor, 1, 2, 2, time=0.1)
    a2scan(motor, 1, 2, 2, time=0.1)
    a3scan(motor, 1, 2, 2, time=0.1)
    dscan(motor, 1, 2, 2, time=0.1)
    d2scan(motor, 1, 2, 2, time=0.1)
    d3scan(motor, 1, 2, 2, time=0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, time=0.1)
    tscan(1, 2, 2, time=0.1)
    dtscan(1, 2, 2, time=0.1)
    th2th(1, 2, 2, time=0.1)
    flyer = FlyMagic('wheee', motor, det1, det2)
    gs.FLYERS = [flyer]
    ct()
コード例 #4
0
def test_basic_usage():
    try:
        import metadatastore
    except ImportError:
        raise nose.SkipTest
    from bluesky.global_state import gs
    from bluesky.spec_api import (ct, ascan, a2scan, a3scan, dscan, d2scan,
                                  d3scan, mesh, tscan, dtscan, th2th)
    gs.DETS = [det]
    with assert_raises(TraitError):
        gs.DETS = [det, det]  # no duplicate data keys
    gs.TEMP_CONTROLLER = motor
    gs.TH_MOTOR = motor1
    gs.TTH_MOTOR = motor2
    gs.RE.md['owner'] = 'test'
    gs.RE.md['group'] = 'test'
    gs.RE.md['beamline_id'] = 'test'
    gs.RE.md['config'] = {}
    # without count time specified
    ct()
    ct(num=3)  # passing kwargs through to scan
    ascan(motor, 1, 2, 2)
    a2scan(motor, 1, 2, 2)
    a3scan(motor, 1, 2, 2)
    dscan(motor, 1, 2, 2)
    d2scan(motor, 1, 2, 2)
    d3scan(motor, 1, 2, 2)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3)
    tscan(1, 2, 2)
    dtscan(1, 2, 2)
    th2th(1, 2, 2)
    # with count time specified as positional arg
    ct()
    ascan(motor, 1, 2, 2, 0.1)
    a2scan(motor, 1, 2, 2, 0.1)
    a3scan(motor, 1, 2, 2, 0.1)
    dscan(motor, 1, 2, 2, 0.1)
    d2scan(motor, 1, 2, 2, 0.1)
    d3scan(motor, 1, 2, 2, 0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, 0.1)
    tscan(1, 2, 2, 0.1)
    dtscan(1, 2, 2, 0.1)
    th2th(1, 2, 2, 0.1)
    # with count time specified as keyword arg
    ct()
    ascan(motor, 1, 2, 2, time=0.1)
    a2scan(motor, 1, 2, 2, time=0.1)
    a3scan(motor, 1, 2, 2, time=0.1)
    dscan(motor, 1, 2, 2, time=0.1)
    d2scan(motor, 1, 2, 2, time=0.1)
    d3scan(motor, 1, 2, 2, time=0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, time=0.1)
    tscan(1, 2, 2, time=0.1)
    dtscan(1, 2, 2, time=0.1)
    th2th(1, 2, 2, time=0.1)
コード例 #5
0
ファイル: test_simple_api.py プロジェクト: klauer/bluesky
def test_basic_usage():
    gs.DETS = [det]
    with assert_raises(TraitError):
        gs.DETS = [det, det]  # no duplicate data keys
    gs.TEMP_CONTROLLER = motor
    gs.TH_MOTOR = motor1
    gs.TTH_MOTOR = motor2
    gs.RE.md["group"] = "test"
    gs.RE.md["beamline_id"] = "test"
    gs.RE.md["config"] = {}
    # without count time specified
    ct()
    ascan(motor, 1, 2, 2)
    a2scan(motor, 1, 2, 2)
    a3scan(motor, 1, 2, 2)
    dscan(motor, 1, 2, 2)
    d2scan(motor, 1, 2, 2)
    d3scan(motor, 1, 2, 2)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3)
    tscan(1, 2, 2)
    dtscan(1, 2, 2)
    th2th(1, 2, 2)
    # with count time specified as positional arg
    ct()
    ascan(motor, 1, 2, 2, 0.1)
    a2scan(motor, 1, 2, 2, 0.1)
    a3scan(motor, 1, 2, 2, 0.1)
    dscan(motor, 1, 2, 2, 0.1)
    d2scan(motor, 1, 2, 2, 0.1)
    d3scan(motor, 1, 2, 2, 0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, 0.1)
    tscan(1, 2, 2, 0.1)
    dtscan(1, 2, 2, 0.1)
    th2th(1, 2, 2, 0.1)
    # with count time specified as keyword arg
    ct()
    ascan(motor, 1, 2, 2, time=0.1)
    a2scan(motor, 1, 2, 2, time=0.1)
    a3scan(motor, 1, 2, 2, time=0.1)
    dscan(motor, 1, 2, 2, time=0.1)
    d2scan(motor, 1, 2, 2, time=0.1)
    d3scan(motor, 1, 2, 2, time=0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, time=0.1)
    tscan(1, 2, 2, time=0.1)
    dtscan(1, 2, 2, time=0.1)
    th2th(1, 2, 2, time=0.1)
コード例 #6
0
def test_basic_usage():
    gs.DETS = [det]
    with assert_raises(TraitError):
        gs.DETS = [det, det]  # no duplicate data keys
    gs.TEMP_CONTROLLER = motor
    gs.TH_MOTOR = motor1
    gs.TTH_MOTOR = motor2
    gs.RE.md['group'] = 'test'
    gs.RE.md['beamline_id'] = 'test'
    gs.RE.md['config'] = {}
    # without count time specified
    ct()
    ascan(motor, 1, 2, 2)
    a2scan(motor, 1, 2, 2)
    a3scan(motor, 1, 2, 2)
    dscan(motor, 1, 2, 2)
    d2scan(motor, 1, 2, 2)
    d3scan(motor, 1, 2, 2)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3)
    tscan(1, 2, 2)
    dtscan(1, 2, 2)
    th2th(1, 2, 2)
    # with count time specified as positional arg
    ct()
    ascan(motor, 1, 2, 2, 0.1)
    a2scan(motor, 1, 2, 2, 0.1)
    a3scan(motor, 1, 2, 2, 0.1)
    dscan(motor, 1, 2, 2, 0.1)
    d2scan(motor, 1, 2, 2, 0.1)
    d3scan(motor, 1, 2, 2, 0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, 0.1)
    tscan(1, 2, 2, 0.1)
    dtscan(1, 2, 2, 0.1)
    th2th(1, 2, 2, 0.1)
    # with count time specified as keyword arg
    ct()
    ascan(motor, 1, 2, 2, time=0.1)
    a2scan(motor, 1, 2, 2, time=0.1)
    a3scan(motor, 1, 2, 2, time=0.1)
    dscan(motor, 1, 2, 2, time=0.1)
    d2scan(motor, 1, 2, 2, time=0.1)
    d3scan(motor, 1, 2, 2, time=0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, time=0.1)
    tscan(1, 2, 2, time=0.1)
    dtscan(1, 2, 2, time=0.1)
    th2th(1, 2, 2, time=0.1)
コード例 #7
0
ファイル: test_simple_api.py プロジェクト: ambarb/bluesky
def test_basic_usage():
    gs.DETS = [det]
    gs.TEMP_CONTROLLER = motor
    gs.TH_MOTOR = motor1
    gs.TTH_MOTOR = motor2
    gs.RE.md['group'] = 'test'
    gs.RE.md['beamline_id'] = 'test'
    gs.RE.md['config'] = {}
    # without count time specified
    ct()
    ascan(motor, 1, 2, 2)
    a2scan(motor, 1, 2, 2)
    a3scan(motor, 1, 2, 2)
    dscan(motor, 1, 2, 2)
    d2scan(motor, 1, 2, 2)
    d3scan(motor, 1, 2, 2)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3)
    tscan(1, 2, 2)
    dtscan(1, 2, 2)
    th2th(1, 2, 2)
    # with count time specified as positional arg
    ct()
    ascan(motor, 1, 2, 2, 0.1)
    a2scan(motor, 1, 2, 2, 0.1)
    a3scan(motor, 1, 2, 2, 0.1)
    dscan(motor, 1, 2, 2, 0.1)
    d2scan(motor, 1, 2, 2, 0.1)
    d3scan(motor, 1, 2, 2, 0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, 0.1)
    tscan(1, 2, 2, 0.1)
    dtscan(1, 2, 2, 0.1)
    th2th(1, 2, 2, 0.1)
    # with count time specified as keyword arg
    ct()
    ascan(motor, 1, 2, 2, time=0.1)
    a2scan(motor, 1, 2, 2, time=0.1)
    a3scan(motor, 1, 2, 2, time=0.1)
    dscan(motor, 1, 2, 2, time=0.1)
    d2scan(motor, 1, 2, 2, time=0.1)
    d3scan(motor, 1, 2, 2, time=0.1)
    mesh(motor1, 1, 2, 2, motor2, 1, 2, 3, time=0.1)
    tscan(1, 2, 2, time=0.1)
    dtscan(1, 2, 2, time=0.1)
    th2th(1, 2, 2, time=0.1)
コード例 #8
0
ファイル: scans.py プロジェクト: licode/hxntools
def absolute_scan(motor, start, finish, intervals, time=None, *, md=None):
    yield from _pre_scan(total_points=intervals + 1, count_time=time)
    yield from spec_api.ascan(motor, start, finish, intervals, time, md=md)
コード例 #9
0
def sample_plan(sample_list):
    for sample in sample_list:
        s_range = sample_ranges[sample]
        yield from ascan(motor, intervals=10, md={'sample': sample}, **s_range)