Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bluesky_blissdata
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
Container 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
fs-ec
bluesky_blissdata
Commits
bc673c93
Commit
bc673c93
authored
8 months ago
by
Udai Singh
Browse files
Options
Downloads
Patches
Plain Diff
Update dispatcher.py
parent
ecea4be5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#119575
passed
8 months ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bluesky_blissdata/dispatcher.py
+71
-34
71 additions, 34 deletions
src/bluesky_blissdata/dispatcher.py
with
71 additions
and
34 deletions
src/bluesky_blissdata/dispatcher.py
+
71
−
34
View file @
bc673c93
...
...
@@ -72,12 +72,12 @@ class blissdata_dispatcher:
self
.
count_time
=
1
self
.
start
=
[]
self
.
stop
=
[]
#
if self.motors is not None:
#
j=0
#
for i in range(len(self.motors)):
#
self.start.append(doc.get('plan_args')['args'][j+1])
#
self.stop.append(doc.get('plan_args')['args'][j+2])
#
j+=3
if
self
.
motors
is
not
None
and
self
.
scan
.
name
.
lower
().
find
(
"
grid
"
)
>-
1
:
j
=
0
for
i
in
range
(
len
(
self
.
motors
)):
self
.
start
.
append
(
doc
.
get
(
'
plan_args
'
)[
'
args
'
][
j
+
1
])
self
.
stop
.
append
(
doc
.
get
(
'
plan_args
'
)[
'
args
'
][
j
+
2
])
j
+=
3
self
.
devices
:
dict
[
str
,
DeviceDict
]
=
{}
self
.
devices
[
"
timer
"
]
=
DeviceDict
(
name
=
"
timer
"
,
channels
=
[],
metadata
=
{})
...
...
@@ -90,9 +90,10 @@ class blissdata_dispatcher:
ddesc_dict
=
{}
self
.
stream_list
=
{}
_logger
.
debug
(
f
"
Preparing datastream for
{
self
.
uid
}
"
)
_logger
.
debug
(
f
"
prepare scan doc data
{
doc
}
"
)
self
.
acq_chain
:
dict
[
str
,
ChainDict
]
=
{}
self
.
channels
:
dict
[
str
,
ChannelDict
]
=
{}
elem
=
{
'
name
'
:
None
,
"
label
"
:
None
,
'
dtype
'
:
None
,
"
shape
"
:
None
,
"
unit
"
:
None
}
elem
=
{
'
name
'
:
None
,
"
label
"
:
None
,
'
dtype
'
:
None
,
"
shape
"
:
None
,
"
unit
"
:
None
,
'
precision
'
:
None
,
'
plot_type
'
:
0
}
for
dev
in
doc
.
get
(
"
data_keys
"
).
keys
():
elem
[
'
label
'
]
=
dev
dev
=
doc
[
'
data_keys
'
][
dev
]
...
...
@@ -100,22 +101,49 @@ class blissdata_dispatcher:
elem
[
'
dtype
'
]
=
np
.
float64
elem
[
'
shape
'
]
=
dev
.
get
(
'
shape
'
,[])
elem
[
'
precision
'
]
=
dev
.
get
(
'
precision
'
,
4
)
unit
=
""
plot_axes
=
self
.
motors
if
self
.
motors
is
not
None
:
if
elem
[
'
name
'
]
in
self
.
motors
:
device_type
=
"
axis
"
if
(
self
.
scan
.
name
.
lower
().
find
(
"
grid
"
)
>-
1
):
elem
[
'
plot_type
'
]
=
2
elem
[
'
plot_axes
'
]
=
plot_axes
else
:
elem
[
'
plot_type
'
]
=
1
elem
[
'
plot_axes
'
]
=
plot_axes
# if (self.scan_id['name'].lower().find("grid")>-1):
# elem['plot_type']=2
# elem['plot_axes']=plot_axes
# else:
# elem['plot_type']=1
if
self
.
dets
is
not
None
:
if
elem
[
'
name
'
]
in
self
.
dets
:
device_type
=
"
counters
"
elem
[
"
group
"
]
=
"
scatter
"
# if (self.scan_id['name'].lower().find("grid")>-1):
# elem['plot_type']=2
# else:
# elem['plot_type']=1
self
.
devices
[
device_type
][
'
channels
'
].
append
(
elem
[
'
label
'
])
self
.
channels
[
elem
[
'
label
'
]]
=
ChannelDict
(
device
=
device_type
,
if
(
self
.
scan
.
name
.
lower
().
find
(
"
grid
"
)
>-
1
):
self
.
channels
[
elem
[
'
label
'
]]
=
ChannelDict
(
device
=
device_type
,
dim
=
len
(
elem
[
'
shape
'
]),
display_name
=
elem
[
'
label
'
])
display_name
=
elem
[
'
label
'
],
group
=
"
scatter
"
)
else
:
self
.
channels
[
elem
[
'
label
'
]]
=
ChannelDict
(
device
=
device_type
,
dim
=
len
(
elem
[
'
shape
'
]),
display_name
=
elem
[
'
label
'
],
group
=
"
scatter
"
)
encoder
=
NumericStreamEncoder
(
dtype
=
np
.
float64
,
shape
=
elem
[
'
shape
'
])
scalar_stream
=
self
.
scan
.
create_stream
(
elem
[
'
label
'
],
encoder
,
info
=
{
"
unit
"
:
unit
,
"
shape
"
:[],
"
dtype
"
:
"
float64
"
,})
ddesc_dict
[
elem
[
'
label
'
]]
=
elem
if
(
self
.
scan
.
name
.
lower
().
find
(
"
grid
"
)
>-
1
):
scalar_stream
=
self
.
scan
.
create_stream
(
elem
[
'
label
'
],
encoder
,
info
=
{
"
unit
"
:
unit
,
"
shape
"
:[],
"
dtype
"
:
"
float64
"
,
"
group
"
:
"
scatter
"
})
else
:
scalar_stream
=
self
.
scan
.
create_stream
(
elem
[
'
label
'
],
encoder
,
info
=
{
"
unit
"
:
unit
,
"
shape
"
:[],
"
dtype
"
:
"
float64
"
,})
ddesc_dict
[
elem
[
'
label
'
]]
=
dict
(
elem
)
self
.
stream_list
[
elem
[
'
label
'
]]
=
scalar_stream
print
(
ddesc_dict
)
elem
[
'
name
'
]
=
"
timer
"
elem
[
'
label
'
]
=
"
time
"
elem
[
'
dtype
'
]
=
np
.
float64
...
...
@@ -130,7 +158,8 @@ class blissdata_dispatcher:
encoder
=
NumericStreamEncoder
(
dtype
=
np
.
float64
,
shape
=
elem
[
'
shape
'
])
scalar_stream
=
self
.
scan
.
create_stream
(
elem
[
'
label
'
],
encoder
,
info
=
{
"
unit
"
:
unit
,
"
shape
"
:
[],
"
dtype
"
:
"
float64
"
,})
ddesc_dict
[
elem
[
'
label
'
]]
=
elem
ddesc_dict
[
elem
[
'
label
'
]]
=
dict
(
elem
)
print
(
ddesc_dict
)
self
.
stream_list
[
elem
[
'
label
'
]]
=
scalar_stream
# self.scalar_stream = self.scan.create_stream("scalars", encoder, info={"unit": "mV", "embed the info": "you want"})
...
...
@@ -259,7 +288,7 @@ class blissdata_dispatcher:
# "datadesc",
# ],
# "nexuswriter": {
# "devices": {},
# "devices": {},
self.motors[0]
# "instrument_info": {"name": "alba-"+self.scan.beamline, "name@short_name": self.scan.beamline},
# "masterfiles": masterfiles,
# "technique": {},
...
...
@@ -273,27 +302,35 @@ class blissdata_dispatcher:
##################################
"
user_name
"
:
"
bluesky
"
,
# tangosys?
}
scan_info
[
"
plots
"
].
append
({
"
kind
"
:
"
curve-plot
"
})
# Add curves selected in measurement group for plotting
for
elem
in
ddesc_dict
.
items
():
try
:
plot_type
=
elem
[
1
].
get
(
"
plot_type
"
,
0
)
plot_axes
=
elem
[
1
].
get
(
"
plot_axes
"
,
[])
name
=
elem
[
1
].
get
(
"
label
"
,
""
)
axes
=
[]
if
plot_type
==
1
:
for
axis
in
plot_axes
:
if
"
<idx>
"
in
axis
:
axis
=
"
#Pt No
"
axes
.
append
({
"
kind
"
:
"
curve
"
,
"
x
"
:
axis
,
"
y
"
:
name
})
scan_info
[
"
plots
"
].
append
(
{
"
kind
"
:
"
curve-plot
"
,
"
name
"
:
name
,
"
items
"
:
axes
})
elif
plot_type
==
2
:
self
.
info
(
"
Image plot not implemented yet
"
)
except
IndexError
:
continue
axes
=
[]
# for motor in self.motors:
if
self
.
motors
is
not
None
:
elem
=
ddesc_dict
[
self
.
motors
[
0
]]
else
:
elem
=
ddesc_dict
[
'
time
'
]
plot_type
=
elem
.
get
(
"
plot_type
"
,
0
)
plot_axes
=
elem
.
get
(
"
plot_axes
"
,
[])
name
=
elem
.
get
(
"
label
"
,
""
)
if
plot_type
==
1
:
for
axis
in
plot_axes
:
if
elem
[
'
name
'
]
!=
axis
:
axes
.
append
({
"
kind
"
:
"
curve
"
,
"
x
"
:
axis
,
"
y
"
:
elem
[
'
name
'
]})
elif
plot_type
==
2
:
for
axis
in
plot_axes
:
if
elem
[
'
name
'
]
!=
axis
:
axes
.
append
({
"
kind
"
:
"
scatter
"
,
"
x
"
:
axis
,
"
y
"
:
elem
[
'
name
'
]})
elif
plot_type
==
3
:
self
.
info
(
"
Image plot not implemented yet
"
)
if
(
scan_info
[
"
name
"
].
lower
().
find
(
"
grid
"
)
>-
1
):
scan_info
[
"
plots
"
].
append
({
"
kind
"
:
"
scatter-plot
"
,
"
name
"
:
"
Scatter
"
,
"
items
"
:
axes
})
else
:
scan_info
[
"
plots
"
].
append
({
"
kind
"
:
"
curve-plot
"
,
"
name
"
:
"
Curve
"
,
"
items
"
:
axes
})
return
scan_info
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