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
nxtomomill
Commits
2b95e4e4
Commit
2b95e4e4
authored
May 10, 2022
by
Henri Payno
Browse files
add a concatenate util class
parent
c8b6d8a5
Pipeline
#74454
passed with stages
in 3 minutes and 56 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nxtomomill/nexus/__init__.py
View file @
2b95e4e4
...
...
@@ -3,3 +3,4 @@ from .nxobject import NXobject # noqa F401
from
.nxsample
import
NXsample
# noqa F401
from
.nxsource
import
NXsource
# noqa F401
from
.nxtomo
import
NXtomo
# noqa F401
from
.utils
import
concatenate
# noqa F401
nxtomomill/nexus/nxdetector.py
View file @
2b95e4e4
...
...
@@ -30,7 +30,6 @@ __date__ = "03/02/2022"
from
functools
import
partial
from
multiprocessing.sharedctypes
import
Value
from
operator
import
is_not
from
silx.utils.proxy
import
docstring
from
silx.io.url
import
DataUrl
...
...
nxtomomill/nexus/nxtomo.py
View file @
2b95e4e4
...
...
@@ -372,7 +372,6 @@ class NXtomo(NXobject):
nx_tomo
.
start_time
=
min
(
start_times
)
nx_tomo
.
end_time
=
max
(
end_times
)
sample
=
NXsample
.
concatenate
(
tuple
([
nx_obj
.
sample
for
nx_obj
in
nx_objects
]))
nx_tomo
.
sample
=
NXsample
.
concatenate
(
tuple
([
nx_obj
.
sample
for
nx_obj
in
nx_objects
])
)
...
...
nxtomomill/nexus/test/test_nxtomo.py
View file @
2b95e4e4
...
...
@@ -32,7 +32,8 @@ import os
from
tempfile
import
TemporaryDirectory
from
nxtomomill.nexus.nxdetector
import
FieldOfView
import
pytest
from
nxtomomill.nexus.nxtomo
import
NXtomo
from
nxtomomill.nexus
import
NXtomo
from
nxtomomill.nexus
import
concatenate
from
datetime
import
datetime
from
tomoscan.esrf
import
HDF5TomoScan
from
tomoscan.validator
import
ReconstructionValidator
...
...
@@ -287,7 +288,7 @@ def test_nx_tomo(nexus_path_version):
)
# test concatenation
nx_tomo_concat
=
NXtomo
.
concatenate
([
loaded_nx_tomo
,
None
,
loaded_nx_tomo
])
nx_tomo_concat
=
concatenate
([
loaded_nx_tomo
,
None
,
loaded_nx_tomo
])
concat_file
=
os
.
path
.
join
(
folder
,
"concatenated_nexus_file.hdf5"
)
nx_tomo_concat
.
save
(
...
...
@@ -318,3 +319,6 @@ def test_nx_tomo(nexus_path_version):
]
),
)
with
pytest
.
raises
(
TypeError
):
concatenate
([
1
,
2
])
nxtomomill/nexus/utils.py
View file @
2b95e4e4
...
...
@@ -35,6 +35,8 @@ import numpy
import
h5py
from
silx.io.utils
import
h5py_read_dataset
from
nxtomomill.nexus.nxobject
import
NXobject
def
cast_and_check_array_1D
(
array
,
array_name
):
if
not
isinstance
(
array
,
(
type
(
None
),
numpy
.
ndarray
,
Iterable
)):
...
...
@@ -132,3 +134,12 @@ def get_data(file_path, data_path):
return
h5py_read_dataset
(
h5f
[
data_path
])
else
:
return
None
def
concatenate
(
nx_objects
,
**
kwargs
):
if
len
(
nx_objects
)
==
0
:
return
None
else
:
if
not
isinstance
(
nx_objects
[
0
],
NXobject
):
raise
TypeError
(
"nx_objects are expected to be instances of NXobject"
)
return
type
(
nx_objects
[
0
]).
concatenate
(
nx_objects
=
nx_objects
,
**
kwargs
)
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