observation

observation(data, *, gtype=None, **kwargs)

Create an appropriate observation object.

A factory function for creating an appropriate observation object based on the data and args.

If ‘x’ or ‘y’ is given, a PointObservation is created. If ‘x_item’ or ‘y_item’ is given, a TrackObservation is created. If ‘z_item’ is given, a VerticalObservation is created. If ‘at’ is given, a NodeObservation is created. If ‘reach’ is given, a ReachObservation is created. If gtype is explicitly given, it will be used to determine the type of observation.

Parameters

Name Type Description Default
data DataInputType The data to be used for creating the Observation object. required
gtype Literal['point', 'track', 'vertical', 'node', 'reach'] | None The geometry type of the data. If not specified, it will be guessed from the data. None
**kwargs Additional keyword arguments to be passed to the Observation constructor. {}

Returns

Name Type Description
PointObservation or TrackObservation or VerticalObservation or NodeObservation or ReachObservation An observation object of the appropriate type

Examples

>>> import modelskill as ms
>>> o_pt = ms.observation(df, item=0, x=366844, y=6154291, name="Klagshamn")
>>> o_tr = ms.observation("lon_after_lat.dfs0", item="wl", x_item=1, y_item=0)
>>> o_node = ms.observation(df, item="Water Level", at=123, name="123")
>>> o_reach = ms.observation(df, item="Discharge", reach="reach_1", name="reach_1_Q")