Skip to content
Snippets Groups Projects
Commit 246ac8b7 authored by David Verelst's avatar David Verelst
Browse files

prepost.windIO: add tests and corresponding files for user shear

parent a3f43ccd
No related branches found
No related tags found
No related merge requests found
Pipeline #
# User defined shear file
3 5 # nr_hor (v), nr_vert (w)
# v component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# u component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
1.20491 1.20491 1.20491
1.04894 1.04894 1.04894
0.96723 0.96723 0.96723
0.91315 0.91315 0.91315
# w component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# v coordinates (along the horizontal, nr_hor, 0 rotor center)
-57.50
0.00
57.50
# w coordinates (zero is at ground level, height, nr_hor)
0.00
39.38
78.75
118.12
157.50
# User defined shear file
3 5 # nr_hor (v), nr_vert (w)
# v component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.17365 0.17365 0.17365
0.17365 0.17365 0.17365
0.17365 0.17365 0.17365
0.17365 0.17365 0.17365
0.17365 0.17365 0.17365
# u component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.98481 0.98481 0.98481
0.98481 0.98481 0.98481
0.98481 0.98481 0.98481
0.98481 0.98481 0.98481
0.98481 0.98481 0.98481
# w component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# v coordinates (along the horizontal, nr_hor, 0 rotor center)
-57.50
0.00
57.50
# w coordinates (zero is at ground level, height, nr_hor)
0.00
39.38
78.75
118.12
157.50
# User defined shear file
3 5 # nr_hor (v), nr_vert (w)
# v component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
-0.00000 -0.00000 -0.00000
-0.22662 -0.22662 -0.22662
-0.19440 -0.19440 -0.19440
-0.15702 -0.15702 -0.15702
-0.12881 -0.12881 -0.12881
# u component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.79839 0.79839 0.79839
0.93331 0.93331 0.93331
1.02188 1.02188 1.02188
1.08750 1.08750 1.08750
# w component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# v coordinates (along the horizontal, nr_hor, 0 rotor center)
-57.50
0.00
57.50
# w coordinates (zero is at ground level, height, nr_hor)
0.00
39.38
78.75
118.12
157.50
# User defined shear file
3 5 # nr_hor (v), nr_vert (w)
# v component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
-0.37387 -0.37387 -0.37387
-0.20267 -0.20267 -0.20267
-0.06161 -0.06161 -0.06161
0.04413 0.04413 0.04413
0.11303 0.11303 0.11303
# u component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.92748 0.92748 0.92748
0.97925 0.97925 0.97925
0.99810 0.99810 0.99810
0.99903 0.99903 0.99903
0.99359 0.99359 0.99359
# w component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# v coordinates (along the horizontal, nr_hor, 0 rotor center)
-57.50
0.00
57.50
# w coordinates (zero is at ground level, height, nr_hor)
0.00
39.38
78.75
118.12
157.50
# User defined shear file
3 5 # nr_hor (v), nr_vert (w)
# v component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# u component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
1.00000 1.00000 1.00000
1.00000 1.00000 1.00000
1.00000 1.00000 1.00000
1.00000 1.00000 1.00000
1.00000 1.00000 1.00000
# w component, normalized with U_mean, nr_hor (v) rows, nr_vert (w) columns
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
0.00000 0.00000 0.00000
# v coordinates (along the horizontal, nr_hor, 0 rotor center)
-57.50
0.00
57.50
# w coordinates (zero is at ground level, height, nr_hor)
0.00
39.38
78.75
118.12
157.50
......@@ -12,10 +12,11 @@ standard_library.install_aliases()
import unittest
import os
import tempfile
import numpy as np
from wetb.prepost.windIO import LoadResults
from wetb.prepost import windIO
class TestsLoadResults(unittest.TestCase):
......@@ -27,7 +28,7 @@ class TestsLoadResults(unittest.TestCase):
self.fbin = 'Hawc2bin'
def loadresfile(self, resfile):
res = LoadResults(self.respath, resfile)
res = windIO.LoadResults(self.respath, resfile)
self.assertTrue(hasattr(res, 'sig'))
self.assertEqual(res.Freq, 40.0)
self.assertEqual(res.N, 800)
......@@ -45,15 +46,15 @@ class TestsLoadResults(unittest.TestCase):
self.assertEqual(res.FileType, 'BINARY')
def test_compare_ascii_bin(self):
res_ascii = LoadResults(self.respath, self.fascii)
res_bin = LoadResults(self.respath, self.fbin)
res_ascii = windIO.LoadResults(self.respath, self.fascii)
res_bin = windIO.LoadResults(self.respath, self.fbin)
for k in range(res_ascii.sig.shape[1]):
np.testing.assert_allclose(res_ascii.sig[:,k], res_bin.sig[:,k],
rtol=1e-02, atol=0.001)
def test_unified_chan_names(self):
res = LoadResults(self.respath, self.fascii, readdata=False)
res = windIO.LoadResults(self.respath, self.fascii, readdata=False)
self.assertFalse(hasattr(res, 'sig'))
np.testing.assert_array_equal(res.ch_df.index.values, np.arange(0,28))
......@@ -62,5 +63,62 @@ class TestsLoadResults(unittest.TestCase):
'windspeed-global-Vy--2.50-1.00--52.50')
class TestUserWind(unittest.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__), 'data')
self.z_h = 100.0
self.r_blade_tip = 50.0
self.h_ME = 650
self.z = np.array([self.z_h - self.r_blade_tip,
self.z_h + self.r_blade_tip])
def test_deltaphi2aphi(self):
uwind = windIO.UserWind()
profiles = windIO.WindProfiles
for a_phi_ref in [-1.0, 0.0, 0.5]:
phis = profiles.veer_ekman_mod(self.z, self.z_h, h_ME=self.h_ME,
a_phi=a_phi_ref)
d_phi_ref = phis[1] - phis[0]
# a_phi1 = uwind.deltaphi2aphi(d_phi_ref, self.z_h, self.r_blade_tip,
# h_ME=self.h_ME)
a_phi2 = uwind.deltaphi2aphi_opt(d_phi_ref, self.z, self.z_h,
self.r_blade_tip, self.h_ME)
self.assertAlmostEqual(a_phi_ref, a_phi2)
def test_usershear(self):
uwind = windIO.UserWind()
# phi, shear, wdir
combinations = [[1,0,0], [0,-0.2,0], [0,0,-10], [None, None, None],
[0.5,0.2,10]]
for a_phi, shear, wdir in combinations:
rpl = (a_phi, shear, wdir)
try:
fname = 'a_phi_%1.05f_shear_%1.02f_wdir%02i.txt' % rpl
except:
fname = 'a_phi_%s_shear_%s_wdir%s.txt' % rpl
target = os.path.join(self.path, fname)
fid = tempfile.NamedTemporaryFile(delete=False, mode='wb')
target = os.path.join(self.path, fname)
uu, vv, ww, xx, zz = uwind(self.z_h, self.r_blade_tip, a_phi=a_phi,
nr_vert=5, nr_hor=3, h_ME=650.0,
wdir=wdir, io=fid, shear_exp=shear)
# FIXME: this has to be done more clean and Pythonic
# load again for comparison with the reference
uwind.fid.close()
with open(uwind.fid.name) as fid:
contents = fid.readlines()
os.remove(uwind.fid.name)
with open(target) as fid:
ref = fid.readlines()
self.assertEqual(contents, ref)
if __name__ == "__main__":
unittest.main()
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