Skip to content

Instantly share code, notes, and snippets.

@shhong
Created June 16, 2010 08:22
Show Gist options
  • Save shhong/440324 to your computer and use it in GitHub Desktop.
Save shhong/440324 to your computer and use it in GitHub Desktop.
from numpy import mod, median
from numpy import pi
from numpy import vstack, hstack
def restrict_phase(theta):
return mod(theta+pi, 2*pi)-pi
def drmap(i,j, uu):
x = restrict_phase(uu[i,1:-1]-uu[j,1:-1])
y = (uu[i,2:]-uu[j,2:]-uu[i,:-2]+uu[j,:-2])/2
ind = x.argsort()
# y = y - y.mean()
return vstack((x[ind,], y[ind,]))
def drmapz(j, uu, z):
x = restrict_phase(z[1:-1] - uu[j, 1:-1])
y = (z[2:] - uu[j,2:] - z[:-2]+uu[j,:-2])/2
ind = x.argsort()
return vstack((x[ind,], y[ind,]))
#z = hstack((drmap(i,236) for i in range(900)))
#clf(); plot(z[0,],z[1,],'.'); axis([-pi*1.2, pi*1.2, -2, 2])
def drmap_corrected(i,j, uu, periods):
x = restrict_phase(uu[i,1:-1]-uu[j,1:-1])
y = (uu[i,2:]-uu[j,2:]-uu[i,:-2]+uu[j,:-2])/2
ind = x.argsort()
y = y - 4*pi*(1/periods[i]-1/periods[j])
return vstack((x[ind,], y[ind,]))
def drmap_med(i,j, uu):
x = restrict_phase(uu[i,1:-1]-uu[j,1:-1])
y = (uu[i,2:]-uu[j,2:]-uu[i,:-2]+uu[j,:-2])/2
ind = x.argsort()
y = y - median(y)
return vstack((x[ind,], y[ind,]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment