diff options
author | Martin Braun <martin.braun@ettus.com> | 2021-06-09 16:06:36 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-06-10 08:12:45 -0500 |
commit | a04e0c2d30327a96409792a55818ba209ea9dd0a (patch) | |
tree | fb3cd549aa7391015a24c09574ec2aac3b6f9292 | |
parent | ea76face99e8628a1c4189fd2d02849ea58d0c06 (diff) | |
download | uhd-a04e0c2d30327a96409792a55818ba209ea9dd0a.tar.gz uhd-a04e0c2d30327a96409792a55818ba209ea9dd0a.tar.bz2 uhd-a04e0c2d30327a96409792a55818ba209ea9dd0a.zip |
cal: Fix minor issues in the calibration utilities
- Whitespace issues
- Unclear help messages
- Unnecessary derive-from-object
-rw-r--r-- | host/python/uhd/usrp/cal/meas_device.py | 4 | ||||
-rw-r--r-- | host/python/uhd/usrp/cal/switch.py | 7 | ||||
-rw-r--r-- | host/python/uhd/usrp/cal/usrp_calibrator.py | 14 | ||||
-rw-r--r-- | host/utils/uhd_power_cal.py | 4 |
4 files changed, 15 insertions, 14 deletions
diff --git a/host/python/uhd/usrp/cal/meas_device.py b/host/python/uhd/usrp/cal/meas_device.py index 913096a95..5acf76bf1 100644 --- a/host/python/uhd/usrp/cal/meas_device.py +++ b/host/python/uhd/usrp/cal/meas_device.py @@ -158,7 +158,7 @@ class ManualPowerGenerator(SignalGeneratorBase): """ new_power = input( "[RX] Set your signal generator to following output power: " - "{:.1f} dBm, then hit Enter, or enter the closest available power: " + "{:.2f} dBm, then hit Enter, or enter the closest available power: " .format(power_dbm)) if not new_power: return power_dbm @@ -168,7 +168,7 @@ class ManualPowerGenerator(SignalGeneratorBase): except ValueError: new_power = input( "[RX] Set your signal generator to following output power: " - "{:.1f} dBm, then hit Enter, or enter the closest available power: " + "{:.2f} dBm, then hit Enter, or enter the closest available power: " .format(power_dbm)) if not new_power: return power_dbm diff --git a/host/python/uhd/usrp/cal/switch.py b/host/python/uhd/usrp/cal/switch.py index 1b6157fe6..b17318b5e 100644 --- a/host/python/uhd/usrp/cal/switch.py +++ b/host/python/uhd/usrp/cal/switch.py @@ -37,7 +37,7 @@ class ManualSwitch(SwitchBase): options connect call assumes there is no need to pause for connecting measurement device with DUT (e.g. only one path is measured). """ - def __init__(self, direction, options = None): + def __init__(self, direction, options=None): self.direction = direction self.mode = options.get('mode', '') @@ -52,8 +52,9 @@ class ManualSwitch(SwitchBase): """ if self.mode == 'auto': return # no need to wait for manual connection - input("[{}] Connect your signal generator to device channel {}, " - "antenna {}. Then, hit Enter.".format(self.direction, chan, antenna)) + dev_type = "signal generator" if self.direction == 'rx' else "power meter" + input(f"[{self.direction}] Connect your {dev_type} to device channel {chan}, " + f"antenna {antenna}. Then, hit Enter.") class NISwitch(SwitchBase): """ diff --git a/host/python/uhd/usrp/cal/usrp_calibrator.py b/host/python/uhd/usrp/cal/usrp_calibrator.py index a70747201..a095a102c 100644 --- a/host/python/uhd/usrp/cal/usrp_calibrator.py +++ b/host/python/uhd/usrp/cal/usrp_calibrator.py @@ -77,7 +77,7 @@ def subtract_power(p1_db, p2_db): ############################################################################### # Base Class ############################################################################### -class USRPCalibratorBase(object): +class USRPCalibratorBase: """ Base class for device calibration. Every USRP that can do power calibration needs to implement this. @@ -127,7 +127,7 @@ class USRPCalibratorBase(object): def init(self, rate, tone_freq, amplitude): """ Initialize device with finalized values. Not that __init__() needs to - finish before the call site knows the rate, so we can' fold this into + finish before the call site knows the rate, so we can't fold this into __init__(). """ if self._dir == 'tx': @@ -168,7 +168,7 @@ class USRPCalibratorBase(object): stop_hint = stop_hint or stop_max stop = min(stop_hint, stop_max) step = step_hint or DEFAULT_FREQ_STEP - return numpy.arange(start, stop + step, step) + return numpy.arange(start, stop + 1.0, step) def init_frequencies(self, start_hint, stop_hint, step_hint): """ @@ -186,7 +186,7 @@ class USRPCalibratorBase(object): for freq in freqs: self._meas_dev.set_frequency(freq) self._noise[freq] = self._meas_dev.get_power() - print("[TX] Noise floor: {:2} MHz => {:+6.2f} dBm" + print("[TX] Noise floor: {:7.2f} MHz => {:+6.2f} dBm" .format(freq/1e6, self._noise[freq])) else: # Rx print("===== Measuring noise floor across frequency and gain...") @@ -197,7 +197,7 @@ class USRPCalibratorBase(object): for gain in self._gains: self._usrp.set_rx_gain(gain, self._chan) self._noise[freq][gain] = get_usrp_power(self._streamer) - print("[RX] Noise floor: {:2} MHz / {} dB => {:+6.2f} dBFS" + print("[RX] Noise floor: {:7.2f} MHz / {} dB => {:+6.2f} dBFS" .format(freq/1e6, gain, self._noise[freq][gain])) return freqs @@ -299,7 +299,7 @@ class USRPCalibratorBase(object): # result of the equation is in dBm again. We omit the subtract-by-zero # since our variables don't have units. results[gain] = usrp_input_power - recvd_signal_power - self.log("{:2} dB => {:+6.2f} dBm".format(gain, results[gain])) + self.log(f"{gain:4.2f} dB => {results[gain]:+6.2f} dBm") # If we get too close to the noise floor, we stop if recvd_power - self._noise[freq][gain] <= 1.5: self.log("Can no longer detect input signal. Terminating.") @@ -315,7 +315,7 @@ class USRPCalibratorBase(object): self._usrp.set_tx_gain(gain, self._chan) time.sleep(0.1) # Settling time of the USRP, highly conservative results[gain] = self._meas_dev.get_power() - self.log("{:2} dB => {:+6.2f} dBm".format(gain, results[gain])) + self.log(f"{gain:4.2f} dB => {results[gain]:+6.2f} dBm") self.results[freq] = results def store(self): diff --git a/host/utils/uhd_power_cal.py b/host/utils/uhd_power_cal.py index 6be4cc534..d2fcf83cd 100644 --- a/host/utils/uhd_power_cal.py +++ b/host/utils/uhd_power_cal.py @@ -40,14 +40,14 @@ def parse_args(): 'to override this value.', type=float) parser.add_argument( '--step', - help='Frequency Step. Defaults are device-specific.' + help='Frequency Step. Defaults are device-specific. ' 'Note that this is only a hint for the device object, which can choose ' 'to override this value. Devices can also measure at non-regular ' 'frequencies, e.g., to more accurately cover differences between bands.', type=float) parser.add_argument( '--gain-step', type=float, default=1, - help='Gain Step (dB). Defaults to 1 dB.' + help='Gain Step (dB). Defaults to 1 dB. ' 'Note that this is only a hint for the device object, which can choose ' 'to override this value. Devices can also measure at non-regular ' 'gain intervals.') |