Skip to content

Instantly share code, notes, and snippets.

View seumasmorrison's full-sized avatar

James Morrison seumasmorrison

View GitHub Profile
@seumasmorrison
seumasmorrison / buoy_marker.geojson
Created March 5, 2015 10:52
Created with geojson.io
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seumasmorrison
seumasmorrison / toolbox_comparison_helper_functions.py
Created March 20, 2015 16:25
Helper function for processing the historical spectral and wave statistics files as well as data exported from DIWASP via write_csv in Datawell_to_DIWASP
import pandas as pd
from datetime import datetime
from scipy.stats.stats import pearsonr
his_columns = ['date_time', 'tp', 'dirp', 'sprp', 'tz', 'hm0', 'ti', 't1',
'tc', 'tdw2', 'tdw1', 'tpc', 'nu','eps','qp','ss','tref','tsea',
'bat']
hiw_columns = ['date_time','% no reception errors','hmax','tmax','h1_10',
't1_10','h1_3','t1_3','Hav','Tav','Eps','#Waves']
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="BTHub3-****"
key_mgmt=WPA-PSK
proto=RSN
group=CCMP TKIP
pairwise=CCMP TKIP
proto=RSN
psk="********"
@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
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 / pandas-example.py
Created August 17, 2012 10:21
Sample input data and python code for Pandas time-series problem
import pandas as pd
data_frame = pd.io.parsers.read_csv('time-series.csv',index_col = 0, names=['index','heave'])
_max = [[5, 259.0]]
indexes = [x[0] for x in _max ]
index = data_frame.index
timestamps = [index[z] for z in indexes]
#['2011-12-30 00:00:04']
print data_frame.ix[timestamps]
# heave
@seumasmorrison
seumasmorrison / SyntaxErrors
Created September 6, 2012 14:31
python3 matplotlib install - output
/usr/local/lib/python3.2/subprocess.py:389: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
matplotlib: 1.2.x
python: 3.2.3 (default, Sep 6 2012, 14:51:03) [GCC 4.1.2
20080704 (Red Hat 4.1.2-46)]
platform: linux2
@seumasmorrison
seumasmorrison / log_to_dataframe.py
Created November 15, 2012 13:31
Cumulus log files to Pandas Dataframe
# Python modules for taking Cumulus ( sandaysoft.com ) logs into a Pandas
# ( pandas.pydata.org ) DataFrame, and using the date and time columns to
# create a DateTimeIndex for the DataFrame and sort upon it.
import pandas as pd
import os
import glob
from datetime import datetime
log_path = 'D:\\log_files_folder'
@seumasmorrison
seumasmorrison / historical_concat.py
Last active October 12, 2015 21:19
Script for producing date sorted Pandas DataFrames and writing Excel ( xlsx ) files from historical files which can be resampled ( 30 minutes specified ). Used with his/hiw files from Datawell Directional Waverider MK II/III produced by RFBuoy v2.1.27
import os
import glob
import pandas as pd
from datetime import datetime
# Example below assumes following folder hierarchy D:\Buoy_Data\Buoy_Name\Year\Month\
buoy_names = ['Buoy_Name']
buoy_path = 'D:\\Buoy_Data\\'
his_columns = ['date_time', 'Tp', 'dirp', 'sprp', 'Tz', 'Hm0', 'TI', 'T1', 'Tc',
{
"metadata": {
"name": "Basemap HebMarine"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{