diff options
Diffstat (limited to 'dpd/src/Dab_Util.py')
-rw-r--r-- | dpd/src/Dab_Util.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/dpd/src/Dab_Util.py b/dpd/src/Dab_Util.py index b0b3ce3..e3dbfe3 100644 --- a/dpd/src/Dab_Util.py +++ b/dpd/src/Dab_Util.py @@ -23,7 +23,7 @@ class Dab_Util: """Collection of methods that can be applied to an array complex IQ samples of a DAB signal """ - def __init__(self, sample_rate): + def __init__(self, sample_rate, plot=False): """ :param sample_rate: sample rate [sample/sec] to use for calculations """ @@ -31,6 +31,8 @@ class Dab_Util: self.dab_bandwidth = 1536000 #Bandwidth of a dab signal self.frame_ms = 96 #Duration of a Dab frame + self.plot=plot + def lag(self, sig_orig, sig_rec): """ Find lag between two signals @@ -41,9 +43,9 @@ class Dab_Util: off = sig_rec.shape[0] c = np.abs(signal.correlate(sig_orig, sig_rec)) - if logging.getLogger().getEffectiveLevel() == logging.DEBUG: + if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot: dt = datetime.datetime.now().isoformat() - corr_path = (logging_path + "/" + dt + "_tx_rx_corr.pdf") + corr_path = (logging_path + "/" + dt + "_tx_rx_corr.svg") plt.plot(c, label="corr") plt.legend() plt.savefig(corr_path) @@ -95,9 +97,9 @@ class Dab_Util: Returns an aligned version of sig_tx and sig_rx by cropping and subsample alignment """ - if logging.getLogger().getEffectiveLevel() == logging.DEBUG: + if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot: dt = datetime.datetime.now().isoformat() - fig_path = logging_path + "/" + dt + "_sync_raw.pdf" + fig_path = logging_path + "/" + dt + "_sync_raw.svg" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig_tx[:128]), label="TX Frame") @@ -139,9 +141,9 @@ class Dab_Util: sig_tx = sig_tx[:-1] sig_rx = sig_rx[:-1] - if logging.getLogger().getEffectiveLevel() == logging.DEBUG: + if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot: dt = datetime.datetime.now().isoformat() - fig_path = logging_path + "/" + dt + "_sync_sample_aligned.pdf" + fig_path = logging_path + "/" + dt + "_sync_sample_aligned.svg" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig_tx[:128]), label="TX Frame") @@ -161,12 +163,11 @@ class Dab_Util: fig.savefig(fig_path) fig.clf() - sig_rx = sa.subsample_align(sig_rx, sig_tx) - if logging.getLogger().getEffectiveLevel() == logging.DEBUG: + if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot: dt = datetime.datetime.now().isoformat() - fig_path = logging_path + "/" + dt + "_sync_subsample_aligned.pdf" + fig_path = logging_path + "/" + dt + "_sync_subsample_aligned.svg" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig_tx[:128]), label="TX Frame") @@ -188,9 +189,9 @@ class Dab_Util: sig_rx = pa.phase_align(sig_rx, sig_tx) - if logging.getLogger().getEffectiveLevel() == logging.DEBUG: + if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot: dt = datetime.datetime.now().isoformat() - fig_path = logging_path + "/" + dt + "_sync_phase_aligned.pdf" + fig_path = logging_path + "/" + dt + "_sync_phase_aligned.svg" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig_tx[:128]), label="TX Frame") |