Python and chemistry

Check out the new site at https://rkblog.dev.

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

Programming in Python, 14 July 2008


Check out the new site at https://rkblog.dev.
Comment article
Comment article RkBlog main page Search RSS Contact