BUG: Attribute _c2def in class H2aeroBlade
Describing the issue:
I'm new to this project and found it really great. I would like to use it as a dependency for another project.
In general I want to read an HTC file and get the definition of the blades. I found that you can use the wetb.hawc2.blade.H2aeroBlade
class, which also comes with plotting options. However, I'm not able to create an object of this class.
Reproduce the code example:
import os
import matplotlib.pyplot as plt
from wetb.hawc2.blade import H2aeroBlade
filename = "htc/DTU_10MW_RWT.htc"
path = os.path.dirname(__file__) + "/wetb/hawc2/tests/test_files/simulation_setup/DTU10MWRef6.0/"
blade = H2aeroBlade(path + filename)
blade.plot_yz_geometry(plt)
plt.show()
Error message:
Traceback (most recent call last):
File "c:\git\WindEnergyToolbox\wetb\hawc2\htc_contents.py", line 64, in __getattr__
return object.__getattribute__(self, *args, **kwargs)
AttributeError: 'HTCFile' object has no attribute 'blade_c2_def'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\git\WindEnergyToolbox\test_h2_imports.py", line 9, in <module>
blade = H2aeroBlade(path + filename)
File "c:\git\WindEnergyToolbox\wetb\hawc2\blade.py", line 101, in __init__
self.hawc2_splines_data = self.hawc2_splines()
File "c:\git\WindEnergyToolbox\wetb\hawc2\blade.py", line 148, in hawc2_splines
curve_l = np.r_[0, np.cumsum(np.sqrt(np.sum(np.diff(self.c2def[:, :3], 1, 0) ** 2, 1)))]
File "c:\git\WindEnergyToolbox\wetb\hawc2\blade.py", line 127, in c2def
self._c2def = np.array([v.values[1:5] for v in self.htcfile.blade_c2_def if v.name_ == "sec"])
File "c:\git\WindEnergyToolbox\wetb\hawc2\htc_contents.py", line 69, in __getattr__
return self.contents[k]
KeyError: 'blade_c2_def'
Proposed change:
When I change line 127 in wetb.hawc2.blade
from
self._c2def = np.array([v.values[1:5] for v in self.htcfile.blade_c2_def if v.name_ == "sec"])
to
bladename= self.htcfile.aero.link[2]
self._c2def = np.array([v.values[1:5] for v in self.htcfile.new_htc_structure.get_subsection_by_name(bladename).c2_def if v.name_ == "sec"])
it works. I don't know if I am using the toolbox correctly or if it is an actual bug.
Edited by Niklas Jöres