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 ‘node’ is given, a NodeObservation is created.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | DataInputType | The data to be used for creating the Observation object. | required |
| gtype | Literal['point', 'track', 'node'] | 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 NodeObservation | 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", node=123, name="123")