Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OnlineMID
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
dataAnalysis
OnlineMID
Commits
88d697b0
Commit
88d697b0
authored
2 weeks ago
by
Jakobsen, Mads Bregenholt
Browse files
Options
Downloads
Patches
Plain Diff
trying static method
parent
eab60053
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#167507
passed
2 weeks ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_package/src/onlinemid/dataplotters/agipd_module.py
+22
-23
22 additions, 23 deletions
python_package/src/onlinemid/dataplotters/agipd_module.py
python_package/src/onlinemid/utils/image_plotting.py
+1
-4
1 addition, 4 deletions
python_package/src/onlinemid/utils/image_plotting.py
with
23 additions
and
27 deletions
python_package/src/onlinemid/dataplotters/agipd_module.py
+
22
−
23
View file @
88d697b0
...
...
@@ -9,33 +9,11 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg
import
numpy
as
np
def
plot_data
(
data
):
plt
.
switch_backend
(
"
agg
"
)
fig
=
plt
.
figure
(
figsize
=
(
15
,
10
))
plt
.
imshow
(
data
,
interpolation
=
None
)
plt
.
title
(
f
"
this is my plot
"
)
plt
.
xlabel
(
'
kbar
'
)
plt
.
ylabel
(
'
Pk
'
)
canvas
=
FigureCanvasAgg
(
fig
)
canvas
.
draw
()
image_buffer
=
np
.
frombuffer
(
canvas
.
buffer_rgba
(),
dtype
=
np
.
uint8
).
reshape
(
canvas
.
get_width_height
()[::
-
1
]
+
(
4
,))
plt
.
close
(
fig
)
return
image_buffer
class
AgipdModulePlotter
():
def
__init__
(
self
):
self
.
onlineImagePlotter
=
OnlineImagePlotter
(
figsize
=
(
15
,
10
))
def
plot
(
self
,
train_id
,
module_data
):
print
(
"
type trainid
"
,
type
(
train_id
))
...
...
@@ -43,10 +21,31 @@ class AgipdModulePlotter():
print
(
f
"
Error, AgipdModulePlotter.plot received data must be of shape (512, 128), and not
{
module_data
.
shape
}
"
)
return
img
=
self
.
onlineImagePlotter
.
get_image_buffer_if_ready_and_make_new_image
(
train_id
,
plot_data
,
module_data
)
img
=
self
.
onlineImagePlotter
.
get_image_buffer_if_ready_and_make_new_image
(
train_id
,
AgipdModulePlotter
.
make_plot
,
module_data
)
return
img
@staticmethod
def
make_plot
(
data
):
plt
.
switch_backend
(
"
agg
"
)
fig
=
plt
.
figure
(
figsize
=
(
15
,
10
))
plt
.
imshow
(
data
,
interpolation
=
None
)
plt
.
title
(
f
"
this is my plot
"
)
plt
.
xlabel
(
'
kbar
'
)
plt
.
ylabel
(
'
Pk
'
)
canvas
=
FigureCanvasAgg
(
fig
)
canvas
.
draw
()
image_buffer
=
np
.
frombuffer
(
canvas
.
buffer_rgba
(),
dtype
=
np
.
uint8
).
reshape
(
canvas
.
get_width_height
()[::
-
1
]
+
(
4
,))
plt
.
close
(
fig
)
return
image_buffer
\ No newline at end of file
This diff is collapsed.
Click to expand it.
python_package/src/onlinemid/utils/image_plotting.py
+
1
−
4
View file @
88d697b0
...
...
@@ -106,16 +106,13 @@ class DataToPlotToHash():
print
(
f
"
key
{
hash_key
}
does not exist, init plotter
"
)
self
.
hash_keys_and_plotter
[
hash_key
]
=
Plotter
()
else
:
print
(
f
"
self.hash_keys_and_plotter[
{
hash_key
}
] is of type
"
,
type
(
Plotter
))
if
not
isinstance
(
self
.
hash_keys_and_plotter
[
hash_key
],
Plotter
):
print
(
"
wrong type, initializing!
"
)
self
.
hash_keys_and_plotter
[
hash_key
]
=
Plotter
()
print
(
f
"
self.hash_keys_and_plotter[
{
hash_key
}
] is of type
"
,
type
(
Plotter
))
# plotter is initialized, give plotter data
current_img
=
self
.
hash_keys_and_plotter
[
hash_key
].
plot
(
*
args
)
from
karabo.bound
import
Hash
,
Schema
,
ImageData
if
current_img
is
not
None
:
...
...
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