Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
Seitosh
Commits
eedb8d86
Commit
eedb8d86
authored
Feb 15, 2019
by
thomas.forbriger
Browse files
croposp [FEATURE]: let croposplot offer more options
parent
19a87cb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ts/croposp/croposplot.py
View file @
eedb8d86
...
...
@@ -61,6 +61,8 @@ def usage():
print
(
'Usage: '
+
sys
.
argv
[
0
]
+
' [-v]'
)
print
(
' [-o file] [-g|--grid] [--nologlog] [--nologx] [--nology]'
)
print
(
' [--legfontsize s] [--legpos p] [--title t]'
)
print
(
' [--xlabel l] [--ylabel l] [--titfontsize t]'
)
print
(
' [--xlim l] [--ylim l]'
)
print
(
' file [file [file ...]]'
)
print
(
' or: '
+
sys
.
argv
[
0
]
+
' --help|-h'
)
...
...
@@ -80,6 +82,7 @@ def help():
-v be verbose
-o file write to file
--xlabel l set label "l" on x-axis
--ylabel l set label "l" on y-axis
-g|--grid plot grid
--nologlog plot on linear scales
--nologx use linear scale for x-axis
...
...
@@ -87,8 +90,20 @@ def help():
--legfontsize s set font size for legend
--legpos p set position of legend
--title t set plot title
--titfontsize s set font size for legend
--xlim min:max set x-axis limits
--ylim min:max set y-axis limits
"""
)
# -----------------------------------------------------------------------------
class
Error
(
Exception
):
def
__init__
(
self
,
msg
=
""
):
self
.
msg
=
str
(
msg
)
def
display
(
self
):
sys
.
stderr
.
write
(
"croposplot ERROR: "
+
self
.
msg
+
"
\n
"
)
# ============================================================================
def
main
(
argv
=
None
):
...
...
@@ -102,7 +117,7 @@ def main(argv=None):
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'hvo:g'
,
[
'help'
,
'nologlog'
,
'nologx'
,
'nology'
,
'grid'
,
'xlabel='
,
'legfontsize='
,
'title='
,
'legpos='
])
'legpos='
,
'titfontsize='
,
'ylabel='
,
'xlim='
,
'ylim='
])
except
getopt
.
GetoptError
as
err
:
print
(
err
.
msg
)
exit
(
0
)
...
...
@@ -116,9 +131,13 @@ def main(argv=None):
nology
=
False
grid
=
False
xlabel
=
'frequency / Hz'
ylabel
=
None
opt_legendfontsize
=
'xx-small'
opt_titlefontsize
=
'large'
opt_title
=
None
opt_legposition
=
'best'
opt_xlim
=
None
opt_ylim
=
None
for
(
opt
,
arg
)
in
opts
:
if
opt
==
'-v'
:
...
...
@@ -127,10 +146,28 @@ def main(argv=None):
DEBUG
=
True
elif
opt
==
'-o'
:
outfile
=
arg
elif
opt
in
(
"--xlim"
):
try
:
opt_xlim
=
[
float
(
x
)
for
x
in
arg
.
split
(
":"
)]
if
2
!=
len
(
opt_xlim
):
raise
except
:
raise
Error
(
"Invalid 'xlim' argument."
)
elif
opt
in
(
"--ylim"
):
try
:
opt_ylim
=
[
float
(
y
)
for
y
in
arg
.
split
(
":"
)]
if
2
!=
len
(
opt_ylim
):
raise
except
:
raise
Error
(
"Invalid 'ylim' argument."
)
elif
opt
in
(
'--xlabel'
):
xlabel
=
arg
elif
opt
in
(
'--ylabel'
):
ylabel
=
arg
elif
opt
in
(
'--legfontsize'
):
opt_legendfontsize
=
arg
elif
opt
in
(
'--titfontsize'
):
opt_titlefontsize
=
arg
elif
opt
in
(
'--legpos'
):
opt_legposition
=
arg
elif
opt
in
(
'--title'
):
...
...
@@ -185,6 +222,12 @@ def main(argv=None):
sys
.
stdout
.
write
(
"specplot: Disable logscale ...
\n
"
)
plt
.
xlabel
(
xlabel
)
if
ylabel
is
not
None
:
plt
.
ylabel
(
ylabel
)
if
opt_xlim
is
not
None
:
plt
.
xlim
(
opt_xlim
[
0
],
opt_xlim
[
1
])
if
opt_ylim
is
not
None
:
plt
.
ylim
(
opt_ylim
[
0
],
opt_ylim
[
1
])
for
specfile
in
args
:
if
verbose
:
...
...
@@ -202,7 +245,7 @@ def main(argv=None):
plt
.
legend
(
fontsize
=
opt_legendfontsize
,
loc
=
opt_legposition
)
if
opt_title
is
not
None
:
plt
.
title
(
opt_titl
e
)
plt
.
title
(
re
.
sub
(
'
\\\\
n'
,
'
\n
'
,
opt_title
),
fontsize
=
opt_titlefontsiz
e
)
if
outfile
==
'x11'
:
plt
.
show
(
True
)
...
...
src/ts/croposp/tests/Makefile
View file @
eedb8d86
...
...
@@ -186,14 +186,18 @@ psd%foutra.xxx: psd%.001.asc
cat
$<
>>
$@
CPSD_REFFILES
=
$(
addprefix
psd,
$(
addsuffix
foutra.xxx,
$(CPSD_SET)
))
PSD.pdf
:
psd_out.xxx $(CPSD_REFFILES)
$(CROPOSPLOT)
--title
=
"
$@
$(CPSD_CROPOSP_OPT)
"
-v
--grid
-o
$@
$^
$(CROPOSPLOT)
--title
=
"
$@
\n
$(CPSD_CROPOSP_OPT)
"
\
--titfontsize
=
'small'
-v
--grid
-o
$@
$^
%.pdf
:
%_out.xxx
$(CROPOSPLOT)
--title
=
"
$@
$(CPSD_CROPOSP_OPT)
"
-v
--grid
-o
$@
$<
$(CROPOSPLOT)
--title
=
'$@ \n
$(CPSD_CROPOSP_OPT)
'
\
--titfontsize
=
'small'
-v
--grid
-o
$@
$<
%_lin.pdf
:
%_out.xxx
$(CROPOSPLOT)
--title
=
"
$@
$(CPSD_CROPOSP_OPT)
"
-v
--grid
--nology
-o
\
$(CROPOSPLOT)
--title
=
"
$@
\n
$(CPSD_CROPOSP_OPT)
"
\
--titfontsize
=
'small'
-v
--grid
--nology
-o
\
$@
$<
%.pdp
:
%.pdf; evince $<; /bin/rm -fv $<
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment