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

fix bug in data variables for YZGridded flow maps

parent 4cbab6af
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ class FlowMap(FlowBox): ...@@ -32,7 +32,7 @@ class FlowMap(FlowBox):
Y = Y[:, :, na] Y = Y[:, :, na]
H = np.reshape(localWind_j.h.data, X.shape) H = np.reshape(localWind_j.h.data, X.shape)
elif plane[0] == 'YZ': elif plane[0] == 'YZ':
H = Y.T[na, :, :] H = Y.T[:, na, :]
Y = X.T[:, na, :] Y = X.T[:, na, :]
X = np.reshape(localWind_j.x.data, Y.shape) X = np.reshape(localWind_j.x.data, Y.shape)
else: else:
...@@ -46,7 +46,9 @@ class FlowMap(FlowBox): ...@@ -46,7 +46,9 @@ class FlowMap(FlowBox):
if plane[0] == "YZ": if plane[0] == "YZ":
# set flowMap.WS_xylk etc. # set flowMap.WS_xylk etc.
for k in ['WS_eff', 'TI_eff', 'WS', 'WD', 'TI', 'P']: for k in ['WS_eff', 'TI_eff', 'WS', 'WD', 'TI', 'P']:
setattr(self.__class__, "%s_xylk" % k, property(lambda self, k=k: self[k].isel(x=0))) self[k] = self[k].transpose('h', 'y', ...)
setattr(self.__class__, "%s_xylk" % k,
property(lambda self, k=k: self[k].isel(x=0).transpose('y', 'h', ...)))
self.plane = plane self.plane = plane
...@@ -129,7 +131,7 @@ class FlowMap(FlowBox): ...@@ -129,7 +131,7 @@ class FlowMap(FlowBox):
y = self.X[0] y = self.X[0]
x = np.zeros_like(y) + self.plane[1] x = np.zeros_like(y) + self.plane[1]
z = self.simulationResult.windFarmModel.site.elevation(x, y) z = self.simulationResult.windFarmModel.site.elevation(x, y)
c = ax.contourf(self.X, self.Y + z, np.reshape(data.isel(x=0), self.X.shape), levels=levels, cmap=cmap) c = ax.contourf(self.X, self.Y + z, data.isel(x=0), levels=levels, cmap=cmap)
if plot_colorbar: if plot_colorbar:
plt.colorbar(c, label=clabel, ax=ax) plt.colorbar(c, label=clabel, ax=ax)
# plot terrain # plot terrain
...@@ -315,4 +317,4 @@ class YZGrid(Grid): ...@@ -315,4 +317,4 @@ class YZGrid(Grid):
Y, Z = np.meshgrid(y, z) Y, Z = np.meshgrid(y, z)
X = np.zeros_like(Y) + x X = np.zeros_like(Y) + x
return Y, Z, X.flatten(), Y.flatten(), Z.flatten() return Y, Z, X.T.flatten(), Y.T.flatten(), Z.T.flatten()
...@@ -77,6 +77,26 @@ def test_YZGrid_plot_wake_map_perpendicular(): ...@@ -77,6 +77,26 @@ def test_YZGrid_plot_wake_map_perpendicular():
plt.close() plt.close()
def test_YZGrid_variables():
site = IEA37Site(16)
x, y = [0], [0]
windTurbines = IEA37_WindTurbines()
wf_model = IEA37SimpleBastankhahGaussian(site, windTurbines)
sim_res = wf_model(x, y)
fm = sim_res.flow_map(grid=YZGrid(x=100, y=None, resolution=100, extend=.1), wd=270, ws=None)
fm.WS_eff.plot()
plt.plot(fm.y[::10], fm.y[::10] * 0 + 110, '.')
if 0:
print(np.round(fm.WS_eff.interp(h=110)[::10].squeeze().values, 4))
plt.show()
plt.close()
npt.assert_array_almost_equal(fm.WS_eff.interp(h=110)[::10].squeeze(),
[9.1461, 8.4157, 7.3239, 6.058, 5.022, 4.6455, 5.1019, 6.182, 7.446, 8.506], 4)
def test_YZGrid_plot_wake_map_parallel(): def test_YZGrid_plot_wake_map_parallel():
site = IEA37Site(16) site = IEA37Site(16)
x, y = site.initial_position.T x, y = site.initial_position.T
......
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