Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DetectorWriteSim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
EWMSCP
DetectorWriteSim
Commits
0f6d8b37
Commit
0f6d8b37
authored
1 year ago
by
Michael Reuscher
Browse files
Options
Downloads
Patches
Plain Diff
rework
parent
3a1082d5
No related branches found
No related tags found
1 merge request
!4
Python driver and data analysis part
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
visualizer/visualizer/SeabornPlotter.py
+17
-15
17 additions, 15 deletions
visualizer/visualizer/SeabornPlotter.py
visualizer/visualizer/main.py
+0
-2
0 additions, 2 deletions
visualizer/visualizer/main.py
with
17 additions
and
17 deletions
visualizer/visualizer/SeabornPlotter.py
+
17
−
15
View file @
0f6d8b37
import
os
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
seaborn
as
sns
import
matplotlib.pyplot
as
plt
from
matplotlib.offsetbox
import
OffsetImage
,
AnnotationBbox
import
os
sns
.
set_theme
()
...
...
@@ -10,7 +11,7 @@ class SeabornPlotter:
def
__init__
(
self
,
dataframe
,
name
,
data_path
):
self
.
dataframe
=
dataframe
self
.
name
=
name
self
.
path
=
os
.
path
.
join
(
data_path
,
"
Plots
"
)
self
.
path
=
os
.
path
.
join
(
data_path
,
'
Plots
'
)
def
_make_folder
(
self
,
folder_name
):
folder
=
os
.
path
.
join
(
self
.
path
,
folder_name
)
...
...
@@ -43,15 +44,15 @@ class SeabornPlotter:
folder
=
self
.
_make_folder
(
'
Various_Events
'
)
x
=
df
[
'
size
'
]
y
=
df
[
'
duration
'
]
title
=
"
Various Procedure: {
}
"
.
format
(
self
.
name
)
title
=
f
'
Various Procedure:
{
self
.
name
}
'
# Calculate the bins
bins_x
,
bins_y
=
self
.
_prepare_bins
(
df
)
# Set up the plot
f
,
ax
=
plt
.
subplots
(
figsize
=
(
16
,
9
))
sns
.
histplot
(
x
=
x
,
y
=
y
,
color
=
"
blue
"
,
bins
=
[
bins_x
,
bins_y
])
self
.
_add_logo
(
"
desy_logo.png
"
,
logo_size
=
0.1
,
logo_x
=
1.065
,
logo_y
=
0
)
sns
.
histplot
(
x
=
x
,
y
=
y
,
color
=
'
blue
'
,
bins
=
[
bins_x
,
bins_y
])
self
.
_add_logo
(
'
desy_logo.png
'
,
logo_size
=
0.1
,
logo_x
=
1.065
,
logo_y
=
0
)
# Calculate the mean for x and y
mean_x_values
=
df
.
groupby
(
'
size
'
)[
'
size
'
].
mean
()
...
...
@@ -64,16 +65,16 @@ class SeabornPlotter:
ax
.
set_xscale
(
'
log
'
)
ax
.
set_yscale
(
'
log
'
)
ax
.
set_xlabel
(
"
Data size [Bytes]
"
)
ax
.
set_ylabel
(
"
Time/Event [s]
"
)
ax
.
set_ylabel
(
'
Time/Event [s]
'
)
plt
.
title
(
title
)
plt
.
grid
(
True
)
plt
.
xticks
(
rotation
=
45
)
plt
.
legend
()
# Save the plot as an SVG and close
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
"
{
title
}
.svg
"
),
format
=
'
svg
'
)
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
'
{
title
}
.svg
'
),
format
=
'
svg
'
)
plt
.
close
()
print
(
title
+
"
Plot done!
"
)
print
(
title
+
'
Plot done!
'
)
def
plot_scatter_long
(
self
):
# Extract required data and set up the folder for saving the plot
...
...
@@ -81,7 +82,7 @@ class SeabornPlotter:
folder
=
self
.
_make_folder
(
'
Long_Events
'
)
x
=
df
[
'
seconds_since_start
'
]
y
=
df
[
'
duration
'
]
title
=
"
Long Procedure: {
}
"
.
format
(
self
.
name
)
title
=
f
'
Long Procedure:
{
self
.
name
}
'
# Set up the plot
f
,
ax
=
plt
.
subplots
(
figsize
=
(
16
,
9
))
...
...
@@ -136,7 +137,7 @@ class SeabornPlotter:
# Loop through each DataFrames
for
df_key
,
df
in
dataframes
.
items
():
operations
=
df
[
'
Group
'
].
unique
()
title
=
df_key
.
replace
(
"
.dat
"
,
""
)
title
=
df_key
.
replace
(
'
.dat
'
,
''
)
# Number of measures: 'min', 'max', 'mean', 'med', '10%', '90%'
num_measures
=
6
...
...
@@ -155,7 +156,7 @@ class SeabornPlotter:
global_max_speed
=
max
(
df
[
'
speed
'
].
max
()
for
df
in
dataframes
.
values
())
# Add a logo to the plot
self
.
_add_logo
(
"
desy_logo.png
"
,
logo_size
=
0.1
,
logo_x
=
1.08
,
logo_y
=
0
)
self
.
_add_logo
(
'
desy_logo.png
'
,
logo_size
=
0.1
,
logo_x
=
1.08
,
logo_y
=
0
)
# Create subplots for each measure
for
measure_idx
,
measure
in
enumerate
([
'
min
'
,
'
max
'
,
'
mean
'
,
'
med
'
,
'
10%
'
,
'
90%
'
]):
...
...
@@ -164,7 +165,8 @@ class SeabornPlotter:
ax
=
axes
[
row_idx
,
col_idx
]
# Create a barplot for the current measure
sns
.
barplot
(
data
=
df
,
x
=
'
Group
'
,
y
=
'
speed
'
,
hue
=
'
thread
'
,
hue_order
=
df
[
'
thread
'
].
unique
(),
order
=
operations
,
errorbar
=
None
,
ax
=
ax
,
width
=
0.95
,
palette
=
'
cool
'
)
sns
.
barplot
(
data
=
df
,
x
=
'
Group
'
,
y
=
'
speed
'
,
hue
=
'
thread
'
,
hue_order
=
df
[
'
thread
'
].
unique
(),
order
=
operations
,
errorbar
=
None
,
ax
=
ax
,
width
=
0.95
,
palette
=
'
cool
'
)
# Set axis labels and formatting
ax
.
set_yscale
(
'
log
'
)
...
...
@@ -179,6 +181,6 @@ class SeabornPlotter:
# Save the plot as an SVG and close
plt
.
tight_layout
()
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
"
{
title
}
.svg
"
),
format
=
'
svg
'
)
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
'
{
title
}
.svg
'
),
format
=
'
svg
'
)
plt
.
close
()
print
(
title
+
"
Plot done!
"
)
print
(
title
+
'
Plot done!
'
)
This diff is collapsed.
Click to expand it.
visualizer/visualizer/main.py
+
0
−
2
View file @
0f6d8b37
...
...
@@ -31,9 +31,7 @@ def long(l_dataframes, statistics_path):
l_plotter
.
plot_scatter_long
()
# --------------Main------------
def
main
():
# Parse Arguments
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
-d
"
,
"
--data_path
"
,
required
=
True
,
help
=
"
path to Data from Sim
"
)
...
...
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