Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CPUnetLOG
CPUnetPLOT
Commits
fdadec3c
Commit
fdadec3c
authored
May 02, 2016
by
Mario Hock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add possibility to plot with relative base times
Meaning each (sub-)plot starts at zero
parent
82bb9148
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
+42
-12
cnl_file_plot.py
cnl_file_plot.py
+35
-11
cnl_library.py
cnl_library.py
+7
-1
No files found.
cnl_file_plot.py
View file @
fdadec3c
...
...
@@ -14,7 +14,7 @@ import matplotlib.pyplot as plt
import
os
import
copy
from
cnl_library
import
CNLParser
,
calc_ema
,
merge_lists
,
pretty_json
,
get_common_base_time
from
cnl_library
import
CNLParser
,
calc_ema
,
merge_lists
,
pretty_json
,
get_common_base_time
,
get_base_times
import
cnl_plot
import
plot_ticks
...
...
@@ -107,9 +107,18 @@ def plot_net(ax, cnl_file, args):
def
plot
(
subplot_args
,
common_base_time
=
0
):
fig
,
ax
=
plt
.
subplots
()
def
plot
(
subplot_args
,
base_times
=
0
):
"""
[base_times] can either be a single nummer,
this is treated as common base time for all subplots
or a list
with the individual base times (same order as args.files)
"""
fig
,
ax
=
plt
.
subplots
()
i
=
0
current_base_time
=
base_times
# makes sense if a common base_time is used
for
args
in
subplot_args
:
...
...
@@ -120,13 +129,18 @@ def plot(subplot_args, common_base_time=0):
for
filename
in
args
.
files
:
cnl_file
=
cnl_plot
.
parse_cnl_file
(
filename
,
nic_fields
,
nics
)
# if individual base_times are used, get the next one
if
isinstance
(
base_times
,
list
):
current_base_time
=
base_times
[
i
]
i
+=
1
## show some output
print
(
filename
)
#print( pretty_json(cnl_file.get_general_header()) )
#print()
prepare_x_values
(
cnl_file
)
cnl_file
.
x_values
=
[
x
-
c
ommon
_base_time
for
x
in
cnl_file
.
x_values
]
cnl_file
.
x_values
=
[
x
-
c
urrent
_base_time
for
x
in
cnl_file
.
x_values
]
## * Plot *
...
...
@@ -258,6 +272,9 @@ if __name__ == "__main__":
parser
.
add_argument
(
"-d"
,
"--output-dir"
)
parser
.
add_argument
(
"--rel-base-time"
,
action
=
"store_true"
,
help
=
"Do NOT use a common base time, but begin every line at 0. (Do not in conjunction with --reference-files)"
)
## make it pretty
...
...
@@ -310,20 +327,27 @@ if __name__ == "__main__":
## Find common base time
reference
=
list
()
reference
.
extend
(
args
.
reference_files
)
for
args
in
subplot_args
:
reference
.
extend
(
args
.
files
)
common_base_time
=
get_common_base_time
(
reference
)
if
(
not
args
.
rel_base_time
):
reference
=
list
()
reference
.
extend
(
args
.
reference_files
)
for
args
in
subplot_args
:
reference
.
extend
(
args
.
files
)
base_time
=
get_common_base_time
(
reference
)
## Rel base time, find a base-time for each plot
else
:
reference
=
list
()
# reference.extend(args.reference_files)
for
args
in
subplot_args
:
reference
.
extend
(
args
.
files
)
base_time
=
get_base_times
(
reference
)
### Plotting
plot
(
subplot_args
,
common_
base_time
)
plot
(
subplot_args
,
base_time
)
cnl_library.py
View file @
fdadec3c
...
...
@@ -18,7 +18,8 @@ import os
def
get_common_base_time
(
cnl_files
):
def
get_base_times
(
cnl_files
):
base_times
=
list
()
for
file
in
cnl_files
:
...
...
@@ -29,6 +30,11 @@ def get_common_base_time(cnl_files):
base_times
.
append
(
cnl_file
.
get_machine_readable_date
()
)
return
base_times
def
get_common_base_time
(
cnl_files
):
base_times
=
get_base_times
(
cnl_files
)
common_base_time
=
min
(
base_times
)
return
common_base_time
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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