diff --git a/libraries/dsp/st/python/try_histogram.py b/libraries/dsp/st/python/try_histogram.py index d1949096b638c2aa5593ccbe1feb373a8a7dc295..900972cd3a401fdfa326786d9bfdb385fc4eb12c 100644 --- a/libraries/dsp/st/python/try_histogram.py +++ b/libraries/dsp/st/python/try_histogram.py @@ -23,25 +23,33 @@ """Try histogram Usage: -> python try_histogram.py +> python try_histogram.py -h """ +import argparse import numpy as np import matplotlib.pylab as plt figNr = 1 -# Parameters -Nbins = 100 -dc = 0 -mu = 100 -sigma = 15 +# Parse arguments to derive user parameters +_parser = argparse.ArgumentParser('try_histogram') +_parser.add_argument('--Nbins', default=100, type=int, help='Number of bins in historgram') +_parser.add_argument('--dc', default=0.0, type=float, help='DC offset of the data') +_parser.add_argument('--ampl', default=1.0, type=float, help='Amplitude of the sinus data') +_parser.add_argument('--sigma', default=15.0, type=float, help='Standard deviation of the random data') +args = _parser.parse_args() + +Nbins = args.Nbins +dc = args.dc +ampl = args.ampl +sigma = args.sigma # Sinus N = Nbins * 100 t = 2 * np.pi * np.arange(0, N) / N -a = dc + np.sin(t) +a = dc + ampl*np.sin(t) # Plot histogram plt.figure(figNr) @@ -53,7 +61,7 @@ plt.grid(True) figNr += 1 # Gaussian noise -x = mu + sigma * np.random.randn(N) +x = dc + sigma * np.random.randn(N) # Plot histogram plt.figure(figNr)