This file contains hidden or 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
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(custom-safe-themes (quote ("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" default))) | |
'(inhibit-startup-screen t)) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. |
This file contains hidden or 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
#!/usr/bin/python | |
import numpy as np | |
from scipy import integrate | |
import sys | |
import matplotlib as mpl | |
from matplotlib import pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib import animation |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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
#!/usr/bin/python | |
import sys,subprocess | |
#Simple code for starting jobs quick! Made for ATPESC 2014 | |
def usage(): | |
print "%s <directory/name> <# processors>"%(sys.argv[0]) | |
try: |
This file contains hidden or 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 matplotlib as mpl | |
import pylab as pl | |
def colorHist(pngFile): | |
a = pl.imread(pngFile) | |
b = mpl.colors.rgb_to_hsv(a[...,:3])[...,1].flatten() | |
vals,bins,dummy = pl.hist(b,256,visible=False) |
This file contains hidden or 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
#!/usr/bin/python | |
from numpy import * | |
x = random.random([10,3]) | |
x[range(10), fabs(x-0.5).argsort()[:,0]] | |
#Break it down niao | |
x1 = fabs(x-0.5) # numbers closest to 0.5 will be closest to 0 now. |
This file contains hidden or 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
#!/usr/bin/python | |
from scipy import weave | |
from scipy.weave import converters | |
from numpy import * | |
#Yeah that's right stick your code in a fucking comment cause its a weave hack. | |
msdCode = """ | |
double c,d; | |
double *seta,*setb; |
This file contains hidden or 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
#!/usr/bin/python | |
import numpy as np | |
import mayavi.mlab as mlab | |
x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j] | |
s = np.sin(x*y*z)/(x*y*z) | |
mlab.pipeline.image_plane_widget(mlab.pipeline.scalar_field(s), |
This file contains hidden or 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
#Python Euclidean distance | |
dist(a,b): | |
return sum([(i-j)**2 for i,j in zip(a,b)])**0.5 | |
#Scipy-Weave Euclidean distance (x10 faster than standard Python implementation) | |
distcode = """ | |
double c=0.0; | |
for(int i=0;i<64;i++) | |
c += (a[i]-b[i])*(a[i]-b[i]); |
This file contains hidden or 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 the standard python list style code: | |
#Calculate the distance between 2 atoms: | |
def dist(p1,p2): | |
return sum([(a-b)*(a-b) for a,b in zip(p1,p2)])**0.5 | |
#Calculate the angle between 3 atoms: | |
def ang(p1,p2,p3): | |
P12=dist(p1,p2) | |
P13=dist(p1,p3) |