Skip to content

Instantly share code, notes, and snippets.

View phobson's full-sized avatar

Paul Hobson phobson

View GitHub Profile
@phobson
phobson / brew_postgres_failure
Created February 4, 2012 17:13
"brew install -v postgres" failure
lizphair:~ paul$ brew install -v postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
File already downloaded in /Users/paul/Library/Caches/Homebrew
/usr/bin/tar xf /Users/paul/Library/Caches/Homebrew/postgresql-9.1.2.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-python --with-perl --with-ossp-uuid --datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql ARCHFLAGS='-arch x86_64'
./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-python --with-perl --with-ossp-uuid --datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql ARCHFLAGS='-arch x86_64'
c
@phobson
phobson / ros.py
Created April 11, 2012 19:41
Env. eng. numpy.ma example
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
#import DataAccess as db
import pdb
def getTestData():
'''
generates test data
@phobson
phobson / colormapped_line.py
Created May 4, 2012 22:21
Plot a line with a colormap
# Props to Gökhan Sever for the idea
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
x = np.linspace(0, 3 * np.pi, 5000)
y = np.sin(x)
z = np.cos(0.5 * (x[:-1] + x[1:])) # 1st derivative
cmap_z = cm.coolwarm(z)
@phobson
phobson / manual_boxplot_test.py
Created May 27, 2012 15:37
Script to test my exits to axes.boxplot()
'''
This demonstrates the new boxplot functionality.
It trys to create 5 figures, each with 4 subplots. Only the first
fourth figures should work. The second and third figures are
supposed to fail as the number of user-input medians and
confidence intervals do not match the number of columns
in the data.
The first working figure plots all of the data with and without
@phobson
phobson / postgis_error.log
Created June 1, 2012 06:55
homebrew postgis error output
lizphair:Downloads paul$ brew upgrade
==> Upgrading 6 outdated packages, with result:
postgis 2.0.0, sip 4.13.2, qt 4.8.2, pyqt 4.9.1, python 2.7.3, zeromq 2.2.0
==> Upgrading postgis
==> Downloading http://postgis.org/download/postgis-2.0.0.tar.gz
curl: (6) Could not resolve host: postgis.org; nodename nor servname provided, or not known
Error: Download failed: http://postgis.org/download/postgis-2.0.0.tar.gz
@phobson
phobson / process_cursor.py
Created July 5, 2012 23:34
Process a pyodbc database cursor into a numpy record array or pandas dataframe
import pyodbc
import numpy as np
import datetime
import pandas
def processCursor(cur, dataframe=False):
datatypes = []
colinfo = cur.description
for col in colinfo:
if col[1] == unicode:
@phobson
phobson / qqplot_test.py
Created July 31, 2012 13:42
Test script to show probabilities on QQ plot
import numpy as np
import statsmodels.api as sm
import matplotlib.pyplot as plt
x = np.random.normal(4.0, 1.75, size=37)
fig, (ax1, ax2) = plt.subplots(nrows=2)
sm.qqplot(x, prob=False, ax=ax1)
sm.qqplot(x, prob=True, ax=ax2)
@phobson
phobson / microgram.tex
Created August 4, 2012 00:51
upright mus (greek letter in general) in latex
\documentclass{minimal}
\usepackage{siunitx}
\usepackage[sc]{mathpazo}
\linespread{1.05} % Palatino needs more leading (space between lines)
\usepackage[T1]{fontenc}
\begin{document}
who wins?
\si{\micro\gram\per\liter} vs. $\mu$g/L
\end{document}
@phobson
phobson / accerlation.py
Created August 9, 2012 19:30
acceleration
import numpy as np
def acceleration(data):
SSD = np.sum((data.mean() - data)**3)
SCD = np.sum((data.mean() - data)**2)
# catch to make sure SCD isn't zero
if SCD == 0.0:
SCD = 1e-12
acc = SSD / (6 * SCD**1.5)
return acc
@phobson
phobson / proboplot_test.py
Created August 16, 2012 20:16
Testing several scenarios with the new probplot functionality
import matplotlib.pyplot as plt
import scipy.stats as stats
import statsmodels.api as sm
# longley dataset
data = sm.datasets.longley.load()
data.exog = sm.add_constant(data.exog)
model = sm.OLS(data.endog, data.exog)
mod_fit = model.fit()
res = mod_fit.resid