diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-07-25 19:49:09 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-07-25 19:49:09 +0200 |
commit | 80b4eacd1d51a96e120192122774d1e83da2da5e (patch) | |
tree | 461db722889a2f0a32fffa0e2392d18c37b175aa /correlate_with_ref.py | |
parent | d4b41da4ccc7c9f55a8cdc1fa7b3373d067cd986 (diff) | |
download | odr-dab-cir-80b4eacd1d51a96e120192122774d1e83da2da5e.tar.gz odr-dab-cir-80b4eacd1d51a96e120192122774d1e83da2da5e.tar.bz2 odr-dab-cir-80b4eacd1d51a96e120192122774d1e83da2da5e.zip |
Fix webserver process and image update
Diffstat (limited to 'correlate_with_ref.py')
-rwxr-xr-x | correlate_with_ref.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/correlate_with_ref.py b/correlate_with_ref.py index 44e5a16..31e9710 100755 --- a/correlate_with_ref.py +++ b/correlate_with_ref.py @@ -11,6 +11,15 @@ # Licence: The MIT License, see LICENCE file import numpy as np +import matplotlib + +# When running on a machine that has no X server running, the normal +# matplotlib backend won't work. In case we are running as a module by cir_measure, +# switch to the Agg backend +# See http://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server +if __name__ != "__main__": + matplotlib.use("Agg") + import matplotlib.pyplot as pp import sys @@ -50,6 +59,7 @@ class CIR_Correlate: def calc_one_cir_(self, start_ix): """Calculate correlation with phase reference for one start index""" + print("Correlation at {}".format(start_ix)) channel = self.channel_out # As we do not want to correlate of the whole recording that might be @@ -101,19 +111,24 @@ class CIR_Correlate: def plot(self, plot_file): num_correlations = int(len(self.channel_out) / T_TF) + self.null_symbol_ixs = [] + cirs = np.array([ self.calc_one_cir_(i * T_TF) for i in range(num_correlations) ]) - pp.subplot(211) - pp.plot(cirs.sum(axis=0)) - pp.subplot(212) - pp.imshow(cirs, aspect='auto') + fig = pp.figure() + ax1 = fig.add_subplot(211) + ax1.plot(cirs.sum(axis=0)) + ax2 = fig.add_subplot(212) + ax2.imshow(cirs, aspect='auto') if plot_file: - pp.savefig(plot_file) + print("Save to file {}".format(plot_file)) + fig.savefig(plot_file) else: - pp.show() + print("Plotting to screen") + fig.show() if __name__ == "__main__": |