Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
kmap
xsocs
Commits
716ec33c
Commit
716ec33c
authored
Apr 03, 2018
by
Thomas Vincent
Browse files
Add method to get measurement dataset that might be used to normalize
parent
8bac60c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
xsocs/io/XsocsH5.py
View file @
716ec33c
...
...
@@ -248,6 +248,34 @@ class XsocsH5(XsocsH5Base):
path
=
self
.
measurement_tpl
.
format
(
entry
)
+
'/'
+
measurement
return
self
.
_get_array_data
(
path
)
@
_process_entry
def
normalizers
(
self
,
entry
):
"""Returns dataset in measurement that might be used to normalize data
It returns names of scalar values and 1D datasets with same number
of elements as images that are available in the measurement group
:return: Dictionary of {name: data} that might be normalizers
:rtype: collections.OrderedDict
"""
normalizers
=
OrderedDict
()
nb_images
=
self
.
n_images
(
entry
)
path
=
self
.
measurement_tpl
.
format
(
entry
)
+
'/'
with
self
.
_get_file
()
as
h5_file
:
for
name
,
node
in
h5_file
[
path
].
items
():
if
isinstance
(
node
,
_h5py
.
Dataset
)
and
node
.
dtype
.
kind
in
'iuf'
:
# Only get (u)int and float datasets
if
node
.
ndim
==
0
:
# single scalar, make an array of it
normalizers
[
name
]
=
_np
.
array
([
node
[()]]
*
nb_images
)
elif
node
.
ndim
==
1
and
node
.
shape
[
0
]
==
nb_images
:
# same number of values as number of images
normalizers
[
name
]
=
node
[()]
return
normalizers
@
contextmanager
@
_process_entry
def
image_dset_ctx
(
self
,
...
...
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