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
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
1ee39114
Commit
1ee39114
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
rework in progress
parent
7e0f4bbf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/lib/plotting.py
+32
-19
32 additions, 19 deletions
saqc/lib/plotting.py
with
32 additions
and
19 deletions
saqc/lib/plotting.py
+
32
−
19
View file @
1ee39114
...
...
@@ -3,11 +3,11 @@
from
warnings
import
warn
def
plot
(
data
,
flags
,
flagmask
,
varname
,
flagger
,
interactive_backend
=
True
,
title
=
"
Data Plot
"
):
_nans_as_vertical_lines
=
True
def
plot
(
data
,
flags
,
flagmask
,
varname
,
flagger
,
interactive_backend
=
True
,
title
=
"
Data Plot
"
):
import
matplotlib
as
mpl
# the flagmask is True for flags to be shown False otherwise
if
not
interactive_backend
:
# Import plot libs without interactivity, if not needed. This ensures that this can
# produce an plot.png even if tkinter is not installed. E.g. if one want to run this
...
...
@@ -36,8 +36,11 @@ def plot(data, flags, flagmask, varname, flagger, interactive_backend=True, titl
def
plot_vline
(
plt
,
points
,
color
=
'
blue
'
):
# workaround for ax.vlines() as this work unexpected
for
point
in
points
:
plt
.
axvline
(
point
,
color
=
color
,
linestyle
=
'
:
'
)
# normally this should work:
# ax.vlines(idx, *ylim, linestyles=':', color='silver', label="missing")
if
_nans_as_vertical_lines
:
for
point
in
points
:
plt
.
axvline
(
point
,
color
=
color
,
linestyle
=
'
:
'
)
def
_plot
(
varname
,
ax
):
x
=
data
.
index
...
...
@@ -46,40 +49,37 @@ def plot(data, flags, flagmask, varname, flagger, interactive_backend=True, titl
nrofflags
=
len
(
flagger
.
flags
.
categories
)
ax
.
plot
(
x
,
y
,
'
-
'
,
markersize
=
1
,
color
=
'
silver
'
)
if
nrofflags
==
3
:
colors
=
{
0
:
'
silver
'
,
1
:
'
lime
'
,
2
:
'
red
'
}
colors
=
{
0
:
'
silver
'
,
1
:
'
lime
'
,
2
:
'
red
'
}
elif
nrofflags
==
4
:
colors
=
{
0
:
'
silver
'
,
1
:
'
lime
'
,
2
:
'
yellow
'
,
3
:
'
red
'
}
colors
=
{
0
:
'
silver
'
,
1
:
'
lime
'
,
2
:
'
yellow
'
,
3
:
'
red
'
}
else
:
warn
(
f
"
To many flags.
"
,
UserWarning
)
# plot (all) data in silver
# plot all data in silver
ax
.
plot
(
x
,
y
,
'
-
'
,
color
=
'
silver
'
,
label
=
'
data
'
)
# plot
(
all
) missing data in silver
# plot all
unplottable data as vertical lines
nans
=
y
.
isna
()
flagged
=
flagger
.
isFlagged
(
flags_
)
idx
=
y
.
index
[
nans
&
~
flagged
]
# ax.vlines(idx, *ylim, linestyles=':', color='silver', label="missing")
plot_vline
(
ax
,
idx
,
color
=
'
silver
'
)
# plot all flagged
data
in black
# plot all
data and nans that was already
flagged in black
ax
.
plot
(
x
[
flagged
],
y
[
flagged
],
'
.
'
,
color
=
'
black
'
,
label
=
"
flagged by other test
"
)
# plot all flagged missing data (flagged before) in black
idx
=
y
.
index
[
nans
&
flagged
&
~
flagmask
]
# ax.vlines(idx, *ylim, linestyles=':', color='black')
plot_vline
(
ax
,
idx
,
color
=
'
black
'
)
ax
.
set_ylabel
(
varname
)
# plot currently flagged data in color of flag
for
i
,
f
in
enumerate
(
flagger
.
flags
):
if
i
==
0
:
continue
flagged
=
flagger
.
isFlagged
(
flags_
,
flag
=
f
)
&
flagmask
#
if i == 0:
#
continue
flagged
=
flagger
.
isFlagged
(
flags_
,
flag
=
f
,
comparator
=
'
==
'
)
&
flagmask
label
=
f
"
flag:
{
f
}
"
if
i
else
'
data
'
ax
.
plot
(
x
[
flagged
],
y
[
flagged
],
'
.
'
,
color
=
colors
[
i
],
label
=
label
)
color
=
_get_color
(
f
,
flagger
)
ax
.
plot
(
x
[
flagged
],
y
[
flagged
],
'
.
'
,
color
=
color
,
label
=
label
)
idx
=
y
.
index
[
nans
&
flagged
]
# ax.vlines(idx, *ylim, linestyles=':', color=colors[i])
plot_vline
(
ax
,
idx
,
color
=
colors
[
i
])
plot_vline
(
ax
,
idx
,
color
=
color
)
plots
=
len
(
varname
)
if
plots
>
1
:
...
...
@@ -98,3 +98,16 @@ def plot(data, flags, flagmask, varname, flagger, interactive_backend=True, titl
plt
.
legend
()
plt
.
show
()
def
_get_color
(
flag
,
flagger
):
if
flag
==
flagger
.
UNFLAGGED
:
return
'
silver
'
if
flag
==
flagger
.
GOOD
:
return
'
green
'
if
flag
==
flagger
.
BAD
:
return
'
red
'
if
flag
in
list
(
flagger
.
SUSPICIOUS
):
return
'
yellow
'
return
'
blue
'
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