IDL Tips

 
First, make sure that you have visited David Fanning's website and have looked at most (if not all) of his tips and tricks. I will try to put things in here that (I think) are not Fanning's website. The following are arranged in the order that they came to my mind and are only applicable to IDL on linux.
  • Licenses: IDL installations typically have a limited number of licenses. Each instance of the license is tied to display associated with the IDL session and not to the actual number of IDL processes that an user is running. An easy way to reduce the number of licenses that you might be taking up (up to the hard limit of 1), is by starting different 'xterms' on the remote computer (so they all inherit the same DISPLAY variable) and starting IDL on these xterms. Or, you could start up a 'screen' session and have the same DISPLAY variable amongst all the screen windows. You can see the licenses currently being used by calling $IDL_DIR/bin/lmstat -a.
  •  
  • INTEGERS in IDL: Be very wary of the limited range of the integer type in IDL. By default, 'int' has a ridiculously low size of 2 bytes (a short int really). This will result in data overflow/garbage results for an "integer" operation for values exceeding 32767. An easy fix is to put the following line in your IDL startup file:
     
    compile_opt defint32
     
    This will define your default 'int' to be 'long' in IDL terms. Keep in mind that 'long' in IDL is the same size as 'int' in C. If you are reading/writing binary files, then you need to watch out for such size mismatches. On a side-note, there is a very useful function called sizeof in the SOHO library (like the usual sizeof function in C) in IDL, that returns the size of a variable.
  •  
  • Convention: It is generally considered a good habit to use square brackets to perform array indexing and parentheses while calling functions. Thus, val[i] refers to the i'th element of the 'val' array while val(i) calls the function 'val' with the argument i. IDL does not require you to follow this strictly (and a lot of old code has the older convention of parentheses for both functions and array indexing).
  •  
  • True or False: If you programmed in C before IDL, this 'feature' is quite a bad news. In C, a non-zero value is taken as "true" and zero signifies "false". By default in IDL, the behaviour is determined by the least significant bit of the integer -- odd integers are "true" and even integers are "false" !! That, in my fragile C processing brain, is absolutely unacceptable. A way to enforce C behaviour is by putting this line in your startup file:
     
    compile_opt logical_predicate
     
    (Note that IDL behaves in C-like fashion for floats and doubles)

Misc. Tips & Tricks

 
Changing the volume on mplayer
 
The default behaviour of mplayer is to change the volume level by 3% and you achieve this by using the "/" and "*" keys to decrease and increase the volume respectively. However, at least on my system, 3% level is too loud for me and 0% is too *silent* ! If you have this problem, you can invoke mplayer with the command line option "-volstep 1" and change your increment to 1%. Ohh and you should invoke mplayer with the additional command line parameter "-af volume=-20" where the number is the amount of (negative) gain you want for your audio level.
 
Wrong figure numbers while using Fig~\ref{identifier} in latex
 
You probably have your "\label" right after your \begin{figure}. Switch the label to just before \end{figure} and you will get the correct numbering. In the previous (wrong) mode, latex thinks that the (sub)section number is actually your figure (this is probably true for all floating environments, but I havent checked).
 
Unit conversion in linux (not google calculator)
 
There is very nifty command line unit conversion tool - units (!) that is available on linux. It will convert all those astrophysical standard units into any thing you fancy. Hubble parameter in units of "/s", "km/s" to "megaparsec/myr" ..etc. Google calculator does a decent job of normal conversion tasks but units has a larger base system of units. (Cygwin also has "units" -- in case you have a Windows laptop)

Back of the envelope

  • Redshift multiplied by the age of the Universe (in Gyrs) at that redshift ~ 6 (for 1 <= z <= 6) in the current LCDM model. For e.g., at z = 1, the Universe is about 6 Gyrs old (~ 8 Gyrs into the past); at z=2, the Universe is about 3 Gyrs old (~ 11 Gyrs into the past).
  • There are ~ pi x 10^7 seconds in a year.
  • 1 km/s for 1 Myr covers ~ 1 pc.