def test_i_dependent_WS(): ds = xr.Dataset( data_vars={'WS': ('i', [8, 9, 10]), 'P': ('wd', f)}, coords={'wd': np.linspace(0, 360, len(f), endpoint=False)}) site = XRSite(ds) lw = site.local_wind([0, 200, 400], [0, 0, 0], [70, 70, 70], wd=0, ws=10) npt.assert_array_equal(lw.WS, [8, 9, 10]) WS = np.arange(6).reshape(3, 2) + 9 ds = xr.Dataset( data_vars={'WS': (('i', 'ws'), WS), 'Sector_frequency': ('wd', f), 'Weibull_A': ('wd', A), 'Weibull_k': ('wd', k)}, coords={'wd': np.linspace(0, 360, len(f), endpoint=False), 'ws': [9, 10], 'i': [0, 1, 2]}) site = XRSite(ds) lw = site.local_wind([0, 200, 400], [0, 0, 0], [70, 70, 70], wd=0, ws=10) npt.assert_array_equal(lw.WS.squeeze(), [10, 12, 14])
def test_wrong_height(): ti = 0.1 ds = xr.Dataset( data_vars={'Speedup': (['x', 'y', 'h'], np.arange(.8, 1.4, .1).reshape((3, 2, 1))), 'Sector_frequency': ('wd', f), 'Weibull_A': ('wd', A), 'Weibull_k': ('wd', k), 'TI': ti}, coords={'x': [0, 5, 10], 'y': [0, 5], 'h': [100], 'wd': np.linspace(0, 360, len(f), endpoint=False)}) site = XRSite(ds, shear=PowerShear(h_ref=100, alpha=.2), interp_method='linear') y = np.arange(5) x = y * 2 X, Y = np.meshgrid(x, y) x_i, y_i = X.flatten(), Y.flatten() wdir_lst = np.arange(0, 360, 90) wsp_lst = np.arange(3, 6) lw = site.local_wind(x_i=x_i, y_i=y_i, h_i=100, wd=wdir_lst, ws=wsp_lst)