weio

Library to read and write files for wind energy


License
MIT
Install
pip install weio==1.0.0

Documentation

Build Status Donate just a small amount, buy me a coffee!

weio

Library to read and write files, in particular files used by the Wind Energy community. This library is for instance used by the GUI tool pyDatView to plot, export and compare these different files.

Typical file formats supported

  • Various CSV and delimited files
  • Simple Excel files
  • FAST input and output files (including some turbulence files)
  • HAWC2 and HawcStab2 input and output files (still some missing)
  • FLEX output files
  • NetCDF files (partial support for 1D and 2D data for now)

Quickstart

Download, install dependencies, install package and run tests:

git clone https://github.com/ebranlard/weio
cd weio
python -m pip install --user -r requirements.txt  
python -m pip install -e .      # install
python -m unittest discover -v  # run test

Python package usage

import weio 
f=weio.read('file.csv')
print(f.toDataFrame())
f.write('out.csv')

Example for an OpenFAST binary file:

import weio 
df=weio.read('Output.outb').toDataFrame()
plt.plot(df['Time_[s]'], df['GenPwr_[kW']))

Example to change an OpenFAST input file:

import weio 
ED=weio.read('ElastoDyn.dat')
print(ED.keys())
ED['NacMass'] = 100000 # changing nacelle mass value
ED['HubMass'] = 10000  # changing hub mass value
ED.write('ElastoDyn_modified.dat')

Example to change an OpenFAST aerodynamic blade file :

import weio
import numpy as np
Bld=weio.read('NREL5MW_AD15_blade.dat')
nSpan = 10
Spn   = np.linspace(0, 15, nSpan)       # BlSpn, radial stations [m]
CrvAC = np.zeros((nSpan,))              # BlCrvAC, prebend (usually <0) [m]
SwpAC = np.zeros((nSpan,))              # BlSwpC,  sweep                [m]
CrvAng = np.concatenate(([0], np.arctan2((CrvAC[1:]-CrvAC[:-1]),(Spn[1:]-Spn[:-1]))*180/np.pi))
Twist  = np.zeros((nSpan,)) + 1         # BlTwist [deg]
Chord  = np.zeros((nSpan,)) + 5         # BlChord [m]
AFID   = np.zeros((nSpan,)).astype(int) # BlAFID [-]
ADProp = np.column_stack((Spn,CrvAC,SwpAC,CrvAng,Twist,Chord,AFID))
Bld['NumBlNds']     = ADProp.shape[0]
Bld['BldAeroNodes'] = ADProp
Bld.write('AeroDyn_Blade_Modified.dat')

Requirements

The library is compatible python 2.7 and python 3. The script relies on the following python packages: numpy, pandas, xarray

If you have pip installed on your system, you can install them by typing in a terminal:

pip install -r requirements.txt

or type make dep from the main directory.

Download

From the github page, click on the "Clone or download" button, and you may chose to download as Zip. Alternatively, from a command line:

git clone https://github.com/ebranlard/weio
cd weio

Installation

The python packages mentioned in the Requirements section need to be installed.

pip install -e .

or

python setup.py install

Adding more file formats

File formats can be added by implementing a subclass of weio/File.py, for instance weio/VTKFile.py. Existing examples are found in the folder weio. Once implemented the fileformat needs to be registered in weio/__init__.py by adding an import line at the beginning of this script and adding a line in the function fileFormats() of the form formats.append(FileFormat(VTKFile))

Contributing

Any contributions to this project are welcome! If you find this project useful, you can also buy me a coffee (donate a small amount) with the link below:

Donate just a small amount, buy me a coffee!