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

Merge branch 'master' of gitlab.windenergy.dtu.dk:toolbox/WindEnergyToolbox

parents 2387ad6d e9a1ff17
No related branches found
No related tags found
No related merge requests found
Master spreadsheets to generate the set of spreadsheets required as inputs to the DLB calculator.
"Each sheet defines the tags of a DLC, except the main one. The main sheet defines: wind turbine parameters, default tags values, and gusts and turbulence definitions."
"Tags are devided into 3 categories: constants (C), variables (V), and functions (F). The category is specified in the line above the tag."
Constants do not change in a DLC. Variables define the number of cases within a DLC through their combinations. Functions are tags that depends on other tags through and expression.
Parameters: Vrate Vout
12 26
Default constants: [ref_ti] [ref_wind_speed] [tsr] [hub_height] [diameter] [t0] [wdir] [shear_exp] [out_format] [gust] [gust_type] [G_A] [G_phi0] [G_t0] [G_T] [Rotor azimuth] [Free shaft rot] [init_wr] [Pitch 1 DLC22b] [Rotor locked] [Time stuck DLC22b] [Cut-in time] [Stop type] [Pitvel 1] [Pitvel 2] [Grid loss time] [Time pitch runaway] [Induction] [Dyn stall] [dis_setbeta] [long_scale_param] [t_flap_on] [turb_format] [staircase] [Rotor azimuth] [sim_time] [Cut-out time]
0.16 50 8.0 90 178 100 0 0.2 hawc_binary ; 0 0.5 0 ; -1 1 1 4 6 10000 10000 1 2 42 20 1 ; 0 600 10000
Default functions: [Turb base name] [time stop] [turb_dx] [wsp factor] [wind_ramp_t1] [wind_ramp_factor1] [time_start]
"""turb_wsp[wsp]_s[seed]""" [t0]+[sim_time] "[wsp]*[time stop]/8192,0" [tsr]/[wsp] [t0] [wsp factor] [t0]
Gusts:
EOG "min([1,35*(0,8*1,4*[ref_wind_speed]-[wsp]);3,3*[TI]*[wsp]/(1+0,1*[diameter]/[long_scale_param])])"
ECD 15
EWS "(2,5+0,2*6,4*[TI]*[wsp]*([diameter]/[long_scale_param])**0,25)/[diameter]"
EDC "4*arctan([TI]/(1+0,1*[diameter]/[long_scale_param]))*180/pi"
Turbulence:
NTM "([ref_ti]*(0,75*[wsp]+5,6))/[wsp]"
ETM "2*[ref_ti]*(0,072*(0,2*[ref_wind_speed]/2+3)*([wsp]/2-4)+10)/[wsp]"
Wind speeds:
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
Create a master Excel sheet from a series of text files
Command-line usage
------------------
$ python write_master.py [OPTIONS]
Command line options
--------------------
--folder (default='DLCs')
folder containing text files
--filename (default='DLCs.xlsx')
name of Excel file to save incl. extension
--fileend (default='.txt')
text file extention
--delimiter (default='\t')
character separating columns in text files
Author: Jenni Rinker, rink@dtu.dk
"""
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from argparse import ArgumentParser
import numpy as np
import os
import pandas as pd
def write_master(path_to_texts,
excel_name='DLCs.xlsx', file_end='.txt',
delimiter='\t'):
""" Write a master Excel sheet from a series of text files
Args:
path_to_texts (str): path to directory with text files
excel_name (str): filename of generated master Excel file
file_end (str): file ending of text files
delimiter (str): column delimiter in text files
"""
# formatting for header cells
header_dict = {'bold': True, 'font_color': '#1F497D',
'bottom': 2, 'bottom_color': '#95B3D7'}
# get list of text files
text_files = [f for f in os.listdir(path_to_texts) \
if f.endswith(file_end)]
# check if main text file in the specified directory
if 'Main'+file_end not in text_files:
raise ValueError('\"Main\" file not in CSV directory')
# rearrange text files so main page is first and everything
# else is alphabetical
text_files.remove('Main'+file_end)
text_files = ['Main'+file_end] + sorted(text_files)
# open excel file
writer = pd.ExcelWriter(excel_name, engine='xlsxwriter')
# create workbook and add formast
workbook = writer.book
header = workbook.add_format(header_dict)
# loop through text files
for text_name in text_files:
# define path to csv file
text_path = os.path.join(path_to_texts,text_name)
# read data, write to Excel file, and define worksheet handle
text_df = pd.read_table(text_path,
delimiter=delimiter, dtype=str,
header=None)
text_df.to_excel(writer, sheet_name=text_name.rstrip(file_end),
index=False, header=False)
worksheet = writer.sheets[text_name.rstrip(file_end)]
# get column widths by calculating max string lenths
col_widths = text_df.apply(lambda x: np.max([len(str(s)) for s in x]))
# add formatting
for i_col, width in enumerate(col_widths):
worksheet.set_column(i_col, i_col, width)
if 'Main' in text_name: # hardcode first column on main tab
worksheet.set_column('A:A', 16.56)
for i_row in [6,9,13,18,24,28]:
worksheet.set_row(i_row, cell_format=header)
else:
worksheet.set_row(1, cell_format=header)
worksheet.set_zoom(zoom=85)
# save worksheet
writer.save()
return
if __name__ == '__main__':
# define argument parser
parser = ArgumentParser(description="generator of master excel sheet")
parser.add_argument('--folder', type=str, default='DLCs', action='store',
dest='folder', help='Destination folder name')
parser.add_argument('--filename', type=str, default='DLCs.xlsx',
action='store', dest='filename',
help='Master spreadsheet file name')
parser.add_argument('--fileend', type=str, default='.txt',
action='store', dest='fileend',
help='File extension for fileend files')
parser.add_argument('--delimiter', type=str, default='\t',
action='store', dest='delimiter',
help='Text delimiter in files')
opt = parser.parse_args()
# write master Excel files
write_master(opt.folder,
excel_name=opt.filename, file_end=opt.fileend,
delimiter=opt.delimiter)
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