def __init__(self, channel, mixer="control"): """Initialize MixerCalibrationExperiment Experiment. Args: channel: channel identifier string (qubit or edge). mixer: One of 'control', 'measure' to select which mixer to cal. """ if mixer not in ("measure", "control"): raise ValueError( "Unknown mixer {}: must be either 'measure' or 'control'.". format(mixer)) self.mixer = mixer self.settings = config.load_meas_file(config.meas_file) sa = [ name for name, settings in self.settings['instruments'].items() if settings['type'] == 'SpectrumAnalyzer' ] if len(sa) > 1: raise ValueError( "More than one spectrum analyzer is defined in the configuration file." ) if len(sa) == 0: raise ValueError( "No spectrum analyzer is defined in the configuration file.") self.sa = sa[0] logger.debug("Found spectrum analyzer: {}.".format(self.sa)) if "LO" not in self.settings['instruments'][self.sa].keys(): raise ValueError( "No local oscillator is defined for spectrum analyzer {}.". format(self.sa)) try: self.LO = self.settings['instruments'][self.sa]['LO'] except KeyError: raise ValueError( "LO {} for spectrum analyzer {} not found in instrument configuration file!" .format(self.LO, self.sa)) self.channel = channel if channel in self.settings['qubits']: self.channel_settings = self.settings['qubits'][channel] chan_settings = self.settings['qubits'][channel][mixer] elif channel in self.settings['edges']: self.channel_settings = self.settings['edges'][channel] chan_settings = self.settings['edges'][channel] else: raise ValueError( "Could not find channel {} in the configuration file.".format( channel)) self.AWG, self.chan = chan_settings['AWG'].split(" ") if self.settings['instruments'][self.AWG]['type'] != 'APS2': raise ValueError("Mixer calibration only supported for APS2.") self.source = chan_settings['generator'] self.instruments_to_enable = [self.sa, self.LO, self.AWG, self.source] self.instrs_connected = False super(MixerCalibrationExperiment, self).__init__()
def __init__(self, qubit_names, num_shots=10000, expname=None, meta_file=None, save_data=False, optimize=False, set_threshold=True, stream_type='Raw', **kwargs): """Create a single shot fidelity measurement experiment. Assumes that there is a single shot measurement filter in the filter pipeline. Arguments: qubit_names: Names of the qubits to be measured. (str) num_shots: Total number of 0 and 1 measurements used to reconstruct fidelity histograms (int) expname: Experiment name for data saving. meta_file: Meta file for defining custom single-shot fidelity experiment. save_data: If true, will save the raw or demodulated data. optimize: if true, will set the swept parameters to their optimum values""" super(SingleShotFidelityExperiment, self).__init__() self.qubit_names = qubit_names if isinstance(qubit_names, list) else [qubit_names] self.qubit = [QubitFactory(qubit_name) for qubit_name in qubit_names] if isinstance( qubit_names, list) else QubitFactory(qubit_names) # make a copy of the settings to restore default self.saved_settings = config.load_meas_file(config.meas_file) self.settings = deepcopy(self.saved_settings) self.save_data = save_data self.calibration = True self.optimize = optimize self.set_threshold = True self.name = expname self.cw_mode = False self.repeats = num_shots self.ss_stream_type = stream_type if meta_file is None: meta_file = SingleShot(self.qubit) self._squash_round_robins() QubitExpFactory.load_meta_info(self, meta_file) QubitExpFactory.load_instruments(self) QubitExpFactory.load_qubits(self) QubitExpFactory.load_filters(self) if 'sweeps' in self.settings: QubitExpFactory.load_parameter_sweeps(experiment) self.ssf = self.find_single_shot_filter() self.leave_plot_server_open = True
def create(meta_file=None, meas_file=None, expname=None, calibration=False, save_data=True, cw_mode=False, instr_filter=None, repeats=None, single_plotter=True): """Create the experiment, but do not run the sweeps. If *cw_mode* is specified the AWGs will be operated in continuous waveform mode, and will not be stopped and started between succesive sweep points. The *calibration* argument is used by the calibration routines (not intended for direct use) to automatically convert any file writers to IO buffers. The *meta_file* specified here is one output by QGL that specifies which instruments are required and what the SegmentSweep axes are. The *expname* argument is simply used to set the output directory relative to the data directory. If *repeats* is defined this will overide the number of segments gleaned from the meta_info""" # Figure out which config file we should use, defaulting to the supplied argument settings = config.load_meas_file(meas_file) # This is generally the behavior we want auspex.config.single_plotter_mode = single_plotter # Instantiate and perform all of our setup experiment = QubitExperiment() experiment.settings = settings experiment.calibration = calibration experiment.save_data = save_data experiment.name = expname experiment.cw_mode = cw_mode experiment.repeats = repeats if meta_file: QubitExpFactory.load_meta_info(experiment, meta_file) QubitExpFactory.load_instruments(experiment, instr_filter=instr_filter) QubitExpFactory.load_qubits(experiment) QubitExpFactory.load_filters(experiment) if 'sweeps' in settings: QubitExpFactory.load_parameter_sweeps(experiment) return experiment
def test_writehdf5_with_settings(self): exp = SweptTestExperiment() clear_test_data() wr = WriteToHDF5("test_writehdf5.h5", save_settings = True) edges = [(exp.voltage, wr.sink)] exp.set_graph(edges) exp.add_sweep(exp.field, np.linspace(0,100.0,4)) exp.add_sweep(exp.freq, np.linspace(0,10.0,3)) exp.run_sweeps() self.assertTrue(os.path.exists("test_writehdf5-0000.h5")) with h5py.File("test_writehdf5-0000.h5", 'r') as f: self.assertTrue(0.0 not in f['main/data/voltage']) self.assertTrue(np.sum(f['main/data/field']) == 5*3*np.sum(np.linspace(0,100.0,4)) ) self.assertTrue(np.sum(f['main/data/freq']) == 5*4*np.sum(np.linspace(0,10.0,3)) ) self.assertTrue(np.sum(f['main/data/samples']) == 3*4*np.sum(np.linspace(0,4,5)) ) self.assertTrue("Here the run loop merely spews" in f.attrs['exp_src']) self.assertTrue(f['main/data'].attrs['time_val'] == 0) self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz") self.assertTrue(f['header'].attrs['settings'] == config.dump_meas_file(config.load_meas_file(config.meas_file), flatten = True)) os.remove("test_writehdf5-0000.h5")
import h5py from adapt.refine import refine_1D import auspex.config as config config.auspex_dummy_mode = True from auspex.experiment import Experiment from auspex.parameter import FloatParameter from auspex.stream import DataStream, DataAxis, DataStreamDescriptor, OutputConnector from auspex.filters.debug import Print from auspex.filters.io import WriteToHDF5 from auspex.log import logger from auspex.analysis.io import load_from_HDF5 from auspex.analysis import fits config.load_meas_file(config.find_meas_file()) class TestFitMethods(unittest.TestCase): # ----- # Note: with the methods named "Test<xyz>" the unit test invocation # cites zero tests run; renaming the methods as "test<xyz>" render them # runable and revealed call syntax issues... # def TestT1Fit(self): #def testT1Fit(self): # Added try/except trap with alternate syntax -- TJR """Test the fit_t1 experiment """ # Set parameters and generate synthetic data in natural units T1 = 40 * 1e3 # 40 us xdata = np.arange(20,120020,1000) synth_data = fits.t1_model(xdata, 1, T1, 0)