Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Python in a physics lab

1,455 views

Published on

Talk at PyCon Taiwan 2013.

The basic premise: Python is uniquely suited to run a physics lab end-to-end.

Published in: Technology, Education
  • Be the first to comment

Python in a physics lab

  1. 1. Lab overviewExperiment XVerdictPython in a physics labGergely ImrehPyCon TaiwanMay 25, 2013Gergely Imreh Python in a physics lab
  2. 2. Lab overviewExperiment XVerdictLab overviewGergely Imreh Python in a physics lab
  3. 3. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisExperiment XLaundry list of an experimentPlanning and theoryInstrument controlInterfaceAnalysis and archivingGergely Imreh Python in a physics lab
  4. 4. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisTheoryTools of theory:Gergely Imreh Python in a physics lab
  5. 5. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisRS-232 Serialimport serialinstrument = serial.Serial("/dev/ttyUSB0",baudrate=19200,timeout=1)instrument.write(cmd)Gergely Imreh Python in a physics lab
  6. 6. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisGergely Imreh Python in a physics lab
  7. 7. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisGPIB: General Purpose Interface Busimport visaoscilloscope = visa.instrument("GPIB::12")oscilloscope.write("*IDN?")print oscilloscope.read()Gergely Imreh Python in a physics lab
  8. 8. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisGergely Imreh Python in a physics lab
  9. 9. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisFireWire IEEE-1394import pydc1394lib = pydc1394.DC1394Library()cams = l.enumerate_cameras()cam0 = fw.Camera(l, cams[0][’guid’], isospeed=800)image = numpy.array(cam0.current_image, dtype=’f’)Gergely Imreh Python in a physics lab
  10. 10. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisctypesimport ctypesmy_dll = ctypes.windll.dll_namereceive_data = my_dll.ReceiveDatareceive_data.restype = ctypes.c_longprint receive_data()Gergely Imreh Python in a physics lab
  11. 11. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisUSB Test and Measurement Classimport osfile = os.open(device, os.O_RDWR)os.write(file, command)Gergely Imreh Python in a physics lab
  12. 12. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisPyMCU - Python controller microcontroller unitimport pymcuboard = pymcu.mcuModule()board.pinHigh(1)board.pausems(500)board.pinLow(1)board.pausems(500)Gergely Imreh Python in a physics lab
  13. 13. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisInterfaceTools of controlGergely Imreh Python in a physics lab
  14. 14. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisAnalysisTools of analysis:Gergely Imreh Python in a physics lab
  15. 15. Lab overviewExperiment XVerdictPreparationTalking to instrumentsInterfaceAnalysisMatplotlib aka. pylabimport pylabimport numpydata = numpy.loadtxt(’data.csv’)pylab.plot(data[:, 0], data[:, 1])pylab.show()Gergely Imreh Python in a physics lab
  16. 16. Lab overviewExperiment XVerdictCompetitorsGergely Imreh Python in a physics lab
  17. 17. Lab overviewExperiment XVerdictBalanceGergely Imreh Python in a physics lab
  18. 18. Lab overviewExperiment XVerdictimrehg@gmail.comhttps://gergely.imreh.netGergely Imreh Python in a physics lab

×