def test_timescan(beacon): session = beacon.get("test_session") session.setup() counter_class = getattr(setup_globals, 'TestScanGaussianCounter') counter = counter_class("gaussian", 10, cnt_time=0.1) s = scans.timescan(0.1, counter, npoints=10, return_scan=True, save=False) scan_data = scans.get_data(s) assert numpy.array_equal(scan_data['gaussian'], counter.data)
def test_ascan(beacon): session = beacon.get("test_session") session.setup() counter_class = getattr(setup_globals, 'TestScanGaussianCounter') m1 = getattr(setup_globals, 'm1') counter = counter_class("gaussian", 10, cnt_time=0) s = scans.ascan(m1, 0, 10, 10, 0, counter, return_scan=True, save=False) assert m1.position() == 10 scan_data = scans.get_data(s) assert numpy.array_equal(scan_data['gaussian'], counter.data)
def test_pointscan(beacon): session = beacon.get("test_session") session.setup() m0 = getattr(setup_globals, 'm0') counter_class = getattr(setup_globals, 'TestScanGaussianCounter') counter = counter_class("gaussian", 10, cnt_time=0) print counter.data points = [0.0, 1.0, 3.0, 7.0, 8.0, 10.0, 12.0, 15.0, 20.0, 50.0] s = scans.pointscan(m0, points, 0, counter, return_scan=True, save=False) assert m0.position() == 50.0 scan_data = scans.get_data(s) assert numpy.array_equal(scan_data['m0'], points) assert numpy.array_equal(scan_data['gaussian'], counter.data)
def test_mca_default_chain_ascan(beacon): # Get controllers m0 = beacon.get('m0') mca = beacon.get('simu1') # Counters counters = mca.counters.spectrum.values() counters += mca.counters.realtime.values() counters += mca.counters.events.values() # Run scan scan = scans.ascan( m0, 0, 10, 3, 0.1, *counters, return_scan=True, save=False) # Checks assert_data_consistency(scans.get_data(scan), realtime=0.1)
def test_dscan(beacon): session = beacon.get("test_session") session.setup() counter_class = getattr(setup_globals, 'TestScanGaussianCounter') counter = counter_class("gaussian", 10, cnt_time=0) m1 = getattr(setup_globals, 'm1') # contrary to ascan, dscan returns to start pos start_pos = m1.position() s = scans.dscan(m1, -2, 2, 10, 0, counter, return_scan=True, save=False) assert m1.position() == start_pos scan_data = scans.get_data(s) assert numpy.allclose(scan_data['m1'], numpy.linspace(start_pos-2, start_pos+2, 10), atol=5e-4) assert numpy.array_equal(scan_data['gaussian'], counter.data)
def test_dscan(beacon): session = beacon.get("test_session") session.setup() counter_class = getattr(setup_globals, 'TestScanGaussianCounter') counter = counter_class("gaussian", 10, cnt_time=0) m1 = getattr(setup_globals, 'm1') # contrary to ascan, dscan returns to start pos start_pos = m1.position() s = scans.dscan(m1, -2, 2, 10, 0, counter, return_scan=True, save=False) assert m1.position() == start_pos scan_data = scans.get_data(s) assert numpy.allclose(scan_data['m1'], numpy.linspace(start_pos - 2, start_pos + 2, 10), atol=5e-4) assert numpy.array_equal(scan_data['gaussian'], counter.data)
def test_mca_step_soft_scan(beacon): m0 = beacon.get("roby") # Get mca simu = beacon.get("simu1") mca_device = McaAcquisitionDevice(simu, npoints=3, preset_time=0.1) # Add counters mca_device.add_counters(simu.counters.spectrum.values()) mca_device.add_counters(simu.counters.realtime.values()) mca_device.add_counters(simu.counters.events.values()) # Create chain chain = AcquisitionChain() chain.add(LinearStepTriggerMaster(3, m0, 0, 1), mca_device) # Run scan scan = Scan(chain, 'mca_test', None) scan.run() # Checks assert_data_consistency(scans.get_data(scan), realtime=0.1)
def test_mca_continuous_sync_scan(beacon): m0 = beacon.get("roby") # Get mca simu = beacon.get("simu1") mca_device = McaAcquisitionDevice( simu, block_size=2, npoints=5, trigger_mode=McaAcquisitionDevice.SYNC) # Add counters mca_device.add_counters(simu.counters.spectrum.values()) mca_device.add_counters(simu.counters.realtime.values()) mca_device.add_counters(simu.counters.events.values()) # Create chain chain = AcquisitionChain() chain.add(MotorMaster(m0, 0, 1, time=1.0), mca_device) # Run scan scan = Scan(chain, 'mca_test', None) scan.run() # Checks assert_data_consistency(scans.get_data(scan), realtime=0.4)