IDL tips for the Weeks Lab

A collection of various emails from Gianguido, Kazem, Ken, and others.

Lab Home -- People -- Experimental facilities -- Publications -- Experimental pictures -- Links

NOTE: Some of these programs are only available within the Weeks Lab, they are not part of our general IDL distribution. If you have a crucial need for one of these programs, contact Eric (weeks / physics.emory.edu).

gmovie4

From gianguido.cianci / gmail.com Wed Dec 19 16:59:00 2007

I have (very slightly) modified a program I found online and called it gmovie4. It has two main advantages over other 'movie.pro procedures:

1) if you click with a mouse on the scroll bar, you can then choose what frame to look at, or use the left/right arrows on the keyboard to go one frame at a time in each direction. It's like a super version of flick.pro

2) click on Window->Toolbars->Delay Bar and 3 boxes pop up on the bottom where you can set the time between frames and the time the first and last frames are shown when looping.

Note that there are other features too, like left clicking zooms in while the movie is playing and the middle button allows you to drag the movie around while it is playing too... If you explore the menus, you'll see that it also allows to export a movie to various formats thogh we do not currently have the mpeg license. Also note that it starts up by playing the movie once really fast as it loads it.


fover3dto2d

From gianguido.cianci / gmail.com Wed Dec 19 16:59:00 2007

'fover3dto2d' is similar to its ancestors and should be familiar to you. But, it takes a single 3D stack and treats the x, y or z(default) axis as if it were time. What that does is rather than draw 3d white blobs over your colloids, it will draw a disc (or circle if you use /circ) only when the center of the colloid in on screen. I like it better this way. Give it a try if you want.


gplotp & gplott

From gianguido.cianci / gmail.com Mon Jan 7 16:28:49 2008

gplotp, tr

is identical to plotp, only each particle ID is plotted with a different color. Also,

gplott, tr

or

gplott, pt, /pretrack

is identical to plotp but plots positions with colors from red to blue which represent time. Note that you need /pretrack for pretrack arrays!

Let me know if you have any problems or suggestions.

