Git Product home page Git Product logo

weio's Introduction

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)
  • Bladed output files
  • 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

Additional file formats can be added as follows:

  • Copy paste the template file _weio/_NEWFILE_TEMPLATE.py, for instance to weio/MyFormatFile.py
  • Adjust the classname, the default extensions, and implement the reader (function _read()) and optionally the writer.
  • Register the fileformat in weio/__init__.py by adding an import line in the function fileFormats(). Registering the fileformat is useful when using weio with pyDatView, or, when using the automatic reader functionality: weio.read('any_file.ext')

That's it. If possible, add some unittests and examples files:

  • Unittests are found in the folder weio/tests/. You can create a file test_myformat.py in this folder, using existing tests for inspiration.
  • Examples files can be placed in the folder weio/tests/example_files/. Try to use a minimal size for the example files (e.g. a couple of bytes/Kb).
  • To run your test from the repository root, type python -m weio.tests.tests_myformat.

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!

weio's People

Contributors

arash7444 avatar cambrown52 avatar ebranlard avatar ewquon avatar matthieuirondelle avatar samwilson22 avatar simonhh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.