Hardware, programming and astronomy tutorials and reviews.

Python and chemistry

I've been doing a lot of gas chromatography tests lately (tetrachloride carbon decomposition in pulse dielectric barrier discharge) and the chromatograph (HP) makes CH1 or CDF (ANDI/netCDF Mass Spectrometry Data Interchange format) files. And for CDFs in python we have pycdf. Here is a mass chart generator:

from pycdf import *
from Numeric import *
from os import listdir
from pylab import *

cdfs = listdir('cdf/')
for i in cdfs:
	nc = CDF('cdf/' + i)
	varnames = nc.variables().keys()
	v = nc.var(varnames[14])[:]
	v = v[0:2000]
	xlabel('time (ns)')
	title('chromatograph ' + i)
	savefig('smiec/' + i + '.png')
	print 'Making chart for: ' + i

Python programming, 14 July 2008, Piotr Maliński

Comment article