Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .github/workflows/development-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-latest
# GitHub publishes Python 3.9 builds for Ubuntu 24.04.
- os: ubuntu-24.04
python-version: 3.9
python: xvfb-run python3
pip_arg: ""
Expand Down Expand Up @@ -50,7 +51,7 @@ jobs:
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
5 changes: 4 additions & 1 deletion openfast_toolbox/airfoils/polar_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def tryReading(f, reader):
# --- Rename columns - Standardize column names
if standardizeCols:
COLS_TODO= {**DEFAULT_COLUMNS,**DEFAULT_COLUMNS_EXT}
# Index values are read-only with pandas 3, rename through a list
new_cols = list(df.columns)
for ic, col in enumerate(df.columns):
c = col.strip().lower().replace('_','')
c = c.replace('aoa','alpha')
Expand All @@ -249,11 +251,12 @@ def tryReading(f, reader):
if c.startswith(kk):
cnew = COLS_TODO.pop(kk)
#print('changing {} to {}'.format(c, cnew))
df.columns.values[ic] = cnew # rename column
new_cols[ic] = cnew # rename column
found=True
break
if not found:
print('[WARN] PolarFile: The following column was not understood: {}'.format(col))
df.columns = new_cols

# --- Standardize data
for k,v in DEFAULT_COLUMNS.items():
Expand Down
2 changes: 1 addition & 1 deletion openfast_toolbox/converters/hawc2ToBeamDyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def hawc2ToBeamDyn(H2MeanLine, H2Structure, BDBldFileOut, BDMainFileOut=None, BD
else:
c2def = CSVFile(H2MeanLine).toDataFrame()
# For the equations below to be generic we force the column names
c2def.columns.values[0:4]=['x_[m]','y_[m]','z_[m]','twist_[deg]']
c2def.columns = ['x_[m]','y_[m]','z_[m]','twist_[deg]'] + list(c2def.columns[4:])

# --- If necessary, interpolate mean line to user defined positions
c2def_old = c2def.copy()
Expand Down
4 changes: 2 additions & 2 deletions openfast_toolbox/io/cactus_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def timeDataToOpenFAST(self, df):
df.insert(c , 'RtAeroFzh_[N]' ,-(np.cos(theta)*df['Fz Coeff. (-)'] + np.sin(theta)*df['Fx Coeff. (-)'])*F0 ); c+=1
df.insert(c , 'RtAeroMxh_[N-m]' , df['Torque Coeff. (-)']*Q0) ; c+=1
df.insert(c , 'RtAeroPwr_[W]' , df['Power Coeff. (-)']*P0) ; c+=1
df['RtAeroPwr_[W]'].values[0]=df['RtAeroPwr_[W]'].values[1]
df.iloc[0, df.columns.get_loc('RtAeroPwr_[W]')] = df['RtAeroPwr_[W]'].iloc[1]

df.insert(c , 'RotSpeed_[rpm]' , self.RPM*ones) ; c+=1

Expand All @@ -260,7 +260,7 @@ def timeDataToOpenFAST(self, df):
df.insert(c , 'Z'+sb+'AeroFzg_[N]' , df['Blade'+sb+' Fy Coeff. (-)']*F0) ; c+=1
df.insert(c , 'Z'+sb+'AeroMzg_[N-m]' , df['Blade'+sb+' Torque Coeff. (-)']*Q0) ; c+=1

df['Y'+sb+'AeroPwr_[W]'].values[0] = df['Y'+sb+'AeroPwr_[W]'].values[1]
df.iloc[0, df.columns.get_loc('Y'+sb+'AeroPwr_[W]')] = df['Y'+sb+'AeroPwr_[W]'].iloc[1]

df.insert(c , 'Wind1VelX_[m/s]' , U*ones) ; c+=1

Expand Down
8 changes: 5 additions & 3 deletions openfast_toolbox/postpro/postpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,14 +1392,16 @@ def remap_df(df, ColMap, bColKeepNewOnly=False, inPlace=False, dataDict=None, ve


# Applying renaming only now so that expressions may be applied in any order
# Index values are read-only with pandas 3, rename through a list
new_cols = list(df.columns)
for k,v in RenameMap.items():
if verbose:
print('Renaming column {:15s} > {}'.format(v,k))
k=k.strip()
iCol = list(df.columns).index(v)
df.columns.values[iCol]=k
iCol = new_cols.index(v)
new_cols[iCol]=k
ColNew.append(k)
df.columns = df.columns.values # Hack to ensure columns are updated
df.columns = new_cols

if len(ColMapMiss)>0:
print('[FAIL] The following columns were not found in the dataframe:',ColMapMiss)
Expand Down
33 changes: 33 additions & 0 deletions openfast_toolbox/postpro/tests/test_remap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import unittest

import numpy as np
import pandas as pd

from openfast_toolbox.postpro import postpro
from openfast_toolbox.tools import pandalib


class TestRemap(unittest.TestCase):

def _check_remap(self, remap_df):
df = pd.DataFrame({'Wind1VelX_[m/s]': [8.0, 9.0], 'RotSpeed_[rpm]': [10.0, 12.0]})
ColMap = {
'WS_[m/s]' : 'Wind1VelX_[m/s]', # rename
'RotSpeed_[rad/s]' : '{RotSpeed_[rpm]} * 2*np.pi/60', # new column
}
df2 = remap_df(df, ColMap)
self.assertEqual(list(df2.columns), ['WS_[m/s]', 'RotSpeed_[rpm]', 'RotSpeed_[rad/s]'])
np.testing.assert_allclose(df2['WS_[m/s]'], [8.0, 9.0])
np.testing.assert_allclose(df2['RotSpeed_[rad/s]'], np.array([10.0, 12.0])*2*np.pi/60)
# The input dataframe is not modified
self.assertEqual(list(df.columns), ['Wind1VelX_[m/s]', 'RotSpeed_[rpm]'])

def test_remap_postpro(self):
self._check_remap(postpro.remap_df)

def test_remap_pandalib(self):
self._check_remap(pandalib.remap_df)


if __name__ == '__main__':
unittest.main()
8 changes: 5 additions & 3 deletions openfast_toolbox/tools/pandalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ def remap_df(df, ColMap, bColKeepNewOnly=False, inPlace=False, dataDict=None, ve
Found=True

# Applying renaming only now so that expressions may be applied in any order
# Index values are read-only with pandas 3, rename through a list
new_cols = list(df.columns)
for k,v in RenameMap.items():
if verbose:
print('Renaming column {:15s} > {}'.format(v,k))
k=k.strip()
iCol = list(df.columns).index(v)
df.columns.values[iCol]=k
iCol = new_cols.index(v)
new_cols[iCol]=k
ColNew.append(k)
df.columns = df.columns.values # Hack to ensure columns are updated
df.columns = new_cols

if len(ColMapMiss)>0:
print('[FAIL] The following columns were not found in the dataframe:',ColMapMiss)
Expand Down
Loading