diff --git a/wetb/hawc2/tests/test_files/htcfiles/test_turb.htc b/wetb/hawc2/tests/test_files/htcfiles/test_turb.htc new file mode 100644 index 0000000000000000000000000000000000000000..59c46b8e86969f77490028a50e1f68aab15cf1cd --- /dev/null +++ b/wetb/hawc2/tests/test_files/htcfiles/test_turb.htc @@ -0,0 +1,34 @@ + begin simulation; + time_stop 1; + solvertype 1; (newmark) + on_no_convergence continue; + convergence_limits 1000 1 1e-08; +;logfile ./log/nasty_gust.log ; +; + begin newmark; + deltat 0.025; + end newmark; + end simulation; +;---------------------------------------------------------------------------------------------------------------------------------------------------------------- + begin wind; + density 1.225; + wsp 10; + tint 1; + horizontal_input 0; 0=false, 1=true + windfield_rotations 0 0 0; yaw, tilt, rotation + center_pos0 0 0 -10; hub heigth + shear_format 1 0; 0=none,1=constant,2=log,3=power,4=linear + turb_format 1; + tower_shadow_method 0; 0=none, 1=potential flow, 2=jet + begin mann; + create_turb_parameters 30 1 3.9 1 1; L, alfaeps, gamma, seed, highfrq compensation + filename_u ./turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001u.turb; + filename_v ./turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001v.turb; + filename_w ./turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001w.turb; + box_dim_u 512 0.977; + box_dim_v 8 16; + box_dim_w 8 16; + end mann; + + end wind; +exit; \ No newline at end of file diff --git a/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001u.turb b/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001u.turb new file mode 100644 index 0000000000000000000000000000000000000000..40082e68a428dd7e3010c8cc456c90add6339433 Binary files /dev/null and b/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001u.turb differ diff --git a/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001v.turb b/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001v.turb new file mode 100644 index 0000000000000000000000000000000000000000..9b37fe3ffbbf4ad57d028632eaa8f7a1bafd9e1d Binary files /dev/null and b/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001v.turb differ diff --git a/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001w.turb b/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001w.turb new file mode 100644 index 0000000000000000000000000000000000000000..18bc75e353d0b48f671cb8a86810bd85d3fca162 Binary files /dev/null and b/wetb/hawc2/tests/test_files/turb/mann_l30.0_ae1.00_g3.9_h1_512x8x8_0.977x16.00x16.00_s0001w.turb differ diff --git a/wetb/hawc2/tests/test_turbulence_file.py b/wetb/hawc2/tests/test_turbulence_file.py new file mode 100644 index 0000000000000000000000000000000000000000..8525d3b416f6c8db6adc6287dda42a26456c736e --- /dev/null +++ b/wetb/hawc2/tests/test_turbulence_file.py @@ -0,0 +1,38 @@ +''' +Created on 17/07/2014 + +@author: MMPE +''' +from __future__ import unicode_literals +from __future__ import print_function +from __future__ import division +from __future__ import absolute_import +from future import standard_library +from wetb.hawc2.turbulence_file import TurbulenceFile +standard_library.install_aliases() +import os +import unittest +from wetb.hawc2.pc_file import PCFile + + +import numpy as np + +tfp = os.path.join(os.path.dirname(__file__), 'test_files/') # test file path + + +class TestPCFile(unittest.TestCase): + + def setUp(self): + unittest.TestCase.setUp(self) + + # def test_TurbulenceFile(self): + # TurbulenceFile(tfp + "turb/mann_l29.4_ae1.00_g3.9_h1_64x8x8_1.000x2.00x2.00_s1001u.turb") + + def test_load_from_htc(self): + u, v, w = TurbulenceFile.load_from_htc(tfp + "htcfiles/test_turb.htc") + self.assertEqual(u.data.shape, (512, 64)) + + +if __name__ == "__main__": + #import sys;sys.argv = ['', 'Test.testName'] + unittest.main() diff --git a/wetb/hawc2/turbulence_file.py b/wetb/hawc2/turbulence_file.py new file mode 100644 index 0000000000000000000000000000000000000000..c7875e624ac08a51970e5a6b35225deb9f5df1cf --- /dev/null +++ b/wetb/hawc2/turbulence_file.py @@ -0,0 +1,39 @@ +''' +Created on 22. jun. 2017 + +@author: mmpe +''' +import os + +import numpy as np +from wetb.hawc2.htc_file import HTCFile +from wetb.wind.turbulence import mann_turbulence + + +class TurbulenceFile(object): + def __init__(self, filename, Nxyz, dxyz, transport_speed=10, mean_wsp=0, center_position=(0, 0, -20)): + self.filename = filename + self.Nxyz = Nxyz + self.dxyz = dxyz + self.transport_speed = transport_speed + self.mean_wsp = mean_wsp + self.center_position = center_position + self.data = mann_turbulence.load(filename, Nxyz) + + + + @staticmethod + def load_from_htc(htcfilename, modelpath=None, type='mann'): + htc = HTCFile(htcfilename, modelpath) + + Nxyz = np.array([htc.wind[type]['box_dim_%s'%uvw][0] for uvw in 'uvw']) + dxyz = np.array([htc.wind[type]['box_dim_%s'%uvw][1] for uvw in 'uvw']) + center_position = htc.wind.center_pos0.values + wsp = htc.wind.wsp + return [TurbulenceFile(os.path.join(htc.modelpath , htc.wind[type]['filename_%s'%uvw][0]), Nxyz, dxyz,wsp, (0,wsp)[uvw=='u'], center_position) for uvw in 'uvw'] + + + + +if __name__ == '__main__': + pass \ No newline at end of file