TrackObservation
modelskill.TrackObservation
Bases: Observation
Class for observation with locations moving in space, e.g. satellite altimetry
The data needs in addition to the datetime of each single observation point also, x and y coordinates.
Create TrackObservation from dfs0 or DataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
(str, Path, Dataset, DataFrame, Dataset)
|
path to dfs0 file or object with track data |
required |
item |
(str, int)
|
item name or index of values, 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 file basename |
None
|
x_item |
(str, int)
|
item name or index of x-coordinate, by default 0 |
0
|
y_item |
(str, int)
|
item name or index of y-coordinate, by default 1 |
1
|
keep_duplicates |
(str, bool)
|
strategy for handling duplicate timestamps (xarray.Dataset.drop_duplicates): "first" to keep first occurrence, "last" to keep last occurrence, False to drop all duplicates, "offset" to add milliseconds to consecutive duplicates, by default "first" |
'first'
|
quantity |
Quantity
|
The quantity of the observation, for validation with model results For MIKE dfs files this is inferred from the EUM information |
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
|
weight |
float
|
weighting factor for skill scores, by default 1.0 |
1.0
|
Examples:
>>> df = pd.DataFrame(
... {
... "t": pd.date_range("2010-01-01", freq="10s", periods=n),
... "x": np.linspace(0, 10, n),
... "y": np.linspace(45000, 45100, n),
... "swh": [0.1, 0.3, 0.4, 0.5, 0.3],
... }
... )
>>> df = df.set_index("t")
>>> df
x y swh
t
2010-01-01 00:00:00 0.0 45000.0 0.1
2010-01-01 00:00:10 2.5 45025.0 0.3
2010-01-01 00:00:20 5.0 45050.0 0.4
2010-01-01 00:00:30 7.5 45075.0 0.5
2010-01-01 00:00:40 10.0 45100.0 0.3
>>> t1 = TrackObservation(df, name="fake")
>>> t1.n_points
5
>>> t1.values
array([0.1, 0.3, 0.4, 0.5, 0.3])
>>> t1.time
DatetimeIndex(['2010-01-01 00:00:00', '2010-01-01 00:00:10',
'2010-01-01 00:00:20', '2010-01-01 00:00:30',
'2010-01-01 00:00:40'],
dtype='datetime64[ns]', name='t', freq=None)
>>> t1.x
array([ 0. , 2.5, 5. , 7.5, 10. ])
>>> t1.y
array([45000., 45025., 45050., 45075., 45100.])
Source code in modelskill/obs.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
plot
instance-attribute
equals
sel
to_dataframe
Convert matched data to pandas DataFrame
Include x, y coordinates only if gtype=track
Returns:
Type | Description |
---|---|
DataFrame
|
data as a pandas DataFrame |
Source code in modelskill/timeseries/_timeseries.py
trim
Trim observation data to a given time interval
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time |
Timestamp
|
start time |
None
|
end_time |
Timestamp
|
end time |
None
|
buffer |
str
|
buffer time around start and end time, by default "1s" |
'1s'
|
Source code in modelskill/timeseries/_timeseries.py
modelskill.timeseries._plotter.MatplotlibTimeSeriesPlotter
Bases: TimeSeriesPlotter
Source code in modelskill/timeseries/_plotter.py
hist
Plot histogram of timeseries values
Wraps pandas.DataFrame hist() method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bins |
int
|
specification of bins, by default 100 |
100
|
title |
str
|
plot title, default: observation name |
None
|
color |
str
|
plot color, by default "#d62728" |
None
|
**kwargs |
other keyword arguments to df.hist() |
{}
|
Returns:
Type | Description |
---|---|
matplotlib axes
|
|
Source code in modelskill/timeseries/_plotter.py
timeseries
Plot timeseries
Wraps pandas.DataFrame plot() method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
plot title, default: [name] |
None
|
color |
str
|
plot color, by default '#d62728' |
None
|
marker |
str
|
plot marker, by default '.' |
'.'
|
linestyle |
str
|
line style, by default None |
'None'
|
**kwargs |
other keyword arguments to df.plot() |
{}
|