Particle tracking using IDL -- John C. Crocker and Eric R. Weeks
Home | Download software | Tutorial | Extra software

eclip.pro

(or click here if that link fails)

I find this useful when extracting portions of a data set, similar to polycut. Suppose we have an array, such as a pretrack array, with a bunch of columns:

IDL> help,pta

PTA             FLOAT     = Array[6, 717892]

Maybe pta(0,*) is the x-coordinate, pta(1,*) is the y-coordinate, and pta(5,*) is the time step. Suppose you want to look at only points between time=0 and time=10. You could do a where command:

IDL> w=where(pta(5,*) ge 0 and pta(5,*) le 10)
IDL> ptb=pta(*,w)

However, this is a tiny bit tedious to type. Instead, you can use eclip:

IDL> ptb=eclip(pta,[5,0,10])

The vector [5,0,10] requests a cut on column #5, accepting values between 0 and 10. So, a tiny bit of typing is saved. However, you can combine several cuts all at once, if you like:

IDL> ptc=eclip(pta,[5,0,10],[0,50.0,58.3],[2,1e4,2e4])

Thus only points for which 0 <= pta(5,*) <= 10 AND 50.0 <= pta(0,*) <= 58.3 AND 1e4 <= pta(2,*) <= 2e4 are used. You can combine up to six different cuts at once. I find this command most useful when I have some pretracked data, and I want to reject bunches of it for some reason.

eclip also takes one keyword, /invert, which then passes all data that would have otherwise been rejected. In other words, define ptd:

IDL> ptd=eclip(pta,[5,0,10],[0,50.0,58.3],[2,1e4,2e4],/invert)

Using the previous definition of ptc, note that the union of ptc and ptd is pta (the original array), and the intersection of ptc and ptd is empty. ptd contains points for which pta(5,*) < 0 OR pta(5,*) > 10 OR pta(0,*) < 50 OR ...


One other option taken by eclip is /WHERE, which rather than returning the clipped array, returns the indices corresponding to the clipping. If you're familiar with the IDL built-in where command, this usage is probably obvious to you.


The "E" in eclip stands for "Eric" since I wrote it.


Contact us