diff --git a/python/tools/drf_plot.py b/python/tools/drf_plot.py index 14a0d5a..b824529 100644 --- a/python/tools/drf_plot.py +++ b/python/tools/drf_plot.py @@ -12,7 +12,7 @@ $Id$ - Simple program to load 16 bit IQ data and make some basic plots. Command + Simple program to load (nominal) 16 bit IQ data and make some basic plots. Command line options are supported and data frames may be filtered from the output. The program can offset into a data file to limit the memory usage when plotting a subset of a data file. @@ -175,7 +175,7 @@ def power_plot(data, sfreq, toffset, log_scale, zscale, title): return fig -def iq_process(data, sfreq, toffset, modulus, integration, log_scale, title): +def iq_process(data, sfreq, toffset, modulus, integration, log_scale, nbits, title): """Break voltages by modulus and display each block. Integration here acts as a pure average on the voltage level data prior to iq plotting. """ @@ -202,13 +202,16 @@ def iq_process(data, sfreq, toffset, modulus, integration, log_scale, title): block_toffset += block_size / sfreq else: - yield iq_plot(data, toffset, log_scale, title) + yield iq_plot(data, toffset, log_scale, nbits, title) -def iq_plot(data, toffset, log_scale, title): +def iq_plot(data, toffset, log_scale, nbits, title): """Plot an IQ circle from the data in linear or log scale.""" print("iq") + # data is assumed to be maximum 1.0 coming in from the file + data *= 2**nbits + if log_scale: rx_raster_r = ( np.sign(data.real) * np.log10(np.abs(data.real) + 1e-30) / np.log10(2.0) @@ -217,7 +220,8 @@ def iq_plot(data, toffset, log_scale, title): np.sign(data.imag) * np.log10(np.abs(data.imag) + 1e-30) / np.log10(2.0) ) else: - data *= 1.0 / 32768.0 + # scale back to unity + data /= 2**nbits rx_raster_r = data.real rx_raster_i = data.imag @@ -231,6 +235,7 @@ def iq_plot(data, toffset, log_scale, title): ax.grid(True) ax.set_xlabel("I") ax.set_ylabel("Q") + ax.axis("equal") ax.set_title(title) return fig @@ -1043,6 +1048,9 @@ def usage(): " -t