internal function
Parses over a turbine's data file to get hub height, capacity, rotor diameter and powercurve.
Used for loading into the TurbineLibrary table
Source code in reskit/wind/core/turbine_library.py
| def parse_turbine(path):
"""
**internal function**
Parses over a turbine's data file to get hub height, capacity, rotor diameter and powercurve.
Used for loading into the TurbineLibrary table
"""
meta = OrderedDict()
with open(path) as fin:
# Meta extraction mode
while True:
line = fin.readline()[:-1]
if line == "" or line[0] == "#":
continue # skip blank lines and comment lines
if "power curve" in line.lower():
break
sLine = line.split(",")
if sLine[0].lower() == "hubheight" or sLine[0].lower() == "hub_height":
heights = []
for h in sLine[1:]:
h = h.replace('"', "")
h = h.strip()
h = h.replace(" ", "")
try:
h = float(h)
heights.append(h)
except:
try:
a, b = rangeRE.search(h).groups()
a = int(a)
b = int(b)
for hh in range(a, b + 1):
heights.append(hh)
except:
raise RuntimeError("Could not understand heights")
meta["Hub_Height"] = np.array(heights)
else:
try:
meta[sLine[0].title()] = float(sLine[1])
except:
meta[sLine[0].title()] = sLine[1]
# Extract power profile
tmp = pd.read_csv(fin)
tmp = np.array([(ws, output) for i, ws, output in tmp.iloc[:, :2].itertuples()])
power = PowerCurve(tmp[:, 0], tmp[:, 1] / tmp[:, 1].max())
return TurbineInfo(power, meta)
|