예제 #1
0
파일: test_plans.py 프로젝트: st3107/xpdAcq
def test_create_dark_frame_preprocessor():
    det = DiffractionDetector(name="det")
    shutter = Shutter(name="shutter")
    xbp = XrayBasicPlans(shutter, "open", "closed", None)
    dark_frame_preprocessor = xbp.create_dark_frame_preprocessor(detector=det,
                                                                 max_age=3600)
    summarize_plan(dark_frame_preprocessor(xbp.count([det], 2)))
예제 #2
0
def test_daq_fixed_target_scan(RE, daq, hw, sample_file):
    logger.debug('test_daq_fixed_target_scan')
    ss = [1, 2]

    msgs = list(
        nbp.daq_fixed_target_scan(sample='test_sample',
                                  detectors=[hw.det],
                                  x_motor=hw.motor1,
                                  y_motor=hw.motor2,
                                  scan_motor=hw.motor3,
                                  ss=ss,
                                  n_shots=3,
                                  path=sample_file,
                                  record=True,
                                  events=1))
    configure_message = None
    for msg in msgs:
        if msg.command == 'configure' and msg.obj is daq:
            configure_message = msg
            break

    assert configure_message.kwargs['record'] is True
    assert configure_message.kwargs['controls'] == [
        hw.motor1, hw.motor2, hw.motor3
    ]
    RE(msgs)
    summarize_plan(msgs)
예제 #3
0
def test_count_with_calib():
    if "shutter" not in xpd_configuration:
        xpd_configuration["shutter"] = shctl1
    poni_file = rs_fn("xpdacq", "tests/Ni_poni_file.poni")
    md = xbt.load_calibration_md(poni_file)
    plan = xbt.count_with_calib([pe1c], num=2, delay=3, calibration_md=md)
    summarize_plan(plan)
예제 #4
0
파일: test_plans.py 프로젝트: st3107/xpdAcq
def test_MultiDistPlans(fake_devices, calib_data, db):
    ai0 = pyFAI.AzimuthalIntegrator(dist=0)
    ai1 = pyFAI.AzimuthalIntegrator(dist=1)
    mdp = MultiDistPlans(fake_devices.motor1, 0, 1, db, fake_devices.motor2,
                         calib_data, fake_devices.motor2)
    mdp.add_dist(0, "test0", ai0)
    mdp.add_dist(1, "test1", ai1)
    summarize_plan(mdp.count([fake_devices.det1], 2))
예제 #5
0
def test_my_list_grid_scan1():
    xpd_configuration["shutter"] = shctl1
    motor = hw().motor
    plan = my_list_grid_scan(xpd_pe1c,
                             motor, [1.],
                             cs700, [300., 400., 500.],
                             acquire_time=0.2,
                             images_per_set=300,
                             wait_for_step=20.)
    summarize_plan(plan)
예제 #6
0
파일: plans.py 프로젝트: st3107/xpdAcq
 def print_plan(self, *plans: Union[int, str]):
     """
     Print the plan information.
     Parameters
     ----------
     plans
         The plan index or plan name key
     """
     for plan in plans:
         plan_gen = self.get_plan(plan)
         summarize_plan(plan_gen)
예제 #7
0
def test_grid_scan():
    trigger_and_read = helper.shutter_wrapper(bps.trigger_and_read,
                                              movers.shctl1, 0, 100, 0)
    one_nd_step = helper.take_reading_wrapper(bps.one_nd_step,
                                              trigger_and_read)
    plan = bp.grid_scan([movers.cs700],
                        movers.cs700,
                        -1,
                        1,
                        3,
                        per_step=one_nd_step)
    sim.summarize_plan(plan)
예제 #8
0
def test_daq_fixed_target_multi_scan(RE, daq, hw, sample_file):
    logger.debug('test_daq_fixed_target_scan')
    ss = [1, 2]

    msgs = list(
        nbp.daq_fixed_target_multi_scan(sample='test_sample',
                                        detectors=[hw.det],
                                        x_motor=hw.motor1,
                                        y_motor=hw.motor2,
                                        scan_motor=hw.motor3,
                                        ss=ss,
                                        n_shots=3,
                                        path=sample_file,
                                        record=True,
                                        events=1))
    configure_message = None
    for msg in msgs:
        if msg.command == 'configure' and msg.obj is daq:
            configure_message = msg
            break

    assert configure_message.kwargs['record'] is True
    assert configure_message.kwargs['controls'] == [
        hw.motor1, hw.motor2, hw.motor3
    ]

    expected_moves = [
        1,  # scan_motor[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        2,  # scan_motor[1]
        -20.342057291666624,  # x[1]
        26.412369791666656,
        -20.342057291666624,  # x[1]
        26.412369791666656,
        -20.342057291666624,  # x[1]
        26.412369791666656
    ]  # y[1]

    moves = [msg.args[0] for msg in msgs if msg.command == 'set']
    reads = [msg for msg in msgs if msg.command == 'read']
    assert moves == expected_moves
    assert len(reads) == 24
    RE(msgs)
    summarize_plan(msgs)
