From 732c0f7ef1f29046feaf9809872fffcc67bad408 Mon Sep 17 00:00:00 2001 From: Matthew Ware Date: Tue, 24 Sep 2019 18:47:21 -0400 Subject: [PATCH] First attempt at fake data from spec_an. -MW --- src/auspex/instruments/bbn.py | 28 ++++++++++++++++++++++++++- src/auspex/qubit/mixer_calibration.py | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/auspex/instruments/bbn.py b/src/auspex/instruments/bbn.py index 818363e0..5a37ae05 100644 --- a/src/auspex/instruments/bbn.py +++ b/src/auspex/instruments/bbn.py @@ -49,6 +49,13 @@ aps1_missing = True libaps = MagicMock() +spec_an_missing = False +fake_spec_an = False +if config.auspex_dummy_mode: + spec_an_missing = True + fake_spec_an = True + spec_an = MagicMock() + class DigitalAttenuator(SCPIInstrument): """BBN 3 Channel Instrument""" instrument_type = "Digital attenuator" @@ -124,6 +131,10 @@ class SpectrumAnalyzer(SCPIInstrument): def __init__(self, resource_name=None, *args, **kwargs): super(SpectrumAnalyzer, self).__init__(resource_name, *args, **kwargs) + if spec_an_missing: + logger.warning("Using dummy spectrum analyzer") + if fake_spec_an: + self.interface = MagicMock() def connect(self, resource_name=None, interface_type=None): super(SpectrumAnalyzer, self).connect(resource_name, interface_type) @@ -146,9 +157,24 @@ def get_voltage(self): " at {}.".format(self.resource_name)) return volt + def spew_fake_data(self, random_mag=0.1): + """ + Generate fake data for the SpectrumAnalyzer. For unittest usage. + + Returns a random voltage reading + """ + # import ipdb; ipdb.set_trace(); + v = np.zeros((1,), dtype=np.float64) + # import ipdb; ipdb.set_trace(); + v += random_mag*np.random.random((1,)) + return v + @property def voltage(self): - return self.get_voltage() + if fake_spec_an: + return spew_fake_data() + else: + return self.get_voltage() def peak_amplitude(self): volt = self.get_voltage() diff --git a/src/auspex/qubit/mixer_calibration.py b/src/auspex/qubit/mixer_calibration.py index eea4f207..74a57d06 100644 --- a/src/auspex/qubit/mixer_calibration.py +++ b/src/auspex/qubit/mixer_calibration.py @@ -342,7 +342,8 @@ def init_instruments(self): LO_freq = self.source.frequency - self.sa.IF_FREQ if self.sideband_modulation: LO_freq -= self.SSB_FREQ - self.LO.frequency = LO_freq + # generator freqs will always be positive + self.LO.frequency = np.abs(LO_freq) self.LO.output = True self._setup_awg_ssb() time.sleep(0.1)