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
67e20718
Commit
67e20718
authored
May 12, 2022
by
Henri Payno
Browse files
current: only register current with start_time if find only one electric current
parent
33fa0a94
Pipeline
#74674
passed with stages
in 3 minutes and 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nxtomomill/converter/hdf5/acquisition/standardacquisition.py
View file @
67e20718
...
...
@@ -520,15 +520,19 @@ class StandardAcquisition(BaseAcquisition):
new_know_electric_currents
=
{}
if
start_time
is
None
or
end_time
is
None
:
_logger
.
warning
(
"Unable to find start_time and / or end_time. Will pick the first available electricl_current for the frame"
)
if
start_time
!=
end_time
:
_logger
.
warning
(
f
"Unable to find
{
'start_time'
if
start_time
is
None
else
'end_time'
}
. Will pick the first available electric_current for the frame"
)
t_time
=
start_time
or
end_time
# if at least one can find out
new_know_electric_currents
[
str_datetime_to_numpy_datetime64
(
t_time
)
]
=
(
electric_currents
[
0
]
*
unit_factor
)
else
:
_logger
.
error
(
"Unable to find start_time and end_time. Will not register any machine electric current"
)
elif
len
(
electric_currents
)
==
1
:
# if we have only one value, consider the machine electric current is constant during this time
# might be improved later if we can know if current is determine at the
...
...
@@ -537,9 +541,6 @@ class StandardAcquisition(BaseAcquisition):
new_know_electric_currents
[
str_datetime_to_numpy_datetime64
(
start_time
)
]
=
(
electric_currents
[
0
]
*
unit_factor
)
new_know_electric_currents
[
str_datetime_to_numpy_datetime64
(
end_time
)
]
=
(
electric_currents
[
0
]
*
unit_factor
)
else
:
# linspace from datetime within ms precision.
# see https://localcoder.org/creating-numpy-linspace-out-of-datetime#credit_4
...
...
nxtomomill/converter/hdf5/test/test_hdf5converter.py
View file @
67e20718
...
...
@@ -1035,16 +1035,12 @@ def test_machine_electric_current():
"2022-01-15T21:07:58.360095+02:00"
,
"2022-01-15T21:07:59.360095+02:00"
,
)
end_times
=
(
"2022-01-15T21:07:59.170095+02:00"
,
None
)
for
(
node_name
,
machine_elec_current_ma
,
st
,
et
)
in
zip
(
node_names
,
machine_elec_current
,
start_times
,
end_times
for
(
node_name
,
machine_elec_current_ma
,
st
)
in
zip
(
node_names
,
machine_elec_current
,
start_times
):
h5f
[
f
"
{
node_name
}
/instrument/machine/current"
]
=
machine_elec_current_ma
h5f
[
f
"
{
node_name
}
/instrument/machine/current"
].
attrs
[
"unit"
]
=
"mA"
if
st
is
not
None
:
h5f
[
node_name
][
"start_time"
]
=
st
if
et
is
not
None
:
h5f
[
node_name
][
"end_time"
]
=
et
h5f
[
node_name
][
"start_time"
]
=
st
assert
"4.1"
in
h5f
assert
"5.1"
in
h5f
...
...
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