def laserScan2D(width, height, delta, peakArea, fileName): # Scans an area with given width and height at a # step rate of delta. peakArea is int value for # the location of peak with a scale from 0 to 10,000 startTime = time.clock() h = 0 w = 0 n = 0 m = 0 x = np.arange(0, width + delta, delta) y = np.arange(0, height + delta, delta) Y, X = np.meshgrid(y, x) tValues = np.zeros((np.size(x), np.size(y))) vValues = np.zeros((np.size(x), np.size(y))) # set up scope scanRange = 1000 scope = vi.instrument("TCPIP::138.67.12.235::INSTR") sRead.setParam(scope, peakArea - scanRange, peakArea + scanRange) # get motor and zero location motor = mC.setupMotor() while w <= width: h = 0 m = 0 while h <= height: mC.moveTo(motor, w, h) time.sleep(0.5) x, y = sRead.getData(scope, peakArea - scanRange, peakArea + scanRange) t, v = findPeak(x, y) tValues[n, m] = t vValues[n, m] = v h = h + delta m = m + 1 w = w + delta n = n + 1 # Estimates Time Left timeLeft = (width - w) / w * (time.clock() - startTime) / 60 print "Est. Time Left " + np.str(timeLeft) + "min" mC.moveTo(motor, 0, 0) # Contour Plot of Time makePlot2D(X, Y, tValues, fileName + " Time") # Contour Plot of Voltage makePlot2D(X, Y, vValues, fileName + " Voltage") # File Output np.savez(fileName + ".npz", X=X, Y=Y, tValues=tValues, vValues=vValues) # Time Taken Calc timeTaken = (time.clock() - startTime) / 60 # in min print "Time Taken " + np.str(timeTaken) motor.close() scope.close() return timeTaken, tValues
def laserScan1D(width, height, delta, peakArea, fileName): # Scans an area with given width and height at a # step rate of delta. peakArea is int value for # the location of peak with a scale from 0 to 10,000 startTime = time.clock() h = 0 w = 0 n = 0 m = 0 x = np.arange(0, width + delta, delta) y = np.arange(0, height + delta, delta) Y, X = np.meshgrid(y, x) tValues = np.array([[]]) vValues = np.array([[]]) # set up scope scanRange = 240 scope = vi.instrument("TCPIP::138.67.12.235::INSTR") sRead.setParam(scope, peakArea - scanRange, peakArea + scanRange) # get motor and zero location motor = mC.setupMotor() while w <= width: h = 0 m = 0 while h <= height: mC.moveTo(motor, w, h) time.sleep(3) t1, v1 = sRead.getData(scope, peakArea - scanRange, peakArea + scanRange) time.sleep(1) t2, v2 = sRead.getData(scope, peakArea - scanRange, peakArea + scanRange) t = [np.average([t1[x], t2[x]]) for x in range(len(t1))] v = [np.average([v1[x], v2[x]]) for x in range(len(v1))] if h == 0 and w == 0: tValues = [t] vValues = [v] else: tValues = np.append(tValues, [t], axis=0) vValues = np.append(vValues, [v], axis=0) h = h + delta m = m + 1 w = w + delta n = n + 1 # Estimates Time Left timeLeft = (width - w) / w * (time.clock() - startTime) / 60 print "Est. Time Left " + np.str(timeLeft) + "min" mC.moveTo(motor, 0, 0) motor.close() scope.close() # File Output np.savez(fileName + ".npz", X=X, Y=Y, tValues=tValues, vValues=vValues) # Plot of Time vs Voltage makePlot1D(tValues, vValues, fileName) # Time Taken Calc timeTaken = (time.clock() - startTime) / 60 # in min print "Time Taken " + np.str(timeTaken) return timeTaken, tValues, vValues