Skip to content

Commit

Permalink
Merge branch 'develop' into f/flaps
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Feb 13, 2020
2 parents aad15e1 + 94be268 commit 7cc3f57
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
13 changes: 9 additions & 4 deletions Examples/example_08.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# In this example:
# - Load openfast output data
# - Trim the time series
# - Plot some available channels

# Python Modules
Expand All @@ -16,15 +17,19 @@
fast_io = wtc_utilities.FAST_IO()

# Define openfast output filenames
filenames = ["../Test_Cases/5MW_Land/5MW_Land.outb"]
# filenames = ["../Test_Cases/5MW_Land/5MW_Land.outb"]

# ---- Note: Could plot multiple cases, and binaries...
# filenames = ["../Test_Cases/5MW_Land/5MW_Land.out",
# "../Test_Cases/5MW_Land/5MW_Land.outb"]
filenames = ["../Test_Cases/5MW_Land/5MW_Land.out",
"../Test_Cases/5MW_Land/5MW_Land.outb"]

# Load output info and data
allinfo, alldata = fast_io.load_output(filenames)

# Trim time series
for i,(info,data) in enumerate(zip(allinfo,alldata)):
alldata[i] = fast_io.trim_output(info, data, tmin=0, tmax=50)

# Define Plot cases
# --- Comment,uncomment, create, and change these as desired...
cases = {}
Expand All @@ -33,4 +38,4 @@
cases['Rotor Performance'] = ['RtVAvgxh', 'RtTSR', 'RtAeroCp']

# Plot, woohoo!
fast_io.plot_fast_out(cases, allinfo, alldata)
fast_io.plot_fast_out(cases, allinfo, alldata)
33 changes: 32 additions & 1 deletion ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,38 @@ def freadRowOrderTableBuffered(fid, n, type_in, nCols, nOff=0, type_out='float64
'attribute_units': ChanUnit}
return data, info

def trim_output(self, info, data, tmin=0, tmax=100000):
'''
Trim loaded fast output data
Parameters
----------
info : dict
info from load_output containing:
- name: filename
- description: description of dataset
- channels: list of channel names
- attribute_units: list of attribute units
data : ndarray
output data from load_outputinfo
tmin : float, optional
start time
tmax : float, optional
end time
Returns
-------
data : ndarray
input data ndarray with values trimed to times tmin and tmax
'''
time_init = np.ndarray.flatten(data[:, info['channels'].index('Time')])
Tinds = np.where(time_init<=tmin)
Tinds = np.append(Tinds, np.where(time_init>=tmax))
tvals = [time.tolist() for time in time_init[Tinds]]

data = np.delete(data, Tinds, 0)

return data
class FileProcessing():
"""
Class FileProcessing used to write out controller
Expand Down Expand Up @@ -645,4 +676,4 @@ def load_from_txt(txt_filename):
# self.Cp_table = Cp
# self.Ct_table = Ct
# self.Cq_table = Cq
return pitch_initial_rad, TSR_initial, Cp, Ct, Cq
return pitch_initial_rad, TSR_initial, Cp, Ct, Cq

0 comments on commit 7cc3f57

Please sign in to comment.