VerticalObservation

VerticalObservation(
    data,
    *,
    item=None,
    x=None,
    y=None,
    z_item=0,
    name=None,
    weight=1.0,
    quantity=None,
    aux_items=None,
    attrs=None,
)

Observation of a vertical profile at a fixed (x, y) location.

Create a VerticalObservation from a dfs0 file, mikeio.Dataset, pandas.DataFrame or xarray.Dataset in long format: one row per (time, z) pair, with one item/column holding the vertical coordinate and another holding the observed value. At least two items are required (z + value); if more are present, item must be given.

Parameters

Name Type Description Default
data (str, Path, pd.DataFrame, mikeio.Dfs0, mikeio.Dataset, xr.Dataset) Input data or path to a dfs0 file. required
item int or str Index or name of the value item. Required if the input has more than two items. None
x float x-coordinate of the profile location, inferred from data when possible. None
y float y-coordinate of the profile location, inferred from data when possible. None
z_item int or str Index or name of the item holding the vertical coordinate, by default 0. 0
name str Name of the observation, by default the file or item name. None
weight float Weighting factor for skill scores in a ComparerCollection, by default 1.0. 1.0
quantity Quantity Observed quantity, for MIKE files this is inferred from the EUM information None
aux_items list[int | str] Auxiliary items to keep alongside the value item, by default None. None
attrs dict Additional attributes to be added to the underlying dataset. None

Notes

A dfs0 with N depth levels has its profile timestamps repeated N times on a non-equidistant time axis. Duplicate (time, z) pairs are not allowed and will raise a ValueError.

Examples

From a pandas.DataFrame in long format:

import modelskill as ms
import pandas as pd

times = pd.to_datetime(["2010-01-01 01:00"] * 3 + ["2010-01-01 02:00"] * 3)
df = pd.DataFrame(
    {
        "z": [0.0, -5.0, -10.0, 0.0, -5.0, -10.0],
        "Salinity": [30.0, 30.2, 30.3, 30.4, 30.2, 30.2],
    },
    index=times,
)
ms.VerticalObservation(
    df,
    item="Salinity",
    z_item="z",
    x=12.0,
    y=55.0,
    quantity=ms.Quantity("Salinity", "PSU"),
)
<VerticalObservation>: Salinity
Time: 2010-01-01 01:00:00 - 2010-01-01 02:00:00
Quantity: Salinity [PSU]

From a dfs0 file (with z and Salinity items):

ms.VerticalObservation(
    "../data/vertical/VerticalProfile_obs1.dfs0",
    item="Salinity",
    z_item="z",
    x=657500,
    y=6553600,
)
<VerticalObservation>: VerticalProfile_obs1
Time: 2022-06-12 11:43:00 - 2022-06-20 11:06:00
Quantity: Salinity [PSU]

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)
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'