Skip to content
GitLab
Menu
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
cc07294a
Commit
cc07294a
authored
Nov 12, 2020
by
Thomas Vincent
Browse files
use h5py_read_dataset where needed
parent
9b4d33b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
xsocs/io/XsocsH5.py
View file @
cc07294a
...
...
@@ -39,6 +39,11 @@ import numpy as _np
from
.XsocsH5Base
import
XsocsH5Base
from
._utils
import
str_to_h5_utf8
,
find_NX_class
try
:
# silx >= 0.14
from
silx.io.utils
import
h5py_read_dataset
except
ImportError
:
# Fall back for silx < 0.14
from
..util.silx_io_utils
import
h5py_read_dataset
class
InvalidEntryError
(
Exception
):
pass
...
...
@@ -80,7 +85,7 @@ class XsocsH5(XsocsH5Base):
def
title
(
self
,
entry
):
with
self
.
_get_file
()
as
h5_file
:
path
=
entry
+
'/title'
return
h5
_file
[
path
][()]
return
h5
py_read_dataset
(
h5_file
[
path
],
decode_ascii
=
True
)
@
_process_entry
def
entry_filename
(
self
,
entry
):
...
...
xsocs/process/merge/KmapMerger.py
View file @
cc07294a
...
...
@@ -47,6 +47,11 @@ import fabio
from
...io
import
XsocsH5
from
...
import
config
try
:
# silx >= 0.14
from
silx.io.utils
import
h5py_read_dataset
except
ImportError
:
# Fall back for silx < 0.14
from
...util.silx_io_utils
import
h5py_read_dataset
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -397,7 +402,7 @@ class KmapMerger(object):
except
KeyError
:
raise
ValueError
(
'Scan ID {0} not found.'
.
format
(
scan_id
))
command
=
scan
[
'title'
][()]
command
=
h5py_read_dataset
(
scan
[
'title'
],
decode_ascii
=
True
)
try
:
return
parse_scan_command
(
command
)
...
...
@@ -426,7 +431,8 @@ class KmapMerger(object):
calibration
=
{}
# Parse spec header to find calibration
header
=
scan
[
'instrument/specfile/scan_header'
][()]
header
=
h5py_read_dataset
(
scan
[
'instrument/specfile/scan_header'
],
decode_ascii
=
True
)
for
line
in
header
:
if
line
.
startswith
(
'#UDETCALIB '
)
or
line
.
startswith
(
'#UMONO '
):
params
=
line
.
split
(
' '
)[
1
].
strip
().
split
(
','
)
...
...
@@ -746,7 +752,8 @@ def _add_edf_data(scan_id,
entry_h5f
.
copy_group
(
spec_h5_fn
,
scan_id
,
entry
)
with
h5py
.
File
(
spec_h5_fn
,
mode
=
'r'
)
as
spec_h5
:
command
=
spec_h5
[
scan_id
][
'title'
][()]
command
=
h5py_read_dataset
(
spec_h5
[
scan_id
][
'title'
],
decode_ascii
=
True
)
command_params
=
parse_scan_command
(
command
)
entry_h5f
.
set_scan_params
(
entry
,
**
command_params
)
...
...
xsocs/process/merge/KmapSpecParser.py
View file @
cc07294a
...
...
@@ -39,6 +39,10 @@ from threading import Thread
import
h5py
from
silx.io
import
convert
try
:
# silx >= 0.14
from
silx.io.utils
import
h5py_read_dataset
except
ImportError
:
# Fall back for silx < 0.14
from
...util.silx_io_utils
import
h5py_read_dataset
# regular expression matching the imageFile comment line
...
...
@@ -246,7 +250,8 @@ def _spec_get_img_filenames(spec_h5_filename):
regx
=
re
.
compile
(
_IMAGEFILE_LINE_PATTERN
)
for
k_scan
,
v_scan
in
h5_f
.
items
():
header
=
v_scan
[
'instrument/specfile/scan_header'
][()]
header
=
h5py_read_dataset
(
v_scan
[
'instrument/specfile/scan_header'
],
decode_ascii
=
True
)
imgfile_match
=
[
m
for
line
in
header
if
line
.
startswith
(
'#C imageFile'
)
for
m
in
[
regx
.
match
(
line
.
strip
())]
if
m
]
...
...
Write
Preview
Supports
Markdown
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