ps: unfortunately, if you surround these with the (g)aprint/bprint/cprint commands, it does not seem to work :-(

ps2: like the original plotp, these procedures accept all the options you could pass to an ordinary (inbuilt) plot command, like /iso or /nodata or title='my title' .


n_params

From kdesmond / moses.physics.emory.edu Mon Feb 11 15:03:05 2008

Here is an example of n_params.

FUNCTION rodfeatures, image,  thres, vol_range, squeezefac =
squeezefac, micperpix = micperpix, outputfile = outputfile

IF n_params() EQ 0 THEN BEGIN

   print, 'rodfeatures, image,  thres, vol_range, squeezefac =
squeezefac, micperpix = micperpix, outputfile = outputfile'

   return, -1

ENDIF


fsc_color

From gianguido.cianci / gmail.com Fri Dec 14 15:45:39 2007

This works nicely on my mac, haven't tried it yet on linux (can somebody try and let me know?). I can get both color plots on the screen and in postscript files!!

Basically you need to use color=fsc_color('colorname')

(And you might need to use /color with aprint.pro for color postscript images)

;;To see what colors are available:

print, fsc_color(/names), format='(6A18)'


;;A simple example:

i=indgen(100)/10.
gaprint ;for PS output, optional

plot, i, cos(i), /nodata
oplot, i, cos(i), color=fsc_color('red'), thick=3
oplot, i, sin(i), color=fsc_color('green'), thick=3

cprint ;only if you did gaprint


;;Somewhat fancier...

gaprint

n=50.
z=dist(n)
surface, cos(z/n*5), color=fsc_color('red'), /lower_only, /noerase, /save
surface, cos(z/n*5), color=fsc_color('blue'), /upper_only, /noerase
surface, cos(z/n*5), /nodata, /noerase, xthick=2, ythick=2, zthick=2, charth=2
contour, z, /noerase, /t3d, zvalue=1, color=fsc_color('green'), nlevels=10

cprint


ver & hor

From kedmond / physics.emory.edu Fri Jun 6 15:18:39 2008

I thought that I should let you all know about two simple programs that I've been using for the past couple of years. They're called "ver.pro" and "hor.pro". They are programs for IDL that simply draw vertical or horizontal lines onto an existing plot. They're located in spicysquid:/home/kedmond/idl/

To use them, just type "ver, 10" and a vertical line will appear at 10, on the x-axis. "hor.pro" works in the same way. You can also do things like this:

var, 10, color=fsc_color('green'), thick=3, line=3

That will draw a dashed line that is green at x=10 with a thickness of 3. Anyways, I thought they're super simple programs, but can be helpful when plotting results. Have fun!


addheader

From kdesmond / moses.physics.emory.edu Thu Jun 12 18:39:58 2008

To add a header to your code simply type the following in IDL.

If the first line of your program is the call sequence to run your program, then type

IDL> addheader, 'program name'

If the first line of your program is not the call sequence to run your program, then type

IDL> addheader, 'program name', line = line number
note line number is the line in your program where the call sequence is written.


correlatemovie

From gianguido.cianci / gmail.com Sun Jan 20 19:21:11 2008

You may have noticed that every now and then, some of the slices of some of the stacks you have acquired seem mismatched or shifted with respect to the rest of the stack they belong to.

If you do this:

IDL> c=correlatemovie('filenames', /tif)
IDL> surface, 1-c

you will get a surface plot with the x-axis representing the z-position through a stack, the y-axis representing frame number, and the z-axis represents the amount of decorrelation between consecutive frames at those times and z values. You can also tvscl, big(1-c) to see the surface from above, where a bright spot indicates a possible problem...

It is a simple program and there may be more efficient ways to write it. But I suggest you ALWAYS run this on 3D VT-Eye data and if you see many spikes in the plot of 1-c then you should investigate further!!!


krm_motion.pro

A version of rm_motion.pro, written by Kazem, that operates on only one of the coordinates.


kplot.pro & related tools

Written by Ken Desmond

Here are some new functions I wrote to make plotting in IDL easier:
kplot
  Handles /xl and /yl better, can smooth data, and can be used to
   set actual font size
koplot
  Used in conjunction with kplot
times_font
  Changes font type to times new roman
font_size
  Return charsize needed to have text written with desired font size
ktex2idl
  Converts Latex into IDL for labeling axis

Note all functions are designed to work when outputted to postscript.

The main purpose of these programs is to make publish and talk worthy plots quickly.


Features of kplot

kplot works like plot but has a few more keywords. Also kplot does a better job of handling /xl and /yl.

Following keywords:

Examples for using kplot

;comparing /xl and /yl
;note the difference between using kplot and plot
plot, sin(findgen(100)/30.), /xl, /yl
kplot, sin(findgen(100)/30.), /xl, /yl

;using kplot to smooth data
noise=randomu(seed,100)/20.
kplot, sin(findgen(100)/30.)+noise
kplot, sin(findgen(100)/30.)+noise, smooth=5

;using kplot to set font size 
;  if you print this to postscript and then print the postscript file 
;  from a print it will have a font size of 12pt
kplot, sin(findgen(100)/30.), font=12

Features of koplot

Use koplot like oplot and like koplot


Features of times_font

Changes the font type to Times New Roman


Features of font_size

Returns the charsize for the inputed font_size

Example:
;To print 'test' to a postscript file with font size = 12
xyouts, 0.5, 0.5, charsize=font_size(12), /normal

Features of ktex2idl

Example:
aprint, file='test.ps'
kplot, sin(findgen(100)/30.), xtitle = ktex2idl('$\Delta{}t$ (sec)'),
$
          ytitle = ktex2idl('$\langle{}\Delta{}r^2\rangle$
($\mu$m$^2$)')
cprint


kmovie.pro

Written by Ken Desmond

;Program allows you to view three planes at once with toggle controls
;to change viewing planes

;options
;
; normal mode
;    s - play slower
;    f - play faster
;    r - reverse direction
;    q - quit program
;    t - switch to plane view mode
;
;
; plane view mode
;    a - toggle x position right
;    d - toggle x position left
;    s - toggle y position down
;    w - toggle y position up
;    q - toggle z position down
;    e - toggle z position up
;    c - turn cross hairs on and off
;    b - turn on and off box
;    m - manually enter values
;    l - locate id
;    o - enable clicking
;    z - enable zoom
;    r - resize image (0 resets size)
;    t - threshold first image
;    h - list options
;    f - flick between two images
;    n - switch to normal mode
;    x - quit program

Use instead of "gmovie" or "movie", in other words,

where 'a' is an image stack.


Bounding Boxes

From gianguido.cianci / gmail.com Sun Aug 30 00:00:29 2009

bbox_add.pl -- This script is run as "bbox_add.pl blah.eps" and *automagically* adds a tight bounding box to the file. Worked great in a few tests I ran :-) No matter how many times I made figures, setting bounding box values was always a trial and error and error and error process for me... hopefully no more.

A webpage (code links at the bottom) by David Fanning allows for an easy way to set device keywords while making figures. In fact, you could use it once to set your figure attributes and then save them to a file and use that file to load DEVICE settings everytime you need to make a figure.