Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
35
Issue boards
Milestones
Wiki
Code
Merge requests
7
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
c31a354c
Commit
c31a354c
authored
3 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Plain Diff
Merge branch 'plotInHistory' into cookBux
parents
37d283c9
e4fce003
No related branches found
Branches containing commit
No related tags found
Tags containing commit
7 merge requests
!685
Release 2.4
,
!684
Release 2.4
,
!567
Release 2.2.1
,
!566
Release 2.2
,
!501
Release 2.1
,
!372
fix doctest snippets
,
!369
Current documentation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
saqc/core/modules/tools.py
+1
-3
1 addition, 3 deletions
saqc/core/modules/tools.py
saqc/funcs/tools.py
+3
-11
3 additions, 11 deletions
saqc/funcs/tools.py
saqc/lib/plotting.py
+35
-38
35 additions, 38 deletions
saqc/lib/plotting.py
with
39 additions
and
52 deletions
saqc/core/modules/tools.py
+
1
−
3
View file @
c31a354c
...
...
@@ -39,9 +39,7 @@ class Tools(ModuleBase):
max_gap
:
Optional
[
FreqString
]
=
None
,
stats
:
bool
=
False
,
history
:
Optional
[
Literal
[
"
valid
"
,
"
complete
"
]]
=
"
valid
"
,
ax_kwargs
:
Optional
[
dict
]
=
None
,
fig_kwargs
:
Optional
[
dict
]
=
None
,
scatter_kwargs
:
Optional
[
dict
]
=
None
,
xscope
:
Optional
[
slice
]
=
None
,
stats_dict
:
Optional
[
dict
]
=
None
,
store_kwargs
:
Optional
[
dict
]
=
None
,
**
kwargs
,
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/tools.py
+
3
−
11
View file @
c31a354c
...
...
@@ -253,10 +253,7 @@ def plot(
max_gap
:
Optional
[
FreqString
]
=
None
,
stats
:
bool
=
False
,
history
:
Optional
[
Literal
[
"
valid
"
,
"
complete
"
]]
=
"
valid
"
,
s
:
Optional
[
slice
]
=
None
,
ax_kwargs
:
Optional
[
dict
]
=
None
,
fig_kwargs
:
Optional
[
dict
]
=
None
,
scatter_kwargs
:
Optional
[
dict
]
=
None
,
xscope
:
Optional
[
slice
]
=
None
,
stats_dict
:
Optional
[
dict
]
=
None
,
store_kwargs
:
Optional
[
dict
]
=
None
,
**
kwargs
,
...
...
@@ -313,7 +310,7 @@ def plot(
``Matplotlib.axes.Axes.set()`` property batch setter for the axes showing the
data plot. The most relevant of those properties might be
"
ylabel
"
,
"
title
"
and in addition:
"
ylim
"
.
The
"
y
lim
"
keyword can be passed a slice object with date offset entries to controll figure
The
"
x
lim
"
keyword can be passed a slice object with date offset entries to controll figure
scope.
...
...
@@ -375,9 +372,6 @@ def plot(
else
:
mpl
.
use
(
"
Agg
"
)
# ensure a proper size in stored plot
if
fig_kwargs
is
None
:
fig_kwargs
=
{
"
figsize
"
:
(
16
,
9
)}
fig
=
makeFig
(
data
=
data
,
...
...
@@ -387,9 +381,7 @@ def plot(
max_gap
=
max_gap
,
stats
=
stats
,
history
=
history
,
ax_kwargs
=
ax_kwargs
,
fig_kwargs
=
fig_kwargs
,
scatter_kwargs
=
scatter_kwargs
,
xscope
=
xscope
,
stats_dict
=
stats_dict
,
)
...
...
This diff is collapsed.
Click to expand it.
saqc/lib/plotting.py
+
35
−
38
View file @
c31a354c
...
...
@@ -9,7 +9,7 @@ import numpy as np
import
matplotlib
as
mpl
import
itertools
import
matplotlib.pyplot
as
plt
import
seaborn
from
saqc.constants
import
*
from
saqc.core
import
Flags
from
saqc.lib.types
import
DiosLikeT
,
FreqString
...
...
@@ -23,6 +23,18 @@ STATSDICT = {
"
flagged percentage
"
:
lambda
x
,
y
,
z
:
round
(((
y
>=
z
).
sum
())
/
len
(
x
),
2
),
}
PLOT_KWARGS
=
{
"
alpha
"
:
0.7
}
AX_KWARGS
=
{}
FIG_KWARGS
=
{
"
figsize
"
:
(
16
,
9
)}
SCATTER_KWARGS
=
{
"
marker
"
:
[
"
s
"
,
"
D
"
,
"
^
"
,
"
o
"
],
"
color
"
:
seaborn
.
color_palette
(
"
dark
"
),
"
alpha
"
:
0.5
,
"
zorder
"
:
10
,
"
edgecolors
"
:
"
black
"
,
"
s
"
:
70
,
}
def
makeFig
(
data
:
DiosLikeT
,
...
...
@@ -32,9 +44,7 @@ def makeFig(
max_gap
:
Optional
[
FreqString
]
=
None
,
stats
:
bool
=
False
,
history
:
Optional
[
Literal
[
"
valid
"
,
"
complete
"
]]
=
"
valid
"
,
ax_kwargs
:
Optional
[
dict
]
=
None
,
fig_kwargs
:
Optional
[
dict
]
=
None
,
scatter_kwargs
:
Optional
[
dict
]
=
None
,
xscope
:
Optional
[
slice
]
=
None
,
stats_dict
:
Optional
[
dict
]
=
None
,
):
"""
...
...
@@ -63,16 +73,7 @@ def makeFig(
stats : bool, default False
Whether to include statistics table in plot.
ax_kwargs : dict, default None
Keyword arguments controlling plot generation. Will be passed on to the
``Matplotlib.axes.Axes.set()`` property batch setter for the axes showing the
data plot. The most relevant of those properties might be
"
ylabel
"
,
"
title
"
and in addition:
"
ylim
"
.
The
"
ylim
"
keyword can be passed a slice object with date offset entries.
fig_kwargs : dict, default None
Keyword arguments controlling figure generation. None defaults to
{
"
figsize
"
: (16, 9)}
xscope :
stats_dict: dict, default None
(Only relevant if `stats`=True).
...
...
@@ -109,22 +110,17 @@ def makeFig(
>>>
func
=
lambda
x
,
y
,
z
:
round
((
x
.
isna
().
sum
())
/
len
(
x
),
2
)
"""
if
ax_kwargs
is
None
:
ax_kwargs
=
{}
if
fig_kwargs
is
None
:
fig_kwargs
=
{}
if
scatter_kwargs
is
None
:
scatter_kwargs
=
{}
if
stats_dict
is
None
:
stats_dict
=
{}
# data retrieval
d
=
data
[
field
]
# data slicing:
s
=
ax_kwargs
.
pop
(
"
ylim
"
,
slice
(
Non
e
)
)
d
=
d
[
s
]
flags_vals
=
flags
[
field
][
s
]
flags_hist
=
flags
.
history
[
field
].
hist
.
loc
[
s
]
xscope
=
xscope
or
slice
(
xscop
e
)
d
=
d
[
xscope
]
flags_vals
=
flags
[
field
][
xscope
]
flags_hist
=
flags
.
history
[
field
].
hist
.
loc
[
xscope
]
flags_meta
=
flags
.
history
[
field
].
meta
if
stats
:
stats_dict
.
update
(
STATSDICT
)
...
...
@@ -138,7 +134,7 @@ def makeFig(
d
=
_insertBlockingNaNs
(
d
,
max_gap
)
# figure composition
fig
=
mpl
.
pyplot
.
figure
(
constrained_layout
=
True
,
**
fig_kwargs
)
fig
=
mpl
.
pyplot
.
figure
(
constrained_layout
=
True
,
**
FIG_KWARGS
)
grid
=
fig
.
add_gridspec
()
if
stats
:
plot_gs
,
tab_gs
=
grid
[
0
].
subgridspec
(
ncols
=
2
,
nrows
=
1
,
width_ratios
=
[
5
,
1
])
...
...
@@ -156,8 +152,6 @@ def makeFig(
flags_meta
,
history
,
level
,
ax_kwargs
,
scatter_kwargs
,
na_mask
,
)
return
fig
...
...
@@ -193,24 +187,27 @@ def _plotVarWithFlags(
flags_meta
,
history
,
level
,
ax_kwargs
,
scatter_kwargs
,
na_mask
,
):
ax
.
set_title
(
datser
.
name
)
ax
.
plot
(
datser
,
color
=
"
black
"
)
ax
.
set
(
**
ax_kwargs
)
ax
.
plot
(
datser
,
color
=
"
black
"
,
**
PLOT_KWARGS
)
ax
.
set
(
**
AX_KWARGS
)
scatter_kwargs
=
SCATTER_KWARGS
.
copy
()
shape_cycle
=
scatter_kwargs
.
pop
(
"
marker
"
,
"
o
"
)
shape_cycle
=
itertools
.
cycle
(
toSequence
(
shape_cycle
))
color_cycle
=
scatter_kwargs
.
pop
(
"
color
"
,
plt
.
rcParams
[
"
axes.prop_cycle
"
].
by_key
()[
"
color
"
]
)
color_cycle
=
itertools
.
cycle
(
toSequence
(
color_cycle
))
scatter_kwargs
=
SCATTER_KWARGS
.
copy
()
if
history
:
shape_cycle
=
scatter_kwargs
.
pop
(
"
marker
"
,
"
o
"
)
shape_cycle
=
itertools
.
cycle
(
toSequence
(
shape_cycle
))
color_cycle
=
scatter_kwargs
.
pop
(
"
color
"
,
plt
.
rcParams
[
"
axes.prop_cycle
"
].
by_key
()[
"
color
"
]
)
color_cycle
=
itertools
.
cycle
(
toSequence
(
color_cycle
))
for
i
in
flags_hist
.
columns
:
scatter_kwargs
.
update
({
"
label
"
:
flags_meta
[
i
][
"
func
"
].
split
(
"
.
"
)[
-
1
]})
flags_i
=
flags_hist
[
i
].
astype
(
float
)
if
history
==
"
complete
"
:
scatter_kwargs
.
update
(
{
"
color
"
:
next
(
color_cycle
),
"
marker
"
:
next
(
shape_cycle
)}
)
_plotFlags
(
ax
,
datser
,
flags_i
,
na_mask
,
level
,
scatter_kwargs
)
if
history
==
"
valid
"
:
# only plot those flags, that do not get altered later on:
...
...
@@ -234,7 +231,7 @@ def _plotVarWithFlags(
)
ax
.
legend
()
else
:
scatter_kwargs
.
update
({
"
color
"
:
scatter_kwargs
.
pop
(
"
color
"
,
"
r
"
)})
scatter_kwargs
.
update
({
"
color
"
:
next
(
color_cycle
),
"
marker
"
:
next
(
shape_cycle
)})
_plotFlags
(
ax
,
datser
,
flags_vals
,
na_mask
,
level
,
scatter_kwargs
)
...
...
This diff is collapsed.
Click to expand it.
David Schäfer
@schaefed
mentioned in commit
63b55c6d
·
2 years ago
mentioned in commit
63b55c6d
mentioned in commit 63b55c6d7dadb0e612b23a897f292d5ffc14cb52
Toggle commit list
David Schäfer
@schaefed
mentioned in commit
684dc8a0
·
2 years ago
mentioned in commit
684dc8a0
mentioned in commit 684dc8a0515470d644fc85fee95d07661c8dd572
Toggle commit list
David Schäfer
@schaefed
mentioned in commit
8f7a90e4
·
1 year ago
mentioned in commit
8f7a90e4
mentioned in commit 8f7a90e4aed61c79a9dc8d67541a46beba0907e8
Toggle commit list
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