Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AMBS
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
AMBS
Commits
eaefb332
Commit
eaefb332
authored
May 28, 2021
by
Michael Langguth
Browse files
Options
Downloads
Patches
Plain Diff
Add automated labeling of x- any a-axis to plot_cond_quantile-function.
parent
6be4c2e6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
video_prediction_tools/postprocess/postprocess_plotting.py
+15
-5
15 additions, 5 deletions
video_prediction_tools/postprocess/postprocess_plotting.py
with
15 additions
and
5 deletions
video_prediction_tools/postprocess/postprocess_plotting.py
+
15
−
5
View file @
eaefb332
...
@@ -15,6 +15,7 @@ import matplotlib
...
@@ -15,6 +15,7 @@ import matplotlib
matplotlib
.
use
(
'
Agg
'
)
matplotlib
.
use
(
'
Agg
'
)
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
mpl_toolkits.basemap
import
Basemap
from
mpl_toolkits.basemap
import
Basemap
from
general_utils
import
provide_default
def
plot_cond_quantile
(
quantile_panel
:
xr
.
DataArray
,
data_marginal
:
xr
.
DataArray
,
plt_fname
:
str
,
opt
:
dict
):
def
plot_cond_quantile
(
quantile_panel
:
xr
.
DataArray
,
data_marginal
:
xr
.
DataArray
,
plt_fname
:
str
,
opt
:
dict
):
...
@@ -39,18 +40,20 @@ def plot_cond_quantile(quantile_panel: xr.DataArray, data_marginal: xr.DataArray
...
@@ -39,18 +40,20 @@ def plot_cond_quantile(quantile_panel: xr.DataArray, data_marginal: xr.DataArray
raise
ValueError
(
"
%{0}: The coordinates of quantile_panel must be [
'
bin_center
'
,
'
quantile
'
]
"
.
format
(
method
))
raise
ValueError
(
"
%{0}: The coordinates of quantile_panel must be [
'
bin_center
'
,
'
quantile
'
]
"
.
format
(
method
))
bins_c
=
quantile_panel
[
"
bin_center
"
]
bins_c
=
quantile_panel
[
"
bin_center
"
]
bins
=
np
.
arange
(
bins_c
[
0
]
-
0.5
,
bins_c
+
0.5
+
1.
)
bin_width
=
bins_c
[
1
]
-
bins_c
[
0
]
bins
=
np
.
arange
(
bins_c
[
0
]
-
bin_width
/
2.
,
bins_c
+
1.5
*
bin_width
/
2
,
bin_width
)
quantiles
=
quantile_panel
[
"
quantile
"
]
quantiles
=
quantile_panel
[
"
quantile
"
]
nquantiles
=
len
(
quantiles
)
nquantiles
=
len
(
quantiles
)
if
nquantiles
%
2
!=
1
:
if
nquantiles
%
2
!=
1
:
raise
ValueError
(
"
%{0}: Number of quantiles must be odd.
"
.
format
(
method
))
raise
ValueError
(
"
%{0}: Number of quantiles must be odd.
"
.
format
(
method
))
ls_all
=
get_ls_mirrored
(
int
(
nquantiles
/
2
))
ls_all
=
get_ls_mirrored
(
int
(
nquantiles
/
2
))
lw_all
=
list
(
np
.
full
(
nquantiles
)
,
2.
)
lw_all
=
list
(
np
.
full
(
nquantiles
,
2.
)
)
lw_all
[
int
(
nquantiles
/
2
)]
=
1.5
lw_all
[
int
(
nquantiles
/
2
)]
=
1.5
# start plotting
# start plotting
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
12
,
6
))
figsize
=
provide_default
(
opt
,
"
figsize
"
,
(
12
,
6
))
fig
,
ax
=
plt
.
subplots
(
figsize
=
figsize
)
# plot reference line
# plot reference line
ax
.
plot
(
bins_c
,
bins_c
,
color
=
'
k
'
,
label
=
'
reference 1:1
'
,
linewidth
=
1.
)
ax
.
plot
(
bins_c
,
bins_c
,
color
=
'
k
'
,
label
=
'
reference 1:1
'
,
linewidth
=
1.
)
...
@@ -63,10 +66,17 @@ def plot_cond_quantile(quantile_panel: xr.DataArray, data_marginal: xr.DataArray
...
@@ -63,10 +66,17 @@ def plot_cond_quantile(quantile_panel: xr.DataArray, data_marginal: xr.DataArray
xr
.
plot
.
hist
(
data_marginal
,
ax
=
ax2
,
bins
=
bins
,
color
=
"
k
"
,
alpha
=
0.3
)
xr
.
plot
.
hist
(
data_marginal
,
ax
=
ax2
,
bins
=
bins
,
color
=
"
k
"
,
alpha
=
0.3
)
ax2
.
set_yscale
(
"
log
"
)
ax2
.
set_yscale
(
"
log
"
)
ax
.
set_ylabel
(
"
2m temperature from ERA5 [°C]
"
,
fontsize
=
16
)
ylabel
=
"
{0} [{1}]
"
.
format
(
provide_default
(
quantile_panel
.
attr
,
"
data_cond_longname
"
,
"
conditiong variable
"
),
ax
.
set_xlabel
(
"
Predicted 2m temperature from SAVP [°C]
"
,
fontsize
=
16
)
provide_default
(
quantile_panel
.
attr
,
"
data_cond_unit
"
,
"
unknown
"
))
xlabel
=
"
{0} [{1}]
"
.
format
(
provide_default
(
quantile_panel
.
attr
,
"
data_cond_longname
"
,
"
target variable
"
),
provide_default
(
quantile_panel
.
attr
,
"
data_cond_unit
"
,
"
unknown
"
))
ax
.
set_ylabel
(
ylabel
,
fontsize
=
16
)
ax2
.
set_ylabel
(
"
counts
"
,
fontsize
=
16
)
ax
.
set_xlabel
(
xlabel
,
fontsize
=
16
)
ax
.
tick_params
(
axis
=
"
both
"
,
labelsize
=
14
)
ax
.
tick_params
(
axis
=
"
both
"
,
labelsize
=
14
)
ax2
.
tick_params
(
axis
=
"
both
"
,
labelsize
=
14
)
fig
.
savefig
(
plt_fname
)
fig
.
savefig
(
plt_fname
)
plt
.
close
(
"
all
"
)
plt
.
close
(
"
all
"
)
...
...
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