<jupyter_start><jupyter_text>Track comparison for global wave model<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib_inline.backend_inline import set_matplotlib_formats
set_matplotlib_formats('png')
%matplotlib inline

from mikeio.eum import EUMType, ItemInfo
from fmskill import ModelResult, TrackObservation, Connector<jupyter_output><empty_output><jupyter_text>Big dataRun the download.ipynb first<jupyter_code>fn = '../data/SW_gwm_3a_extracted_2018.dfs0'
mr = ModelResult(fn, name='GWM')
fn = '../data/altimetry_3a_2018_filter1.dfs0'
o1 = TrackObservation(fn, item=2, name='3a')
con = Connector(o1, mr[2])
cc = con.extract()
cc['3a'].skill(end='2018-1-15')
cc['3a'].skill()<jupyter_output><empty_output><jupyter_text>Spatial skillSpatial skill with 1 deg bins and default bin edges.<jupyter_code>ss = cc.spatial_skill(metrics=['bias'], bins=(np.arange(-180,180,1), np.arange(-90,90,1)), n_min=20)<jupyter_output><empty_output><jupyter_text>Add attrs and plot<jupyter_code>ss.ds['bias'].attrs = dict(long_name="Bias of significant wave height, Hm0",units="m")
ss.ds['n'].attrs = dict(long_name="N of significant wave height",units="-")
fig, axes = plt.subplots(ncols=1, nrows=2, figsize = (8, 10))
ss.plot('n', ax=axes[0])
ss.plot('bias', ax=axes[1]);<jupyter_output><empty_output><jupyter_text>Multiple bins - spatial skill for wave height Use all_df to obtain and df argument to pass customized data back to comparer.<jupyter_code>all_df = cc.all_df.copy()
mean_val = all_df[['mod_val','obs_val']].mean(axis=1)
all_df['val_cat'] = pd.cut(mean_val,[0,2,5,np.inf],labels=["Hm0[m]=[0, 2)","Hm0[m]=[2, 5)","Hm0[m]=[5, inf)"])
all_df.head()
ss = cc.spatial_skill(df=all_df, by=["val_cat"], metrics=["bias"], bins=(np.arange(-180,180,5), np.arange(-90,90,5)), n_min=20)
ss.ds['bias'].attrs = dict(long_name="Bias of significant wave height, Hm0", units="m")
ss.ds['n'].attrs = dict(long_name="N of significant wave height", units="-")
ss.ds['val_cat'].attrs = dict(long_name="Range of sign. wave height, Hm0", units="m")
ss.plot('n', figsize=(12,4));
ss.plot('bias', figsize=(12,4));<jupyter_output><empty_output>