Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
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
Container registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Merge requests
!318
Resolve "release v1.4.0"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "release v1.4.0"
release_v1.4.0
into
master
Overview
0
Commits
229
Pipelines
3
Changes
1
Merged
Ghost User
requested to merge
release_v1.4.0
into
master
3 years ago
Overview
0
Commits
229
Pipelines
3
Changes
1
Expand
Closes
#317 (closed)
Edited
3 years ago
by
Ghost User
0
0
Merge request reports
Viewing commit
a6ba5850
Prev
Next
Show latest version
1 file
+
29
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
a6ba5850
fir filter can be used with daily data
· a6ba5850
leufen1
authored
4 years ago
mlair/data_handler/data_handler_with_filter.py
+
29
−
4
Options
@@ -117,15 +117,40 @@ class DataHandlerFirFilterSingleStation(DataHandlerFilterSingleStation):
filter_add_unfiltered
=
DEFAULT_ADD_UNFILTERED
,
**
kwargs
):
# self._check_sampling(**kwargs)
# self.original_data = None # ToDo: implement here something to store unfiltered data
self
.
filter_cutoff_period
=
(
lambda
x
:
[
x
]
if
isinstance
(
x
,
tuple
)
else
to_list
(
x
))(
filter_cutoff_period
)
self
.
fs
=
self
.
_get_fs
(
**
kwargs
)
self
.
filter_cutoff_period
,
removed_index
=
self
.
_prepare_filter_cutoff_period
(
filter_cutoff_period
,
self
.
fs
)
self
.
filter_cutoff_freq
=
self
.
_period_to_freq
(
self
.
filter_cutoff_period
)
assert
len
(
self
.
filter_cutoff_period
)
==
len
(
filter_order
)
self
.
filter_order
=
filter_order
assert
len
(
self
.
filter_cutoff_period
)
==
(
len
(
filter_order
)
-
len
(
removed_index
))
self
.
filter_order
=
self
.
_prepare_filter_order
(
filter_order
,
removed_index
,
self
.
fs
)
self
.
filter_window_type
=
filter_window_type
self
.
_add_unfiltered
=
filter_add_unfiltered
self
.
fs
=
self
.
_get_fs
(
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
@staticmethod
def
_prepare_filter_order
(
filter_order
,
removed_index
,
fs
):
order
=
[]
for
i
,
o
in
enumerate
(
filter_order
):
if
i
not
in
removed_index
:
fo
=
int
(
o
*
fs
)
fo
=
fo
+
1
if
fo
%
2
==
0
else
fo
order
.
append
(
fo
)
return
order
@staticmethod
def
_prepare_filter_cutoff_period
(
filter_cutoff_period
,
fs
):
"""
Frequency must be smaller than the sampling frequency fs. Otherwise remove given cutoff period pair.
"""
cutoff_tmp
=
(
lambda
x
:
[
x
]
if
isinstance
(
x
,
tuple
)
else
to_list
(
x
))(
filter_cutoff_period
)
cutoff
=
[]
removed
=
[]
for
i
,
(
low
,
high
)
in
enumerate
(
cutoff_tmp
):
low
=
low
if
(
low
is
None
or
low
>
2.
/
fs
)
else
None
high
=
high
if
(
high
is
None
or
high
>
2.
/
fs
)
else
None
if
any
([
low
,
high
]):
cutoff
.
append
((
low
,
high
))
else
:
removed
.
append
(
i
)
return
cutoff
,
removed
@staticmethod
def
_period_to_freq
(
cutoff_p
):
return
list
(
map
(
lambda
x
:
(
1.
/
x
[
0
]
if
x
[
0
]
is
not
None
else
None
,
1.
/
x
[
1
]
if
x
[
1
]
is
not
None
else
None
),
Loading