Skip to content

Instantly share code, notes, and snippets.

@jiffyclub
jiffyclub / per-capita.ipynb
Last active August 29, 2015 14:15
Plotting Software Carpentry data using plotly: http://software-carpentry.org/blog/2015/02/plot-this.html
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / scientific_python_demo.ipynb
Created February 19, 2015 04:38
Demo from SF Python Project Night 2015-02-18
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!doctype html>
<html>
<head>
<meta charset="utf-8" .>
<title>g2</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.rawgit.com/jiffyclub/snakeviz/v0.4.0/snakeviz/static/snakeviz.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="https://cdn.rawgit.com/jiffyclub/snakeviz/v0.4.0/snakeviz/static/vendor/jquery.dataTables.min.css" rel="stylesheet">
</head>
@jiffyclub
jiffyclub / loc_then_groupby.html
Created April 16, 2015 23:47
SnakeViz profile of running df.loc[df.price > 10000].groupby('cut').carat.mean() on a Pandas DataFrame containing the diamonds dataset. See rendered at https://cdn.rawgit.com/jiffyclub/317ae693c15a0aac6cc4/raw/621f23f778beba7b26537ada73e64eb356901bc1/loc_then_groupby.html.
<!doctype html>
<html>
<head>
<meta charset="utf-8" .>
<title>tmppou4ttv_</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.rawgit.com/jiffyclub/snakeviz/v0.4.0/snakeviz/static/snakeviz.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="https://cdn.rawgit.com/jiffyclub/snakeviz/v0.4.0/snakeviz/static/vendor/jquery.dataTables.min.css" rel="stylesheet">
</head>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / msky.py
Created October 25, 2011 00:29
Find modal sky on an array.
import numpy, pylab, scipy
from scipy import optimize
# Uses MEANCLIP from above
from meanclip import meanclip
def msky(inarray, do_plot=0, verbose=0, ptitle='', func=0):
"""
Find modal sky on an array.
@jiffyclub
jiffyclub / mytotal.py
Created October 25, 2011 00:32
Collapse 2-D array into one dimension.
import numpy
# Uses MEANCLIP from above
from meanclip import meanclip
def mytotal(inarray, axis, type='meanclip'):
"""
Collapse 2-D array in one dimension.
.. note:: MYTOTAL routine from ACS library.
@jiffyclub
jiffyclub / gist:1310949
Created October 25, 2011 00:36
Calculate a resistant estimate of the dispersion of a distribution. For an uncontaminated distribution, this is identical to the standard deviation.
import numpy
def robust_sigma(in_y, zero=0):
"""
Calculate a resistant estimate of the dispersion of
a distribution. For an uncontaminated distribution,
this is identical to the standard deviation.
Use the median absolute deviation as the initial
estimate, then weight points using Tukey Biweight.
@jiffyclub
jiffyclub / gausspsf2d.py
Created October 25, 2011 00:40
Simpler version of `PSF_GAUSSIAN` in IDL.
"""
Simpler version of `PSF_GAUSSIAN` in IDL.
:Authors: Pey Lian Lim (Python)
:Organization: Space Telescope Science Institute
:History:
* 2010/08/17 PLL converted from IDL to Python.
"""
# External modules
import numpy