Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bc5e33d
Depreciating python 2 (#19)
ebranlard Jul 31, 2022
083b69e
TDMS: update
ebranlard Aug 11, 2022
0b61a62
Adding xarray and nptdms to requirements, no more optional requirements
ebranlard Aug 11, 2022
6412685
FAST: adding recent HD input files
ebranlard Aug 16, 2022
8ea2c4a
TDMS: adding tests and support for no time track
ebranlard Aug 16, 2022
4f034ea
RoscoPerf: adding convenient functions
ebranlard Aug 16, 2022
3b0b1c5
Misc updates
ebranlard Nov 1, 2022
1ddcd3d
FAST: update of SD read/write
ebranlard Nov 7, 2022
5642e44
Update of SubDyn reader
ebranlard Nov 13, 2022
f8d6765
FAST: fix out list issue
ebranlard Nov 20, 2022
7e38388
FAST: update of input deck for beamdyn driver
ebranlard Nov 20, 2022
7bca93f
Yaml: small rewrite and unittests
ebranlard Nov 20, 2022
5602541
Remove constraint on OutList
ebranlard Dec 1, 2022
fdaf9cd
Graph: proptoNode for SD and HD
ebranlard Dec 9, 2022
420dd85
Graph: nodal to elem if requested
ebranlard Dec 9, 2022
3f6cea4
Graph: removing print
ebranlard Dec 9, 2022
4b34dbc
Fix setup.py
ebranlard Dec 9, 2022
8626d2e
Graph: updates for HD, some TODOs still
ebranlard Dec 9, 2022
38cb14b
Reintroducing __init__.py for convenience
ebranlard Dec 9, 2022
295b19d
Merge branch 'main' into dev
ebranlard Dec 19, 2022
df6b273
Merge branch 'dev' of https://github.com/ebranlard/weio into dev
ebranlard Dec 19, 2022
08e2c4c
HAWC2: update of htc
ebranlard Dec 19, 2022
b27d2c1
SDSum: adding arguments for mode sorting and removing zeros
ebranlard Jan 5, 2023
e9f0045
Update for MoorDyn v2
ebranlard Jan 13, 2023
0fcc92c
Functions to work with AMR-Wind netcdf data and turbsim data (#25)
ebranlard Jan 13, 2023
70cdf67
Adding Pickle and ROSCO DISCON
ebranlard Jan 25, 2023
8d9991d
Merge branch 'dev' of https://github.com/ebranlard/weio into dev
ebranlard Jan 25, 2023
f3eb781
Starting converters
ebranlard Jul 17, 2023
e52a5c5
TDMS: still optional, tests are then optional
ebranlard Jul 17, 2023
f8a23f8
Update from pydatview
ebranlard Jul 17, 2023
8536f03
Mann: adding test for Mann box
ebranlard Jul 18, 2023
cb3a963
FASTLin: starting more robust read
ebranlard Jul 19, 2023
9c22703
Mann: comments
ebranlard Jul 19, 2023
513f3b3
Misc updates
ebranlard Oct 20, 2023
cc3f51d
Misc updates
ebranlard Oct 20, 2023
94c4f0e
FASTOut: faster reader
ebranlard Nov 20, 2023
87f5b54
GH: testing more python versions
ebranlard Nov 20, 2023
a45fe61
FASTOut: faster, and 2D fields
ebranlard Nov 28, 2023
5df30f6
BDSum: starting BD summary file
ebranlard Nov 28, 2023
36c7c60
FAST Output Description and WEIO pip install fix (issues #27 and #28)…
mutricyl Mar 1, 2024
44f15f3
Misc updates from welib
ebranlard Sep 27, 2024
59e74d7
Merge branch 'dev' of github.com:ebranlard/weio into dev
ebranlard Sep 27, 2024
2879c00
Adding plot3d, airfoil, and yaml + misc updates from welib
ebranlard Sep 16, 2025
0ef9fde
Fixing github workflow
ebranlard Sep 16, 2025
69ac4a0
Update of version to 2.0
ebranlard Sep 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9, 3.11, 3.12]

steps:
# --- Install steps
Expand Down
280 changes: 140 additions & 140 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,140 +1,140 @@
[![Build status](https://github.com/ebranlard/weio/workflows/Tests/badge.svg)](https://github.com/ebranlard/weio/actions?query=workflow%3A%22Tests%22)
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>

# 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](https://github.com/ebranlard/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:
```bash
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
```python
import weio
f=weio.read('file.csv')
print(f.toDataFrame())
f.write('out.csv')
```
Example for an OpenFAST binary file:
```python
import weio
df=weio.read('Output.outb').toDataFrame()
plt.plot(df['Time_[s]'], df['GenPwr_[kW']))
```
Example to change an OpenFAST input file:
```python
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 :
```python
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, and has limited requirements.
If you have pip installed on your system, you can install them by typing in a terminal:
```bash
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:
```bash
git clone https://github.com/ebranlard/weio
cd weio
```

## Installation
The python packages mentioned in the Requirements section need to be installed.
```bash
pip install -e .
```
or
```bash
python setup.py install
```


## Adding more file formats
There are two ways to add a file format. If your file format is fairly generic (e.g. CSV, Excel) you can add it directly to weio (see Option 1 below). Otherwise, it is recommended to use Option 2 below.

### Option 1: Adding a generic/wind energy file format to this repository
Additional file formats (that are either generic, or commonly used by the wind energy community) can be added as follows:

- Copy paste the template file `weio/_NEWFILE_TEMPLATE.py`, to, for instance `weio/my_format_file.py`
- Edit this file. Adjust the classname and the default extensions. Implement the reader (function `_read()`) and optionally the writer. Look for XXX in this file and replace them with appropriate value for your file format.
- 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`.

### Option 2: Adding specific/confidential file formats
Specific file formats can be added in the `<UserData>` folder of weio.
Depending on your platform, the `<UserData>` directory will be:

- `C:/Users/<USERNAME>/AppData/Roaming/weio` on Windows
- `<HOME>/.local/share/weio/` on Linux
- `<HOME>/Library/Application Support/weio/` on MacOS

To add specfic file formats, follow the following steps:

- Create the `<UserData>` directory if it doesn't exist.

- Copy paste the template file `weio/_NEWFILE_TEMPLATE.py`, to, for instance `<UserData>/my_format_file.py`.

- Edit this file. Adjust the classname and the default extensions. Implementing the reader (function `_read()`) and optionally the writer. Look for XXX in this file and replace them with appropriate values for your file format. NOTE: it's important to have "File" in your classname, for instance the class name could be "MyFormatFile". You can also adjust the priority level (the priority static method), which will define how early the fileformat will be tried in the list of fileformats.

The fileformats should now be available within weio. The function `weio.read` will loop through all available file formats and attempt to read a given file. You can call `weio.fileFormats` to see the list of supported fileformats and see where your newly added format is located in this list. The added class may be accessed as follows `from weio.user import MyFormatFile".

## 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:


<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>



[![Build status](https://github.com/ebranlard/weio/workflows/Tests/badge.svg)](https://github.com/ebranlard/weio/actions?query=workflow%3A%22Tests%22)
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>
# 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](https://github.com/ebranlard/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:
```bash
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
```python
import weio
f=weio.read('file.csv')
print(f.toDataFrame())
f.write('out.csv')
```
Example for an OpenFAST binary file:
```python
import weio
df=weio.read('Output.outb').toDataFrame()
plt.plot(df['Time_[s]'], df['GenPwr_[kW']))
```
Example to change an OpenFAST input file:
```python
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 :
```python
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 3, and has limited requirements.
If you have pip installed on your system, you can install them by typing in a terminal:
```bash
pip install -r requirements.txt
```
## 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:
```bash
git clone https://github.com/ebranlard/weio
cd weio
```
## Installation
The python packages mentioned in the Requirements section need to be installed.
```bash
pip install -e .
```
or
```bash
python setup.py install
```
## Adding more file formats
There are two ways to add a file format. If your file format is fairly generic (e.g. CSV, Excel) you can add it directly to weio (see Option 1 below). Otherwise, it is recommended to use Option 2 below.
### Option 1: Adding a generic/wind energy file format to this repository
Additional file formats (that are either generic, or commonly used by the wind energy community) can be added as follows:
- Copy paste the template file `weio/_NEWFILE_TEMPLATE.py`, to, for instance `weio/my_format_file.py`
- Edit this file. Adjust the classname and the default extensions. Implement the reader (function `_read()`) and optionally the writer. Look for XXX in this file and replace them with appropriate value for your file format.
- 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`.
### Option 2: Adding specific/confidential file formats
Specific file formats can be added in the `<UserData>` folder of weio.
Depending on your platform, the `<UserData>` directory will be:
- `C:/Users/<USERNAME>/AppData/Roaming/weio` on Windows
- `<HOME>/.local/share/weio/` on Linux
- `<HOME>/Library/Application Support/weio/` on MacOS
To add specfic file formats, follow the following steps:
- Create the `<UserData>` directory if it doesn't exist.
- Copy paste the template file `weio/_NEWFILE_TEMPLATE.py`, to, for instance `<UserData>/my_format_file.py`.
- Edit this file. Adjust the classname and the default extensions. Implementing the reader (function `_read()`) and optionally the writer. Look for XXX in this file and replace them with appropriate values for your file format. NOTE: it's important to have "File" in your classname, for instance the class name could be "MyFormatFile". You can also adjust the priority level (the priority static method), which will define how early the fileformat will be tried in the list of fileformats.
The fileformats should now be available within weio. The function `weio.read` will loop through all available file formats and attempt to read a given file. You can call `weio.fileFormats` to see the list of supported fileformats and see where your newly added format is located in this list. The added class may be accessed as follows `from weio.user import MyFormatFile".
## 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:
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .weio import *
77 changes: 77 additions & 0 deletions developper_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Developer Notes



## Release Steps
Typically releases are done for each new version of OpenFAST

1. Create a pull request from main to dev
2. Make sure the input file in the `data` directory are compatible with the new OpenFAST version
3. Change the file VERSION (and/or setup.py)
4. Merge pull request to main
5. Tag the commit using `git tag -a vX.X.X`
6. Upload to pypi and conda (see below)


## Upload a new version for pip
Detailled steps are provided further below.

### Summary
Remember to change VERSION file and/or setup.py
```bash
python setup.py sdist
twine upload dist/* # upload to pypi
```



### (Step 0 : create an account on pypi)

### Step 1: go to your repo
Go to folder
```bash
cd path/to/weio
```

### Step 2: change version in setup.py and tag it
change VERSION in setup.py
```
git add setup.py VERSION
git commit "Version X.X.X"
git tag -a
```

### Step 3: Create a source distribution
```bash
python setup.py sdist
```

### Step 4: Install twine
```bash
pip install twine
```

### Step 5: Ubplot to pypi
Run twine to upload to Pypi (will ask for username and password)
```bash
twine upload dist/*
```

### After clone / first time
Add `.gitconfig` to your path, to apply filters on jupyter notebooks
```bash
git config --local include.path ../.gitconfig
```



## Upload a new version to Conda
TODO
TODO
TODO

conda-forge,
make a pull request there.
- setup build script (https://conda-forge.org/docs/maintainer/adding_pkgs.html).
see e.g. FLORIS (https://github.com/conda-forge/floris-feedstock/blob/master/recipe/meta.yaml).
- make a pull request to https://github.com/conda-forge/staged-recipes/
Loading