def recall_recording(self, fileName, fileFormat='csv'): """ Recalls a data file as a recording in VSA using SCPI commands. Args: fileName (str): Full absolute file name of the recording to be loaded. fileFormat (str): Format of recording file. ('CSV', 'E3238S', 'MAT', 'MAT7', 'N5110A', 'N5106A', 'SDF', 'TEXT') """ if not os.path.exists(fileName): raise error.VSAError('Path or file name does not exist.') # Ensure fileName is a valid file type validExtensions = [ 'csv', 'cap', 'mat', 'hdf', 'h5', 'bin', 'sdf', 'dat', 'txt' ] if fileName.split('.')[-1].lower() not in validExtensions: raise error.VSAError( f'Invalid file format. Extension must be in {validExtensions}') # Ensure fileFormat is a valid choice if fileFormat.lower() not in [ 'csv', 'e3238s', 'mat', 'mat7', 'n5110a', 'n5106a', 'sdf', 'text' ]: raise error.VSAError( 'Incorrect file format. Must be "csv", "e3238s", "mat", "mat7", "n5110a", "n5106a", "sdf", or "text".' ) # Load the recording self.write(f'mmemory:load:recording "{fileName}", "{fileFormat}"') # VSA helpfully reports an error if the file and the selected file format don't match. Check this here. self.err_check()
def configure_ddemod(self, **kwargs): """ Configures digital demodulation settings in VSA using SCPI commands. Keyword Args: cf (float): Analyzer center frequency in Hz. amp (float): Analyzer reference level/vertical range in dBm. modType (str): String defining digital modulation format. symRate (float): Symbol rate in symbols/sec. measFilter (str): Sets the measurement filter type. refFilter (str): Sets the reference filter type. filterAlpha (float): Filter alpha/rolloff factor. Must be between 0 and 1. measLength (int): Measurement length in symbols. eqState (bool): Turns the equalizer on or off. eqLength (int): Length of the equalizer filter in symbols. eqConvergence (float): Equalizer convergence factor. """ if 'ddem' not in self.meas.lower(): raise error.VSAError( f'Measurement type is currently "{self.meas}". Measurement type must be "ddem" to configure digital demod.' ) # Check to see which keyword arguments the user sent and call the appropriate function for key, value in kwargs.items(): if key == 'cf': self.set_cf(value) elif key == 'amp': self.set_amp(value) elif key == 'span': self.set_span(value) elif key == 'modType': self.set_modType(value) elif key == 'symRate': self.set_symRate(value) elif key == 'measFilter': self.set_measFilter(value) elif key == 'refFilter': self.set_refFilter(value) elif key == 'filterAlpha': self.set_filterAlpha(value) elif key == 'measLength': self.set_measLength(value) elif key == 'eqState': self.set_eqState(value) elif key == 'eqLength': self.set_eqLength(value) elif key == 'eqConvergence': self.set_eqConvergence(value) else: raise KeyError(f'Invalid keyword argument: "{key}"') # Handy way to actually visualize everything. The defaults in VSA are terrible. self.write('display:layout 2, 2') self.err_check()
def __init__(self, host, port=5025, timeout=10, reset=False, vsaHardware=None): super().__init__(host, port, timeout) # Set up hardware if not isinstance(vsaHardware, str) and vsaHardware is not None: raise error.VSAError( 'vsaHardware must be a string indicating which hardware platform to use.' ) self.hw = vsaHardware if vsaHardware is not None: self.set_hw(vsaHardware) if reset: # Reset, wait for reset to finish, and stop acquisition self.write('system:preset') self.query('*opc?') self.write('init:pause') # Pause measurement before doing anything self.write('init:pause') # Initialize global attributes self.cf = float(self.query('sense:frequency:center?')) self.amp = float(self.query('input:analog:range:dbm?')) self.span = float(self.query('sense:frequency:span?')) self.meas = self.query('measure:configure?') # Initialize measurement-specific attributes. # Digital Demod self.modType = '' self.symRate = 0 self.measFilter = '' self.refFilter = '' self.filterAlpha = 0 self.measLength = 0 self.eqState = False self.eqLength = 0 self.eqConvergence = 0 # Vector self.rbw = 0 self.time = 0
def configure_vector(self, **kwargs): """ Configures vector measurement mode in VSA using SCPI commands. Keyword Args: cf (float): Analyzer center frequency in Hz. amp (float): Analyzer reference level/vertical range in dBm. span (float): Analyzer span in Hz. rbw (float): Resolution bandwidth in Hz. time (float): Analysis time in sec. """ if 'vect' not in self.meas.lower(): raise error.VSAError( f'Measurement type is currently "{self.meas}". Measurement type must be "vect" to configure digital demod.' ) # Check to see which keyword arguments the user sent and call the appropriate function for key, value in kwargs.items(): if key == 'cf': self.set_cf(value) elif key == 'amp': self.set_amp(value) elif key == 'span': self.set_span(value) elif key == 'rbw': self.set_rbw(value) elif key == 'time': self.set_time(value) else: raise KeyError(f'Invalid keyword argument: "{key}"') # Check for conflicting settings in keyword arguments (RBW and acq time). lowerKeys = [k.lower() for k in kwargs.keys()] if 'time' in lowerKeys and 'rbw' in lowerKeys: warnings.warn( 'When both acquisition time and RBW are set, the last one configured will override the first.' ) self.err_check()