From f90eeb32e7d43238816d636214fa573eb5ad7ba7 Mon Sep 17 00:00:00 2001 From: jimohyusuf Date: Mon, 2 Oct 2023 17:46:34 -0400 Subject: [PATCH] add LOG freq option for PNA5222A --- .../lab_instruments/Agilent_N5222A_NA.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lightlab/equipment/lab_instruments/Agilent_N5222A_NA.py b/lightlab/equipment/lab_instruments/Agilent_N5222A_NA.py index f554464..05d5039 100644 --- a/lightlab/equipment/lab_instruments/Agilent_N5222A_NA.py +++ b/lightlab/equipment/lab_instruments/Agilent_N5222A_NA.py @@ -125,21 +125,22 @@ def sweepSetup(self, startFreq, stopFreq, nPts=None, dwell=None, ifBandwidth=Non self.getSwpDuration(forceHardware=True) - def sweepEnable(self, swpState=None): + def sweepEnable(self, swpState=None, swpType='LOG'): ''' Switches between sweeping (True) and CW (False) modes Args: swpState (bool): If None, only gets, doesn't set. + swpType (bool): LOGARITHMIC (LOG), LINEAR (LIN), POWER (POW), CONTINUOUS WAVE (CW), SEGMENT (SEG), PHASE (PHAS) Returns: (bool): is the output sweeping ''' if swpState is not None: - self.setConfigParam('SENS:SWE:TYPE', 'LIN' if swpState else 'CW') + self.setConfigParam('SENS:SWE:TYPE', swpType if swpState else 'CW') if self.swpRange is not None: self.setConfigParam('SENS:FREQ:STAR', self.swpRange[0], forceHardware=True) # Hack self.setConfigParam('SENS:FREQ:STOP', self.swpRange[1], forceHardware=True) # Hack - return self.getConfigParam('SENS:SWE:TYPE') == 'LIN' + return self.getConfigParam('SENS:SWE:TYPE') == swpType def normalize(self): pass @@ -209,7 +210,14 @@ def spectrum(self): fStart = float(self.getConfigParam('SENS:FREQ:STAR')) fStop = float(self.getConfigParam('SENS:FREQ:STOP')) - freqs = np.linspace(fStart, fStop, len(dbm)) + + swpType = self.getConfigParam('SENS:SWE:TYPE') + + if swpType == 'LOG': + freqs = np.logspace(np.log10(fStart), np.log10(fStop), len(dbm)) + else: + freqs = np.linspace(fStart, fStop, len(dbm)) + # return freqs, dbm return Spectrum(freqs, dbm)