Skip to content

Commit

Permalink
Merge pull request #309 from DHI/skillarray-in-skilldataset
Browse files Browse the repository at this point in the history
SkillTable is a collection of SkillArrays
  • Loading branch information
jsmariegaard authored Dec 11, 2023
2 parents 55883fd + 005f181 commit 9579b46
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 390 deletions.
6 changes: 4 additions & 2 deletions docs/api/skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Aggregated Skill

::: modelskill.skill.AggregatedSkill
::: modelskill.skill.SkillTable

::: modelskill.skill.AggregatedSkillPlotter
::: modelskill.skill.SkillArray

::: modelskill.skill.SkillArrayPlotter

## Gridded Skill

Expand Down
16 changes: 8 additions & 8 deletions modelskill/comparison/_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ..plotting import taylor_diagram, TaylorPoint

from ._collection_plotter import ComparerCollectionPlotter
from ..skill import AggregatedSkill
from ..skill import SkillTable
from ..skill_grid import SkillGrid
from ..settings import options, reset_option

Expand Down Expand Up @@ -415,7 +415,7 @@ def skill(
by: Optional[Union[str, List[str]]] = None,
metrics: Optional[List[str]] = None,
**kwargs,
) -> Optional[AggregatedSkill]:
) -> Optional[SkillTable]:
"""Aggregated skill assessment of model(s)
Parameters
Expand Down Expand Up @@ -491,7 +491,7 @@ def skill(

res = _groupby_df(df.drop(columns=["x", "y"]), by, metrics)
res = cmp._add_as_col_if_not_in_index(df, skilldf=res)
return AggregatedSkill(res)
return SkillTable(res)

def _add_as_col_if_not_in_index(
self, df, skilldf, fields=["model", "observation", "variable"]
Expand Down Expand Up @@ -695,7 +695,7 @@ def mean_skill(
weights: Optional[Union[str, List[float], Dict[str, float]]] = None,
metrics: Optional[list] = None,
**kwargs,
) -> Optional[AggregatedSkill]: # TODO raise error if no data?
) -> Optional[SkillTable]: # TODO raise error if no data?
"""Weighted mean of skills
First, the skill is calculated per observation,
Expand All @@ -718,7 +718,7 @@ def mean_skill(
Returns
-------
AggregatedSkill
SkillTable
mean skill assessment as a skill object
See also
Expand Down Expand Up @@ -789,14 +789,14 @@ def weighted_mean(x):

# output
res = cmp._add_as_col_if_not_in_index(df, res, fields=["model", "variable"])
return AggregatedSkill(res.astype({"n": int}))
return SkillTable(res.astype({"n": int}))

def mean_skill_points(
self,
*,
metrics: Optional[list] = None,
**kwargs,
) -> Optional[AggregatedSkill]: # TODO raise error if no data?
) -> Optional[SkillTable]: # TODO raise error if no data?
"""Mean skill of all observational points
All data points are pooled (disregarding which observation they belong to),
Expand All @@ -816,7 +816,7 @@ def mean_skill_points(
Returns
-------
AggregatedSkill
SkillTable
mean skill assessment as a skill object
See also
Expand Down
8 changes: 4 additions & 4 deletions modelskill/comparison/_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
TimeTypes,
IdOrNameTypes,
)
from ..skill import AggregatedSkill
from ..skill import SkillTable
from ..skill_grid import SkillGrid
from ..settings import options, register_option, reset_option
from ..utils import _get_name
Expand Down Expand Up @@ -911,7 +911,7 @@ def skill(
by: Optional[Union[str, List[str]]] = None,
metrics: Optional[list] = None,
**kwargs,
) -> AggregatedSkill:
) -> SkillTable:
"""Skill assessment of model(s)
Parameters
Expand All @@ -926,7 +926,7 @@ def skill(
Returns
-------
AggregatedSkill
SkillTable
skill assessment object
See also
Expand Down Expand Up @@ -969,7 +969,7 @@ def skill(
df = cmp.to_dataframe() # TODO: avoid df if possible?
res = _groupby_df(df.drop(columns=["x", "y"]), by, metrics)
res = self._add_as_col_if_not_in_index(df, skilldf=res)
return AggregatedSkill(res)
return SkillTable(res)

def _add_as_col_if_not_in_index(self, df, skilldf):
"""Add a field to skilldf if unique in df"""
Expand Down
Loading

0 comments on commit 9579b46

Please sign in to comment.