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
caf68737
Commit
caf68737
authored
3 years ago
by
v.gramlich1
Browse files
Options
Downloads
Patches
Plain Diff
Workaround in statistics.py, climatological_skill_scores
parent
b15528b9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!302
Draft: Resolve "Class-based Oversampling technique"
Pipeline
#75568
passed
3 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/helpers/statistics.py
+45
-1
45 additions, 1 deletion
mlair/helpers/statistics.py
with
45 additions
and
1 deletion
mlair/helpers/statistics.py
+
45
−
1
View file @
caf68737
...
@@ -301,6 +301,47 @@ class SkillScores:
...
@@ -301,6 +301,47 @@ class SkillScores:
observation_name
=
self
.
observation_name
)
observation_name
=
self
.
observation_name
)
for
(
first
,
second
)
in
combinations
]
for
(
first
,
second
)
in
combinations
]
return
skill_score
return
skill_score
'''
def climatological_skill_scores(self, internal_data: Data, forecast_name: str) -> xr.DataArray:
"""
Calculate climatological skill scores according to Murphy (1988).
Calculate all CASES I - IV and terms [ABC][I-IV]. Internal data has to be set by initialisation, external data
is part of parameters.
:param internal_data: internal data
:param forecast_name: name of the forecast to use for this calculation (must be available in `data`)
:return: all CASES as well as all terms
"""
ahead_names = list(self.external_data[self.ahead_dim].data)
all_terms = [
'
AI
'
,
'
AII
'
,
'
AIII
'
,
'
AIV
'
,
'
BI
'
,
'
BII
'
,
'
BIV
'
,
'
CI
'
,
'
CIV
'
,
'
CASE I
'
,
'
CASE II
'
,
'
CASE III
'
,
'
CASE IV
'
]
skill_score = xr.DataArray(np.full((len(all_terms), len(ahead_names)), np.nan), coords=[all_terms, ahead_names],
dims=[
'
terms
'
, self.ahead_dim])
for iahead in ahead_names:
data = internal_data.sel({self.ahead_dim: iahead})
skill_score.loc[[
"
CASE I
"
,
"
AI
"
,
"
BI
"
,
"
CI
"
], iahead] = np.stack(self._climatological_skill_score(
data, mu_type=1, forecast_name=forecast_name, observation_name=self.observation_name).values.flatten())
skill_score.loc[[
"
CASE II
"
,
"
AII
"
,
"
BII
"
], iahead] = np.stack(self._climatological_skill_score(
data, mu_type=2, forecast_name=forecast_name, observation_name=self.observation_name).values.flatten())
if self.external_data is not None and self.observation_name in self.external_data.coords[
"
type
"
]:
external_data = self.external_data.sel({self.ahead_dim: iahead,
"
type
"
: [self.observation_name]})
skill_score.loc[[
"
CASE III
"
,
"
AIII
"
], iahead] = np.stack(self._climatological_skill_score(
data, mu_type=3, forecast_name=forecast_name, observation_name=self.observation_name,
external_data=external_data).values.flatten())
skill_score.loc[[
"
CASE IV
"
,
"
AIV
"
,
"
BIV
"
,
"
CIV
"
], iahead] = np.stack(self._climatological_skill_score(
data, mu_type=4, forecast_name=forecast_name, observation_name=self.observation_name,
external_data=external_data).values.flatten())
return skill_score
'''
def
climatological_skill_scores
(
self
,
internal_data
:
Data
,
forecast_name
:
str
)
->
xr
.
DataArray
:
def
climatological_skill_scores
(
self
,
internal_data
:
Data
,
forecast_name
:
str
)
->
xr
.
DataArray
:
"""
"""
...
@@ -314,6 +355,9 @@ class SkillScores:
...
@@ -314,6 +355,9 @@ class SkillScores:
:return: all CASES as well as all terms
:return: all CASES as well as all terms
"""
"""
if
self
.
external_data
is
None
:
ahead_names
=
[]
else
:
ahead_names
=
list
(
self
.
external_data
[
self
.
ahead_dim
].
data
)
ahead_names
=
list
(
self
.
external_data
[
self
.
ahead_dim
].
data
)
all_terms
=
[
'
AI
'
,
'
AII
'
,
'
AIII
'
,
'
AIV
'
,
'
BI
'
,
'
BII
'
,
'
BIV
'
,
'
CI
'
,
'
CIV
'
,
'
CASE I
'
,
'
CASE II
'
,
'
CASE III
'
,
all_terms
=
[
'
AI
'
,
'
AII
'
,
'
AIII
'
,
'
AIV
'
,
'
BI
'
,
'
BII
'
,
'
BIV
'
,
'
CI
'
,
'
CIV
'
,
'
CASE I
'
,
'
CASE II
'
,
'
CASE III
'
,
...
...
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