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
tomotools
tomoscan
Commits
1efd86cb
Commit
1efd86cb
authored
Jun 24, 2020
by
Tomas Farago
Committed by
payno
Jun 24, 2020
Browse files
[tomohdf5scan] fix units conversion from _get_value and return distance in meter now
parent
04693d98
Changes
1
Show whitespace changes
Inline
Side-by-side
tomoscan/esrf/hdf5scan.py
View file @
1efd86cb
...
...
@@ -482,10 +482,12 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
pixel_size
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""return x pixel size in meter"""
return
self
.
x_pixel_size
@
property
def
x_pixel_size
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""return x pixel size in meter"""
if
(
self
.
_x_pixel_size
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_x_pixel_size
,
self
.
_y_pixel_size
=
self
.
_get_x_y_pixel_values
()
...
...
@@ -496,17 +498,17 @@ class HDF5TomoScan(TomoScanBase):
"""read x and y pixel values"""
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
x_pixel_dataset
=
h5_file
[
self
.
_entry
][
self
.
_X_PIXEL_SIZE_PATH
]
_x_pixel_size
=
self
.
_get_value
(
x_pixel_dataset
,
default_unit
=
'
micro
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_size
=
self
.
_get_value
(
y_pixel_dataset
,
default_unit
=
'
micro
meter'
)
_y_pixel_size
=
self
.
_get_value
(
y_pixel_dataset
,
default_unit
=
'meter'
)
return
_x_pixel_size
,
_y_pixel_size
def
_get_x_y_magnified_pixel_values
(
self
):
with
h5py
.
File
(
self
.
master_file
,
'r'
,
swmr
=
True
)
as
h5_file
:
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
=
'
micro
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_size
=
self
.
_get_value
(
y_m_pixel_dataset
,
default_unit
=
'
micro
meter'
)
_y_m_pixel_size
=
self
.
_get_value
(
y_m_pixel_dataset
,
default_unit
=
'meter'
)
return
_x_m_pixel_size
,
_y_m_pixel_size
def
_get_dim1_dim2
(
self
):
...
...
@@ -517,6 +519,7 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
y_pixel_size
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""return y pixel size in meter"""
if
(
self
.
_y_pixel_size
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_x_pixel_size
,
self
.
_y_pixel_size
=
self
.
_get_x_y_pixel_values
()
...
...
@@ -524,6 +527,7 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
x_magnified_pixel_size
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""return x magnified pixel size in meter"""
if
(
self
.
_x_magnified_pixel_size
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_x_magnified_pixel_size
,
self
.
_y_magnified_pixel_size
=
self
.
_get_x_y_magnified_pixel_values
()
...
...
@@ -531,6 +535,7 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
y_magnified_pixel_size
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""return y magnified pixel size in meter"""
if
(
self
.
_y_magnified_pixel_size
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_x_magnified_pixel_size
,
self
.
_y_magnified_pixel_size
=
self
.
_get_x_y_magnified_pixel_values
()
...
...
@@ -538,6 +543,7 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
distance
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""return sample detector distance in meter"""
if
(
self
.
_distance
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_check_hdf5scan_validity
()
...
...
@@ -548,6 +554,7 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
energy
(
self
)
->
typing
.
Union
[
None
,
float
]:
"""energy in keV"""
if
(
self
.
_energy
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
)):
self
.
_check_hdf5scan_validity
()
...
...
@@ -654,7 +661,7 @@ class HDF5TomoScan(TomoScanBase):
unit
=
node
.
attrs
[
'units'
]
else
:
unit
=
default_unit
return
value
*
metricsystem
.
MetricSystem
.
from_value
(
unit
).
value
return
value
/
metricsystem
.
MetricSystem
.
from_value
(
unit
).
value
def
_check_hdf5scan_validity
(
self
):
if
self
.
master_file
is
None
:
...
...
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