Skip to content

Instantly share code, notes, and snippets.

View pmarshwx's full-sized avatar

Patrick Marsh pmarshwx

View GitHub Profile
@pmarshwx
pmarshwx / ipy_notebook_axes_bug.ipynb
Created October 25, 2012 14:09
Notebook to show bug in rendering figures with text in axes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pmarshwx
pmarshwx / FFT_smoothing.ipynb
Created October 19, 2012 17:12
Learning how to use FFT to do KDE
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pmarshwx
pmarshwx / rotated_anisotropic_gaussian_kde.pyx
Created October 16, 2012 17:05
Rotated, Anisotropic Gaussian Kernel Density Estimation
cimport cython
import numpy as np
cimport numpy as np
cdef extern from 'math.h':
float exp(float x)
float cos(float x)
float sin(float x)
float fabs(float x)
@pmarshwx
pmarshwx / figure_crash.ipynb
Created September 7, 2012 22:27
Crash of IPython Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pmarshwx
pmarshwx / prospectus.ipynb
Created September 4, 2012 00:36
Explanation of Dissertation Research Using IPython Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pmarshwx
pmarshwx / latlonkwtext.py
Created August 19, 2012 19:37
Simple script to test the latlon keword argument added to plot
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
def draw_map_background(m, ax):
ax.set_axis_bgcolor('#729FCF')
m.fillcontinents(color='#FAFAFA', ax=ax, zorder=0)
m.drawstates(ax=ax)
m.drawcountries(ax=ax)
m.drawcoastlines(ax=ax)
KM = 1000.
clat = 39.3
@pmarshwx
pmarshwx / Traceback
Created July 11, 2012 04:27
A self-contained example script to highlight the quadmesh bug on OSX using MacOSX backend
Commit: 8c57e4fe4909815092af470f4a036c80b407382c
Traceback (most recent call last):
File "/Users/pmarsh/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/pmarsh/.local/lib/python2.7/site-packages/matplotlib/figure.py", line 927, in draw
func(*args)
File "/Users/pmarsh/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
@pmarshwx
pmarshwx / hatch.py
Created April 13, 2012 16:25
Example showing hatching problem with matplotlib
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(10) * 10
y = np.random.rand(10) * 10
plt.fill(x, y, fill=False, hatch='/', linestyle='dashed')
plt.savefig('incorrect_example.png')
plt.show()
@pmarshwx
pmarshwx / centered_text_issue.py
Created March 9, 2012 03:31
Centered Text Issue
#!/usr/bin/env python
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import axes_divider as divider
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredText
def add_center_text(ax):
pos = ax.get_position().bounds
l, b, w, h = pos
@pmarshwx
pmarshwx / find_distance.py
Created October 25, 2011 14:06
Find the shortest geometric distance between four observations and 1148 forecast locations
import numpy as np
def great_circle(lon1, lat1, lon2, lat2):
delta = lon2 - lon1
a = np.radians(lat1)
b = np.radians(lat2)
c = np.radians(delta)
x = np.sin(a) * np.sin(b) + np.cos(a) * np.cos(b) * np.cos(c)