Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
2f693bfc
Commit
2f693bfc
authored
5 years ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Added common line argument parser, to avoid having to edit the file change user parameters.
parent
94103ebe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/dsp/st/python/try_histogram.py
+16
-8
16 additions, 8 deletions
libraries/dsp/st/python/try_histogram.py
with
16 additions
and
8 deletions
libraries/dsp/st/python/try_histogram.py
+
16
−
8
View file @
2f693bfc
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment