diff --git a/py_wake/site/xrsite.py b/py_wake/site/xrsite.py index 9da2111d157d58b688419ba5b38b4e332dbe7ec9..911b4de221357332c731eaea772190982beb402f 100644 --- a/py_wake/site/xrsite.py +++ b/py_wake/site/xrsite.py @@ -432,7 +432,7 @@ class GlobalWindAtlasSite(XRSite): self.gwc_ds['TI'] = ti ds = self.gwc_ds.interp(roughness=roughness).rename(height='h') if height is not None: - ds = ds.interp(z=height) + ds = ds.interp(h=height) XRSite.__init__(self, ds=ds, **kwargs) def _read_gwc(self, lat, long): # pragma: no cover diff --git a/py_wake/tests/test_sites/test_xrsite.py b/py_wake/tests/test_sites/test_xrsite.py index 5445acbc5f7b260b596d7d2be4588dd0e25357a3..2838cd30569769a5d2468ebf0e7a1b9e5d46a691 100644 --- a/py_wake/tests/test_sites/test_xrsite.py +++ b/py_wake/tests/test_sites/test_xrsite.py @@ -296,6 +296,29 @@ def test_GlobalWindAtlasSite(): for var, atol in [('Sector_frequency', 0.03), ('Weibull_A', 1.6), ('Weibull_k', 0.4)]: npt.assert_allclose(site.ds.interp(h=70)[var], ref.ds[var], atol=atol) + def get_mean_ws(h): + lw = site.local_wind(wd=270, ws=10, h=h) + return weibull.mean(lw['Weibull_A_ilk'], lw['Weibull_k_ilk']).flatten().squeeze() + + try: + site2 = GlobalWindAtlasSite(lat, long, roughness=0.001, ti=0.075, height=[75, 150]) + except (HTTPError, URLError): + pytest.xfail('HTTPError in GlobalWindAtlasSite') + + if 0: + h = np.linspace(10, 200) + plt.plot([get_mean_ws(h) for h in h], h) + plt.plot( + weibull.mean( + site2.ds.sel( + wd=270, ws=10).Weibull_A, site2.ds.sel( + wd=270, ws=10).Weibull_k), [ + 75, 150], '.r') + plt.show() + + npt.assert_array_equal(weibull.mean(site2.ds.sel(wd=270, ws=10).Weibull_A, site2.ds.sel(wd=270, ws=10).Weibull_k), + [get_mean_ws(h) for h in [75, 150]]) + def test_wrong_height(): ti = 0.1