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
6be4c2e6
Commit
6be4c2e6
authored
4 years ago
by
Michael Langguth
Browse files
Options
Downloads
Patches
Plain Diff
Add attributes to quantile_panel in calculate_cond_quantiles-function.
parent
c831fefb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
video_prediction_tools/postprocess/statistical_evaluation.py
+12
-1
12 additions, 1 deletion
video_prediction_tools/postprocess/statistical_evaluation.py
with
12 additions
and
1 deletion
video_prediction_tools/postprocess/statistical_evaluation.py
+
12
−
1
View file @
6be4c2e6
...
@@ -15,6 +15,7 @@ try:
...
@@ -15,6 +15,7 @@ try:
l_tqdm
=
True
l_tqdm
=
True
except
:
except
:
l_tqdm
=
False
l_tqdm
=
False
from
general_utils
import
provide_default
# basic data types
# basic data types
da_or_ds
=
Union
[
xr
.
DataArray
,
xr
.
Dataset
]
da_or_ds
=
Union
[
xr
.
DataArray
,
xr
.
Dataset
]
...
@@ -56,6 +57,13 @@ def calculate_cond_quantiles(data_fcst: xr.DataArray, data_ref: xr.DataArray, fa
...
@@ -56,6 +57,13 @@ def calculate_cond_quantiles(data_fcst: xr.DataArray, data_ref: xr.DataArray, fa
raise
ValueError
(
"
%{0}: Choose either
'
calibration_refinement
'
or
'
likelihood-base_rate
'
for factorization
"
raise
ValueError
(
"
%{0}: Choose either
'
calibration_refinement
'
or
'
likelihood-base_rate
'
for factorization
"
.
format
(
method
))
.
format
(
method
))
# get and set some basic attributes
data_cond_longname
=
provide_default
(
data_cond
.
attr
,
"
longname
"
,
"
conditioning_variable
"
)
data_cond_unit
=
provide_default
(
data_cond
.
attr
,
"
unit
"
,
"
unknown
"
)
data_tar_longname
=
provide_default
(
data_tar
.
attr
,
"
longname
"
,
"
target_variable
"
)
data_tar_unit
=
provide_default
(
data_cond
.
attr
,
"
unit
"
,
"
unknown
"
)
# get bins for conditioning
# get bins for conditioning
data_cond_min
,
data_cond_max
=
np
.
floor
(
np
.
min
(
data_cond
)),
np
.
ceil
(
np
.
max
(
data_cond
))
data_cond_min
,
data_cond_max
=
np
.
floor
(
np
.
min
(
data_cond
)),
np
.
ceil
(
np
.
max
(
data_cond
))
bins
=
list
(
np
.
arange
(
int
(
data_cond_min
),
int
(
data_cond_max
)
+
1
))
bins
=
list
(
np
.
arange
(
int
(
data_cond_min
),
int
(
data_cond_max
)
+
1
))
...
@@ -63,7 +71,9 @@ def calculate_cond_quantiles(data_fcst: xr.DataArray, data_ref: xr.DataArray, fa
...
@@ -63,7 +71,9 @@ def calculate_cond_quantiles(data_fcst: xr.DataArray, data_ref: xr.DataArray, fa
nbins
=
len
(
bins
)
-
1
nbins
=
len
(
bins
)
-
1
# initialize quantile data array
# initialize quantile data array
quantile_panel
=
xr
.
DataArray
(
np
.
full
((
nbins
,
nquantiles
),
np
.
nan
),
quantile_panel
=
xr
.
DataArray
(
np
.
full
((
nbins
,
nquantiles
),
np
.
nan
),
coords
=
{
"
bin_center
"
:
bins_c
,
"
quantile
"
:
quantiles
},
dims
=
[
"
bin_center
"
,
"
quantile
"
])
coords
=
{
"
bin_center
"
:
bins_c
,
"
quantile
"
:
quantiles
},
dims
=
[
"
bin_center
"
,
"
quantile
"
],
attrs
=
{
"
cond_var_name
"
:
data_cond_longname
,
"
cond_var_unit
"
:
data_cond_unit
,
"
tar_var_name
"
:
data_tar_longname
,
"
tar_var_unit
"
:
data_tar_unit
})
# fill the quantile data array
# fill the quantile data array
for
i
in
np
.
arange
(
nbins
):
for
i
in
np
.
arange
(
nbins
):
# conditioning of ground truth based on forecast
# conditioning of ground truth based on forecast
...
@@ -73,6 +83,7 @@ def calculate_cond_quantiles(data_fcst: xr.DataArray, data_ref: xr.DataArray, fa
...
@@ -73,6 +83,7 @@ def calculate_cond_quantiles(data_fcst: xr.DataArray, data_ref: xr.DataArray, fa
return
quantile_panel
,
data_cond
return
quantile_panel
,
data_cond
def
avg_metrics
(
metric
:
da_or_ds
,
dim_name
:
str
):
def
avg_metrics
(
metric
:
da_or_ds
,
dim_name
:
str
):
"""
"""
Averages metric over given dimension
Averages metric over given dimension
...
...
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