diff --git a/tests/test_files/fuga_files/4xV52SiteList.txt b/tests/test_files/fuga_files/4xV52SiteList.txt new file mode 100644 index 0000000000000000000000000000000000000000..5fcefec4b66ef3c7dae2ed54055d741033b8852b --- /dev/null +++ b/tests/test_files/fuga_files/4xV52SiteList.txt @@ -0,0 +1,54 @@ +4xV52Farm +2 +V52-0.85MWLower[h=50.00] +50. 30 +V52-0.85MWUpper[h=108.00] +108. 30 +-8879 2367 +-8253 4048 +-7730 5610 +-8383 548 +-6810 1800 +-6230 3900 +-6768 -395 +-6000 5800 +-4860 2500 +-4740 600 +-5153 -1319 +-4030 5900 +-3890 4200 +-2990 -300 +-2850 2100 +-1932 -3215 +-2050 6100 +-1790 4200 +-1320 600 +-1140 -1500 +-720 2600 +-70 6000 +520 4100 +610 -600 +680 1200 +700 -4700 +902 -2700 +1750 2600 +1910 5800 +2009 459 +2440 -5600 +2830 -3600 +2900 4100 +3890 2400 +3970 -1400 +4130 -6700 +4710 -4900 +4870 600 +4970 -3200 +5850 -7700 +5860 -1100 +6490 -5800 +6850 -2800 +7820 -7900 +7840 -4500 +8830 -6200 +9800 -7900 +-3553 -2250 \ No newline at end of file diff --git a/tests/test_files/fuga_files/TurbineSiteList.txt b/tests/test_files/fuga_files/TurbineSiteList.txt new file mode 100644 index 0000000000000000000000000000000000000000..03f2e5aa61a74d10839b1519a76cbd2c508e937b --- /dev/null +++ b/tests/test_files/fuga_files/TurbineSiteList.txt @@ -0,0 +1,81 @@ +Vestas_V80_(2_MW_offshore)[h=67.00] +1 423974 6151447 67,0 9,99 10,00 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +2 424033 6150889 67,0 9,99 10,00 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +3 424092 6150332 67,0 9,99 10,00 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +4 424151 6149774 67,0 9,99 10,00 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +5 424210 6149216 67,0 9,99 10,00 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +6 424268 6148658 67,0 9,99 10,00 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +7 424327 6148101 67,0 9,99 9,99 1334 100,0 Vestas V80 (2 MW offshore)(Tab #1) +8 424386 6147543 67,0 9,99 9,99 1334 100,0 Vestas V80 (2 MW offshore)(Tab #1) +11 424534 6151447 67,0 9,99 10,05 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +12 424593 6150889 67,0 9,99 10,05 1360 102,0 Vestas V80 (2 MW offshore)(Tab #1) +13 424652 6150332 67,0 9,99 10,05 1360 102,0 Vestas V80 (2 MW offshore)(Tab #1) +14 424711 6149774 67,0 9,99 10,05 1360 102,0 Vestas V80 (2 MW offshore)(Tab #1) +15 424770 6149216 67,0 9,99 10,05 1360 102,0 Vestas V80 (2 MW offshore)(Tab #1) +16 424829 6148658 67,0 9,99 10,05 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +17 424888 6148101 67,0 9,99 10,03 1347 101,0 Vestas V80 (2 MW offshore)(Tab #1) +18 424947 6147543 67,0 9,99 10,01 1341 100,5 Vestas V80 (2 MW offshore)(Tab #1) +21 425094 6151447 67,0 9,99 9,20 1065 79,8 Vestas V80 (2 MW offshore)(Tab #1) +22 425153 6150889 67,0 9,99 9,23 1079 80,9 Vestas V80 (2 MW offshore)(Tab #1) +23 425212 6150332 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +24 425271 6149774 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +25 425330 6149216 67,0 9,99 9,23 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +26 425389 6148658 67,0 9,99 9,23 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +27 425448 6148101 67,0 9,99 9,19 1058 79,3 Vestas V80 (2 MW offshore)(Tab #1) +28 425507 6147543 67,0 9,99 10,03 1347 101,0 Vestas V80 (2 MW offshore)(Tab #1) +31 425654 6151447 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +32 425713 6150889 67,0 9,99 9,25 1079 80,9 Vestas V80 (2 MW offshore)(Tab #1) +33 425772 6150332 67,0 9,99 9,24 1079 80,9 Vestas V80 (2 MW offshore)(Tab #1) +34 425831 6149774 67,0 9,99 9,24 1079 80,9 Vestas V80 (2 MW offshore)(Tab #1) +35 425890 6149216 67,0 9,99 9,23 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +36 425950 6148659 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +37 426009 6148101 67,0 9,99 9,20 1065 79,8 Vestas V80 (2 MW offshore)(Tab #1) +38 426068 6147543 67,0 9,99 10,03 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +41 426214 6151447 67,0 9,99 9,10 1031 77,2 Vestas V80 (2 MW offshore)(Tab #1) +42 426273 6150889 67,0 9,99 9,13 1037 77,8 Vestas V80 (2 MW offshore)(Tab #1) +43 426332 6150332 67,0 9,99 9,11 1037 77,8 Vestas V80 (2 MW offshore)(Tab #1) +44 426392 6149774 67,0 9,99 9,12 1037 77,8 Vestas V80 (2 MW offshore)(Tab #1) +45 426451 6149216 67,0 9,99 9,11 1037 77,8 Vestas V80 (2 MW offshore)(Tab #1) +46 426510 6148659 67,0 9,99 9,08 1024 76,7 Vestas V80 (2 MW offshore)(Tab #1) +47 426569 6148101 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +48 426628 6147543 67,0 9,99 10,04 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +51 426774 6151447 67,0 9,99 9,00 996 74,7 Vestas V80 (2 MW offshore)(Tab #1) +52 426833 6150889 67,0 9,99 9,03 1010 75,7 Vestas V80 (2 MW offshore)(Tab #1) +53 426892 6150332 67,0 9,99 9,02 1003 75,2 Vestas V80 (2 MW offshore)(Tab #1) +54 426952 6149774 67,0 9,99 9,02 1003 75,2 Vestas V80 (2 MW offshore)(Tab #1) +55 427011 6149216 67,0 9,99 9,01 1003 75,2 Vestas V80 (2 MW offshore)(Tab #1) +56 427070 6148659 67,0 9,99 9,09 1024 76,7 Vestas V80 (2 MW offshore)(Tab #1) +57 427129 6148101 67,0 9,99 9,21 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +58 427189 6147543 67,0 9,99 10,04 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +61 427334 6151447 67,0 9,99 8,98 990 74,2 Vestas V80 (2 MW offshore)(Tab #1) +62 427393 6150889 67,0 9,99 9,00 996 74,7 Vestas V80 (2 MW offshore)(Tab #1) +63 427453 6150332 67,0 9,99 8,99 996 74,7 Vestas V80 (2 MW offshore)(Tab #1) +64 427512 6149774 67,0 9,99 8,98 990 74,2 Vestas V80 (2 MW offshore)(Tab #1) +65 427571 6149216 67,0 9,99 8,97 990 74,2 Vestas V80 (2 MW offshore)(Tab #1) +66 427631 6148659 67,0 9,99 9,11 1031 77,2 Vestas V80 (2 MW offshore)(Tab #1) +67 427690 6148101 67,0 9,99 9,23 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +68 427749 6147543 67,0 9,99 10,04 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +71 427894 6151447 67,0 9,99 8,76 924 69,3 Vestas V80 (2 MW offshore)(Tab #1) +72 427953 6150889 67,0 9,99 8,79 936 70,2 Vestas V80 (2 MW offshore)(Tab #1) +73 428013 6150332 67,0 9,99 8,77 930 69,7 Vestas V80 (2 MW offshore)(Tab #1) +74 428072 6149774 67,0 9,99 8,76 924 69,3 Vestas V80 (2 MW offshore)(Tab #1) +75 428132 6149216 67,0 9,99 8,99 996 74,7 Vestas V80 (2 MW offshore)(Tab #1) +76 428191 6148659 67,0 9,99 9,11 1031 77,2 Vestas V80 (2 MW offshore)(Tab #1) +77 428250 6148101 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +78 428310 6147543 67,0 9,99 10,04 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +81 428454 6151447 67,0 9,99 8,75 918 68,8 Vestas V80 (2 MW offshore)(Tab #1) +82 428513 6150889 67,0 9,99 8,77 924 69,3 Vestas V80 (2 MW offshore)(Tab #1) +83 428573 6150332 67,0 9,99 8,75 924 69,3 Vestas V80 (2 MW offshore)(Tab #1) +84 428632 6149774 67,0 9,99 8,75 924 69,3 Vestas V80 (2 MW offshore)(Tab #1) +85 428692 6149216 67,0 9,99 8,99 996 74,7 Vestas V80 (2 MW offshore)(Tab #1) +86 428751 6148659 67,0 9,99 9,10 1031 77,2 Vestas V80 (2 MW offshore)(Tab #1) +87 428811 6148101 67,0 9,99 9,23 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +88 428870 6147543 67,0 9,99 10,04 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) +91 429014 6151447 67,0 9,99 8,50 846 63,4 Vestas V80 (2 MW offshore)(Tab #1) +92 429074 6150889 67,0 9,99 8,52 852 63,9 Vestas V80 (2 MW offshore)(Tab #1) +93 429133 6150332 67,0 9,99 8,49 846 63,4 Vestas V80 (2 MW offshore)(Tab #1) +94 429193 6149774 67,0 9,99 8,75 924 69,3 Vestas V80 (2 MW offshore)(Tab #1) +95 429252 6149216 67,0 9,99 9,00 996 74,7 Vestas V80 (2 MW offshore)(Tab #1) +96 429312 6148659 67,0 9,99 9,11 1037 77,8 Vestas V80 (2 MW offshore)(Tab #1) +97 429371 6148101 67,0 9,99 9,22 1072 80,3 Vestas V80 (2 MW offshore)(Tab #1) +98 429431 6147543 67,0 9,99 10,04 1354 101,5 Vestas V80 (2 MW offshore)(Tab #1) \ No newline at end of file diff --git a/tests/test_fuga/test_pyfuga.py b/tests/test_fuga/test_pyfuga.py index 7e9e6c05c0077e2f7399216680b5afd1615be3d2..7f71d346abe3a95ba3d7f437334899a5836bd164 100644 --- a/tests/test_fuga/test_pyfuga.py +++ b/tests/test_fuga/test_pyfuga.py @@ -13,17 +13,19 @@ from topfarm.cost_models.fuga.pascal_dll import PascalDLL from topfarm.cost_models.fuga.py_fuga import PyFuga import os from topfarm.cost_models.fuga import py_fuga +import sys fuga_path = os.path.abspath(os.path.dirname(py_fuga.__file__)) + '/Colonel/' def _test_parallel(id): - pyFuga = PyFuga(farm_name='Horns Rev 1', - turbine_model_path=fuga_path + 'LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', - tb_x=[423974, 424033], tb_y=[6151447, 6150889], - mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, - farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1\hornsrev0.lib') + pyFuga = PyFuga() + pyFuga.setup(farm_name='Horns Rev 1', + turbine_model_path=fuga_path + 'LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', + tb_x=[423974, 424033], tb_y=[6151447, 6150889], + mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, + farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1\hornsrev0.lib') print(pyFuga.stdout_filename, id) for i in range(1): print(threading.current_thread(), id) @@ -35,24 +37,31 @@ class Test(unittest.TestCase): def lib_missing(self): lib_path = os.path.dirname(py_fuga.__file__) + "/Colonel/FugaLib/FugaLib.%s" % ('so', 'dll')[os.name == 'nt'] - return os.path.isfile(lib_path) is False + if os.path.isfile(lib_path) is False: + sys.stderr.write("Fugalib '%s' not found\n"%lib_path) + return True + return False def get_fuga(self, tb_x=[423974, 424033], tb_y=[6151447, 6150889]): - return PyFuga(farm_name='Horns Rev 1', - turbine_model_path=fuga_path + 'LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', - tb_x=tb_x, tb_y=tb_y, - mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, - farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1/hornsrev_north_only.lib', climate_interpolation=False) + pyFuga = PyFuga() + pyFuga.setup(farm_name='Horns Rev 1', + turbine_model_path=fuga_path + 'LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', + tb_x=tb_x, tb_y=tb_y, + mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, + farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1/hornsrev_north_only.lib', climate_interpolation=False) + return pyFuga def testCheckVersion(self): - if self.lib_missing(): return + if self.lib_missing(): + return lib = PascalDLL(fuga_path + "FugaLib/FugaLib.%s" % ('so', 'dll')[os.name == 'nt']) self.assertRaisesRegex(Exception, "This version of FugaLib supports interface version ", lib.CheckInterfaceVersion, 1) pyFuga = self.get_fuga() # check that current interface version match pyFuga.cleanup() def testSetup(self): - if self.lib_missing(): return + if self.lib_missing(): + return pyFuga = self.get_fuga() self.assertEqual(pyFuga.get_no_tubines(), 2) self.assertIn("Loading", pyFuga.log) @@ -63,22 +72,24 @@ class Test(unittest.TestCase): pyFuga.cleanup() def testAEP_one_tb(self): - if self.lib_missing(): return + if self.lib_missing(): + return pyFuga = self.get_fuga([0], [0]) - np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0], [0]]).T), [7.44121, 7.44121, 0.424962, 1.]) + np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0], [0]]).T), [7.450272, 7.450272, 0.424962, 1.]) pyFuga.cleanup() def testAEP(self): - if self.lib_missing(): return + if self.lib_missing(): + return pyFuga = self.get_fuga() - np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 200], [0, 0]]).T), [14.848055, 14.882419, 0.423981, 0.997691]) + np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 200], [0, 0]]).T), [14.866138, 14.900544, 0.423981, 0.997691]) np.testing.assert_array_almost_equal(pyFuga.get_aep_gradients(np.array([[0, 200], [0, 0]]).T), 0) - np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 0], [0, 200]]).T), [12.110134, 14.882419, 0.3458, 0.813721]) - np.testing.assert_array_almost_equal(pyFuga.get_aep_gradients(np.array([[0, 0], [0, 200]]).T), [[-0.001792, 0.001792], - [-0.008116, 0.008116], + np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 0], [0, 200]]).T), [12.124883, 14.900544, 0.3458, 0.813721]) + np.testing.assert_array_almost_equal(pyFuga.get_aep_gradients(np.array([[0, 0], [0, 200]]).T), [[-0.001794, 0.001794], + [-0.008126, 0.008126], [0., 0.]]) - np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 200], [0, 200]]).T), [14.846827, 14.882419, 0.423946, 0.997608]) + np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 200], [0, 200]]).T), [14.864909, 14.900544, 0.423946, 0.997608]) np.testing.assert_array_almost_equal(pyFuga.get_aep_gradients(np.array([[0, 200], [0, 200]]).T), [[-5.165553e-06, 5.165553e-06], [1.599768e-06, -1.599768e-06], [0.000000e+00, 0.000000e+00]]) @@ -86,7 +97,7 @@ class Test(unittest.TestCase): # def test_parallel(self): # from multiprocessing import Pool -# +# # with Pool(5) as p: # print(p.map(_test_parallel, [1, 2])) diff --git a/tests/test_fuga/test_turbine_site_list_reader.py b/tests/test_fuga/test_turbine_site_list_reader.py new file mode 100644 index 0000000000000000000000000000000000000000..0be6f8bff052a7469a0576432bffeff5215355fd --- /dev/null +++ b/tests/test_fuga/test_turbine_site_list_reader.py @@ -0,0 +1,36 @@ +''' +Created on 14. maj 2018 + +@author: mmpe +''' +import unittest + +import numpy as np +from tests.test_files import tfp +from tests.test_fuga.test_pyfuga import fuga_path +from topfarm.cost_models.fuga.turbine_site_list_reader import read_turbine_site_list,\ + read_MR_turbine_site_list + + +class TestTurbineSiteListReader(unittest.TestCase): + + def testRead(self): + model, ids, pos = read_turbine_site_list(tfp + "fuga_files/TurbineSiteList.txt") + self.assertEqual(model, "Vestas_V80_(2_MW_offshore)[h=67.00]") + self.assertEqual(ids[-1], "98") + np.testing.assert_array_equal(pos[-1], [429431, 6147543, 67]) + + def testMRRead(self): + farm_name, nacelle_models, pos = read_MR_turbine_site_list(tfp + "fuga_files/4xV52SiteList.txt") + self.assertEqual(farm_name, "4xV52Farm") + name, (z, arm) = nacelle_models[0] + self.assertEqual(name, "V52-0.85MWLower[h=50.00]") + self.assertEqual(z, 50) + self.assertEqual(arm, 30) + np.testing.assert_array_equal(pos[0], [-8879, 2367]) + np.testing.assert_array_equal(pos[-1], [-3553., -2250.]) + + +if __name__ == "__main__": + #import sys;sys.argv = ['', 'Test.testName'] + unittest.main() diff --git a/topfarm/cost_models/fuga/Colonel b/topfarm/cost_models/fuga/Colonel index 63d550ac397e2058fc278ecf1488323440a786fc..100b7842bbeb29ba6f51556fbc24d01cf153efe1 160000 --- a/topfarm/cost_models/fuga/Colonel +++ b/topfarm/cost_models/fuga/Colonel @@ -1 +1 @@ -Subproject commit 63d550ac397e2058fc278ecf1488323440a786fc +Subproject commit 100b7842bbeb29ba6f51556fbc24d01cf153efe1 diff --git a/topfarm/cost_models/fuga/py_fuga.py b/topfarm/cost_models/fuga/py_fuga.py index 54c7423d96b5d610ca553913ddd0dbc35f34899b..6a8de07b72e42bec1025a037c43e65b1267f15d0 100644 --- a/topfarm/cost_models/fuga/py_fuga.py +++ b/topfarm/cost_models/fuga/py_fuga.py @@ -18,16 +18,13 @@ from topfarm.cost_models.fuga.pascal_dll import PascalDLL c_double_p = POINTER(c_double) c_int_p = POINTER(ctypes.c_int32) +fuga_path = os.path.abspath(os.path.dirname(__file__)) + '/Colonel/' + class PyFuga(object): - interface_version = 2 - - def __init__(self, - farm_name='Horns Rev 1', - turbine_model_path='./LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', - tb_x=[423974, 424033], tb_y=[6151447, 6150889], - mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, - farms_dir='./LUT/', wind_atlas_path='Horns Rev 1\hornsrev.lib', climate_interpolation=True): + interface_version = 3 + + def __init__(self): atexit.register(self.cleanup) with NamedTemporaryFile() as f: self.stdout_filename = f.name + "pyfuga.txt" @@ -38,7 +35,14 @@ class PyFuga(object): self.lib = PascalDLL(lib_path) self.lib.CheckInterfaceVersion(self.interface_version) - self.lib.Setup(self.stdout_filename, float(mast_position[0]), float(mast_position[1]), float(mast_position[2]), + self.lib.Initialize(self.stdout_filename) + + def setup(self, farm_name='Horns Rev 1', + turbine_model_path='./LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]', + tb_x=[423974, 424033], tb_y=[6151447, 6150889], + mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0, + farms_dir='./LUT/', wind_atlas_path='Horns Rev 1\hornsrev.lib', climate_interpolation=True): + self.lib.Setup(float(mast_position[0]), float(mast_position[1]), float(mast_position[2]), float(z0), float(zi), float(zeta0)) tb_x_ctype = np.array(tb_x, dtype=np.float).ctypes @@ -51,13 +55,7 @@ class PyFuga(object): assert os.path.isfile(farms_dir + wind_atlas_path), farms_dir + wind_atlas_path self.lib.SetupWindClimate(farms_dir, wind_atlas_path, climate_interpolation) - assert len(tb_x) == self.get_no_tubines(), self.log + "\n%d" % self.get_no_tubines() - - -# self.lib.setup_old(farms_dir, farm_name, turbine_model_path, -# float(mast_position[0]), float(mast_position[1]), float(mast_position[2]), -# float(z0),float(zi),float(zeta0), -# wind_atlas_path) + #assert len(tb_x) == self.get_no_tubines(), self.log + "\n%d!=%d" % (self.get_no_tubines(),len(tb_x)) def cleanup(self): if hasattr(self, 'lib'): @@ -74,22 +72,13 @@ class PyFuga(object): except Exception: pass - def __init__old(self): - path = r'C:\mmpe\programming\pascal\Fuga\Colonel\FugaLib/' - self.lib = PascalDLL(path + 'FugaLib.dll') - - self.lib.setup(path + '../LUT/Farms/', 'Horns Rev 1', path + '../LUT/', - 0., 0., 70., - 0.0001, 400., 0., - 'Horns Rev 1\hornsrev0.lib') - def get_no_tubines(self): no_turbines_p = c_int_p(c_int(0)) self.lib.GetNoTurbines(no_turbines_p) return no_turbines_p.contents.value def move_turbines(self, tb_x, tb_y): - assert len(tb_x) == len(tb_y) == self.get_no_tubines() + assert len(tb_x) == len(tb_y) == self.get_no_tubines(), (len(tb_x) ,len(tb_y), self.get_no_tubines()) tb_x_ctype = np.array(tb_x, dtype=np.float).ctypes tb_y_ctype = np.array(tb_y, dtype=np.float).ctypes diff --git a/topfarm/cost_models/fuga/tests/__init__.py b/topfarm/cost_models/fuga/tests/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/topfarm/cost_models/fuga/turbine_site_list_reader.py b/topfarm/cost_models/fuga/turbine_site_list_reader.py new file mode 100644 index 0000000000000000000000000000000000000000..31b0c517f68a68e13df2de66f931d8ba747cf2d4 --- /dev/null +++ b/topfarm/cost_models/fuga/turbine_site_list_reader.py @@ -0,0 +1,23 @@ +import numpy as np + + +def read_turbine_site_list(filename): + with open(filename) as fid: + lines = fid.readlines() + turbine_model_name = lines[0].strip() + data = np.array([l.replace(",", ".").split()[:4] for l in lines[1:] if l.strip() != ""]) + turbine_ids = data[:, 0] + turbine_positions = data[:, 1:].astype(np.float) + return turbine_model_name, turbine_ids, turbine_positions + + +def read_MR_turbine_site_list(filename): + with open(filename) as fid: + lines = fid.readlines() + farm_name = lines[0].strip() + nPairs = int(lines[1]) + + nacelle_models = ([(lines[2 + 2 * i].strip(), list(map(float, lines[2 + 2 * i + 1].split()))) for i in range(nPairs)]) + turbine_positions = np.array([l.replace(",", ".").split()[:4] for l in lines[2 + 2 * nPairs:] if l.strip() != ""]).astype(np.float) + return farm_name, nacelle_models, turbine_positions +