Python Libraries from GSECARS

A set of libraries and applications for collecting and working with x-ray data from synchrotrons

Matt Newville, Mark Rivers

Currently supported Python modules developed at CARS: See also and for other related projects.

 Many of the remaining links here are to work of Mark Rivers from approximately 2001. These modules are not well-supported, and many of these have been replaced by code linked above. We keep thee links for historical purposes.

Plotting Modules

BltPlot Enhancements to the Pmw.Blt.Graph widget
myTkTop Workaround for bug in Pmw.Blt.Graph

Mathematics Modules

mpfit General non-linear least squares data fitting, based on MINPACK
CARSMath Miscellaneous math functions.
spline Spline fitting
func Support module required by spline

General EPICS Modules

epicsPV Interface to EPICS channel access, enhancements to CaChannel 
epicsMotor Interface to EPICS motor record
epicsScaler Interface to EPICS scaler record
epicsLogger GUI application to log EPICS PVs to the screen and to a disk file

Multi-channel Analyzer (MCA) Modules

Mca Device-independent Multi-Channel Analyzer class
hardwareMca Virtual class for hardware MCAs, subclass of Mca
epicsMca EPICS Multi-Channel Analyzer class, subclass of Mca
Med Device-independent Multi-Element Detector class
epicsMed EPICS Multi-Element Detector class, subclass of Med
fitPeaks Fit Gaussian peaks to spectra
jcpds Powder diffraction lines at high pressure and high temperature
Xrf Utility functions for X-ray Fluorescence (XRF)
mcaDisplay GUI for display and control of MCAs.  Device-independent.
mcaCalibrateEnergy GUI to calibrate energy of an MCA
mcaCalibrate2Theta GUI to calibrate 2-theta of an MCA
mcaControlPresets GUI to control presets of an MCA
mcaPeakFit GUI to fit peaks and background of an MCA
medDisplay GUI for display and control of an epicsMed
localMedLayout Site-specific module to define geometry of a multi-element detector


The above packages require one or more of the following Python packages available elsewhere:

Python Python 2.2.1.  The above packages have been tested with Python 2.1 and 2.2.1. I recommend using 2.2.1 or higher, since future enhancements may require it.
Numpy Numerical Python
Pmw Python MegaWidgets for Tkinter
Blt Plotting toolkit
EPICS support EPICS support files.  Includes Geoff Savage's CaPython and CaChannel, but with pre-built binaries for Python 2.1 and 2.2 on Windows and Linux.  Also includes Ezca, another interface to EPICS Channel Access, written by Matt Newville.

Installation on Windows platforms

Fetching and installing the above packages is a bit of a nuisance.  Blt requires some messing around to get it to run with Python on Windows.  The following is a simple procedure for getting Python 2.2.1 with the above up and running on any Windows machine with all of the above modules.

Command to send a Postscript file to the printer.  Used by mcaDisplay and BltPlot.  Default = "print ", which will print to default printer. Example:

print /d:\\cars5\GSEFLOOR

The path to the JCPDS files.  Example:


Path to the file containing XRF fluorescence lines.  Example:


Location of a file to store preferences for the mcaDisplay program.  Example:


Command to start a Web browser with help on the mcaDisplay program. Example:


Suggestions and comments to: Mark Rivers : (
Last modified: September 28, 2002