Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am vgauthier on github.
* I am vgauthier (https://keybase.io/vgauthier) on keybase.
* I have a public key whose fingerprint is 2DFE B470 E2A1 97CB 4CE9 8CD2 9317 A153 5D11 CA80
To claim this, I am signing this object:
@vgauthier
vgauthier / ipython-progress.py
Last active January 4, 2017 16:31
jupyter notebook progress bar
from ipywidgets import FloatProgress
from IPython.display import display
import time
max_count = 100
f = FloatProgress(min=0, max=max_count) # instantiate the bar
display(f) # display the bar
count = 0
@vgauthier
vgauthier / gist:4343692
Created December 20, 2012 08:04
Python: Function to plot an nice error bar with Matplotlib
def errorfill(x, y, yerr, color=None, alpha_fill=0.3, ax=None):
# Plot the standart error bar stolen from http://tonysyu.github.com/plotting-error-bars.html
ax = ax if ax is not None else plt.gca()
if color is None:
color = ax._get_lines.color_cycle.next()
if np.isscalar(yerr) or len(yerr) == len(y):
ymin = y - yerr
ymax = y + yerr
elif len(yerr) == 2:
ymin, ymax = yerr
@vgauthier
vgauthier / gist:3986827
Created October 31, 2012 12:37
Python: Distance with Spherical Coordinates
def distance(lat1,lon1,lat2,lon2):
import math
# Earth Radius in KM
R = 6371
dLat = math.radians(lat2-lat1);
dLon = math.radians(lon2-lon1);
lat1 = math.radians(lat1);
lat2 = math.radians(lat2);
a = math.sin(dLat/2) * math.sin(dLat/2) + math.sin(dLon/2) * math.sin(dLon/2) * math.cos(lat1) * math.cos(lat2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))