Mercurial > ~darius > hgwebdir.cgi > pyinst
comparison rs_fsp7_noisetest.py @ 56:91b476ebc0f2
Run through 2to3
author | Daniel O'Connor <doconnor@gsoft.com.au> |
---|---|
date | Tue, 08 Dec 2020 14:00:45 +1030 |
parents | 42621291eb9b |
children | 23c96322cfb6 |
comparison
equal
deleted
inserted
replaced
55:ad5942d22f78 | 56:91b476ebc0f2 |
---|---|
117 enr = 10 ** (enrdb / 10) | 117 enr = 10 ** (enrdb / 10) |
118 nf = 10 * math.log10(enr / (y - 1)) | 118 nf = 10 * math.log10(enr / (y - 1)) |
119 return nf | 119 return nf |
120 | 120 |
121 def donoisetest(r, enr): | 121 def donoisetest(r, enr): |
122 print "Acquiring with noise off.." | 122 print("Acquiring with noise off..") |
123 setnoise(r, False) | 123 setnoise(r, False) |
124 off = getnoise(r) | 124 off = getnoise(r) |
125 print "Acquiring with noise on.." | 125 print("Acquiring with noise on..") |
126 setnoise(r, True) | 126 setnoise(r, True) |
127 on = getnoise(r) | 127 on = getnoise(r) |
128 return off, on, calcnf(enr, off, on) | 128 return off, on, calcnf(enr, off, on) |
129 | 129 |
130 if __name__ == '__main__': | 130 if __name__ == '__main__': |
157 # Connect to the analyser | 157 # Connect to the analyser |
158 r = rsib.RSIBDevice(addr) | 158 r = rsib.RSIBDevice(addr) |
159 | 159 |
160 # ID instrument | 160 # ID instrument |
161 r.write('*IDN?') | 161 r.write('*IDN?') |
162 print "ID is " + r.read(5) | 162 print("ID is " + r.read(5)) |
163 | 163 |
164 # Setup parameters | 164 # Setup parameters |
165 setup(r, freq, options.span, options.sweeps, options.bw) | 165 setup(r, freq, options.span, options.sweeps, options.bw) |
166 | 166 |
167 r.write("INIT:CONT OFF") | 167 r.write("INIT:CONT OFF") |
168 | 168 |
169 nfs = [] | 169 nfs = [] |
170 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) | 170 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)) |
171 while options.repeat == None or options.repeat > 0: | 171 while options.repeat == None or options.repeat > 0: |
172 off, on, nf = donoisetest(r, enr) | 172 off, on, nf = donoisetest(r, enr) |
173 print "Off %.3f dBm/Hz, on %.3f dBm/Hz, NF %.2f dB" % (off, on, nf) | 173 print("Off %.3f dBm/Hz, on %.3f dBm/Hz, NF %.2f dB" % (off, on, nf)) |
174 nfs.append(nf) | 174 nfs.append(nf) |
175 if options.repeat == None: | 175 if options.repeat == None: |
176 print "Press enter to perform a new measurement" | 176 print("Press enter to perform a new measurement") |
177 sys.stdin.readline() | 177 sys.stdin.readline() |
178 else: | 178 else: |
179 options.repeat -= 1 | 179 options.repeat -= 1 |
180 | 180 |
181 if len(nfs) > 1: | 181 if len(nfs) > 1: |
182 nfs = numpy.array(nfs) | 182 nfs = numpy.array(nfs) |
183 print "NF min: %.1f dBm/Hz, max: %.1f dBm/Hz, avg: %.1f dBm/hz, stddev: %.1f" % ( | 183 print("NF min: %.1f dBm/Hz, max: %.1f dBm/Hz, avg: %.1f dBm/hz, stddev: %.1f" % ( |
184 nfs.min(), nfs.max(), nfs.sum() / len(nfs), numpy.std(nfs)) | 184 nfs.min(), nfs.max(), nfs.sum() / len(nfs), numpy.std(nfs))) |