IDL Related Tips and Help
Tutorials
- A Guide to IDL for Astronomers- an extensive step-by-step tutorial and reference. Great for beginners.
- Prof. J. D. Monnier's short IDL tutorial which should take about 2 hours to complete.
- Using IDL to Manipulate and Visualize Scientific Data
-
IDL 8.0:
- IDL 8.0: a new graphics interface - short tutorial by Michael Galloy
- IDL 8.0 wrap-up - links to other tutorials by Michael Galloy
Installation and Setup
To Install IDL 7 on a new Mac (>10.8), the easiest way might be to drag-and-drop the Applications/itt/ folder from an older machine.
IDL has a fairly easy to use installer for MacOS X now, but in order to get it working properly there are some steps to be taken that don't seem to be described well anywhere. However, over at Macsingularity there is a post on installing IDL (v6.3 on Tiger 10.4)that will take you through either setting up proper aliases or setting your shell environment so you can run IDL from the command line easily.
Other Resources
Setup Paths
Choose an appropriate location for your external IDL libraries (e.g., AstroPro), for example /users/you/Library/IDL/. Modify your IDLPATH:
setenv IDL_PATH ":+/users/you/Library/IDL/"
for tcsh.
- Setting Up the IDL Environmentfrom v6.2 Manual
- IDL Setupfrom A Guide to IDL for Astronomers
- IDL Setupfrom A. Barth at UC Irvine.
License
If you are on a network with a license server, you will also need to set proper access to that in your .cshrc file. For example:
setenv LM_LICENSE_FILE '1700@idllicense'
Programs that require user cursor interactions do not work properly.
- To fix this, you can enable click through in X11 so that IDL cursor commands will return events
- Type in terminal:
10.5 and later defaults write org.x.X11 wm_click_through -bool true
10.4 and earlier defaults write com.apple.x11 wm_click_through -bool true
- Restart X11, this procedure just needs to be done once. For more see this post at Macsingularity.
Colors are all wrong now matter what color table you chose (colors are all red).
- This is likely because you are using an indexed color (choosing a color between 0-255), but your display is 24 bit. The solution is to use undecomposed color:
- Put this in your program or your IDL startup file (needs to be done once every IDL session):
device, decomposed = 0
- Much more details here.
Automatic Session Recording
- If you're obsessive about keeping track of your IDL history, there's a straightforward way to make IDL always record a unique journal file of your session.
- Just put the following lines at the endof your IDL_START file:
; Always create a journal file with today's date and time fs = '(I2.2)' caldat, julday(), mon, d, y, h, min datstr = string(y, format='(I4.2)') + $ string(mon, format=fs) + $ string(d, format=fs) + '_' + $ string(h, format=fs) + $ string(min, format=fs) + '.jrn' journal, datstr
- Then every time you start IDL you will have a journal file created in your working directory with the date and time: e.g., "20080507_1056.jrn".
Properly Setting Defaults in IDL
Many people use
IF NOT KEYWORD_SET(var) THEN var=default
IF N_ELEMENTS(var) EQ 0 THEN var=default
IDL> print, test
% PRINT: Variable is undefined: TEST.
% Execution halted at: $MAIN$
IDL> if n_elements(test) eq 0 then test = 0
IDL> print, test
0
IDL> if (not keyword_set(test)) then test = 1
IDL> print, test
1
IDL> print, test
% PRINT: Variable is undefined: TEST.
% Execution halted at: $MAIN$
IDL> if (not keyword_set(test)) then test = 0
IDL> print, test
0
IDL> if n_elements(test) eq 0 then test = 1
IDL> print, test
0
grep -i "IF NOT KEYWORD_SET(" ~/idl/astrolib/pro/*.pro | grep -i "=" | wc 121 1072 11771
... almost as common as doing it correctly:
grep -i "IF N_ELEMENTS(" ~/idl/astrolib/pro/*.pro | grep -i "EQ 0" | grep "=" | wc 216 2054 21567