Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BEA data analysis utils
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philipp Niedermayer
BEA data analysis utils
Commits
9a88cb27
Commit
9a88cb27
authored
2 years ago
by
Philipp Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
Generalize avg function
parent
61a58ffa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data/common.py
+6
-1
6 additions, 1 deletion
data/common.py
with
6 additions
and
1 deletion
data/common.py
+
6
−
1
View file @
9a88cb27
...
...
@@ -46,7 +46,12 @@ CMD_BEAM_INJECTION = 283
def
avg
(
*
data
,
n
=
100
):
return
[
np
.
array
(
d
)[:
int
(
len
(
d
)
/
n
)
*
n
].
reshape
(
-
1
,
n
).
mean
(
axis
=
1
)
for
d
in
data
]
if
n
else
data
"""
Averages the data by combining n subsequent points into one (works on last axis)
"""
result
=
[]
for
d
in
data
:
w
=
int
(
d
.
shape
[
-
1
]
/
n
)
result
.
append
(
d
[...,:
w
*
n
].
reshape
(
*
d
.
shape
[:
-
1
],
w
,
n
).
mean
(
axis
=-
1
))
return
result
def
smooth
(
*
data
,
n
):
return
[
scipy
.
signal
.
savgol_filter
(
d
,
n
,
0
)
for
d
in
data
]
if
n
else
data
...
...
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