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
a8194826
Commit
a8194826
authored
Feb 25, 2020
by
payno
Browse files
[HDF5Scan] first raw add of the `christian` hdf5/nexus file for tomography
parent
d195d5c1
Pipeline
#21855
failed with stages
in 53 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/hdf5scan.py
View file @
a8194826
...
...
@@ -37,6 +37,7 @@ import numpy
from
silx.io.url
import
DataUrl
from
silx.utils.enum
import
Enum
as
_Enum
from
tomoscan.utils
import
docstring
from
silx.io.utils
import
get_data
import
logging
import
typing
...
...
@@ -312,9 +313,7 @@ class HDF5TomoScan(TomoScanBase):
"""
if
self
.
_tomo_n
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
):
if
self
.
projections
:
filter_fct
=
lambda
x
:
x
.
is_return
is
False
none_returnproj_frames
=
list
(
filter
(
filter_fct
,
self
.
projections
))
return
len
(
none_returnproj_frames
)
return
len
(
self
.
projections
)
else
:
return
None
else
:
...
...
@@ -388,17 +387,17 @@ class HDF5TomoScan(TomoScanBase):
@
property
def
dim_1
(
self
):
if
self
.
_dim_1
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
):
with
h5py
.
File
(
self
.
master_file
,
'r'
)
as
h5_fil
e
:
assert
self
.
_DET_META_PATH
in
h5_file
[
self
.
_entry
]
self
.
_dim_1
=
h5_file
[
self
.
_entry
][
self
.
_DET_META_PATH
][
'size'
][
0
]
if
self
.
projections
is
not
Non
e
:
if
len
(
self
.
projections
)
>
0
:
self
.
_dim_1
,
self
.
_dim_2
=
get_data
(
self
.
projections
[
0
]).
shape
return
self
.
_dim_1
@
property
def
dim_2
(
self
):
if
self
.
_dim_2
is
None
and
self
.
master_file
and
os
.
path
.
exists
(
self
.
master_file
):
with
h5py
.
File
(
self
.
master_file
,
'r'
)
as
h5_fil
e
:
assert
self
.
_DET_META_PATH
in
h5_file
[
self
.
_entry
]
self
.
_dim_
2
=
h5_file
[
self
.
_entry
][
self
.
_DET_META_PATH
][
'size'
][()][
1
]
if
self
.
projections
is
not
Non
e
:
if
len
(
self
.
projections
)
>
0
:
self
.
_dim_
1
,
self
.
_dim_2
=
get_data
(
self
.
projections
[
0
]).
shape
return
self
.
_dim_2
@
property
...
...
@@ -458,14 +457,17 @@ class HDF5TomoScan(TomoScanBase):
@
docstring
(
TomoScanBase
.
get_proj_angle_url
)
def
get_proj_angle_url
(
self
)
->
dict
:
res
=
{}
if
self
.
projections
is
not
None
:
for
frame
in
self
.
projections
:
res
[
frame
.
rotation_angle
]
=
frame
.
url
if
self
.
return_projs
:
for
frame
in
self
.
return_projs
:
res
[
str
(
frame
.
rotation_angle
)
+
'(1)'
]
=
frame
.
url
return
res
if
self
.
frames
is
not
None
:
res
=
{}
for
frame
in
self
.
frames
:
if
frame
.
image_key
is
ImageKey
.
PROJECTION
:
if
frame
.
is_return
is
False
:
res
[
frame
.
rotation_angle
]
=
frame
.
url
else
:
res
[
str
(
frame
.
rotation_angle
)
+
'(1)'
]
=
frame
.
url
return
res
else
:
return
None
def
__str__
(
self
):
return
'hdf5 scan(path: %s, master_file: %s, entry: %s)'
%
(
self
.
path
,
...
...
tomoscan/esrf/test/test_hdf5scan.py
View file @
a8194826
...
...
@@ -163,34 +163,31 @@ class TestHDF5Scan(HDF5TestBaseClass):
def
testFlats
(
self
):
"""Make sure flats are valid"""
n_flats
=
42
flats
=
self
.
scan
.
flats
self
.
assertEqual
(
len
(
flats
),
n_flats
)
self
.
assertEqual
(
self
.
scan
.
ref_n
,
n_flats
)
with
self
.
assertRaises
(
NotImplementedError
):
flats
=
self
.
scan
.
flats
n_ref
=
21
self
.
assertEqual
(
self
.
scan
.
ref_n
,
n_ref
)
self
.
scan
.
ff_interval
# for now not implemented
# not implemented at the moment
data
=
numpy
.
arange
(
2048
*
2048
)
data
.
reshape
(
2048
,
2048
)
# not implemented at the moment
self
.
assertEqual
(
self
.
scan
.
ff_interval
,
21
)
def
testDims
(
self
):
self
.
assertEqual
(
self
.
scan
.
dim_1
,
20
)
self
.
assertEqual
(
self
.
scan
.
dim_2
,
20
)
def
testAxisUtils
(
self
):
self
.
assertEqual
(
self
.
scan
.
scan_range
,
360
)
self
.
assertEqual
(
self
.
scan
.
tomo_n
,
100
)
# self.assertEqual(self.scan.dim_1, 2048)
# self.assertEqual(self.scan.dim_2, 2048)
self
.
assertEqual
(
self
.
scan
.
scan_range
,
180
)
self
.
assertEqual
(
self
.
scan
.
tomo_n
,
1500
)
proj0_file_path
=
'../../../../../../users/opid19/W:/clemence/visualtomo/data_test2/tomo0001/tomo_0000.h5'
radios_urls_evolution
=
self
.
scan
.
get_proj_angle_url
()
self
.
assertEquals
(
len
(
radios_urls_evolution
),
1
00
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
file_path
(),
proj0_file_path
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_slice
(),
(
'0'
,)
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_path
(),
'/entry
_
0000/
measurement/pcoedge64
/data'
)
self
.
assertEquals
(
len
(
radios_urls_evolution
),
1
503
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
file_path
(),
self
.
scan
.
master_file
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_slice
(),
22
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_path
(),
'/entry0000/
instrument/detector
/data'
)
def
testDarkRefUtils
(
self
):
self
.
assertEqual
(
self
.
scan
.
tomo_n
,
100
)
self
.
assertEqual
(
self
.
scan
.
pixel_size
[
1
],
6.5
)
self
.
assertEqual
(
self
.
scan
.
tomo_n
,
1500
)
# TODO: add after merge
# self.assertTrue(numpy.isclose(self.scan.get_pixel_size(unit='mm'), 0.05))
def
suite
():
...
...
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