Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.io.stream
Commits
ec188036
Commit
ec188036
authored
Sep 27, 2021
by
Vincent POLLET
Browse files
Write timestamps to file as dataset attributes along with data
parent
4669efb1
Pipeline
#54317
failed with stage
in 99 minutes and 1 second
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
bob/io/stream/stream.py
View file @
ec188036
...
...
@@ -862,7 +862,16 @@ class StreamSave(StreamFilter):
raise
ValueError
(
"Output file is not a valid StreamFile."
)
def
put
(
self
,
data
,
timestamp
=
None
):
self
.
file
.
put_frame
(
self
.
name
,
data
)
"""Pass data and timestamp to the :obj:`~bob.io.stream.StreamFile` to write to disk.
Parameters
----------
data : :obj:`numpy.ndarray`
data to write to file.
timestamp : int or float
Timestamp of `data`, by default None.
"""
self
.
file
.
put_frame
(
self
.
name
,
data
,
timestamp
)
################################################################################
...
...
bob/io/stream/stream_file.py
View file @
ec188036
...
...
@@ -200,7 +200,7 @@ class StreamFile:
# TODO rotate if requested
return
data
def
put_frame
(
self
,
name
,
data
):
def
put_frame
(
self
,
name
,
data
,
timestamp
=
None
):
"""Appends `data` (a frame of a stream) to the hdf5 file.
Parameters
...
...
@@ -211,3 +211,9 @@ class StreamFile:
Data frame to append.
"""
self
.
hdf5_file
.
append
(
name
,
data
)
if
timestamp
is
not
None
:
try
:
previous_timestamps
=
self
.
hdf5_file
.
get_attribute
(
"timestamps"
,
name
)
except
RuntimeError
:
# No previous timestamps
previous_timestamps
=
[]
self
.
hdf5_file
.
set_attribute
(
"timestamps"
,
np
.
append
(
previous_timestamps
,
timestamp
),
name
)
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