Skip to content

Instantly share code, notes, and snippets.

View seumasmorrison's full-sized avatar

James Morrison seumasmorrison

View GitHub Profile
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 / 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']
@seumasmorrison
seumasmorrison / datenum2datetime.py
Last active July 16, 2017 23:31 — forked from conradlee/datenum2datetime.py
Function for converting from matlab datenum to Python datetime
from datetime import datetime, timedelta
matlab_datenum = 731965.04835648148
def matlab_to_python_datetime(matlab_datenum):
return datetime.fromordinal(int(matlab_datenum)) + timedelta(days=matlab_datenum%1) - timedelta(days = 366)
matlab_to_python_datetime(matlab_datenum)
@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 / dict_his.py
Created February 26, 2015 17:19
Python dictionary columns of 'his' file with explanatory descriptions.
{'datetime':'Timestamp: date and time (ISO8601)',
'Tp': 'the peak period (the reciprocal of the peak frequency) [s]',
'Dirp': 'the wave direction at the peak frequency [°]',
'Sprp': 'the directional spread at the peak frequency [°]',
'Tz': 'the zero-upcross period [s]',
'Hs': 'the significant wave height [cm]',
'TI': 'the integral period, or Tm(-2,0) [s]',
'T1': 'the mean period, or Tm(0,1) [s]',
'Tc': 'the crest period, or Tm(2,4) [s]',
'Tdw2': 'wave period Tm(-1,1) [s]',
import sys
# Be safe and define a maximum of frames we're trying to walk up
MAX_FRAMES = 20
def save_to_interactive(dct):
n = 0
# Walk up the stack looking for '__name__'
# with a value of '__main__' in frame globals
for n in range(MAX_FRAMES):
@seumasmorrison
seumasmorrison / lgo_dec_s_to_dec_deg.py
Last active August 29, 2015 14:15
Improved version of previous script ( https://gist.github.com/seumasmorrison/d3f3afa96b350163909b ) for importing and converting post processed data reliably
import LatLon
import pandas as pd
import re
# Function for importing Leica Geo Office created comma separated variables
# files from post processed data, decimal seconds coordinates are converted
# to decimal degrees.
def read_lgo_csv_decimal_seconds_to_decimal_degrees(input_file, output_file):
cols = ['id','type','timestamp', 'Latitude', 'Longtitude', 'Height',
@seumasmorrison
seumasmorrison / hist_concat.py
Created February 9, 2015 12:53
Module for concatenating, resampling and writing Datawell his/hiw files as Excel spreadsheets, modified from hebtools version
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 06 14:38:11 2015
@author: le12jm
"""
from datetime import datetime
#from hebtools.common import wave_power
import glob
@seumasmorrison
seumasmorrison / dmds_to_decimal_degrees.py
Last active August 29, 2015 14:14
Coordinate conversion from Degrees Minutes Decimal Second to Decimal Degrees on points exported from Leica Geo Office in csv format using LatLon and Pandas. Used for preparation for import to QGIS for creating contours from points with the Contours plugin.
import LatLon
import pandas as pd
import re
leica_points = pd.read_csv('D://project_3.csv',names=['id','type','timestamp','Latitude','Longtitude','Height','Quality'])
coords = []
chars = '[\xb0\'"]'
for index, row in leica_points.iterrows():
lat_dmds = re.sub(chars,'',row.Latitude)
long_dmds = re.sub(chars,'',row.Longtitude)
# translate_multipoint
# Translation of Shapefile record geometries in a functional style.
from fiona import collection
from functools import partial
from itertools import imap
import logging
log = logging.getLogger()