def test_get_pulses(self): pulse_sequence = PulseSequence() self.assertListEqual(pulse_sequence.get_pulses(), []) pulse1 = DCPulse(name='dc1', amplitude=1.5, duration=10, t_start=1) pulse2 = DCPulse(name='dc2', amplitude=2.5, duration=10, t_start=1) pulse3 = TriggerPulse(name='trig', duration=12, t_start=1) pulse_sequence.add(pulse1, pulse2, pulse3) subset_pulses = pulse_sequence.get_pulses() self.assertEqual(subset_pulses[0], pulse1) self.assertListEqual(subset_pulses, [pulse1, pulse2, pulse3]) subset_pulses = pulse_sequence.get_pulses(t_start=1) self.assertListEqual(subset_pulses, [pulse1, pulse2, pulse3]) subset_pulses = pulse_sequence.get_pulses(duration=10) self.assertListEqual(subset_pulses, [pulse1, pulse2]) subset_pulses = pulse_sequence.get_pulses(amplitude=1.5) self.assertListEqual(subset_pulses, [pulse1]) subset_pulses = pulse_sequence.get_pulses(amplitude=('>', 1.5)) self.assertListEqual(subset_pulses, [pulse2]) subset_pulses = pulse_sequence.get_pulses(amplitude=('>=', 1.5)) self.assertListEqual(subset_pulses, [pulse1, pulse2]) pulse = pulse_sequence.get_pulse(amplitude=1.5) self.assertEqual(pulse, pulse1) pulse = pulse_sequence.get_pulse(duration=12) self.assertEqual(pulse, pulse3) with self.assertRaises(RuntimeError): pulse_sequence.get_pulse(duration=10)
def test_get_pulses_connection(self): connection = SingleConnection(output_instrument='ins1', output_channel=Channel('ins1', 'ch1'), input_instrument='ins2', input_channel=Channel('ins1', 'ch1'), label='connection') pulse_sequence = PulseSequence() pulse1, pulse2 = pulse_sequence.add( Pulse('pulse1', duration=1, connection=connection), Pulse('pulse1', duration=2)) retrieved_pulse = pulse_sequence.get_pulse(connection=connection) self.assertEqual(retrieved_pulse, pulse1) retrieved_pulse = pulse_sequence.get_pulse( name='pulse1', connection_label='connection') self.assertEqual(retrieved_pulse, pulse1) pulse2.connection_label = 'connection' self.assertEqual(len(pulse_sequence.get_pulses(connection=connection)), 2)
def test_multipulse(self): self.layout.acquisition_channels([]) self.layout.primary_instrument('pulseblaster') self.layout.acquisition_instrument('ATS') self.layout.add_connection(output_arg='pulseblaster.ch1', input_arg='arbstudio.trig_in', trigger=True) self.layout.add_connection(output_arg='pulseblaster.ch2', input_arg='ATS.trig_in', trigger=True) c1 = self.layout.add_connection(output_arg='arbstudio.ch1', input_arg='chip.TGAC', pulse_modifiers={'amplitude_scale': 1}) c2 = self.layout.add_connection( output_arg='arbstudio.ch2', input_arg='chip.DF', pulse_modifiers={'amplitude_scale': -1.5}) c3 = self.layout.add_connection(output_arg='arbstudio.ch3', input_arg='ATS.chC') self.layout.combine_connections(c1, c2, default=True) self.layout.add_connection(output_arg='chip.output', input_arg='ATS.chA') self.layout.acquisition_channels([('chip.output', 'output'), ('arbstudio.ch3', 'pulses')]) trigger_connections = self.layout.get_connections( input_instrument='arbstudio', trigger=True) self.assertEqual(len(trigger_connections), 1) trigger_connection = trigger_connections[0] self.assertEqual(trigger_connection.output['instrument'], 'pulseblaster') pulse_sequence = PulseSequence() empty_pulse = DCPulse(name='empty', t_start=0, duration=10, amplitude=1.5) load_pulse = DCPulse(name='load', t_start=10, duration=10, amplitude=-1.5) read_pulse = DCPulse(name='read', t_start=20, duration=10, amplitude=0, acquire=True) pulses = [empty_pulse, load_pulse, read_pulse] for pulse in pulses: pulse_sequence.add(pulse) self.layout.pulse_sequence = pulse_sequence self.layout.setup(samples=100) # Test pulseblaster self.assertEqual(len(self.interfaces['pulseblaster'].pulse_sequence), 4) self.assertEqual(len(self.pulseblaster.instructions()), 7) self.assertEqual([ins[0] for ins in self.pulseblaster.instructions()], [1, 0, 1, 0, 3, 0, 0]) self.assertEqual(self.pulseblaster.instructions()[-1][2], 1) # Test arbstudio pulse_sequence = self.interfaces['arbstudio'].pulse_sequence self.assertEqual(len(pulse_sequence), 6) pulses_ch1 = pulse_sequence.get_pulses(output_arg='arbstudio.ch1') self.assertEqual([p.t_start for p in pulses_ch1], [0, 10, 20]) self.assertEqual([p.amplitude for p in pulses_ch1], [1.5, -1.5, 0]) pulses_ch2 = pulse_sequence.get_pulses(output_arg='arbstudio.ch2') self.assertEqual([p.t_start for p in pulses_ch2], [0, 10, 20]) self.assertEqual([p.amplitude for p in pulses_ch2], [-2.25, 2.25, 0]) # Test ATS pulse_sequence = self.interfaces['ATS'].pulse_sequence input_pulse_sequence = self.interfaces['ATS'].input_pulse_sequence self.assertEqual(len(pulse_sequence), 2) self.assertEqual(len(input_pulse_sequence), 1) configuration_settings = self.interfaces['ATS'].configuration_settings( ) acquisition_settings = self.interfaces['ATS'].acquisition_settings() self.assertEqual(acquisition_settings['buffers_per_acquisition'], 100) self.assertTrue( abs(acquisition_settings['samples_per_record'] - 1000) < 16) self.assertEqual(acquisition_settings['channel_selection'], 'AC')