def get_xlim(self): _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) start = start_freq stop = start_freq + (nop - 1) * bin_size return start, stop
def do_set_video_bw(self, video_bw): vbw_max = 250e3 vbw_min = 0.1 _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) span = (nop - 1) * bin_size res_bw = self.get_res_bw() reject_if = self.get_reject_if() if not res_bw: res_bw = 250e3 if video_bw > res_bw: video_bw = res_bw vbw_6MHz_allowed = False if span > 100e6: vbw_min = 6.5e3 if span > 200e3 and start_freq < 16e6: vbw_min = 6.5e3 if start_freq > 200e6 and span > 200e6: vbw_6MHz_allowed = True if video_bw > vbw_max: if vbw_6MHz_allowed and video_bw > 3e6: video_wb = 6e6 else: video_bw = vbw_max if video_bw < vbw_min: video_bw = vbw_min _signal_hound.config_sweep_coupling(self._device, res_bw, video_bw, reject_if)
def get_tracedata(self): ''' Get the data of the current trace in mW ''' _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) min = (ctypes.c_float * nop)() max = (ctypes.c_float * nop)() datamin = np.zeros(nop) datamax = np.zeros(nop) for _ in range(self.averages): end = 0 while end < nop: begin, end = _signal_hound.get_partial_sweep_32f( self._device, min, max) plt.pause(0.05) datamin += 10.**(np.asarray(max, dtype=np.float) / 10.) datamax += 10.**(np.asarray(min, dtype=np.float) / 10.) datax = np.linspace(start_freq, start_freq + bin_size * (nop - 1), nop) datamin = datamin / self.averages datamax = datamax / self.averages return [datax, datamin, datamax]
def do_get_nop(self): ''' Get Number of Points (nop) for sweep Input: None Output: nop (int) ''' logging.debug(__name__ + ' : getting Number of Points') _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) return nop
def do_get_startfreq(self): ''' Get Start frequency Input: None Output: span (float) : Start Frequency in Hz ''' logging.debug(__name__ + ' : getting start frequency') _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) return start_freq
def do_get_centerfreq(self): ''' Get the center frequency Input: None Output: cf (float) :Center Frequency in Hz ''' logging.debug(__name__ + ' : getting center frequency') _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) return start_freq + (nop - 1) * bin_size / 2.
def do_get_span(self): ''' Get Span Input: None Output: span (float) : Span in Hz ''' #logging.debug(__name__ + ' : getting center frequency') _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) span = (nop - 1) * bin_size #float( self.ask('SENS1:FREQ:SPAN?')) return span
def do_set_stopfreq(self, val): ''' Set STop frequency Input: val (float) : Stop Frequency in Hz Output: None ''' logging.debug(__name__ + ' : setting start freq to %s Hz' % val) _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) if nop < 2: nop = 1 #stop = start_freq + (nop-1)*bin_size new_center = (val + start_freq) * 0.5 new_span = val - start_freq _signal_hound.config_center_span(self._device, new_center, new_span) self.get_centerfreq() self.get_stopfreq() self.get_span()
def do_set_span(self, span): ''' Set Span Input: span (float) : Span in KHz Output: None ''' logging.debug(__name__ + ' : setting span to %s Hz' % span) _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) start = start_freq if nop < 2: nop = 2 stop = start_freq + (nop - 1) * bin_size _signal_hound.config_center_span(self._device, (start + stop) * 0.5, span) self.get_startfreq() self.get_stopfreq() self.get_centerfreq()
def do_set_centerfreq(self, cf): ''' Set the center frequency Input: cf (float) :Center Frequency in Hz Output: None ''' logging.debug(__name__ + ' : setting center frequency to %s' % cf) _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) if nop < 2: nop = 2 start = start_freq stop = start_freq + (nop - 1) * bin_size span = stop - start _signal_hound.config_center_span(self._device, cf, span) self.get_startfreq() self.get_stopfreq() self.get_span()
def get_freqpoints(self, query=False): _signal_hound.initiate(self._device, _signal_hound.sweeping, 0) nop, start_freq, bin_size = _signal_hound.query_sweep_info( self._device) return np.linspace(start_freq, start_freq + bin_size * (nop - 1), nop)