from_matched
from_matched(
data,*,
=0,
obs_item=None,
mod_items=None,
aux_items=None,
quantity=None,
name=1.0,
weight=None,
x=None,
y=None,
z=None,
x_item=None,
y_item )
Create a Comparer from data that is already matched (aligned).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | [pd.DataFrame, str, Path, mikeio.Dfs0, mikeio.Dataset] | DataFrame (or object that can be converted to a DataFrame e.g. dfs0) with columns obs_item, mod_items, aux_items | required |
obs_item | [str, int] | Name or index of observation item, by default first item | 0 |
mod_items | Iterable[str, int] | Names or indicies of model items, if None all remaining columns are model items, by default None | None |
aux_items | Iterable[str, int] | Names or indicies of auxiliary items, by default None | None |
quantity | Quantity | Quantity of the observation and model results, by default Quantity(name=“Undefined”, unit=“Undefined”) | None |
name | str | Name of the comparer, by default None (will be set to obs_item) | None |
x | float | x-coordinate of observation, by default None | None |
y | float | y-coordinate of observation, by default None | None |
z | float | z-coordinate of observation, by default None | None |
x_item | str | int | None | Name of x item, only relevant for track data | None |
y_item | str | int | None | Name of y item, only relevant for track data | None |
Examples
>>> import pandas as pd
>>> import modelskill as ms
>>> df = pd.DataFrame({'stn_a': [1,2,3], 'local': [1.1,2.1,3.1]}, index=pd.date_range('2010-01-01', periods=3))
>>> cmp = ms.from_matched(df, obs_item='stn_a') # remaining columns are model results
>>> cmp
<Comparer>
Quantity: Undefined [Undefined]=3
Observation: stn_a, n_points=0.100
Model: local, rmse>>> df = pd.DataFrame({'stn_a': [1,2,3], 'local': [1.1,2.1,3.1], 'global': [1.2,2.2,3.2], 'nonsense':[1,2,3]}, index=pd.date_range('2010-01-01', periods=3))
>>> cmp = ms.from_matched(df, obs_item='stn_a', mod_items=['local', 'global'])
>>> cmp
<Comparer>
Quantity: Undefined [Undefined]=3
Observation: stn_a, n_points=0.100
Model: local, rmseglobal, rmse=0.200 Model: