Skip to content

Instantly share code, notes, and snippets.

@seumasmorrison
Created October 30, 2014 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seumasmorrison/9fe180d6b687e3a58618 to your computer and use it in GitHub Desktop.
Save seumasmorrison/9fe180d6b687e3a58618 to your computer and use it in GitHub Desktop.
Takes the path to an Datawell Waverider MKIII HIS(Historical Spectra) file and returns a DateTimeIndexed Dataframe with the option of resampling to 30 minutes.
import pandas as pd
from datetime import datetime
def month_his_to_df(his_file_path, resample=True):
his_columns = ['date_time', 'Tp', 'dirp', 'sprp', 'Tz', 'Hm0', 'TI', 'T1',
'Tc', 'Tdw2', 'Tdw1', 'Tpc', 'nu','eps','QP','Ss','TRef',
'TSea','Bat']
month_dataframe = pd.io.parsers.read_csv(his_file_path, names = his_columns)
date_time_array = []
for date_time_string in month_dataframe['date_time'].values:
date_time_array.append(datetime.strptime(date_time_string[:-5],
"%Y-%m-%dT%H:%M:%S"))
month_dataframe.index = pd.DatetimeIndex(date_time_array)
if resample:
month_dataframe = month_dataframe.resample('30Min')
return month_dataframe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment