Skip to content

Instantly share code, notes, and snippets.

View seumasmorrison's full-sized avatar

James Morrison seumasmorrison

View GitHub Profile
@seumasmorrison
seumasmorrison / iterate_over_hva_files.ipy
Created June 5, 2017 16:57
IPython snippet for iterating over hva files in multiple directories on one level which uses shells command and cd single line magic
for directory in dirs:
%cd {directory}
!pwd
hva_files = !ls *.hva
for hva_file in hva_files:
!decode_hva.exe -f csv -o {hva_file[:-4]}%s.csv {hva_file}
%cd ..
@seumasmorrison
seumasmorrison / plot_wad_awac.ipynb
Last active July 3, 2017 15:13
Script for plotting data from a wad file exported by Nortek's Storm software recorded by an AWAC ( Acoustic wave and current profiler ).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seumasmorrison
seumasmorrison / Nortek_Signature_Workflow.ipynb
Last active May 16, 2017 11:43
A notebook for working with ad2cp mat files produced by Nortek's Signature Deployment software ( the code is for the files exported without the 3d box ticked ). Including some example plotting code using 3d xarray DataArrays. 40 days worth of high frequency continuous data is approximately 7.4GB and can be worked with on a machine with 16GB of RAM.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from datetime import datetime, timedelta
def from_matlab_datetime(matlab_datenum):
return datetime.fromordinal(int(matlab_datenum)) + timedelta(days=matlab_datenum%1) - timedelta(days = 366)
def datetime2matlabdn(dt):
mdn = dt + timedelta(days = 366)
frac_seconds = (dt-datetime(dt.year,dt.month,dt.day,0,0,0)).seconds / (24.0 * 60.0 * 60.0)
frac_microseconds = dt.microsecond / (24.0 * 60.0 * 60.0 * 1000000.0)
return mdn.toordinal() + frac_seconds + frac_microseconds
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
b = !ls
cd C:\ffmpeg\bin
for file_name in b[6:]:
input_file = '"G:\\videos\\' + file_name + '"'
output_file = '"G:\\videos\\' + file_name[:-4] + '.mov"'
os.system('ffmpeg -i ' + input_file + " " + output_file)
@seumasmorrison
seumasmorrison / buoy_his_to_df_sorted.ipynb
Last active August 27, 2015 14:23
Process HIS from W@ves21 RAW into time indexed Pandas DataFrames
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seumasmorrison
seumasmorrison / read_mat_file_timeseries.ipynb
Created August 27, 2015 11:00
Notebook for reading David's Matlab .mat time series of significant wave height and mean period and converting into a time indexed Pandas DataFrame
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import pandas as pd
os.chdir('D://J_Morrison//Data//Datawell//Siadar_HebMarine1')
wave_height_dfs = []
for year in os.listdir('.'):
os.chdir(year)
for month in os.listdir('.'):
os.chdir(month)
wave_height_dfs.append(pd.read_hdf('buoy_data.h5','wave_height'))
os.chdir('..')
@seumasmorrison
seumasmorrison / dedupe_df.py
Created June 30, 2015 09:42
Deduping a DataFrame index
def dedupe_df(df):
df['index'] = df.index
df = df.drop_duplicates(subset='index')
df = df.drop("index",1)
return df