From e4a24133eff441f8c4e26249acd20636210db481 Mon Sep 17 00:00:00 2001 From: Emmanuel Branlard Date: Thu, 8 Aug 2024 14:56:55 -0400 Subject: [PATCH] Misc: pandas future warning --- pydatview/fast/postpro.py | 51 ++++++++++++++++++++++++++++-- pydatview/io/gnuplot_file.py | 2 +- pydatview/tools/fatigue.py | 4 +-- pydatview/tools/signal_analysis.py | 8 ++--- 4 files changed, 56 insertions(+), 9 deletions(-) diff --git a/pydatview/fast/postpro.py b/pydatview/fast/postpro.py index f7bb78e..421e4cd 100644 --- a/pydatview/fast/postpro.py +++ b/pydatview/fast/postpro.py @@ -689,6 +689,52 @@ def spanwiseColEDTwr(Cols): def spanwiseColAD(Cols): """ Return column info, available columns and indices that contain AD spanwise data""" ADSpanMap=dict() +# From AeroDyn_AllBldNd: TODO Use it directly.. +# "ALPHA ","AXIND ","AXIND_QS ","BEM_CT_QS","BEM_F_QS ","BEM_KP_QS","BEM_K_QS ","CD ", & +# "CD_QS ","CHI ","CL ","CLRNC ","CL_QS ","CM ","CMA ","CM_QS ", & +# "CN ","CPMIN ","CT ","CURVE ","CX ","CXA ","CY ","DEBUG1 ", & +# "DEBUG2 ","DEBUG3 ","DYNP ","FBN ","FBS ","FBT ","FBXA ","FBXI ", & +# "FBXL ","FBXP ","FBYA ","FBYI ","FBYL ","FBYP ","FBZA ","FBZI ", & +# "FBZL ","FBZP ","FD ","FL ","FN ","FT ","FX ","FXA ", & +# "FXI ","FXL ","FXP ","FY ","FYI ","FYL ","FYP ","FZI ", & +# "FZL ","FZP ","GAM ","GEOMPHI ","M ","MBN ","MBS ","MBT ", & +# "MBXA ","MBXI ","MBXL ","MBXP ","MBYA ","MBYI ","MBYL ","MBYP ", & +# "MBZA ","MBZI ","MBZL ","MBZP ","MM ","MXI ","MXL ","MXP ", & +# "MYI ","MYL ","MYP ","MZA ","MZI ","MZL ","MZP ","PHI ", & +# "RE ","SGCAV ","SIGCR ","STVX ","STVXA ","STVXI ","STVXL ","STVXP ", & +# "STVY ","STVYA ","STVYI ","STVYL ","STVYP ","STVZ ","STVZA ","STVZI ", & +# "STVZL ","STVZP ","THETA ","TNIND ","TNIND_QS ","TOE ","UA_FLAG ","UA_X1 ", & +# "UA_X2 ","UA_X3 ","UA_X4 ","UA_X5 ","UIN ","UIR ","UIT ","VDISX ", & +# "VDISXA ","VDISXI ","VDISXL ","VDISXP ","VDISY ","VDISYA ","VDISYI ","VDISYL ", & +# "VDISYP ","VDISZ ","VDISZA ","VDISZI ","VDISZL ","VDISZP ","VINDX ","VINDXA ", & +# "VINDXI ","VINDXL ","VINDXP ","VINDY ","VINDYA ","VINDYI ","VINDYL ","VINDYP ", & +# "VINDZA ","VINDZI ","VINDZL ","VINDZP ","VREL ","VUNDX ","VUNDXA ","VUNDXI ", & +# "VUNDXL ","VUNDXP ","VUNDY ","VUNDYA ","VUNDYI ","VUNDYL ","VUNDYP ","VUNDZ ", & +# "VUNDZA ","VUNDZI ","VUNDZL ","VUNDZP ","VX ","VY "/) +# CHARACTER(ChanLen), PARAMETER :: ParamUnitsAry(166) = (/ character(ChanLen) :: & ! This lists the units corresponding to the allowed parameters +# "(deg) ","(-) ","(-) ","(-) ","(-) ","(-) ","(-) ","(-) ", & +# "(-) ","(deg) ","(-) ","(m) ","(-) ","(-) ","(-) ","(-) ", & +# "(-) ","(-) ","(-) ","(deg) ","(-) ","(-) ","(-) ","(-) ", & +# "(-) ","(-) ","(Pa) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ", & +# "(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ", & +# "(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ", & +# "(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ","(N/m) ", & +# "(N/m) ","(N/m) ","(m^2/s)","(1/0) ","(-) ","(N-m/m)","(N-m/m)","(N-m/m)", & +# "(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)", & +# "(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)", & +# "(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(N-m/m)","(deg) ", & +# "(-) ","(-) ","(-) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(deg) ","(-) ","(-) ","(deg) ","(-) ","(rad) ", & +# "(rad) ","(-) ","(-) ","(-) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ", & +# "(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) ","(m/s) "/) + + for sB in ['B1','B2','B3']: ADSpanMap['^[A]*'+sB+r'N(\d*)Alpha_\[deg\]'] =sB+'Alpha_[deg]' ADSpanMap['^[A]*'+sB+r'N(\d*)AxInd_\[-\]' ] =sB+'AxInd_[-]' @@ -698,6 +744,7 @@ def spanwiseColAD(Cols): ADSpanMap['^[A]*'+sB+r'N(\d*)BEM_kp_qs\[-\]' ]=sB+'BEM_kp_qs_[-]' ADSpanMap['^[A]*'+sB+r'N(\d*)BEM_F_qs\[-\]' ]=sB+'BEM_F_qs_[-]' ADSpanMap['^[A]*'+sB+r'N(\d*)BEM_CT_qs_\[-\]' ]=sB+'BEM_CT_qs_[-]' + ADSpanMap['^[A]*'+sB+r'N(\d*)Chi_\[deg\]' ]=sB+'Chi_[deg]' ADSpanMap['^[A]*'+sB+r'N(\d*)Cl_\[-\]' ] =sB+'Cl_[-]' ADSpanMap['^[A]*'+sB+r'N(\d*)Cd_\[-\]' ] =sB+'Cd_[-]' ADSpanMap['^[A]*'+sB+r'N(\d*)Cm_\[-\]' ] =sB+'Cm_[-]' @@ -1571,10 +1618,10 @@ def bin_mean_DF(df, xbins, colBin ): raise Exception('The column `{}` does not appear to be in the dataframe'.format(colBin)) xmid = (xbins[:-1]+xbins[1:])/2 df['Bin'] = pd.cut(df[colBin], bins=xbins, labels=xmid ) # Adding a column that has bin attribute - df2 = df.groupby('Bin').mean() # Average by bin + df2 = df.groupby('Bin', observed=False).mean() # Average by bin # also counting df['Counts'] = 1 - dfCount=df[['Counts','Bin']].groupby('Bin').sum() + dfCount=df[['Counts','Bin']].groupby('Bin', observed=False).sum() df2['Counts'] = dfCount['Counts'] # Just in case some bins are missing (will be nan) df2 = df2.reindex(xmid) diff --git a/pydatview/io/gnuplot_file.py b/pydatview/io/gnuplot_file.py index 496c41c..29c8a32 100644 --- a/pydatview/io/gnuplot_file.py +++ b/pydatview/io/gnuplot_file.py @@ -33,7 +33,7 @@ class GNUPlotFile(File): @staticmethod def defaultExtensions(): """ List of file extensions expected for this fileformat""" - return ['.dat'] + return ['.dat','.raw'] @staticmethod def formatName(): diff --git a/pydatview/tools/fatigue.py b/pydatview/tools/fatigue.py index e88936d..f5b25e0 100644 --- a/pydatview/tools/fatigue.py +++ b/pydatview/tools/fatigue.py @@ -213,9 +213,9 @@ def bin_count(x, bins, meanBin=True): df = pd.DataFrame(data=x, columns=['x']) xmid = (bins[:-1]+bins[1:])/2 df['x_mid']= pd.cut(df['x'], bins= bins, labels = xmid ) # Adding a column that has bin attribute - df2 = df.groupby('x_mid').mean() # Average by bin + df2 = df.groupby('x_mid', observed=False).mean() # Average by bin df['N'] = 1 - dfCount = df[['N','x_mid']].groupby('x_mid').sum() + dfCount = df[['N','x_mid']].groupby('x_mid', observed=False).sum() df2['N'] = dfCount['N'] # Just in case some bins are missing (will be nan) df2 = df2.reindex(xmid) diff --git a/pydatview/tools/signal_analysis.py b/pydatview/tools/signal_analysis.py index 09d902e..755ed5d 100644 --- a/pydatview/tools/signal_analysis.py +++ b/pydatview/tools/signal_analysis.py @@ -260,15 +260,15 @@ def applySampler(x_old, y_old, sampDict, df_old=None): if sample_time <= 0: raise Exception('Error: sample time must be positive') - time_index = pd.TimedeltaIndex(x_old, unit="S") - x_new = pd.Series(x_old, index=time_index).resample("{:f}S".format(sample_time)).mean().interpolate().values + time_index = pd.TimedeltaIndex(x_old, unit="s") + x_new = pd.Series(x_old, index=time_index).resample("{:f}s".format(sample_time)).mean().interpolate().values if df_old is not None: - df_new = df_old.set_index(time_index, inplace=False).resample("{:f}S".format(sample_time)).mean() + df_new = df_old.set_index(time_index, inplace=False).resample("{:f}s".format(sample_time)).mean() df_new = df_new.interpolate().reset_index(drop=True) return x_new, df_new if y_old is not None: - y_new = pd.Series(y_old, index=time_index).resample("{:f}S".format(sample_time)).mean() + y_new = pd.Series(y_old, index=time_index).resample("{:f}s".format(sample_time)).mean() y_new = y_new.interpolate().values return x_new, y_new