Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
Issue boards
Milestones
Wiki
Code
Merge requests
8
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
Service Desk
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
rdm-software
SaQC
Commits
0a813ccf
Commit
0a813ccf
authored
4 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
bfx@modelling_polyFit
parent
45baa07c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!193
Release 1.4
,
!188
Release 1.4
,
!49
Dataprocessing features
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
saqc/funcs/data_modelling.py
+6
-6
6 additions, 6 deletions
saqc/funcs/data_modelling.py
saqc/lib/ts_operators.py
+8
-0
8 additions, 0 deletions
saqc/lib/ts_operators.py
with
14 additions
and
6 deletions
saqc/funcs/data_modelling.py
+
6
−
6
View file @
0a813ccf
...
...
@@ -8,10 +8,10 @@ from saqc.lib.ts_operators import polyRoller, polyRollerNoMissing, polyRoller_nu
validationAgg
@register
def
modelling_polyFit
(
data
,
field
,
flagger
,
winsz
,
polydeg
,
numba
=
'
auto
'
,
eval_flags
=
True
,
min_periods
=
0
,
**
kwargs
):
to_fit
=
data
[
field
].
copy
()
data
=
data
.
copy
()
to_fit
=
data
[
field
]
flags
=
flagger
.
getFlags
(
field
)
if
numba
==
'
auto
'
:
if
to_fit
.
shape
[
0
]
<
200000
:
...
...
@@ -33,10 +33,10 @@ def modelling_polyFit(data, field, flagger, winsz, polydeg, numba='auto', eval_f
if
numba
:
residues
=
to_fit
.
rolling
(
winsz
,
center
=
True
).
apply
(
polyRoller_numba
,
args
=
(
miss_marker
,
val_range
,
center_index
,
polydeg
),
engine
=
'
numba
'
,
engine_kwargs
=
{
'
no_python
'
:
True
})
raw
=
True
,
engine
=
'
numba
'
,
engine_kwargs
=
{
'
no_python
'
:
True
})
else
:
residues
=
to_fit
.
rolling
(
winsz
,
center
=
True
).
apply
(
polyRoller
,
args
=
(
miss_marker
,
val_range
,
center_index
,
polydeg
))
args
=
(
miss_marker
,
val_range
,
center_index
,
polydeg
)
,
raw
=
True
)
residues
=
residues
-
to_fit
residues
[
na_mask
]
=
np
.
nan
else
:
...
...
@@ -44,10 +44,10 @@ def modelling_polyFit(data, field, flagger, winsz, polydeg, numba='auto', eval_f
if
numba
:
residues
=
to_fit
.
rolling
(
winsz
,
center
=
True
).
apply
(
polyRollerNoMissing_numba
,
args
=
(
val_range
,
center_index
,
polydeg
),
engine
=
'
numba
'
,
engine_kwargs
=
{
'
no_python
'
:
True
})
engine
=
'
numba
'
,
engine_kwargs
=
{
'
no_python
'
:
True
}
,
raw
=
True
)
else
:
residues
=
to_fit
.
rolling
(
winsz
,
center
=
True
).
apply
(
polyRollerNoMissing
,
args
=
(
val_range
,
center_index
,
polydeg
))
args
=
(
val_range
,
center_index
,
polydeg
)
,
raw
=
True
)
data
[
field
]
=
residues
if
eval_flags
:
...
...
This diff is collapsed.
Click to expand it.
saqc/lib/ts_operators.py
+
8
−
0
View file @
0a813ccf
...
...
@@ -367,6 +367,7 @@ def _fit_x(a, b):
@nb.jit
def
fit_poly
(
x
,
y
,
deg
):
# a numba compatible polynomial fit function
a
=
_coeff_mat
(
x
,
deg
)
p
=
_fit_x
(
a
,
y
)
# Reverse order so p[0] is coefficient of highest order
...
...
@@ -375,6 +376,7 @@ def fit_poly(x, y, deg):
@nb.jit
def
eval_polynomial
(
P
,
x
):
# a numba compatible polynomial evaluator
result
=
0
for
coeff
in
P
:
result
=
x
*
result
+
coeff
...
...
@@ -382,6 +384,7 @@ def eval_polynomial(P, x):
def
polyRoller_numba
(
in_slice
,
miss_marker
,
val_range
,
center_index
,
poly_deg
):
# numba compatible function to roll with when modelling data with polynomial model
miss_mask
=
(
in_slice
==
miss_marker
)
x_data
=
val_range
[
~
miss_mask
]
y_data
=
in_slice
[
~
miss_mask
]
...
...
@@ -390,11 +393,14 @@ def polyRoller_numba(in_slice, miss_marker, val_range, center_index, poly_deg):
def
polyRollerNoMissing_numba
(
in_slice
,
val_range
,
center_index
,
poly_deg
):
# numba compatible function to roll with when modelling data with polynomial model -
# it is assumed, that in slice is an equidistant sample
fitted
=
fit_poly
(
val_range
,
in_slice
,
deg
=
poly_deg
)
return
eval_polynomial
(
fitted
,
center_index
)
def
polyRoller
(
in_slice
,
miss_marker
,
val_range
,
center_index
,
poly_deg
):
# function to roll with when modelling data with polynomial model
miss_mask
=
(
in_slice
==
miss_marker
)
x_data
=
val_range
[
~
miss_mask
]
y_data
=
in_slice
[
~
miss_mask
]
...
...
@@ -403,5 +409,7 @@ def polyRoller(in_slice, miss_marker, val_range, center_index, poly_deg):
def
polyRollerNoMissing
(
in_slice
,
val_range
,
center_index
,
poly_deg
):
# function to roll with when modelling data with polynomial model
# it is assumed, that in slice is an equidistant sample
fitted
=
poly
.
polyfit
(
x
=
val_range
,
y
=
in_slice
,
deg
=
poly_deg
)
return
poly
.
polyval
(
center_index
,
fitted
)
\ No newline at end of file
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