Exemplo n.º 1
0
def readFASTOutAscii(filename):
    # Read with panda
    f = weio.FASTOutFile(filename)
    df = f.toDataFrame()
    #df=pd.read_csv(filename, sep='\t', skiprows=[0,1,2,3,4,5,7])
    #df.rename(columns=lambda x: x.strip(),inplace=True)
    return df
Exemplo n.º 2
0
def powerCurvePostProWindStep(outfile,
                              wndfile=None,
                              tWindow=20,
                              ColMap={},
                              WS=None,
                              KeepAll=False):
    def renameCol(x):
        for k, v in ColMap.items():
            if x == v:
                return k
        return x

    # --- Reading wind and output file
    print('Reading input...')
    out = weio.FASTOutFile(outfile).toDataFrame()
    wnd = weio.FASTWndFile(wndfile).toDataFrame()

    if len(ColMap) > 0:
        out.rename(columns=renameCol, inplace=True)
    #units=['('s.split('[')[1].split(']')[0] for s in out.columns.values
    # --- Looping on wind values, and averaging data over a window
    if WS is None:
        WS = np.sort(np.unique(wnd['WindSpeed_[m/s]']))
    print(WS)
    tWS = out['WS_[m/s]'].values
    t = out['Time_[s]'].values
    tol = 0.01
    Iall = np.arange(len(t))
    result = None
    for i, ws in enumerate(WS):
        b = abs(tWS - ws) < tol
        I = Iall[b]
        iEnd = I[-1]
        tEnd = t[iEnd]
        tStart = t[iEnd] - tWindow
        IWindow = (t > tStart) & (t < tEnd)
        print('WS ', ws, ' t ', tStart, '-', tEnd)
        MeanValues = pd.DataFrame(out[IWindow].mean()).transpose()
        if i == 0:
            result = MeanValues.copy()
        else:
            result = result.append(MeanValues, ignore_index=True)

    # --- Sorting by WS
    result.sort_values(['WS_[m/s]'], inplace=True)
    result.reset_index(drop=True, inplace=True)

    # --- Eliminating unnecessary columns
    if len(ColMap) > 0 and (not KeepAll):
        ColNames = list(ColMap.keys())
    else:
        ColNames = result.columns.values
    result = result[ColNames]

    # --- Rounding
    result = result.round(4)
    #result.plot(x='Wind1VelX',y=I)
    #plt.show()
    return result
Exemplo n.º 3
0
def parametricPostPro(workdir,TimeAvgWindow=10,ColKeep=None,ColSort=None):
    OutFiles=glob.glob(os.path.join(workdir,'*.outb'))
    result=None
    if len(OutFiles)<=0:
        raise Exception('No outb files found in {}'.format(workdir))
    for i,f in enumerate(OutFiles):
        print(f)
        df=weio.FASTOutFile(f).toDataFrame()
        if ColKeep is not None:
            df=df[ColKeep]
        ## Start time and end time of window
        iEndTime=df.index[-1]
        endTime=df['Time_[s]'][iEndTime]
        iStartTime=(df['Time_[s]']-(endTime-TimeAvgWindow)).abs().idxmin()
        startTime=df['Time_[s]'][df.index[iStartTime]]
        ## Absolute and relative differences at wind extremities
        DeltaValuesAbs=(df.iloc[iEndTime]-df.iloc[iStartTime]).abs()
        DeltaValuesRel=(df.iloc[iEndTime]-df.iloc[iStartTime]).abs()/df.iloc[iEndTime]
        EndValues=df.iloc[iEndTime]
        ## Stats values during window
        IWindow=df['Time_[s]']>startTime
        MeanValues = pd.DataFrame(df[IWindow].mean()).transpose()
        StdValues  = df[IWindow].std()
        if i==0:
            result = MeanValues.copy()
        else:
            result=result.append(MeanValues, ignore_index=True)

    if ColSort is not None:
        # Sorting 
        result.sort_values([ColSort],inplace=True,ascending=True)
        result.reset_index(drop=True,inplace=True) 

    #result.drop(['Time'],axis=1,inplace=True)
    #result.drop(['Wind1VelY'],axis=1,inplace=True)
    #result.drop(['Wind1VelZ'],axis=1,inplace=True)
    #result.rename(columns=lambda x:'WS'    if x=='Wind1VelX' else x,inplace=True)
    #result.rename(columns=lambda x:'RPM'   if x=='RotSpeed' else x,inplace=True)
    #result.rename(columns=lambda x:'Pitch' if x=='BldPitch1' else x,inplace=True)
    #result.plot(x='Wind1VelX',y=I)
    #print(result)
    #plt.show()
    return result 
Exemplo n.º 4
0
n = 1

# save plot and/or data?
plt_grid = True  # creates subplot for each observer if True
save_fig = False
save_data = True

#########################################################################################################################################

# produces full path
AAfilename = input_dir + '/' + AAname
OF2filename = input_dir + '/' + OF2name
outputfilename = output_dir + '/' + outputname + "AAOutputFile3"

# read file data
AA_3 = weio.FASTOutFile(AAfilename).toDataFrame()
OF2 = weio.FASTOutFile(OF2filename).toDataFrame()

# determine number of observers
num_obs = (AA_3.shape[1] - 1) / (7 * 34)

# calculate sample time for n revolutions
rpm = OF2[["RotSpeed_[rpm]"]].mean()[0]
time_revs = n * 60 / rpm
tot_time = AA_3["Time_[s]"].max()
if time_revs < tot_time:
    sample_time = tot_time - time_revs
else:
    print(
        "Error: Time for number of revolutions exceeds simulation time. Reduce n."
    )
Exemplo n.º 5
0
    ) + os.sep + 'reg_tests' + os.sep + 'r-test' + os.sep + 'glue-codes' + os.sep + 'openfast' + os.sep + 'IEA_LB_RWT-AeroAcoustics'
else:
    FAST_directory = os.path.dirname(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
    ) + os.sep + 'openfast' + os.sep + 'reg_tests' + os.sep + 'r-test' + os.sep + 'glue-codes' + os.sep + 'openfast' + os.sep + 'IEA_LB_RWT-AeroAcoustics'
AAfilename = FAST_directory + os.sep + 'IEA_LB_RWT-AeroAcoustics_1.out'
OFfilename = FAST_directory + os.sep + 'IEA_LB_RWT-AeroAcoustics.out'
locfilename = FAST_directory + os.sep + 'AA_ObserverLocations_Map.dat'
output_dir = os.path.dirname(os.path.realpath(__file__))
outputfilename = output_dir + os.sep + "data_output1"

#########################################################################################################################################
## Read in data, manipulate it, and plot it
# reads in file data
AA_1 = weio.FASTOutFile(AAfilename).toDataFrame()
OF = weio.FASTOutFile(OFfilename).toDataFrame()
location = pd.read_csv(locfilename,
                       delimiter='\s+',
                       skiprows=[0, 1],
                       names=['x', 'y', 'z'])

# determine number of observers
num_obs = AA_1.shape[1] - 1

# calculate sample time for n revolutions
rpm = OF[["RotSpeed_[rpm]"]].mean()[0]
yaw = OF[["YawPzn_[deg]"]].mean()[0] / 180. * np.pi
time_revs = n * 60 / rpm
tot_time = AA_1["Time_[s]"].max()
if time_revs < tot_time: