RkBlog

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]
	ylabel('signal')
	xlabel('time (ns)')
	title('chromatograph ' + i)
	plot(v)
	savefig('smiec/' + i + '.png')
	clf()
	print 'Making chart for: ' + i
RkBlog

Python programming, 14 July 2008, Piotr Maliński

Comment article