xarray.Dataset.traj.skill#
- abstract Dataset.traj.skill(expected, method='liu-weissberg', **kwargs)#
Compare the skill score between this trajectory and an expected trajectory.
- Parameters:
- Returns:
skill (
DataArray
) – The skill-score in the combined dimensions of both datasets.
Notes
Both datasets must have the same number of trajectories (N:N), or at least one of the datasets (normally the expected) must have a single trajectory only (1:N, N:1, 1:1).
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.Any additional dimensions will be broadcasted, so that the result include the combined dimensions of both datasets.
Some skillscore methods (e.g. liu-weissberg) are not symmetrical. This specific skillscore is normalized on the length of the expected / observed trajectories. Thus a.traj.skill(b) will provide different numerical results than b.traj.skill(a).
Examples
>>> import xarray as xr >>> import trajan as _ >>> import lzma >>> b = lzma.open('examples/barents.nc.xz') >>> ds = xr.open_dataset(b) >>> expected = ds.copy() >>> ds = ds.traj.gridtime('1h') >>> expected = expected.traj.gridtime(ds.time) >>> skill = ds.traj.skill(expected)
>>> skill # Returns 1 since comparing to itself <xarray.DataArray 'Skillscore' (trajectory: 2)> Size: 16B array([1., 1.]) Coordinates: * trajectory (trajectory) int64 16B 0 1 Attributes: method: liu-weissberg
>>> expected = ds.isel(trajectory=0) >>> skill = ds.traj.skill(expected)
>>> skill <xarray.DataArray 'Skillscore' (trajectory: 2)> Size: 16B array([1. , 0.60805799]) Coordinates: * trajectory (trajectory) int64 16B 0 1 Attributes: method: liu-weissberg