**Particle tracking using IDL -- John C. Crocker and
Eric R. Weeks**

Home |
Download software |
Tutorial |
Extra software

# IDL routines to calculate the pair correlation function *g(r)*

*Slight revision July 22, 2005 -- fixed a bug when rmax is an
integer rather than a float*

*Slight revision June 14, 2005 -- fixed a bug in the plotting,
which did not affect the output data, fortunately!*
Usage:

**IDL> gr = ericgr2d(data)**

IDL> plot,gr(0,*),gr(1,*)

The default is to assume the data is in the form (x,y, --- ,t)
where the first two columns are positions, the next few columns
are arbitrary (and could be missing), and the last column is a
timestamp. If you have tracked data:
**IDL> gr = ericgr2d(data,/track)**

There are other options as well. The default is to calculate
g(r) for 0 < r < 10, with a spacing of every 0.01. (See here for brief explanation.) To
override this, you can use the following keywords:
**IDL> gr = ericgr2d(data,rmin=1.0,rmax=100.0,deltar=0.1)**

It's used exactly the same as the 2D program. The coding
is quite different, though, for boring
technical reasons, thus you have to use a different program.
One warning that's only for **ericgr3d**: again due to boring
technical reasons, you shouldn't set **rmax** to be
more than half of the spatial extent of your data in *X*
and *Y*. **ericgr2d** doesn't have this problem.

This program plots an update of g(r) at each step, which
you can prevent with the /noplot keyword.

- What is the pair correlation function?
- How to calculate g(r)
**IDL routines to calculate g(r)**
*(you are here)*
- Extra g(r) routines -- unsupported

## Contact us

- This page was written by
Eric Weeks:
weeks(at)physics.emory.edu