Skip to content

Commit

Permalink
add LOG freq option for PNA5222A
Browse files Browse the repository at this point in the history
  • Loading branch information
jimohyusuf committed Oct 2, 2023
1 parent e3e261c commit f90eeb3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lightlab/equipment/lab_instruments/Agilent_N5222A_NA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit f90eeb3

Please sign in to comment.