diff options
Diffstat (limited to 'dpd/src')
| -rw-r--r-- | dpd/src/Adapt.py | 2 | ||||
| -rw-r--r-- | dpd/src/Dab_Util.py | 10 | ||||
| -rw-r--r-- | dpd/src/MER.py | 5 | ||||
| -rw-r--r-- | dpd/src/Model.py | 26 | ||||
| -rw-r--r-- | dpd/src/phase_align.py | 6 | ||||
| -rwxr-xr-x | dpd/src/subsample_align.py | 4 | 
6 files changed, 29 insertions, 24 deletions
diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py index 2fb596f..7b33851 100644 --- a/dpd/src/Adapt.py +++ b/dpd/src/Adapt.py @@ -24,7 +24,7 @@ class Adapt:      """      def __init__(self, port, coef_path): -        logging.info("Instantiate Adapt object") +        logging.debug("Instantiate Adapt object")          self.port = port          self.coef_path = coef_path          self.host = "localhost" diff --git a/dpd/src/Dab_Util.py b/dpd/src/Dab_Util.py index b0b3ce3..8a53004 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,7 +43,7 @@ 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")              plt.plot(c, label="corr") @@ -95,7 +97,7 @@ 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" @@ -139,7 +141,7 @@ 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" diff --git a/dpd/src/MER.py b/dpd/src/MER.py index 54ef6c6..2075ef5 100644 --- a/dpd/src/MER.py +++ b/dpd/src/MER.py @@ -75,8 +75,9 @@ class MER:          spectrum = self._calc_spectrum(tx) -        dt = datetime.datetime.now().isoformat() -        fig_path = logging_path + "/" + dt + "_MER.pdf" +        if debug: +            dt = datetime.datetime.now().isoformat() +            fig_path = logging_path + "/" + dt + "_MER.pdf"          MERs = []          for i, (x, y) in enumerate(self._split_in_carrier( diff --git a/dpd/src/Model.py b/dpd/src/Model.py index 2aa9feb..dc526c5 100644 --- a/dpd/src/Model.py +++ b/dpd/src/Model.py @@ -20,7 +20,7 @@ class Model:      """Calculates new coefficients using the measurement and the old      coefficients""" -    def __init__(self, coefs_am, coefs_pm): +    def __init__(self, coefs_am, coefs_pm, plot=False):          self.coefs_am = coefs_am          self.coefs_history = [coefs_am, ]          self.mses = [0, ] @@ -30,6 +30,8 @@ class Model:          self.coefs_pm_history = [coefs_pm, ]          self.errs_phase = [0, ] +        self.plot=plot +      def sample_uniformly(self, txframe_aligned, rxframe_aligned, n_bins=4):          """This function returns tx and rx samples in a way          that the tx amplitudes have an approximate uniform  @@ -144,19 +146,19 @@ class Model:          rx_range = rx_range[(rx_range_dpd > 0) & (rx_range_dpd < 2)]          rx_range_dpd = rx_range_dpd[(rx_range_dpd > 0) & (rx_range_dpd < 2)] -        if logging.getLogger().getEffectiveLevel() == logging.DEBUG: -            logging.debug("txframe: min %f, max %f, median %f" % -                          (np.min(np.abs(txframe_aligned)), -                           np.max(np.abs(txframe_aligned)), -                           np.median(np.abs(txframe_aligned)) -                           )) +        logging.debug("txframe: min %f, max %f, median %f" % +                      (np.min(np.abs(txframe_aligned)), +                       np.max(np.abs(txframe_aligned)), +                       np.median(np.abs(txframe_aligned)) +                       )) -            logging.debug("rxframe: min %f, max %f, median %f" % -                          (np.min(np.abs(rx_choice)), -                           np.max(np.abs(rx_choice)), -                           np.median(np.abs(rx_choice)) -                           )) +        logging.debug("rxframe: min %f, max %f, median %f" % +                      (np.min(np.abs(rx_choice)), +                       np.max(np.abs(rx_choice)), +                       np.median(np.abs(rx_choice)) +                       )) +        if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot:              dt = datetime.datetime.now().isoformat()              fig_path = logging_path + "/" + dt + "_Model.pdf" diff --git a/dpd/src/phase_align.py b/dpd/src/phase_align.py index 7045586..f8e38c4 100644 --- a/dpd/src/phase_align.py +++ b/dpd/src/phase_align.py @@ -15,7 +15,7 @@ import sys  import matplotlib.pyplot as plt -def phase_align(sig, ref_sig): +def phase_align(sig, ref_sig, plot=False):      """Do phase alignment for sig relative to the reference signal      ref_sig. @@ -26,7 +26,7 @@ def phase_align(sig, ref_sig):      real_diffs = np.cos(angle_diff)      imag_diffs = np.sin(angle_diff) -    if logging.getLogger().getEffectiveLevel() == logging.DEBUG: +    if logging.getLogger().getEffectiveLevel() == logging.DEBUG and plot:          dt = datetime.datetime.now().isoformat()          fig_path = logging_path + "/" + dt + "_phase_align.pdf" @@ -66,7 +66,7 @@ def phase_align(sig, ref_sig):      ))      sig = sig * np.exp(1j * -angle) -    if logging.getLogger().getEffectiveLevel() == logging.DEBUG: +    if logging.getLogger().getEffectiveLevel() == logging.DEBUG and plot:          plt.subplot(515)          plt.plot(np.angle(ref_sig[:128]), label="ref_sig")          plt.plot(np.angle(sig[:128]), label="sig") diff --git a/dpd/src/subsample_align.py b/dpd/src/subsample_align.py index d0f3dba..cc2b975 100755 --- a/dpd/src/subsample_align.py +++ b/dpd/src/subsample_align.py @@ -29,7 +29,7 @@ def gen_omega(length):      return omega -def subsample_align(sig, ref_sig): +def subsample_align(sig, ref_sig, plot=False):      """Do subsample alignment for sig relative to the reference signal      ref_sig. The delay between the two must be less than sample @@ -68,7 +68,7 @@ def subsample_align(sig, ref_sig):      if optim_result.success:          best_tau = optim_result.x -        if 1: +        if plot:              corr = np.vectorize(correlate_for_delay)              ixs = np.linspace(-1, 1, 100)              taus = corr(ixs)  | 
