Skip to content

Instantly share code, notes, and snippets.

View seumasmorrison's full-sized avatar

James Morrison seumasmorrison

View GitHub Profile
syntax on
filetype indent plugin on
set tabstop=8 expandtab shiftwidth=4 softtabstop=4
colorscheme torte
set guifont=Consolas:h14
set bs=2
set ruler
set modeline
set ls=2
set nu
@seumasmorrison
seumasmorrison / .vimrc
Last active December 17, 2015 02:59
vimrc
set tabstop=8 expandtab shiftwidth=4 softtabstop=4
set guifont=Consolas:h14
set bs=2
set ruler
set modeline
set ls=2
set nu
set nocompatible
@seumasmorrison
seumasmorrison / delft3d.md
Last active May 4, 2016 16:26
Setup commands for Delft3d using gfortran

Delft3d setup instructions

Delft3d revision 5.01.00.2163 setup up on Ubuntu 12.04 (Prescise Pangolin).

Inspired by:

@seumasmorrison
seumasmorrison / .bashrc
Last active December 18, 2015 07:39
.bashrc
alias ll='ls -alF --color=auto'
alias la='ls -A --color=auto'
alias l='ls -CF --color=auto'
alias lt='ls -alFt --color=auto'
alias vi=vim
al() { command ls -al "$@" | less ; }
lh() {ls -lt $1|head;}
EDITOR=vim
@seumasmorrison
seumasmorrison / unzip_his.sh
Created June 11, 2013 15:16
For iterating over zipped months of buoy data and extracting out the history files.
unzip_his() { for line in $(unzip -l $1 \
| grep his \
| awk '{print $4}');
do
echo $1 $line
unzip -p $1 $line > $(echo $line | sed -re 's/^.+\///');
done
}
for zip in "$@"
@seumasmorrison
seumasmorrison / datawell_viz.md
Last active May 31, 2019 03:33
Datawell processing scripts

As part of the HebMarine project a number of scripts were developed for processing the data recieved from the Datawell Waverider buoys and latterly the Nortek AWAC ADCPs.

Spectral polar plot

A number of approaches were taken with the various data outputs from the buoys. Visual representations of 3 minutely spectral data took place every half hour after the sync had taken place with the recieving station. This produced a polar contour plot for each buoy based on the direction, power spectral density, spread and skew. See Spectral Polar Plot repository and accompanying plot_spectra.py. The colorbar represents power spectral density (m2/Hz), the peak value on the plot can deviate from the max psd in the spectral file due to a hard to fit surface. ![example plot](https://b

@seumasmorrison
seumasmorrison / spt_m0_spectral_moment.py
Last active December 23, 2015 06:39
Calculate significant wave height from a Datawell spt file with even bin spacings of 0.005hz using the zeroth spectral moment (m0) with trapezoid rule.
import pandas as pd
file_name = 'Bragar_HebMarine2$}2012-01-18T22h46Z.spt'
def calc_sig_wave_height(file_name):
max_psd = pd.read_csv(file_name, skiprows=range(12,200)).values[3][0]
spt_freq = pd.read_csv(file_name, skiprows=13, names=['frequency','psd','direction','spread','skew','kurtosis'])
psd = spt_freq.psd * max_psd
calc_sig_wave_height = 4 * np.sqrt(0.5 * 0.005 * ( psd[0] + psd[len(psd)-1] + 2 * psd[1:-1].sum()))
#sig_wave_height = pd.read_csv(file_name, skiprows=range(12,200)).values[1][0]
@seumasmorrison
seumasmorrison / decibar_to_metres_depth.py
Last active December 24, 2015 13:49
Function for converting salt water pressure readings to depth in metres taking account of latitude. Based upon Seabird description of UNESCO formulae - http://www.seabird.com/application_notes/AN69.htm
import math
def decibars_to_metres(latitude, pressure):
x = (math.sin(latitude/ 57.29578))**2
g = 9.780318 * ( 1.0 + ( 5.2788*(10**-3) + (2.36*(10**-5)) * x) * x ) + \
(1.092 * (10**-6) ) * pressure
return (((-1.82*(10**-15) * pressure + 2.279*(10**-10) ) * \
pressure - 2.2512*(10**-5) * pressure + 9.72659) * pressure) / g
@seumasmorrison
seumasmorrison / valeport.py
Created October 9, 2013 11:11
Valeport text file to Pandas pickle and Excel xlsx file
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 09 09:58:44 2013
Read text files for MiniCTD exported from Valeport Datalog Express Scroll
Display, writes Excel xlsx and pickle file, creates pickle of main DataFrame
with another DataFrame as metadata attribute
@author: James Morrison
"""
@seumasmorrison
seumasmorrison / setup.sh
Last active December 31, 2015 12:39
Building adcirc for adc_50_99_12 on Ubuntu 12.04
wget http://www.mpich.org/static/downloads/1.4.1/mpich2-1.4.1.tar.gz
tar -xvf mpich2-1.4.1.tar.gz
cd mpich2-1.4.1/
sudo ./configure CFLAGS=-fPIC FFLAGS=-fPIC FC=gfortran --enable-shared --enable-lib-depend --prefix=/mirror/mpich2
sudo make && sudo make install
sudo apt-get install gfortran
alias f90='gfortran'
cd work
sed -i s/#compiler=gnu/compiler=gnu/ cmplrflags.mk