def __init__(self): self.stage = stage.Stage() self.stage.initialize() # self.stage.find_home() self.lockin = lockinController(serial_port='/dev/ttyUSB2') print self.lockin.get_idn() self.lockin.send('OFLT 8') # 100 ms self.hittite = None self._have_found_home = False
import time import sys import numpy as np from kid_readout.roach import heterodyne from kid_readout.utils import data_file, sweeps from kid_readout.analysis.resonator import fit_best_resonator from kid_readout.equipment import hittite_controller, lockin_controller # fg = FunctionGenerator() hittite = hittite_controller.hittiteController(addr='192.168.0.200') lockin = lockin_controller.lockinController() print lockin.get_idn() ri = heterodyne.RoachHeterodyne() ri.set_lo(1210.0) f0s = np.load('/data/readout/resonances/2015-11-03-starcryo-nevins-initial-resonances-160mK.npy') suffix = "mmw_frequency_sweep" mmw_source_modulation_freq = ri.set_modulation_output(rate=7) mmw_atten_turns = (7.0, 7.0) print "modulating at: {}".format(mmw_source_modulation_freq), nf = len(f0s) atonce = 32 if nf % atonce > 0: print "extending list of resonators to make a multiple of ", atonce f0s = np.concatenate((f0s, np.arange(1, 1 + atonce - (nf % atonce)) + f0s.max()))
__author__ = 'gjones' import time import sys import numpy as np from kid_readout.roach import heterodyne from kid_readout.utils import data_file, sweeps from kid_readout.equipment import hittite_controller, lockin_controller hittite = hittite_controller.hittiteController(addr='192.168.0.200') lockin = lockin_controller.lockinController() print lockin.get_idn() ri = heterodyne.RoachHeterodyne(adc_valon='/dev/ttyUSB0') ri.iq_delay = 0 ri.set_lo(1410.0) #group_1_lo = 1020.0 #group_2_lo = 1410.0 #all_f0s = np.load('/data/readout/resonances/2016-01-13-jpl-2015-10-park-dark-32-resonances-split-at-1300.npy') -0.5 #group_1_f0 = all_f0s[all_f0s < 1300] #group_2_f0 = all_f0s[all_f0s > 1300] """ all_f0s = np.load('/data/readout/resonances/2016-02-12-jpl-park-100nm-32-resonances.npy') group_1_f0 = all_f0s[all_f0s<1500] group_2_f0 = all_f0s[all_f0s>1800] group_1_lo = 1220.0 group_2_lo = 1810.0 """
def main(f_initial, attenuation, stream_time=30, suffix='compressor_noise', coarse_exponent=19, fine_exponent=21, modulation_state='high', modulation_rate=7, transient_wait=10, f_mmw_source=0, mmw_atten_turns=(np.nan, np.nan),num_streams=1): roach = baseband.RoachBaseband() roach.set_modulation_output(modulation_state) roach.set_dac_attenuator(attenuation) df = data_file.DataFile(suffix=suffix) df.log_hw_state(roach) def prompt(): raw_input("Turn off the compressor and hit Enter to begin.") if modulation_state == 'low': lockin = lockin_controller.lockinController() df.nc.mmw_atten_turns = mmw_atten_turns # Compressor on coarse_sweep_on = acquire.sweep(roach, f_initial, coarse_exponent, transient_wait=transient_wait) f_coarse_on = np.array([r.f_0 for r in acquire.fit_sweep_data(coarse_sweep_on)]) print("Compressor on: coarse - initial [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * delta_f) for delta_f in f_coarse_on - f_initial])) df.log_hw_state(roach) fine_sweep_on = acquire.sweep(roach, f_coarse_on, fine_exponent, transient_wait=transient_wait) f_fine_on = np.array([r.f_0 for r in acquire.fit_sweep_data(fine_sweep_on)]) print("Compressor on: fine - coarse [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * delta_f) for delta_f in f_fine_on - f_coarse_on])) df.add_sweep(fine_sweep_on) df.log_hw_state(roach) on_start_time = time.time() stream_on, address = acquire.timestream(roach, f_fine_on, stream_time, transient_wait=transient_wait) if modulation_state == 'low': roach.set_modulation_output(modulation_rate) time.sleep(5) x, y, r, theta = lockin.get_data() roach.set_modulation_output('low') else: x=0 df.add_timestream_data(stream_on, roach, on_start_time, mmw_source_freq=f_mmw_source, zbd_voltage=x) # Compressor off print("Preparing fine sweep with compressor off.") df.log_hw_state(roach) fine_sweep_off = acquire.sweep(roach, f_coarse_on, fine_exponent, transient_wait=transient_wait, run=prompt) print("Done with fine sweep. Turn on the compressor.") f_fine_off = np.array([r.f_0 for r in acquire.fit_sweep_data(fine_sweep_off)]) print("off - on [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * delta_f) for delta_f in f_fine_off - f_fine_on])) df.add_sweep(fine_sweep_off) df.log_hw_state(roach) off_start_time = time.time() stream_off, address = acquire.timestream(roach, f_fine_on, stream_time, transient_wait=transient_wait, run=prompt) print("Done with stream. Turn on the compressor.") if modulation_state == 'low': roach.set_modulation_output(modulation_rate) time.sleep(5) x, y, r, theta = lockin.get_data() roach.set_modulation_output('high') else: x = np.nan df.add_timestream_data(stream_off, roach, off_start_time, mmw_source_freq=f_mmw_source, zbd_voltage=x) df.sync() df.close() print("Wrote {}".format(df.filename))
def mmw_source_power_step(f_initial_off, f_initial_on, attenuations, f_mmw_source=0, suffix="mmw", hittite_power=0, long_stream_time=30, modulated_stream_time=4, coarse_exponent=19, fine_exponent=21, modulation_rate_integer=7): if f_mmw_source: from kid_readout.equipment import hittite_controller frequency_multiplication_factor = 12 hittite = hittite_controller.hittiteController() hittite.set_power(hittite_power) # in dBm hittite.set_freq(f_mmw_source / frequency_multiplication_factor) # in Hz hittite.on() lockin = lockin_controller.lockinController() print(lockin.get_idn()) roach = baseband.RoachBaseband() n_coarse_samples = 2**coarse_exponent n_fine_samples = 2**fine_exponent coarse_frequency_resolution = roach.fs / n_coarse_samples fine_frequency_resolution = roach.fs / n_fine_samples coarse_offset_integers = offset_integers[coarse_exponent] fine_offset_integers = offset_integers[fine_exponent] f_coarse_offset = coarse_frequency_resolution * coarse_offset_integers f_fine_offset = fine_frequency_resolution * fine_offset_integers while True: f_source_modulation = roach.set_modulation_output( modulation_rate_integer) print( "\nSet source modulation frequency to {:.1f} Hz. Check the lock-in." .format(f_source_modulation)) try: mmw_attenuator_turns = float( raw_input( "Enter the value to which both attenuators are set, or hit Enter to stop recording data: " )) except ValueError: break start_time = time.time() df = data_file.DataFile(suffix=suffix) df.nc.mmw_atten_turns = (mmw_attenuator_turns, mmw_attenuator_turns) maximum_attenuation = max(attenuations) print( "Setting DAC attenuator to maximum requested attenuation of {:.1f} dB." .format(maximum_attenuation)) roach.set_dac_attenuator(maximum_attenuation) # At the lowest readout power, record a coarse sweep with the source off and a modulated stream at the fit # source-off resonances. sweeps.prepare_sweep(roach, f_initial_off, f_coarse_offset, n_coarse_samples) coarse_sweep_off, stream_mod_off = mmw_source_sweep_and_stream( df, roach, lockin, modulated_stream_time, False, f_mmw_source, 'high', modulation_rate_integer, modulation_rate_integer) f_coarse_fit_off = np.array( [r.f_0 for r in fit_sweep_data(coarse_sweep_off)]) print("Source off: coarse - initial [Hz]: " + ', '.join([ '{:.0f}'.format(1e6 * diff) for diff in f_coarse_fit_off - f_initial_off ])) # At the lowest readout power, record a fine sweep and long stream with the source off. sweeps.prepare_sweep(roach, f_coarse_fit_off, f_fine_offset, n_fine_samples) fine_sweep_off, stream_off = mmw_source_sweep_and_stream( df, roach, lockin, long_stream_time, False, f_mmw_source, 'high', 'high', modulation_rate_integer) f_fine_fit_off = np.array( [r.f_0 for r in fit_sweep_data(fine_sweep_off)]) print("Source off: fine - coarse [Hz]: " + ', '.join([ '{:.0f}'.format(1e6 * diff) for diff in f_fine_fit_off - f_coarse_fit_off ])) # At the lowest readout power, record a coarse sweep with the source on and a modulated stream at the fit # source-on resonances. sweeps.prepare_sweep(roach, f_initial_on, f_coarse_offset, n_coarse_samples) coarse_sweep_on, stream_mod_on = mmw_source_sweep_and_stream( df, roach, lockin, modulated_stream_time, False, f_mmw_source, 'low', modulation_rate_integer, modulation_rate_integer) f_coarse_fit_on = np.array( [r.f_0 for r in fit_sweep_data(coarse_sweep_on)]) print("Source on: coarse - initial [Hz]: " + ', '.join([ '{:.0f}'.format(1e6 * diff) for diff in f_coarse_fit_on - f_initial_on ])) # Use these frequencies for all subsequent sweeps, and add an additional waveform for each stream. print("\nSetting fine sweep frequencies for source-on measurements.") sweeps.prepare_sweep(roach, f_coarse_fit_on, f_fine_offset, n_fine_samples) for k, attenuation in enumerate(attenuations): print( "\nSource-on measurement {} of {}: DAC attenuator at {:.1f} dB." .format(k + 1, len(attenuations), attenuation)) roach.set_dac_attenuator(attenuation) fine_sweep_on, stream = mmw_source_sweep_and_stream( df, roach, lockin, long_stream_time, k > 0, # overwrite after the first. f_mmw_source, 'low', 'low', modulation_rate_integer) f_fine_fit_on = [r.f_0 for r in fit_sweep_data(fine_sweep_on)] print("Source on: fine - coarse [Hz]: " + ', '.join([ '{:.0f}'.format(1e6 * diff) for diff in f_fine_fit_on - f_coarse_fit_on ])) df.close() print("Completed in {:.0f} minutes: {}".format( (time.time() - start_time) / 60, df.filename)) # Clean up. if f_mmw_source: hittite.off() hittite.disconnect()
def main(f_initial, attenuation, stream_time=30, suffix='compressor_noise', coarse_exponent=19, fine_exponent=21, modulation_state='high', modulation_rate=7, transient_wait=10, f_mmw_source=0, mmw_atten_turns=(np.nan, np.nan), num_streams=1): roach = baseband.RoachBaseband() roach.set_modulation_output(modulation_state) roach.set_dac_attenuator(attenuation) df = data_file.DataFile(suffix=suffix) df.log_hw_state(roach) def prompt(): raw_input("Turn off the compressor and hit Enter to begin.") if modulation_state == 'low': lockin = lockin_controller.lockinController() df.nc.mmw_atten_turns = mmw_atten_turns # Compressor on coarse_sweep_on = acquire.sweep(roach, f_initial, coarse_exponent, transient_wait=transient_wait) f_coarse_on = np.array( [r.f_0 for r in acquire.fit_sweep_data(coarse_sweep_on)]) print("Compressor on: coarse - initial [Hz]: " + ', '.join([ '{:.0f}'.format(1e6 * delta_f) for delta_f in f_coarse_on - f_initial ])) df.log_hw_state(roach) fine_sweep_on = acquire.sweep(roach, f_coarse_on, fine_exponent, transient_wait=transient_wait) f_fine_on = np.array( [r.f_0 for r in acquire.fit_sweep_data(fine_sweep_on)]) print("Compressor on: fine - coarse [Hz]: " + ', '.join([ '{:.0f}'.format(1e6 * delta_f) for delta_f in f_fine_on - f_coarse_on ])) df.add_sweep(fine_sweep_on) df.log_hw_state(roach) on_start_time = time.time() stream_on, address = acquire.timestream(roach, f_fine_on, stream_time, transient_wait=transient_wait) if modulation_state == 'low': roach.set_modulation_output(modulation_rate) time.sleep(5) x, y, r, theta = lockin.get_data() roach.set_modulation_output('low') else: x = 0 df.add_timestream_data(stream_on, roach, on_start_time, mmw_source_freq=f_mmw_source, zbd_voltage=x) # Compressor off print("Preparing fine sweep with compressor off.") df.log_hw_state(roach) fine_sweep_off = acquire.sweep(roach, f_coarse_on, fine_exponent, transient_wait=transient_wait, run=prompt) print("Done with fine sweep. Turn on the compressor.") f_fine_off = np.array( [r.f_0 for r in acquire.fit_sweep_data(fine_sweep_off)]) print("off - on [Hz]: " + ', '.join( ['{:.0f}'.format(1e6 * delta_f) for delta_f in f_fine_off - f_fine_on])) df.add_sweep(fine_sweep_off) df.log_hw_state(roach) off_start_time = time.time() stream_off, address = acquire.timestream(roach, f_fine_on, stream_time, transient_wait=transient_wait, run=prompt) print("Done with stream. Turn on the compressor.") if modulation_state == 'low': roach.set_modulation_output(modulation_rate) time.sleep(5) x, y, r, theta = lockin.get_data() roach.set_modulation_output('high') else: x = np.nan df.add_timestream_data(stream_off, roach, off_start_time, mmw_source_freq=f_mmw_source, zbd_voltage=x) df.sync() df.close() print("Wrote {}".format(df.filename))
def mmw_source_power_step(f_initial_off, f_initial_on, attenuations, f_mmw_source=0, suffix="mmw", hittite_power=0, long_stream_time=30, modulated_stream_time=4, coarse_exponent=19, fine_exponent=21, modulation_rate_integer=7): if f_mmw_source: from kid_readout.equipment import hittite_controller frequency_multiplication_factor = 12 hittite = hittite_controller.hittiteController() hittite.set_power(hittite_power) # in dBm hittite.set_freq(f_mmw_source / frequency_multiplication_factor) # in Hz hittite.on() lockin = lockin_controller.lockinController() print(lockin.get_idn()) roach = baseband.RoachBaseband() n_coarse_samples = 2 ** coarse_exponent n_fine_samples = 2 ** fine_exponent coarse_frequency_resolution = roach.fs / n_coarse_samples fine_frequency_resolution = roach.fs / n_fine_samples coarse_offset_integers = offset_integers[coarse_exponent] fine_offset_integers = offset_integers[fine_exponent] f_coarse_offset = coarse_frequency_resolution * coarse_offset_integers f_fine_offset = fine_frequency_resolution * fine_offset_integers while True: f_source_modulation = roach.set_modulation_output(modulation_rate_integer) print("\nSet source modulation frequency to {:.1f} Hz. Check the lock-in.".format(f_source_modulation)) try: mmw_attenuator_turns = float( raw_input("Enter the value to which both attenuators are set, or hit Enter to stop recording data: ")) except ValueError: break start_time = time.time() df = data_file.DataFile(suffix=suffix) df.nc.mmw_atten_turns = (mmw_attenuator_turns, mmw_attenuator_turns) maximum_attenuation = max(attenuations) print("Setting DAC attenuator to maximum requested attenuation of {:.1f} dB.".format(maximum_attenuation)) roach.set_dac_attenuator(maximum_attenuation) # At the lowest readout power, record a coarse sweep with the source off and a modulated stream at the fit # source-off resonances. sweeps.prepare_sweep(roach, f_initial_off, f_coarse_offset, n_coarse_samples) coarse_sweep_off, stream_mod_off = mmw_source_sweep_and_stream(df, roach, lockin, modulated_stream_time, False, f_mmw_source, 'high', modulation_rate_integer, modulation_rate_integer) f_coarse_fit_off = np.array([r.f_0 for r in fit_sweep_data(coarse_sweep_off)]) print("Source off: coarse - initial [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * diff) for diff in f_coarse_fit_off - f_initial_off])) # At the lowest readout power, record a fine sweep and long stream with the source off. sweeps.prepare_sweep(roach, f_coarse_fit_off, f_fine_offset, n_fine_samples) fine_sweep_off, stream_off = mmw_source_sweep_and_stream(df, roach, lockin, long_stream_time, False, f_mmw_source, 'high', 'high', modulation_rate_integer) f_fine_fit_off = np.array([r.f_0 for r in fit_sweep_data(fine_sweep_off)]) print("Source off: fine - coarse [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * diff) for diff in f_fine_fit_off - f_coarse_fit_off])) # At the lowest readout power, record a coarse sweep with the source on and a modulated stream at the fit # source-on resonances. sweeps.prepare_sweep(roach, f_initial_on, f_coarse_offset, n_coarse_samples) coarse_sweep_on, stream_mod_on = mmw_source_sweep_and_stream(df, roach, lockin, modulated_stream_time, False, f_mmw_source, 'low', modulation_rate_integer, modulation_rate_integer) f_coarse_fit_on = np.array([r.f_0 for r in fit_sweep_data(coarse_sweep_on)]) print("Source on: coarse - initial [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * diff) for diff in f_coarse_fit_on - f_initial_on])) # Use these frequencies for all subsequent sweeps, and add an additional waveform for each stream. print("\nSetting fine sweep frequencies for source-on measurements.") sweeps.prepare_sweep(roach, f_coarse_fit_on, f_fine_offset, n_fine_samples) for k, attenuation in enumerate(attenuations): print("\nSource-on measurement {} of {}: DAC attenuator at {:.1f} dB.".format(k + 1, len(attenuations), attenuation)) roach.set_dac_attenuator(attenuation) fine_sweep_on, stream = mmw_source_sweep_and_stream(df, roach, lockin, long_stream_time, k > 0, # overwrite after the first. f_mmw_source, 'low', 'low', modulation_rate_integer) f_fine_fit_on = [r.f_0 for r in fit_sweep_data(fine_sweep_on)] print("Source on: fine - coarse [Hz]: " + ', '.join(['{:.0f}'.format(1e6 * diff) for diff in f_fine_fit_on - f_coarse_fit_on])) df.close() print("Completed in {:.0f} minutes: {}".format((time.time() - start_time) / 60, df.filename)) # Clean up. if f_mmw_source: hittite.off() hittite.disconnect()