def change(param, changes): global flatField, interpolation print("tree changes:") print p for param, change, data in changes: path = p.childPath(param) if path is not None: childName = '.'.join(path) else: childName = param.name() print(' parameter: %s' % childName) print(' change: %s' % change) print(' data: %s' % str(data)) print(' ----------') if childName == 'row' or childName == 'col': print p['row'], p['col'] pix = 8 * p['row'] + p['col'] # retrieve interpolation data (xo, yo) = interpolation[pix] # calculate phase pattern fft_phase = gp.initial_phase_orig(257 - xo, 257 - yo, 512) gp.write2file(fft_phase, gp.phasemap, SLMpath, '99') shutil.copyfile( bobMirrorFileName, '/mnt/SLM/Dan/OptimizeSLM/Patterns/OrigSettings/SLM_100.dat') send(99) print 'From PC: ', wait() f = open(settingsFile, 'w') f.write('%d' % pix + '\n') f.flush() f.close()
def change(param, changes): global flatField, interpolation print("tree changes:") print p for param, change, data in changes: path = p.childPath(param) if path is not None: childName = '.'.join(path) else: childName = param.name() print(' parameter: %s'% childName) print(' change: %s'% change) print(' data: %s'% str(data)) print(' ----------') if childName=='row' or childName=='col': print p['row'], p['col'] pix = 8*p['row'] + p['col'] # retrieve interpolation data (xo,yo)=interpolation[pix] # calculate phase pattern fft_phase = gp.initial_phase_orig(257-xo,257-yo, 512) gp.write2file(fft_phase, gp.phasemap, SLMpath, '99') shutil.copyfile(bobMirrorFileName, '/mnt/SLM/Dan/OptimizeSLM/Patterns/OrigSettings/SLM_100.dat') send(99) print 'From PC: ', wait() f = open(settingsFile, 'w') f.write('%d'%pix + '\n') f.flush() f.close()
infofp.write('# Tacq %f\n'%Tacq) infofp.close() scanparams = np.loadtxt(dataPathInterp+'scanparameters.txt') (xstart, xstop, xstep, ystart, ystop, ystep)=scanparams pixel_list = gp.interpolate2SLM(dataPathInterp, xstart, xstep, ystart, ystep) #print pixel_list cnt = 0 # Set Bob's SLM to a mirror, only need to do this once shutil.copyfile(bobMirrorFileName, '/mnt/SLM/Dan/OptimizeSLM/Patterns/OrigSettings/SLM_100.dat') out_fp = open(dataPath+'rasterOptimize.txt','w') for pixel in pixel_list: (xo,yo)=pixel while True: fft_phase = gp.initial_phase_orig(257-xo,257-yo, 512) #print 'phase_offset',gp.phase_offset gp.write2file(fft_phase, gp.phasemap, SLMpath, '99') send(99) msgin = wait() if int(msgin)<0: print 'problem talking with loading a file on the SLM' break #print 'From PC: ',msgin prev_single, prev_coin = ttag_wrap.getCnts(Tacq, CoincidenceWindow,gate, heraldChan,buf) x_offsetList = np.arange(-2,3)*2 y_offsetList = np.arange(-2,3)*2 cnts = [] norms = []
yshift = 1 infoname = sys.argv[0].strip('.py') + '.info.txt' infofp = open(dataPath + infoname, 'w') infofp.write('# use the pixel mapping in this folder %s\n' % dataPathInterp) infofp.write('# Tacq %f\n' % Tacq) infofp.write('# BOB SLM xshift: %d, yshift: %d\n' % (xshift, yshift)) infofp.close() cnt = 0 while True: for pixel in range(64): [xo, yo] = pixel_list[pixel, :] print '%2d: %.3f %.3f' % (pixel, xo, yo) fft_phase = gp.initial_phase_orig(257 - xo, 257 - yo, 512) #print 'phase_offset',gp.phase_offset # generate encoding matrix seed = cnt + 1 code = gp.encrypt(seed, 512, 128) fft_phase += code # send to Alice SLM gp.write2file(fft_phase, gp.phasemap, SLMpath, '99') # send decoding matrix to Bob SLM decode = gp.decrypt(code, xshift, yshift, nrows) gp.write2file(decode, gp.phasemap, SLMpath, '100') send(99) msg = wait() time.sleep(0.1) if int(msg) < 0: print 'Problem with SLM setting'
heraldChan = 0 # get nanowire pixel locations from scan scanparams = np.loadtxt(dataPathInterp+'scanparameters.txt') (xstart,xstop,xstep,ystart,ystop,ystep)=scanparams pixel_list = gp.interpolate2SLM(dataPathInterp, xstart, xstep, ystart, ystep) pixel = 27 # aim for middle of the nanowire array [xo,yo]= pixel_list[pixel,:] nrows = 512 cnt = 0 seed = 1 # use same random pattern all the time # compute random phase and set alice code = gp.encrypt(seed,512,128) # figure phases to point to pixel fft_phase = gp.initial_phase_orig(257-xo,257-yo, 512) fft_phase += code gp.write2file(fft_phase, gp.phasemap, SLMpath, '99') for xshift in range(-10,11): for yshift in range(-10,11): print 'xshift, yshift: %3d %3d'%(xshift,yshift) # send decoding matrix to Bob SLM, vary xshift, yshift decode = gp.decrypt(code, xshift, yshift, nrows) gp.write2file(decode, gp.phasemap, SLMpath, '100') send(99) msg = wait() if int(msg)<0: print 'Problem with SLM setting' raise('Problem with SLM setting') break
def write(x, y): phase = gp.initial_phase_orig(257. - x, 257. - y, 512) gp.write2file(phase, pm, path, filenumber) shutil.copyfile( bobMirrorFileName, '/mnt/SLM/Dan/OptimizeSLM/Patterns/OrigSettings/SLM_100.dat')