Skip to content

Commit

Permalink
add windowed averaging
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarter committed Jan 14, 2025
1 parent 6ba22ba commit 1624dcc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pCrunch/aeroelastic_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,22 @@ def integrated(self):
@dataproperty
def psd(self):
fs = 1. / np.diff(self.time)[0]
freq, Pxx_den = signal.welch(self.data, fs, axis=0)
freq, Pxx_den = signal.welch(self.data, fs, axis=0)
return freq, Pxx_den

def time_averaging(self, time_window):
"""
Applies averaging window on time-domain loads channels. Window input is seconds
"""
dt = np.diff(self.time)[0]
npts = time_window / dt
window = np.ones(npts) / npts # Basic rectangular filter

data_avg = np.zeros(self.data.shape)
for k in range(len(self.channels)):
data_avg[:,k] = np.convolve(self.data[:,k], window, 'valid')

return data_avg

def get_summary_stats(self):
"""
Expand Down

0 comments on commit 1624dcc

Please sign in to comment.