ReachObservation

ReachObservation(
    data,
    *,
    reach,
    item=None,
    name=None,
    weight=1.0,
    quantity=None,
    aux_items=None,
    attrs=None,
)

Class for observations representing a quantity uniform across a network reach.

Some quantities (e.g. discharge in a river reach) are constant for the whole reach, even though the underlying model stores values at nodes/breakpoints. A ReachObservation associates a timeseries with a named reach; when matched against a :class:~modelskill.model.network.NetworkModelResult the data is extracted from an arbitrary breakpoint that belongs to that reach.

Parameters

Name Type Description Default
data (str, Path, mikeio.Dataset, mikeio.DataArray, pd.DataFrame, pd.Series, xr.Dataset or xr.DataArray) data source with time series for the reach quantity required
reach str Reach identifier (reach name / reach ID) in the network. required
item (int, str) index or name of the wanted item/column, by default None if data contains more than one item, item must be given None
name str user-defined name for easy identification in plots etc, by default derived from data None
weight float weighting factor for skill scores, by default 1.0 1.0
quantity Quantity The quantity of the observation, for validation with model results None
aux_items list list of names or indices of auxiliary items, by default None None
attrs dict additional attributes to be added to the data, by default None None

Examples

>>> import modelskill as ms
>>> o1 = ms.ReachObservation(df, reach="reach_1", name="Q_reach_1")
>>> o2 = ms.ReachObservation(df, item="Discharge", reach="reach_2")

Attributes

Name Description
attrs Attributes of the observation
gtype Geometry type
n_points Number of data points
name Name of time series (value item name)
node node-coordinate
plot Plot using the ComparerPlotter
quantity Quantity of time series
reach Reach ID of this observation.
time Time index
values Values as numpy array
weight Weighting factor for skill scores
x x-coordinate
y y-coordinate

Methods

Name Description
copy Create a deep copy of the TimeSeries.
equals Check if two TimeSeries are equal
sel Select data by label
to_dataframe Convert matched data to pandas DataFrame
trim Trim observation data to a given time interval

copy

ReachObservation.copy()

Create a deep copy of the TimeSeries.

Returns

Name Type Description
TimeSeries Deep copy of the TimeSeries object

equals

ReachObservation.equals(other)

Check if two TimeSeries are equal

sel

ReachObservation.sel(**kwargs)

Select data by label

to_dataframe

ReachObservation.to_dataframe()

Convert matched data to pandas DataFrame

Include x, y coordinates only if gtype=track

Returns

Name Type Description
pd.DataFrame data as a pandas DataFrame

trim

ReachObservation.trim(
    start_time=None,
    end_time=None,
    buffer='1s',
    no_overlap='error',
)

Trim observation data to a given time interval

Parameters

Name Type Description Default
start_time pd.Timestamp start time None
end_time pd.Timestamp end time None
buffer str buffer time around start and end time, by default “1s” '1s'
no_overlap Literal['ignore', 'error', 'warn'] Empty data handling. 'error'