def test_baseband_sweep():
    num_tones = 16
    num_waveforms = 2 ** 5
    num_tone_samples = 2 ** 10
    length_seconds = 0.1
    ri = RoachBaseband(roach=MockRoach("roach"), initialize=False, adc_valon=MockValon())
    center_frequencies = np.linspace(100, 200, num_tones)
    offsets = np.linspace(-20e-3, 20e-3, num_waveforms)
    tone_banks = [center_frequencies + offset for offset in offsets]
    state = {"something": "something state"}

    # Load waveforms one at a time.
    sweep = acquire.run_sweep(
        ri=ri,
        tone_banks=tone_banks,
        num_tone_samples=num_tone_samples,
        length_seconds=length_seconds,
        state=state,
        description="description",
    )
    assert len(sweep.stream_arrays) == num_waveforms
    assert all([stream_array.s21_raw.shape[0] == num_tones for stream_array in sweep.stream_arrays])

    # Pre-load all waveforms.
    acquire.load_baseband_sweep_tones(ri, tone_banks, num_tone_samples)
    sweep = acquire.run_loaded_sweep(ri=ri, length_seconds=length_seconds, state=state, description="description")
    assert len(sweep.stream_arrays) == num_waveforms
    assert all([stream_array.s21_raw.shape[0] == num_tones for stream_array in sweep.stream_arrays])
Beispiel #2
0
def test_baseband_sweep():
    num_tones = 16
    num_waveforms = 2**5
    num_tone_samples = 2**10
    length_seconds = 0.1
    ri = RoachBaseband(roach=MockRoach('roach'),
                       initialize=False,
                       adc_valon=MockValon())
    center_frequencies = np.linspace(100, 200, num_tones)
    offsets = np.linspace(-20e-3, 20e-3, num_waveforms)
    tone_banks = [center_frequencies + offset for offset in offsets]
    state = {'something': 'something state'}

    # Load waveforms one at a time.
    sweep = acquire.run_sweep(ri=ri,
                              tone_banks=tone_banks,
                              num_tone_samples=num_tone_samples,
                              length_seconds=length_seconds,
                              state=state,
                              description="description")
    assert len(sweep.stream_arrays) == num_waveforms
    assert all([
        stream_array.s21_raw.shape[0] == num_tones
        for stream_array in sweep.stream_arrays
    ])

    # Pre-load all waveforms.
    acquire.load_baseband_sweep_tones(ri, tone_banks, num_tone_samples)
    sweep = acquire.run_loaded_sweep(ri=ri,
                                     length_seconds=length_seconds,
                                     state=state,
                                     description="description")
    assert len(sweep.stream_arrays) == num_waveforms
    assert all([
        stream_array.s21_raw.shape[0] == num_tones
        for stream_array in sweep.stream_arrays
    ])
                141.123,
                145.652,
                170.508,
                193.611,
                195.439,
                201.111])

current_f0s = f0s
nsamp = 2**20
step = 1
nstep = 48
offset_bins = legacy_acquire.offset_integers[20]
offsets = offset_bins * 512.0 / nsamp

tic = time.time()
measured_frequencies = acquire.load_baseband_sweep_tones(ri,np.add.outer(offsets,current_f0s),num_tone_samples=nsamp)
logger.info("waveforms loaded in %.1f minutes", (time.time()-tic)/60.)

logger.info(sourcemeter.identify())
sourcemeter.set_current_source()
sourcemeter.set_current_amplitude(0.0)
sourcemeter.enable_output()
ri.set_modulation_output('low')

#ri.set_dac_atten(36)
first = True
#while True: #for dac_atten in [40,36,32,28,24,20]:
for led_current in np.array([0.0,0.1,1,2,4,8])*1e-3:
    sourcemeter.set_current_amplitude(led_current)
    dac_atten = 28
    ri.set_dac_atten(dac_atten)
ri = baseband.RoachBaseband()
ri.initialize()
ri.set_fft_gain(6)

f0s = np.array([104.293, 110.995, 141.123, 145.652, 170.508, 193.611, 195.439, 201.111])

current_f0s = f0s
nsamp = 2 ** 20
step = 1
nstep = 48
offset_bins = legacy_acquire.offset_integers[20]
offsets = offset_bins * 512.0 / nsamp

tic = time.time()
measured_frequencies = acquire.load_baseband_sweep_tones(ri, np.add.outer(offsets, current_f0s), num_tone_samples=nsamp)
logger.info("waveforms loaded in %.1f minutes", (time.time() - tic) / 60.0)

logger.info(sourcemeter.identify())
sourcemeter.set_current_source()
sourcemeter.set_current_amplitude(0.0)
sourcemeter.enable_output()
ri.set_modulation_output("low")

# ri.set_dac_atten(36)
first = True
# while True: #for dac_atten in [40,36,32,28,24,20]:
for led_current in np.array([0.0, 0.1, 1, 2, 4, 8]) * 1e-3:
    sourcemeter.set_current_amplitude(led_current)
    dac_atten = 28
    ri.set_dac_atten(dac_atten)