Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tomotools
tomoscan
Commits
ee14be01
Commit
ee14be01
authored
Aug 24, 2020
by
payno
Browse files
set `HDF5_USE_FILE_LOCKING` when read a file
parent
765872b2
Pipeline
#31769
passed with stages
in 3 minutes and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/hdf5scan.py
View file @
ee14be01
...
@@ -232,6 +232,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -232,6 +232,7 @@ class HDF5TomoScan(TomoScanBase):
raise
ValueError
(
'given file path should be a file'
)
raise
ValueError
(
'given file path should be a file'
)
with
h5py
.
File
(
file_path
,
'r'
,
swmr
=
True
)
as
h5f
:
with
h5py
.
File
(
file_path
,
'r'
,
swmr
=
True
)
as
h5f
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
for
root_node
in
h5f
.
keys
():
for
root_node
in
h5f
.
keys
():
node
=
h5f
[
root_node
]
node
=
h5f
[
root_node
]
if
HDF5TomoScan
.
node_is_nxtomo
(
node
)
is
True
:
if
HDF5TomoScan
.
node_is_nxtomo
(
node
)
is
True
:
...
@@ -406,6 +407,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -406,6 +407,7 @@ class HDF5TomoScan(TomoScanBase):
if
self
.
_rotation_angles
is
None
:
if
self
.
_rotation_angles
is
None
:
self
.
_check_hdf5scan_validity
()
self
.
_check_hdf5scan_validity
()
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
_rotation_angles
=
h5_file
[
self
.
_entry
][
self
.
_ROTATION_ANGLE_PATH
][()]
_rotation_angles
=
h5_file
[
self
.
_entry
][
self
.
_ROTATION_ANGLE_PATH
][()]
# cast in float
# cast in float
self
.
_rotation_angles
=
tuple
([
float
(
angle
)
for
angle
in
_rotation_angles
])
self
.
_rotation_angles
=
tuple
([
float
(
angle
)
for
angle
in
_rotation_angles
])
...
@@ -416,6 +418,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -416,6 +418,7 @@ class HDF5TomoScan(TomoScanBase):
if
self
.
_entry
and
self
.
_image_keys
is
None
:
if
self
.
_entry
and
self
.
_image_keys
is
None
:
self
.
_check_hdf5scan_validity
()
self
.
_check_hdf5scan_validity
()
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
self
.
_image_keys
=
h5_file
[
self
.
_entry
][
self
.
_IMG_KEY_PATH
][()]
self
.
_image_keys
=
h5_file
[
self
.
_entry
][
self
.
_IMG_KEY_PATH
][()]
return
self
.
_image_keys
return
self
.
_image_keys
...
@@ -424,6 +427,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -424,6 +427,7 @@ class HDF5TomoScan(TomoScanBase):
if
self
.
_entry
and
self
.
_image_keys_control
is
None
:
if
self
.
_entry
and
self
.
_image_keys_control
is
None
:
self
.
_check_hdf5scan_validity
()
self
.
_check_hdf5scan_validity
()
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
if
self
.
_IMG_KEY_CONTROL_PATH
in
h5_file
[
self
.
_entry
]:
if
self
.
_IMG_KEY_CONTROL_PATH
in
h5_file
[
self
.
_entry
]:
self
.
_image_keys_control
=
h5_file
[
self
.
_entry
][
self
.
_IMG_KEY_CONTROL_PATH
][()]
self
.
_image_keys_control
=
h5_file
[
self
.
_entry
][
self
.
_IMG_KEY_CONTROL_PATH
][()]
else
:
else
:
...
@@ -497,6 +501,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -497,6 +501,7 @@ class HDF5TomoScan(TomoScanBase):
def
_get_x_y_pixel_values
(
self
):
def
_get_x_y_pixel_values
(
self
):
"""read x and y pixel values"""
"""read x and y pixel values"""
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
x_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_X_PIXEL_SIZE_PATH
]
x_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_X_PIXEL_SIZE_PATH
]
_x_pixel_size
=
self
.
_get_value
(
x_pixel_dataset
,
default_unit
=
'meter'
)
_x_pixel_size
=
self
.
_get_value
(
x_pixel_dataset
,
default_unit
=
'meter'
)
y_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_Y_PIXEL_SIZE_PATH
]
y_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_Y_PIXEL_SIZE_PATH
]
...
@@ -505,6 +510,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -505,6 +510,7 @@ class HDF5TomoScan(TomoScanBase):
def
_get_x_y_magnified_pixel_values
(
self
):
def
_get_x_y_magnified_pixel_values
(
self
):
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
x_m_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_X_PIXEL_MAG_SIZE_PATH
]
x_m_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_X_PIXEL_MAG_SIZE_PATH
]
_x_m_pixel_size
=
self
.
_get_value
(
x_m_pixel_dataset
,
default_unit
=
'meter'
)
_x_m_pixel_size
=
self
.
_get_value
(
x_m_pixel_dataset
,
default_unit
=
'meter'
)
y_m_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_Y_PIXEL_MAG_SIZE_PATH
]
y_m_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_Y_PIXEL_MAG_SIZE_PATH
]
...
@@ -513,6 +519,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -513,6 +519,7 @@ class HDF5TomoScan(TomoScanBase):
def
_get_fov
(
self
):
def
_get_fov
(
self
):
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
,
libver
=
'latest'
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
,
libver
=
'latest'
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
if
self
.
_FOV_PATH
in
h5_file
[
self
.
_entry
]:
if
self
.
_FOV_PATH
in
h5_file
[
self
.
_entry
]:
fov
=
h5_file
[
self
.
_entry
][
self
.
_FOV_PATH
][()]
fov
=
h5_file
[
self
.
_entry
][
self
.
_FOV_PATH
][()]
return
_FOV
.
from_value
(
fov
)
return
_FOV
.
from_value
(
fov
)
...
@@ -556,6 +563,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -556,6 +563,7 @@ class HDF5TomoScan(TomoScanBase):
os
.
path
.
exists
(
self
.
master_file
)):
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_check_hdf5scan_validity
()
self
.
_check_hdf5scan_validity
()
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
distance_dataset
=
h5_file
[
self
.
_entry
][
self
.
_DISTANCE_PATH
]
distance_dataset
=
h5_file
[
self
.
_entry
][
self
.
_DISTANCE_PATH
]
self
.
_distance
=
self
.
_get_value
(
distance_dataset
,
default_unit
=
'm'
)
self
.
_distance
=
self
.
_get_value
(
distance_dataset
,
default_unit
=
'm'
)
return
self
.
_distance
return
self
.
_distance
...
@@ -577,6 +585,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -577,6 +585,7 @@ class HDF5TomoScan(TomoScanBase):
os
.
path
.
exists
(
self
.
master_file
)):
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_check_hdf5scan_validity
()
self
.
_check_hdf5scan_validity
()
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
energy_dataset
=
h5_file
[
self
.
_entry
][
self
.
_ENERGY_PATH
]
energy_dataset
=
h5_file
[
self
.
_entry
][
self
.
_ENERGY_PATH
]
self
.
_energy
=
self
.
_get_value
(
energy_dataset
,
default_unit
=
'keV'
)
self
.
_energy
=
self
.
_get_value
(
energy_dataset
,
default_unit
=
'keV'
)
return
self
.
_energy
return
self
.
_energy
...
@@ -685,6 +694,7 @@ class HDF5TomoScan(TomoScanBase):
...
@@ -685,6 +694,7 @@ class HDF5TomoScan(TomoScanBase):
if
self
.
entry
is
None
:
if
self
.
entry
is
None
:
raise
ValueError
(
'No entry provided'
)
raise
ValueError
(
'No entry provided'
)
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
os
.
environ
[
"HDF5_USE_FILE_LOCKING"
]
=
"FALSE"
if
self
.
_entry
not
in
h5_file
:
if
self
.
_entry
not
in
h5_file
:
raise
ValueError
(
'Given entry %s is not in the master '
raise
ValueError
(
'Given entry %s is not in the master '
'file %s'
%
(
self
.
_entry
,
self
.
master_file
))
'file %s'
%
(
self
.
_entry
,
self
.
master_file
))
...
...
Write
Preview
Markdown
is supported
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