Created
December 5, 2018 03:44
-
-
Save awade/5c9de7836ba80021e3ed80d9e2801b14 to your computer and use it in GitHub Desktop.
Python function for computing rms integral from high frequency to low frequency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
''' | |
Find the rms value of y(x). Here y(f) could be a spectral density or y(t) could be a time series | |
usage: | |
rms_of_y = rms(X,Y); | |
''' | |
def rms(x, y): | |
diff = np.diff(np.squeeze(x)) | |
dx = np.concatenate(([diff[0]], diff), axis=0) | |
# Return rms intergrated from high to low | |
rms = np.flipud(np.sqrt(np.cumsum(np.flipud(np.squeeze(y)**2 * dx)))) | |
return rms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment