Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Datalogger UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scientific Computing and Engineering Group
LippunerAG
WABEsense
Datalogger UI
Commits
729b5928
Commit
729b5928
authored
3 years ago
by
JuanPi Carbajal
Browse files
Options
Downloads
Patches
Plain Diff
serialui: get many samples form logger
parent
ebbb9a64
No related branches found
No related tags found
No related merge requests found
Pipeline
#238412
passed
3 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dataloggerui/serialui.py
+47
-1
47 additions, 1 deletion
dataloggerui/serialui.py
with
47 additions
and
1 deletion
dataloggerui/serialui.py
+
47
−
1
View file @
729b5928
...
...
@@ -160,7 +160,7 @@ def logger_present():
def
connect_logger
(
port
=
None
):
"""
Connect the default logger the given serial port name.
"""
Connect the default logger
to
the given serial port name.
The default logger is :obj:`.wbsLogger`.
...
...
@@ -181,6 +181,13 @@ def connect_logger(port=None):
print
(
f
'
Connected to
{
p
.
description
}
'
)
break
def
disconnect_logger
(
port
=
None
):
"""
Disconnect the default logger.
The default logger is :obj:`.wbsLogger`.
"""
wbsLogger
.
close
()
# -------------
# Getters
...
...
@@ -732,3 +739,42 @@ def data_clear():
delete_samples
=
data_clear
"""
Alias for :func:`~.data_clear`.
"""
def
get_data_to_pandas
(
*
,
from_sample
=
0
,
resample
=
True
):
"""
Get series of smaples and return a :class:`pandas.DataFrame`
Each sample is retieved using :func:`~.get_sample` on the default logger.
Retrieving many samples can take a long time.
Arguments
---------
from_sample: int
Index of the starting sample. It should be lower than :func:`~.get_sample_count`[1]
resample: bool
Whether the data frame should eb resample to the sampling interval of the
logger, as returned by :func:`~.get_sampling_interval`.
Returns
-------
:class:`pandas.DataFrame`
See also
--------
:func:`~.get_sample`
:func:`~.get_sampling_interval`
"""
n_total
=
s
.
get_sample_count
()[
1
]
df
=
[]
for
n
in
range
(
from_sample
,
n_total
):
df
.
append
(
s
.
get_sample
(
sample
=
n
).
_asdict
())
df
=
pd
.
DataFrame
.
from_records
(
df
).
set_index
(
'
datetime
'
)
if
resample
:
sampling
=
s
.
get_sampling_interval
()
s_str
=
f
'
{
sampling
[
0
]
:
d
}{
sampling
[
1
]
}
'
df
=
df
.
rolling
(
s_str
).
mean
().
resample
(
s_str
).
mean
()
return
df
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment