logger.info("Sweep span is {:.1f} MHz".format(offset_frequencies_MHz.ptp()))

# Run
ncf = acquire.new_nc_file(suffix='sweep_stream_on_off')
tic = time.time()
try:
    ri.set_tone_baseband_freqs(offset_array_MHz, nsamp=num_tone_samples)
    for lo_index, lo in enumerate(lo_MHz):
        ri.set_lo(lomhz=lo, chan_spacing=lo_round_to_MHz)
        logger.info("Set LO to {:.3f} MHz".format(lo))
        for attenuation in attenuations:
            ri.set_dac_attenuator(attenuation)
            logger.info("Set DAC attenuation to {:.1f} dB".format(attenuation))
            state = hw.state()
            state['lo_index'] = lo_index
            state['temperature'] = {'package': temps.get_temperature_at(time.time())}
            sweep_array = acquire.run_loaded_sweep(ri, length_seconds=sweep_length_seconds,
                                                   tone_bank_indices=np.arange(num_sweep_tones))
            on_sweep = sweep_array[0]
            off_sweep = sweep_array[1]
            f0_MHz = 1e-6 * on_sweep.resonator.f_0
            logger.info("Fit resonance frequency is {:.3f} MHz".format(f0_MHz))
            # Overwrite the last waveform after the first loop.
            is_first_loop = (lo == lo_MHz[0]) & (attenuation == attenuations[0])
            f_stream_MHz = ri.add_tone_freqs(np.array([f0_MHz, f0_MHz + f_stream_offset_MHz]),
                                             overwrite_last=~is_first_loop)
            # NB: it may be true that select_bank() has to be called before select_fft_bins()
            ri.select_bank(num_sweep_tones)
            ri.select_fft_bins(np.arange(f_stream_MHz.size))
            logger.info("Recording {:.1f} s streams at MHz frequencies {}".format(stream_length_seconds, f_stream_MHz))
            stream_array = ri.get_measurement(num_seconds=stream_length_seconds)
예제 #2
0
    'orientation': 'up',
    'distance_from_base_mm': 25
})
hw = hardware.Hardware(conditioner, magnet)
ri = hardware_tools.r2_with_mk2()
ri.set_dac_atten(40)
ri.set_fft_gain(4)
ri.set_modulation_output('high')

# Run
ncf = acquire.new_nc_file(suffix='sweep')
tic = time.time()
try:
    for lo in progress(lo_MHz):
        state = hw.state()
        state['temperature'] = {
            'package': temps.get_temperature_at(time.time())
        }
        tone_banks = np.array([np.array([f]) for f in lo + offsets_MHz])
        ri.set_lo(lomhz=lo, chan_spacing=round_to_MHz)
        sweep = acquire.run_sweep(ri,
                                  tone_banks=tone_banks,
                                  num_tone_samples=num_tone_samples,
                                  length_seconds=length_seconds,
                                  state=state)
        ncf.write(sweep)
finally:
    ncf.close()
    print("Wrote {}".format(ncf.root_path))
    print("Elapsed time {:.0f} minutes.".format((time.time() - tic) / 60))
예제 #3
0
magnet = hardware.Thing('canceling_magnet',
                        {'orientation': 'up',
                         'distance_from_base_mm': 25})
hw = hardware.Hardware(conditioner, magnet)
ri = hardware_tools.r2_with_mk2()
ri.set_dac_atten(40)
ri.set_fft_gain(4)
ri.set_modulation_output('high')

# Run
ncf = acquire.new_nc_file(suffix='sweep_stream')
tic = time.time()
try:
    for lo in progress(lo_MHz):
        state = hw.state()
        state['temperature'] = {'package': temps.get_temperature_at(time.time())}
        tone_banks = (lo + offsets_MHz)[:, np.newaxis]  # Transform to shape (num_offsets, 1)
        ri.set_lo(lomhz=lo, chan_spacing=round_to_MHz)
        sweep_array = acquire.run_sweep(ri, tone_banks=tone_banks, num_tone_samples=num_tone_samples,
                                        length_seconds=sweep_length_seconds)
        single_sweep = sweep_array[0]
        f0_MHz = 1e-6 * single_sweep.resonator.f_0
        ri.set_tone_freqs(np.array([f0_MHz]), nsamp=num_tone_samples)
        ri.select_fft_bins(np.array([0]))
        stream_array = ri.get_measurement(num_seconds=stream_length_seconds)
        single_stream = stream_array[0]
        sweep_stream = basic.SingleSweepStream(sweep=single_sweep, stream=single_stream, state=state,
                                               description='f_0 = {:.1f}'.format(f0_MHz))
        ncf.write(sweep_stream)
finally:
        ncf.close()