comparison rs_fsp7_noisetest.py @ 52:c1891d9074c1

Add option to run for N iterations and exit.
author Daniel O'Connor <doconnor@gsoft.com.au>
date Thu, 21 Mar 2013 11:48:42 +1030
parents 03b06d71f0fd
children d90acb55ce31
comparison
equal deleted inserted replaced
51:03b06d71f0fd 52:c1891d9074c1
131 parser = optparse.OptionParser(usage = '%prog [options] address frequency') 131 parser = optparse.OptionParser(usage = '%prog [options] address frequency')
132 parser.add_option('-s', '--span', dest = 'span', default = 1e6, help = 'Span frequency (Hz)', type = float) 132 parser.add_option('-s', '--span', dest = 'span', default = 1e6, help = 'Span frequency (Hz)', type = float)
133 parser.add_option('-i', '--input', dest = 'input', default = None, help = 'Input frequency (Hz) for down converters', type = float) 133 parser.add_option('-i', '--input', dest = 'input', default = None, help = 'Input frequency (Hz) for down converters', type = float)
134 parser.add_option('-w', '--sweeps', dest = 'sweeps', default = 20, help = 'Number of sweeps', type = int) 134 parser.add_option('-w', '--sweeps', dest = 'sweeps', default = 20, help = 'Number of sweeps', type = int)
135 parser.add_option('-b', '--bw', dest = 'bw', default = 1000, help = 'Bandwidth (Hz)', type = float) 135 parser.add_option('-b', '--bw', dest = 'bw', default = 1000, help = 'Bandwidth (Hz)', type = float)
136 parser.add_option('-r', '--repeat', dest = 'repeat', help = 'Repetitions (otherwise do one and ask to continue)', type = int)
136 137
137 (options, args) = parser.parse_args() 138 (options, args) = parser.parse_args()
138 139
139 if len(args) != 2: 140 if len(args) != 2:
140 parser.error('Must supply the specan address and centre frequency') 141 parser.error('Must supply the specan address and centre frequency')
162 setup(r, freq, options.span, options.sweeps, options.bw) 163 setup(r, freq, options.span, options.sweeps, options.bw)
163 164
164 r.write("INIT:CONT OFF") 165 r.write("INIT:CONT OFF")
165 166
166 print "Centre: %.1f Mhz, Span %.1f Mhz, Input %.1f MHz, BW %.1f kHz, %d sweeps, ENR %.2f dB" % (freq / 1e6, options.span / 1e6, options.input / 1e6, options.bw / 1e3, options.sweeps, enr) 167 print "Centre: %.1f Mhz, Span %.1f Mhz, Input %.1f MHz, BW %.1f kHz, %d sweeps, ENR %.2f dB" % (freq / 1e6, options.span / 1e6, options.input / 1e6, options.bw / 1e3, options.sweeps, enr)
167 while True: 168 while options.repeat == None or options.repeat > 0:
168 off, on, nf = donoisetest(r, enr) 169 off, on, nf = donoisetest(r, enr)
169 print "Off %.3f dBm/Hz, on %.3f dBm/Hz, NF %.2f dB" % (off, on, nf) 170 print "Off %.3f dBm/Hz, on %.3f dBm/Hz, NF %.2f dB" % (off, on, nf)
170 print "Press enter to perform a new measurement" 171 if options.repeat == None:
171 sys.stdin.readline() 172 print "Press enter to perform a new measurement"
172 173 sys.stdin.readline()
174 else:
175 options.repeat -= 1