VerticalObservation
VerticalObservation(
data,
*,
item=None,
x=None,
y=None,
z_item=0,
name=None,
weight=1.0,
keep_duplicates='first',
quantity=None,
aux_items=None,
attrs=None,
)Class for observations of vertical profiles.
Create a VerticalObservation from a dfs0/nc file or tabular data containing time, vertical coordinate, and observed values.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | (str, Path, pd.DataFrame, mikeio.Dfs0, mikeio.Dataset, xr.Dataset) | Input data with vertical profile observations. | required |
| item | int or str | Index or name of the primary observation item. If the input contains more than one candidate value item, this argument must be provided. | None |
| x | float | x-coordinate of the observation location. If not provided, it is inferred from data when possible. | None |
| y | float | y-coordinate of the observation location. If not provided, it is inferred from data when possible. | None |
| z_item | int or str | Index or name of the vertical coordinate item, by default 0. | 0 |
| name | str | User-defined name for identification in plots and summaries. | None |
| weight | float | Weighting factor for skill scores, by default 1.0. | 1.0 |
| keep_duplicates | ('first', 'last', False) | Strategy for handling duplicate timestamps/z pairs. | "first" |
| quantity | Quantity | Physical quantity metadata used for validation against model results. | None |
| aux_items | list[int | str] | List of auxiliary item names or indices to keep in the dataset. | None |
| attrs | dict | Additional attributes to be added to the underlying dataset. | None |
Examples
>>> import modelskill as ms
>>> import pandas as pd
>>> df = pd.DataFrame(
... {
... "z": [0.0, -5.0, -10.0, 0.0, -5.0, -10.0],
... "value": [0.1, 0.3, 0.4, 0.5, 0.3, 0.3],
... },
... index=pd.to_datetime(
... [
... "2010-01-01 01:00:00",
... "2010-01-01 01:00:00",
... "2010-01-01 01:00:00",
... "2010-01-01 02:00:00",
... "2010-01-01 02:00:00",
... "2010-01-01 02:00:00",
... ]
... ),
... )
>>> df.index.name = "t"
>>> print(df.to_string())
z value
t
2010-01-01 01:00:00 0.0 0.1
2010-01-01 01:00:00 -5.0 0.3
2010-01-01 01:00:00 -10.0 0.4
2010-01-01 02:00:00 0.0 0.5
2010-01-01 02:00:00 -5.0 0.3
2010-01-01 02:00:00 -10.0 0.3>>> o = ms.VerticalObservation(df, item="value", z_item="z", x=12.0, y=55.0)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 |
| 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
VerticalObservation.copy()Create a deep copy of the TimeSeries.
Returns
| Name | Type | Description |
|---|---|---|
| TimeSeries | Deep copy of the TimeSeries object |
equals
VerticalObservation.equals(other)Check if two TimeSeries are equal
sel
VerticalObservation.sel(**kwargs)Select data by label
to_dataframe
VerticalObservation.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
VerticalObservation.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' |