Wednesday, 29 July 2009

Using ipcluster etc with IPython.

Fire up the cluster, then run IPython and copy/paste the code below.


$ ipcluster -n 8



# Set up the parallel function:
from IPython.kernel import client; tc = client.TaskClient()

@tc.parallel() # define parallel load and return data
def go(x):
import numpy, reference
x.load()
f, p = x.PAFECffp[0, 1:], 20 * numpy.log10(abs(x.PAFECffp[1, 1:]) / 20E-6)
return((f, p))

# Create a list of things to throw at the cluster:
ii = [0, 1, 2, 3, 4, 5] # filename extensions.
a = [mfile.File('/full/path/morph_a' + str(i) + '.O07') for i in ii]

# Engage!
res = go(a)


res should now contain a list of results.

No comments:

Post a Comment