예제 #9
0
def test_fixed_target_scan(RE, hw, sample_file):
    logger.debug('test_fixed_target_scan')
    ss = [1, 2]

    msgs = list(
        nbp.fixed_target_scan(sample='test_sample',
                              detectors=[hw.det],
                              x_motor=hw.motor1,
                              y_motor=hw.motor2,
                              scan_motor=hw.motor3,
                              ss=ss,
                              n_shots=3,
                              path=sample_file))
    expected_moves = [
        1,  # scan_motor[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        -20.342057291666624,  # x[1]
        26.412369791666656,  # y[1]
        -20.090364583333283,  # x[2]
        26.41028645833332,  # y[2]
        2,  # scan_motor[1]
        -19.838671874999946,  # x[3]
        26.408203124999986,  # y[3]
        -19.834546874999948,  # x[4]
        26.664453124999994,  # y[4]
        -20.08622265624995,  # x[5]
        26.66232812499999
    ]  # y[5]

    moves = [msg.args[0] for msg in msgs if msg.command == 'set']
    assert moves == expected_moves

    RE(msgs)
    summarize_plan(msgs)

    with pytest.raises(IndexError):
        RE(
            nbp.fixed_target_scan(sample='test_sample',
                                  detectors=[hw.det],
                                  x_motor=hw.motor1,
                                  y_motor=hw.motor2,
                                  scan_motor=hw.motor3,
                                  ss=ss,
                                  n_shots=10,
                                  path=sample_file))
예제 #10
0
    def test_addDeviceDataAsStream(self):
        with Capture_stdout() as received:
            summarize_plan(
                APS_plans.addDeviceDataAsStream(ophyd.sim.motor1,
                                                "test-device"))

        expected = ["  Read ['motor1']"]
        self.assertEqual(str(received), str(expected))

        with Capture_stdout() as received:
            summarize_plan(
                APS_plans.addDeviceDataAsStream(
                    [ophyd.sim.motor2, ophyd.sim.motor3], "test-device-list"))

        expected = [
            "  Read ['motor2']",  # TODO: <-- Why?
            "  Read ['motor2', 'motor3']",
        ]
        self.assertEqual(str(received), str(expected))
예제 #11
0
def print_summary(plan):
    """Print summary of plan

    Prints a minimal version of the plan, showing only moves and
    where events are created.

    Parameters
    ----------
    plan : iterable
        Must yield `Msg` objects
    """
    warn("bluesky.plan_tools.print_summary is deprecated. Use "
         "bluesky.simulators.summarize_plan instead.")
    return _bs.summarize_plan(plan)
예제 #12
0
def test_fixed_target_multi_scan(RE, hw, sample_file):
    logger.debug('test_fixed_target_multi_scan')
    ss = [1, 2]

    msgs = list(
        nbp.fixed_target_multi_scan(sample='test_sample',
                                    detectors=[hw.det],
                                    x_motor=hw.motor1,
                                    y_motor=hw.motor2,
                                    scan_motor=hw.motor3,
                                    ss=ss,
                                    n_shots=3,
                                    path=sample_file))
    expected_moves = [
        1,  # scan_motor[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        -20.59374999999996,  # x[0]
        26.41445312499999,  # y[0]
        2,  # scan_motor[1]
        -20.342057291666624,  # x[1]
        26.412369791666656,
        -20.342057291666624,  # x[1]
        26.412369791666656,
        -20.342057291666624,  # x[1]
        26.412369791666656
    ]  # y[1]

    moves = [msg.args[0] for msg in msgs if msg.command == 'set']
    reads = [msg for msg in msgs if msg.command == 'read']
    assert moves == expected_moves
    assert len(reads) == 24

    RE(msgs)
    summarize_plan(msgs)
예제 #13
0
파일: test_plans.py 프로젝트: st3107/xpdAcq
def test_BasicPlans(fake_devices, calib_data):
    shutter = Shutter(name="shutter")
    xbp = XrayBasicPlans(shutter, "open", "closed", None)
    summarize_plan(xbp.count([fake_devices.det1], 2))
    summarize_plan(
        xbp.grid_scan([fake_devices.det1], fake_devices.motor1, 2, 3, 2))
    summarize_plan(
        xbp.config_by_poni(
            calib_data, resource_filename("xpdacq",
                                          "tests/Ni_poni_file.poni")))
예제 #14
0
 def dryrun(self, tomo_config):
     """use summarize_plan for quick analysis"""
     return summarize_plan(tomo_scan(self, tomo_config))
예제 #15
0
        "hints": {
            "gridding":
            "rectilinear",
            "dimensions": [
                [["cryostat1_T"], "primary"],
                [["spinner_goniohead_X"], "primary"],
                [["cryostat2_T"], "primary"],
            ],
        }
    },
)

# plan = bpp.subs_wrapper(plan, LiveTable([pe1c, shutter, Det_1_Z, cryostat1, sample_motor]))

# COPY this to your terminal, DO NOT run in script
"""
# prview the plan
summarize_plan(dummy_plan)
# execute the plan
xrun(cryostat_sample_dict, plan, subs=[LiveTable([pe1c, shutter, Det_1_Z, cryostat1, sample_motor])])
_configure_area_det(300)

"""

# AN SIDE
# =================================================================================
"""save_kwargs['string'] = (''
                         '{base_folder}/{folder_prefix}/'
                         '{analysis_stage}/'
                         '{human_timestamp}_'
                         '[temp_{raw_event[data][cryostat1_T]:1.2f}'
예제 #16
0
def test_wrapper_count():
    trigger_and_read = helper.shutter_wrapper(bps.trigger_and_read,
                                              movers.shctl1, 0, 100, 0)
    one_shot = helper.take_reading_wrapper(bps.one_shot, trigger_and_read)
    plan = bp.count([movers.cs700], per_shot=one_shot)
    sim.summarize_plan(plan)
예제 #17
0
def test_print_summary(hw):
    det = hw.det
    motor = hw.motor
    print_summary(scan([det], motor, -1, 1, 10))  # old name
    summarize_plan(scan([det], motor, -1, 1, 10))  # new name
    list(print_summary_wrapper(scan([det], motor, -1, 1, 10)))
예제 #18
0
    def test_run_command_file(self):
        filename = os.path.join(_test_path, "actions.txt")
        with Capture_stdout() as received:
            summarize_plan(APS_plans.run_command_file(filename))

        # print(f"|{received}|")
        expected = [
            f'Command file: {filename}',
            '====== ============ ========================',
            'line # action       parameters              ',
            '====== ============ ========================',
            '5      sample_slits 0, 0, 0.4, 1.2          ',
            '7      preusaxstune                         ',
            '10     FlyScan      0, 0, 0, blank          ',
            '11     FlyScan      5, 2, 0, empty container',
            '12     SAXS         0, 0, 0, blank          ',
            '====== ============ ========================',
            '',
            'file line 5: sample_slits 0 0 0.4 1.2',
            'no handling for line 5: sample_slits 0 0 0.4 1.2',
            'file line 7: preusaxstune',
            'no handling for line 7: preusaxstune',
            'file line 10: FlyScan 0   0   0   blank',
            'no handling for line 10: FlyScan 0   0   0   blank',
            'file line 11: FlyScan 5   2   0   "empty container"',
            'no handling for line 11: FlyScan 5   2   0   "empty container"',
            'file line 12: SAXS 0 0 0 blank',
            'no handling for line 12: SAXS 0 0 0 blank',
        ]
        self.assertEqual(str(received), str(expected))

        filename = os.path.join(_test_path, "actions.xlsx")
        with Capture_stdout() as received:
            summarize_plan(APS_plans.run_command_file(filename))

        # print(f"|{received}|")
        expected = [
            f'Command file: {filename}',
            '====== ============ =============================',
            'line # action       parameters                   ',
            '====== ============ =============================',
            '1      mono_shutter open                         ',
            '2      USAXSscan    45.07, 98.3, 0.0, Water Blank',
            '3      saxsExp      45.07, 98.3, 0.0, Water Blank',
            '4      waxwsExp     45.07, 98.3, 0.0, Water Blank',
            '5      USAXSscan    12, 12.0, 1.2, plastic       ',
            '6      USAXSscan    12, 37.0, 0.1, Al foil       ',
            '7      mono_shutter close                        ',
            '====== ============ =============================', '',
            "file line 1: ['mono_shutter', 'open', None, None, None]",
            "no handling for line 1: ['mono_shutter', 'open', None, None, None]",
            "file line 2: ['USAXSscan', 45.07, 98.3, 0.0, 'Water Blank']",
            "no handling for line 2: ['USAXSscan', 45.07, 98.3, 0.0, 'Water Blank']",
            "file line 3: ['saxsExp', 45.07, 98.3, 0.0, 'Water Blank']",
            "no handling for line 3: ['saxsExp', 45.07, 98.3, 0.0, 'Water Blank']",
            "file line 4: ['waxwsExp', 45.07, 98.3, 0.0, 'Water Blank']",
            "no handling for line 4: ['waxwsExp', 45.07, 98.3, 0.0, 'Water Blank']",
            "file line 5: ['USAXSscan', 12, 12.0, 1.2, 'plastic']",
            "no handling for line 5: ['USAXSscan', 12, 12.0, 1.2, 'plastic']",
            "file line 6: ['USAXSscan', 12, 37.0, 0.1, 'Al foil']",
            "no handling for line 6: ['USAXSscan', 12, 37.0, 0.1, 'Al foil']",
            "file line 7: ['mono_shutter', 'close', None, None, None]",
            "no handling for line 7: ['mono_shutter', 'close', None, None, None]"
        ]
        self.assertEqual(str(received), str(expected))
예제 #19
0
def test_move_and_do_many(RE, bt, args, kwargs):
    plans = move_and_do_many(bt, *args, **kwargs)
    for plan in plans:
        summarize_plan(plan)
예제 #20
0
def test_acq_rel_grid_scan():
    plan = mod.acq_rel_grid_scan([], 30, 5, -1, 1, 3, -1, 1, 3)
    summarize_plan(plan)