示例#1
0
view = c.load_balanced_view()

# Submit tasks:
print("Submitting tasks...")

t1 = time.time()
async_results = []
for i in range(400):
	ar = view.apply_async(exposure)
	async_results.append(ar)


print("Submitted tasks: ", len(async_results))

# Block until all tasks are completed.

c.wait(async_results)
t2 = time.time()
t = t2-t1

print("Parallel calculation completed, time = %s s" % t)

# Get the results using the `get` method:

results = [ar.get() for ar in async_results]

# Plot the value of the European call in (volatility, strike) space.

qfuncoutput = qf.qfuncimage(np.real(results),np.imag(results),30)
show()
示例#2
0
amp = 380

darkcts = 0.0 # no idea what is reasonable here, just tinkering
# the ccd specifies 2-3 electrons per pixel per hour

# seems best way to model (classical) detector is with partial loss (2%) 
# and added noise (dark counts)

values = []
for i in range(5000): #this is the loop to parallelize
    print i
    total = bopt.plane_wave_beam(x,y,0,amp,k1) + 
            exp(1j*1)*bopt.plane_wave_beam(x,y,0,0.001*amp,k2) 

    intensity = total * total.conjugate() # + 
                #darkcts*(random.random([max(shape(x)),max(shape(y))]) + 
                #1j*random.random([max(shape(x)),max(shape(y))])) 
                # add dark noise and QE
    K = fftshift(fft(intensity[:,200])) # complex intensity after FFT2
    values.append(K[643]/1e5)

# pixel of interest in FFT is 643 (this is 131 pixels away from the 
# center @ 512) 131 pixels corresponds to the off-axis component of 
# the wave:
# ∆K is 2π / (20e-6 * 1024) = 306.796 rad/m
# 306.796 * 131 is 40190 rad/m which is k * sin(0.005) 
# where k = 2π/780e-9 = 8055365 rad/m TADA!

qfuncoutput = qf.qfuncimage(real(values),imag(values),30)
show()
示例#3
0
 def makeQfig(self, mode=None):  # makes a Qfig for a specified mode
     if mode is None:
         mode = self.peak_mode
     mode_array = self.dataOut[mode, :, :].flatten()
     # takes only the desired mode
     self.qfig = Qfunc.qfuncimage(mode_array, 30, 0)
示例#4
0
def plotMode(modearray, mode, binsize = 10):
	qfig = Qfunc.qfuncimage(modearray[2*mode:2*mode+2], binsize)
	return qfig