python in a physics lab

18
Lab overview Experiment X Verdict Python in a physics lab Gergely Imreh PyCon Taiwan May 25, 2013 Gergely Imreh Python in a physics lab

Upload: gergely-imreh

Post on 02-Jul-2015

763 views

Category:

Technology


3 download

DESCRIPTION

Talk at PyCon Taiwan 2013. The basic premise: Python is uniquely suited to run a physics lab end-to-end.

TRANSCRIPT

Page 1: Python in a physics lab

Lab overviewExperiment X

Verdict

Python in a physics lab

Gergely Imreh

PyCon TaiwanMay 25, 2013

Gergely Imreh Python in a physics lab

Page 2: Python in a physics lab

Lab overviewExperiment X

Verdict

Lab overview

Gergely Imreh Python in a physics lab

Page 3: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Experiment X

Laundry list of an experiment

Planning and theory

Instrument control

Interface

Analysis and archiving

Gergely Imreh Python in a physics lab

Page 4: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Theory

Tools of theory:

Gergely Imreh Python in a physics lab

Page 5: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

RS-232 Serial

import serial

instrument = serial.Serial("/dev/ttyUSB0",

baudrate=19200,

timeout=1)

instrument.write(cmd)

Gergely Imreh Python in a physics lab

Page 6: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Gergely Imreh Python in a physics lab

Page 7: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

GPIB: General Purpose Interface Bus

import visa

oscilloscope = visa.instrument("GPIB::12")

oscilloscope.write("*IDN?")

print oscilloscope.read()

Gergely Imreh Python in a physics lab

Page 8: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Gergely Imreh Python in a physics lab

Page 9: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

FireWire IEEE-1394

import pydc1394

lib = 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

Page 10: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

ctypes

import ctypes

my_dll = ctypes.windll.dll_name

receive_data = my_dll.ReceiveData

receive_data.restype = ctypes.c_long

print receive_data()

Gergely Imreh Python in a physics lab

Page 11: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

USB Test and Measurement Class

import os

file = os.open(device, os.O_RDWR)

os.write(file, command)

Gergely Imreh Python in a physics lab

Page 12: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

PyMCU - Python controller microcontroller unit

import pymcu

board = pymcu.mcuModule()

board.pinHigh(1)

board.pausems(500)

board.pinLow(1)

board.pausems(500)

Gergely Imreh Python in a physics lab

Page 13: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Interface

Tools of control

Gergely Imreh Python in a physics lab

Page 14: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Analysis

Tools of analysis:

Gergely Imreh Python in a physics lab

Page 15: Python in a physics lab

Lab overviewExperiment X

Verdict

PreparationTalking to instrumentsInterfaceAnalysis

Matplotlib aka. pylab

import pylab

import numpy

data = numpy.loadtxt(’data.csv’)

pylab.plot(data[:, 0], data[:, 1])

pylab.show()

Gergely Imreh Python in a physics lab

Page 16: Python in a physics lab

Lab overviewExperiment X

Verdict

Competitors

Gergely Imreh Python in a physics lab

Page 17: Python in a physics lab

Lab overviewExperiment X

Verdict

Balance

Gergely Imreh Python in a physics lab

Page 18: Python in a physics lab

Lab overviewExperiment X

Verdict

[email protected]://gergely.imreh.net

Gergely Imreh Python in a physics lab