Created
October 30, 2014 14:53
-
-
Save seumasmorrison/08488ba1b9383d488daa to your computer and use it in GitHub Desktop.
Function for creating raw files from a hebtools displacements DataFrame and creating custom raw files form it.
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 | |
import datetime | |
import os | |
def make_raw_files(path_to_raw_df, output_folder): | |
raw_df = pd.read_pickle(path_to_raw_df) | |
os.chdir(output_folder) | |
timestamp = datetime.datetime(2013,2,1,0,17,59) | |
half_hour_delta = datetime.timedelta(0,1800) | |
final_timestamp = datetime.datetime(2013,2,28,23,48) | |
while timestamp < final_timestamp: | |
half_hour_end_timestamp = timestamp + half_hour_delta | |
raw_file = raw_df.ix[timestamp:half_hour_end_timestamp] | |
timestamp = half_hour_end_timestamp | |
raw_file = raw_file[['sig_qual','heave','north','west']] | |
raw_file.to_csv(str(timestamp).translate(None,': ') +'.raw', | |
index=False, header=False ) | |
make_raw_files('D://Datawell//Bragar_HebMarine2//2013//February//raw_plus_std', | |
'D://new_raw_output//') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment