Last active
December 23, 2015 06:39
-
-
Save seumasmorrison/6595733 to your computer and use it in GitHub Desktop.
Calculate significant wave height from a Datawell spt file with even bin spacings of 0.005hz using the zeroth spectral moment (m0) with trapezoid rule.
This file contains 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 pandas as pd | |
file_name = 'Bragar_HebMarine2$}2012-01-18T22h46Z.spt' | |
def calc_sig_wave_height(file_name): | |
max_psd = pd.read_csv(file_name, skiprows=range(12,200)).values[3][0] | |
spt_freq = pd.read_csv(file_name, skiprows=13, names=['frequency','psd','direction','spread','skew','kurtosis']) | |
psd = spt_freq.psd * max_psd | |
calc_sig_wave_height = 4 * np.sqrt(0.5 * 0.005 * ( psd[0] + psd[len(psd)-1] + 2 * psd[1:-1].sum())) | |
#sig_wave_height = pd.read_csv(file_name, skiprows=range(12,200)).values[1][0] | |
return calc_sig_wave_height | |
calc_sig_wave_height(file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment