2023-06-06 at IAS
I hereby claim:
- I am roban on github.
- I am robanhk (https://keybase.io/robanhk) on keybase.
- I have a public key whose fingerprint is 22BD E895 8940 7BBC EEA1 CD3B FE6E A1BB 6A0E 3E55
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Swimlane using d3.js</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script> | |
<script type="text/javascript" src="randomData.js"></script> | |
<style> | |
.chart { | |
shape-rendering: crispEdges; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copy_traces(db1, dbname, dbclass, traceclass, **kwargs): | |
"""Copy traces from a db to a new db. | |
""" | |
db = dbclass(dbname=dbname, dbmode='w', **kwargs) | |
db._initialize({}, 1) | |
db.trace_names = db1.trace_names | |
db.chains = 1 | |
# Create the Traces. | |
for name, trace in db1._traces.iteritems(): | |
db._traces[name] = traceclass(name=name, value={0:trace[:]}, db=db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `convert` is part of Image Magick http://www.imagemagick.org | |
# The command below scales the images to 500 pixels (in some dimension), | |
# imposes a delay of 60/100ths of a second between frames, and loops indefinitely. | |
# The "-layers optimize" option reduces the final file size by optimizing the GIF frames, with a difference threshold | |
# controlled by the "-fuzz" parameter. | |
convert -fuzz 2% -layers optimize -scale 500 -delay 60 -loop 0 -verbose IMG_*.JPG animation.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# paste this into an "ipython --pylab" session | |
# You'll need EnrichPy: http://roban.github.com/EnrichPy/ | |
import enrichpy.lifetime | |
mass = logspace(-1,4,300) | |
tlife = enrichpy.lifetime.main_sequence_life_K97(mass) | |
plot(mass, tlife) | |
xscale('log') | |
yscale('log') | |
xlabel('mass (solar masses)') | |
ylabel('stellar lifetime (years)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -s "echo -n 250 > /sys/devices/platform/i8042/serio1/serio2/sensitivity" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first create a list of frames, perhaps by running: | |
# ls -tr *.JPG > frames.txt | |
# Now run mencoder to make the move. I adapted the configuration from | |
# http://blog.hugochinchilla.net/2011/09/time-lapse-videos-mencoder/ | |
# playback at 15 frames per second | |
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect:vqscale=3 -vf scale=1920:1440 -mf type=jpeg:fps=15 mf://@frames.txt -o time_lapse.avi | |
# playback at 30 frames per second |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Routines related to plotting 2D distributions of parameters. | |
The core of this module is plot2Ddist, which plots a two-dimensional | |
distribution with 1D marginal histograms along each axis and optional | |
features like contours and lines indicating ranges and true values. | |
""" | |
import itertools | |
import math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
import numpy | |
import pymc | |
import matplotlib.patches | |
from mpl_toolkits.axes_grid1 import make_axes_locatable | |
import scipy.stats | |
def frac_inside_poly(x,y,polyxy): | |
"""Calculate the fraction of points x,y inside polygon polyxy. | |