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
Commits
4d79f00f
Commit
4d79f00f
authored
4 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
encapsulate all plot routines into a try except statement with a general Exception case
parent
7c87b30f
No related branches found
No related tags found
3 merge requests
!226
Develop
,
!225
Resolve "release v1.2.0"
,
!209
Resolve "Use try except statements for all plots"
Pipeline
#54879
passed
4 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mlair/run_modules/post_processing.py
+77
-39
77 additions, 39 deletions
mlair/run_modules/post_processing.py
with
77 additions
and
39 deletions
mlair/run_modules/post_processing.py
+
77
−
39
View file @
4d79f00f
...
@@ -239,6 +239,7 @@ class PostProcessing(RunEnvironment):
...
@@ -239,6 +239,7 @@ class PostProcessing(RunEnvironment):
model
=
keras
.
models
.
load_model
(
model_name
,
custom_objects
=
model_class
.
custom_objects
)
model
=
keras
.
models
.
load_model
(
model_name
,
custom_objects
=
model_class
.
custom_objects
)
return
model
return
model
# noinspection PyBroadException
def
plot
(
self
):
def
plot
(
self
):
"""
"""
Create all plots.
Create all plots.
...
@@ -263,14 +264,26 @@ class PostProcessing(RunEnvironment):
...
@@ -263,14 +264,26 @@ class PostProcessing(RunEnvironment):
plot_list
=
self
.
data_store
.
get
(
"
plot_list
"
,
"
postprocessing
"
)
plot_list
=
self
.
data_store
.
get
(
"
plot_list
"
,
"
postprocessing
"
)
time_dimension
=
self
.
data_store
.
get
(
"
time_dim
"
)
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
):
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
)
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
):
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
"
)
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
:
if
"
PlotConditionalQuantiles
"
in
plot_list
:
PlotConditionalQuantiles
(
self
.
test_data
.
keys
(),
data_pred_path
=
path
,
plot_folder
=
self
.
plot_path
)
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
"
PlotStationMap
"
in
plot_list
:
if
self
.
data_store
.
get
(
"
hostname
"
)[:
2
]
in
self
.
data_store
.
get
(
"
hpc_hosts
"
)
or
self
.
data_store
.
get
(
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
"
):
"
hostname
"
)[:
6
]
in
self
.
data_store
.
get
(
"
hpc_hosts
"
):
...
@@ -284,25 +297,50 @@ class PostProcessing(RunEnvironment):
...
@@ -284,25 +297,50 @@ class PostProcessing(RunEnvironment):
gens
=
[(
self
.
train_val_data
,
{
"
marker
"
:
8
,
"
ms
"
:
9
}),
gens
=
[(
self
.
train_val_data
,
{
"
marker
"
:
8
,
"
ms
"
:
9
}),
(
self
.
test_data
,
{
"
marker
"
:
9
,
"
ms
"
:
9
})]
(
self
.
test_data
,
{
"
marker
"
:
9
,
"
ms
"
:
9
})]
PlotStationMap
(
generators
=
gens
,
plot_folder
=
self
.
plot_path
,
plot_name
=
"
station_map_var
"
)
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
:
if
"
PlotMonthlySummary
"
in
plot_list
:
PlotMonthlySummary
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
self
.
target_var
,
PlotMonthlySummary
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
self
.
target_var
,
plot_folder
=
self
.
plot_path
)
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
:
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
,
model_setup
=
"
CNN
"
)
PlotClimatologicalSkillScore
(
self
.
skill_scores
[
1
],
plot_folder
=
self
.
plot_path
,
score_only
=
False
,
PlotClimatologicalSkillScore
(
self
.
skill_scores
[
1
],
plot_folder
=
self
.
plot_path
,
score_only
=
False
,
extra_name_tag
=
"
all_terms_
"
,
model_setup
=
"
CNN
"
)
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
:
if
"
PlotCompetitiveSkillScore
"
in
plot_list
:
PlotCompetitiveSkillScore
(
self
.
skill_scores
[
0
],
plot_folder
=
self
.
plot_path
,
model_setup
=
"
CNN
"
)
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
:
if
"
PlotTimeSeries
"
in
plot_list
:
PlotTimeSeries
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
plot_folder
=
self
.
plot_path
,
PlotTimeSeries
(
self
.
test_data
.
keys
(),
path
,
r
"
forecasts_%s_test.nc
"
,
plot_folder
=
self
.
plot_path
,
sampling
=
self
.
_sampling
)
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
:
if
"
PlotAvailability
"
in
plot_list
:
avail_data
=
{
"
train
"
:
self
.
train_data
,
"
val
"
:
self
.
val_data
,
"
test
"
:
self
.
test_data
}
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
)
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
:
if
"
PlotAvailabilityHistogram
"
in
plot_list
:
avail_data
=
{
"
train
"
:
self
.
train_data
,
"
val
"
:
self
.
val_data
,
"
test
"
:
self
.
test_data
}
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)
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
):
def
calculate_test_score
(
self
):
"""
Evaluate test score of model and save locally.
"""
"""
Evaluate test score of model and save locally.
"""
...
...
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