# open faillog if log_errors: fp = open("mcfail.log", "a") # connect to siggen sg = N5183("10.126.110.19") sg.freq(2400e6) sg.amplitude(pin) sg.output(1) # connect to wsa dut = WSA() dut.connect(sys.argv[1]) dut.scpiset("*RST") dut.flush() # create sweep device sd = SweepDevice(dut) # test for a long time t = 0 while t < numtrials: # choose random fstart req_fstart = int(random.random() * 8e9) # choose random fstop req_fstop = req_fstart + int(random.random() * (8e9 - req_fstart))
startT = time() fstart, fstop, spectra_data = sweepdev.capture_power_spectrum( START_FREQ, STOP_FREQ, RBW, {'attenuator': ATTENUATION}, mode=RFE_MODE, average=AVERAGE) freq_range = np.linspace(fstart, fstop, len(spectra_data)) stopT = time() print( f"Averages = {AVERAGE}, time = {stopT-startT:2.2f} sec, len = {len(spectra_data)}" ) plt.plot(freq_range, spectra_data, label='Sweep capture') # %% dut.scpiset(':sweep:list:stop') dut.abort() dut.flush() dut.flush_captures() dut.connect(addr) #%% dut.attenuator() # %% from pyrf.util import collect_data_and_context collect_data_and_context(dut) # %% dut.reset() # %% dut.flush_captures() # %% dut.scpiget(':syst:capt:mode?')
return (pfreq, pamp) # open faillog if log_errors: fp = open("mcfail.log", "a") # connect to siggen sg = N5183("10.126.110.19") sg.freq(2400e6) sg.amplitude(pin) sg.output(1) # connect to wsa dut = WSA() dut.connect(sys.argv[1]) dut.scpiset("*RST") dut.flush() # create sweep device sd = SweepDevice(dut) # test for a long time t = 0 while t < numtrials: # choose random fstart req_fstart = int(random.random() * 8e9) # choose random fstop req_fstop = req_fstart + int(random.random() * (8e9 - req_fstart))
#%% # declare sweep constants RBW = 10e3 F_CENTER = 5.12e9 SPAN = 5e6 TRIGGER_SETTING = { 'type': 'NONE', 'fstart': F_CENTER - SPAN / 2, # some value 'fstop': F_CENTER + SPAN / 2, # some value 'amplitude': -100 } dut.freq(F_CENTER) dut.trigger(TRIGGER_SETTING) dut.scpiset(':SOUR:REF:PLL EXT') # setup graph fstart, fstop, spectra_data = capture_spectrum(dut, RBW, average=100) fig = figure(1) xvalues = np.linspace(fstart, fstop, len(spectra_data)) xlabel("Frequency") ylabel("Amplitude") # plot something plot(xvalues, spectra_data, color='blue') # show graph show()