Skip to content
Snippets Groups Projects
Commit 7efa21b7 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

fix bug in gwa when passing heights

parent 61d70ec6
No related branches found
No related tags found
1 merge request!662fix bug in gwa when passing heights
Pipeline #73262 passed with warnings
...@@ -432,7 +432,7 @@ class GlobalWindAtlasSite(XRSite): ...@@ -432,7 +432,7 @@ class GlobalWindAtlasSite(XRSite):
self.gwc_ds['TI'] = ti self.gwc_ds['TI'] = ti
ds = self.gwc_ds.interp(roughness=roughness).rename(height='h') ds = self.gwc_ds.interp(roughness=roughness).rename(height='h')
if height is not None: if height is not None:
ds = ds.interp(z=height) ds = ds.interp(h=height)
XRSite.__init__(self, ds=ds, **kwargs) XRSite.__init__(self, ds=ds, **kwargs)
def _read_gwc(self, lat, long): # pragma: no cover def _read_gwc(self, lat, long): # pragma: no cover
......
...@@ -296,6 +296,29 @@ def test_GlobalWindAtlasSite(): ...@@ -296,6 +296,29 @@ def test_GlobalWindAtlasSite():
for var, atol in [('Sector_frequency', 0.03), ('Weibull_A', 1.6), ('Weibull_k', 0.4)]: 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) 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(): def test_wrong_height():
ti = 0.1 ti = 0.1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment