Created
October 30, 2014 10:17
-
-
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.
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 | |
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