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
!225
Resolve "release v1.2.0"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "release v1.2.0"
release_v1.2.0
into
master
Overview
0
Commits
96
Pipelines
3
Changes
1
Merged
Ghost User
requested to merge
release_v1.2.0
into
master
4 years ago
Overview
0
Commits
96
Pipelines
3
Changes
1
Expand
Closes
#257 (closed)
Edited
4 years ago
by
Ghost User
0
0
Merge request reports
Viewing commit
4d79f00f
Prev
Next
Show latest version
1 file
+
77
−
39
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
4d79f00f
encapsulate all plot routines into a try except statement with a general Exception case
· 4d79f00f
leufen1
authored
4 years ago
mlair/run_modules/post_processing.py
+
77
−
39
Options
@@ -239,6 +239,7 @@ class PostProcessing(RunEnvironment):
model
=
keras
.
models
.
load_model
(
model_name
,
custom_objects
=
model_class
.
custom_objects
)
return
model
# noinspection PyBroadException
def
plot
(
self
):
"""
Create all plots.
@@ -263,46 +264,83 @@ class PostProcessing(RunEnvironment):
plot_list
=
self
.
data_store
.
get
(
"
plot_list
"
,
"
postprocessing
"
)
time_dimension
=
self
.
data_store
.
get
(
"
time_dim
"
)
if
(
"
filter
"
in
self
.
test_data
[
0
].
get_X
(
as_numpy
=
False
)[
0
].
coords
)
and
(
"
PlotSeparationOfScales
"
in
plot_list
):
PlotSeparationOfScales
(
self
.
test_data
,
plot_folder
=
self
.
plot_path
)
if
(
self
.
bootstrap_skill_scores
is
not
None
)
and
(
"
PlotBootstrapSkillScore
"
in
plot_list
):
PlotBootstrapSkillScore
(
self
.
bootstrap_skill_scores
,
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
if
"
PlotConditionalQuantiles
"
in
plot_list
:
PlotConditionalQuantiles
(
self
.
test_data
.
keys
(),
data_pred_path
=
path
,
plot_folder
=
self
.
plot_path
)
if
"
PlotStationMap
"
in
plot_list
:
if
self
.
data_store
.
get
(
"
hostname
"
)[:
2
]
in
self
.
data_store
.
get
(
"
hpc_hosts
"
)
or
self
.
data_store
.
get
(
"
hostname
"
)[:
6
]
in
self
.
data_store
.
get
(
"
hpc_hosts
"
):
logging
.
warning
(
f
"
Skip
'
PlotStationMap` because running on a hpc node:
{
self
.
data_store
.
get
(
'
hostname
'
)
}
"
)
else
:
gens
=
[(
self
.
train_data
,
{
"
marker
"
:
5
,
"
ms
"
:
9
}),
(
self
.
val_data
,
{
"
marker
"
:
6
,
"
ms
"
:
9
}),
(
self
.
test_data
,
{
"
marker
"
:
4
,
"
ms
"
:
9
})]
PlotStationMap
(
generators
=
gens
,
plot_folder
=
self
.
plot_path
)
gens
=
[(
self
.
train_val_data
,
{
"
marker
"
:
8
,
"
ms
"
:
9
}),
(
self
.
test_data
,
{
"
marker
"
:
9
,
"
ms
"
:
9
})]
PlotStationMap
(
generators
=
gens
,
plot_folder
=
self
.
plot_path
,
plot_name
=
"
station_map_var
"
)
if
"
PlotMonthlySummary
"
in
plot_list
:
PlotMonthlySummary
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
self
.
target_var
,
plot_folder
=
self
.
plot_path
)
if
"
PlotClimatologicalSkillScore
"
in
plot_list
:
PlotClimatologicalSkillScore
(
self
.
skill_scores
[
1
],
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
PlotClimatologicalSkillScore
(
self
.
skill_scores
[
1
],
plot_folder
=
self
.
plot_path
,
score_only
=
False
,
extra_name_tag
=
"
all_terms_
"
,
model_setup
=
"
CNN
"
)
if
"
PlotCompetitiveSkillScore
"
in
plot_list
:
PlotCompetitiveSkillScore
(
self
.
skill_scores
[
0
],
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
if
"
PlotTimeSeries
"
in
plot_list
:
PlotTimeSeries
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
plot_folder
=
self
.
plot_path
,
sampling
=
self
.
_sampling
)
if
"
PlotAvailability
"
in
plot_list
:
avail_data
=
{
"
train
"
:
self
.
train_data
,
"
val
"
:
self
.
val_data
,
"
test
"
:
self
.
test_data
}
PlotAvailability
(
avail_data
,
plot_folder
=
self
.
plot_path
,
time_dimension
=
time_dimension
)
if
"
PlotAvailabilityHistogram
"
in
plot_list
:
avail_data
=
{
"
train
"
:
self
.
train_data
,
"
val
"
:
self
.
val_data
,
"
test
"
:
self
.
test_data
}
PlotAvailabilityHistogram
(
avail_data
,
plot_folder
=
self
.
plot_path
,
)
# time_dimension=time_dimension)
try
:
if
(
"
filter
"
in
self
.
test_data
[
0
].
get_X
(
as_numpy
=
False
)[
0
].
coords
)
and
(
"
PlotSeparationOfScales
"
in
plot_list
):
PlotSeparationOfScales
(
self
.
test_data
,
plot_folder
=
self
.
plot_path
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotSeparationOfScales due to the following error:
{
e
}
"
)
try
:
if
(
self
.
bootstrap_skill_scores
is
not
None
)
and
(
"
PlotBootstrapSkillScore
"
in
plot_list
):
PlotBootstrapSkillScore
(
self
.
bootstrap_skill_scores
,
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotBootstrapSkillScore due to the following error:
{
e
}
"
)
try
:
if
"
PlotConditionalQuantiles
"
in
plot_list
:
PlotConditionalQuantiles
(
self
.
test_data
.
keys
(),
data_pred_path
=
path
,
plot_folder
=
self
.
plot_path
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotConditionalQuantiles due to the following error:
{
e
}
"
)
try
:
if
"
PlotStationMap
"
in
plot_list
:
if
self
.
data_store
.
get
(
"
hostname
"
)[:
2
]
in
self
.
data_store
.
get
(
"
hpc_hosts
"
)
or
self
.
data_store
.
get
(
"
hostname
"
)[:
6
]
in
self
.
data_store
.
get
(
"
hpc_hosts
"
):
logging
.
warning
(
f
"
Skip
'
PlotStationMap` because running on a hpc node:
{
self
.
data_store
.
get
(
'
hostname
'
)
}
"
)
else
:
gens
=
[(
self
.
train_data
,
{
"
marker
"
:
5
,
"
ms
"
:
9
}),
(
self
.
val_data
,
{
"
marker
"
:
6
,
"
ms
"
:
9
}),
(
self
.
test_data
,
{
"
marker
"
:
4
,
"
ms
"
:
9
})]
PlotStationMap
(
generators
=
gens
,
plot_folder
=
self
.
plot_path
)
gens
=
[(
self
.
train_val_data
,
{
"
marker
"
:
8
,
"
ms
"
:
9
}),
(
self
.
test_data
,
{
"
marker
"
:
9
,
"
ms
"
:
9
})]
PlotStationMap
(
generators
=
gens
,
plot_folder
=
self
.
plot_path
,
plot_name
=
"
station_map_var
"
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotStationMap due to the following error:
{
e
}
"
)
try
:
if
"
PlotMonthlySummary
"
in
plot_list
:
PlotMonthlySummary
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
self
.
target_var
,
plot_folder
=
self
.
plot_path
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotMonthlySummary due to the following error:
{
e
}
"
)
try
:
if
"
PlotClimatologicalSkillScore
"
in
plot_list
:
PlotClimatologicalSkillScore
(
self
.
skill_scores
[
1
],
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
PlotClimatologicalSkillScore
(
self
.
skill_scores
[
1
],
plot_folder
=
self
.
plot_path
,
score_only
=
False
,
extra_name_tag
=
"
all_terms_
"
,
model_setup
=
"
CNN
"
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotClimatologicalSkillScore due to the following error:
{
e
}
"
)
try
:
if
"
PlotCompetitiveSkillScore
"
in
plot_list
:
PlotCompetitiveSkillScore
(
self
.
skill_scores
[
0
],
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotCompetitiveSkillScore due to the following error:
{
e
}
"
)
try
:
if
"
PlotTimeSeries
"
in
plot_list
:
PlotTimeSeries
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
plot_folder
=
self
.
plot_path
,
sampling
=
self
.
_sampling
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotTimeSeries due to the following error:
{
e
}
"
)
try
:
if
"
PlotAvailability
"
in
plot_list
:
avail_data
=
{
"
train
"
:
self
.
train_data
,
"
val
"
:
self
.
val_data
,
"
test
"
:
self
.
test_data
}
PlotAvailability
(
avail_data
,
plot_folder
=
self
.
plot_path
,
time_dimension
=
time_dimension
)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotAvailability due to the following error:
{
e
}
"
)
try
:
if
"
PlotAvailabilityHistogram
"
in
plot_list
:
avail_data
=
{
"
train
"
:
self
.
train_data
,
"
val
"
:
self
.
val_data
,
"
test
"
:
self
.
test_data
}
PlotAvailabilityHistogram
(
avail_data
,
plot_folder
=
self
.
plot_path
,
)
# time_dimension=time_dimension)
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot PlotAvailabilityHistogram due to the following error:
{
e
}
"
)
def
calculate_test_score
(
self
):
"""
Evaluate test score of model and save locally.
"""
Loading