xarray.Dataset.traj.skill#

abstract Dataset.traj.skill(other, method='liu-weissberg', **kwargs)#

Compare the skill score between this trajectory and other.

Parameters:
  • other (Dataset) – Another trajectory dataset.

  • method (str) – skill-score method, currently only liu-weissberg.

  • **kwargs – Passed on to the skill-score method.

Returns:

skill (Dataset) – The skill-score in the same dimensions as this dataset.

Notes

The datasets must be sampled (or have observations) at approximately the same timesteps. Consider using gridtime() to interpolate one of the datasets to the other.

The datasets must have the same number of trajectories. If you wish to compare a single trajectory to many others, duplicate it along the trajectory dimension to match the trajectory dimension of the other. See further down for an example.

Examples

>>> import xarray as xr
>>> import trajan as _
>>> import lzma
>>> b = lzma.open('examples/barents.nc.xz')
>>> ds = xr.open_dataset(b)
>>> other = ds.copy()
>>> ds = ds.traj.gridtime('1h')
>>> other = other.traj.gridtime(ds.time)
>>> skill = ds.traj.skill(other)
>>> skill
<xarray.DataArray 'Skillscore' (trajectory: 2)> Size: 8B
array([1., 1.], dtype=float32)
Coordinates:
  * trajectory  (trajectory) int64 16B 0 1
Attributes:
    method:   liu-weissberg

If you need to broadcast a dataset with a single drifter to one with many you can use xarray.broadcast or xarray.Dataset.broadcast_like:

Note

If the other dataset has any other dimensions, on any other variables, you need to exclude those when broadcasting.

>>> b0 = ds.isel(trajectory=0) # `b0` now only has a single drifter (no trajectory dimension)
>>> b0 = b0.broadcast_like(ds)
>>> skill = b0.traj.skill(ds)
>>> skill
<xarray.DataArray 'Skillscore' (trajectory: 2)> Size: 8B
array([1.      , 0.608058], dtype=float32)
Coordinates:
  * trajectory  (trajectory) int64 16B 0 1
Attributes:
    method:   liu-weissberg