Loading...
 

IDL Related Tips and Help

Tutorials

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.

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

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

 

to set default values. However, if the user specifies var=0, KEYWORD_SET evaluates to 0 and "val" will be overwritten by the default. The more robust way to set default values is:
 IF N_ELEMENTS(var) EQ 0 THEN var=default
Here's a simple example that demonstrates the problem:
	 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
And the same in reverse order, to show that N_ELEMENTS doesn't suffer from the same problem:
 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
KEYWORD_SET should be used exclusively for keywords that can be 0, 1, or undefined. Unfortunately, this error extremely common in the astro library (and elsewhere):
	  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 
This test isn't completely fair, as some of these are legitimate uses of KEYWORD_SET, but the vast majority are not (run it yourself without the "| wc" to see).
Page last modified on Tuesday 10 of June, 2014 16:52:12 EDT