Setting up the simulation

### Halo finding and mergertrees

Option 1

Please let me know if you run into issues/bugs using these codes. Also, if you use these codes in your research, please cite Sinha and Holley-Bockelmann, 2012, ApJ, 751, 17. Note, that the second code only creates the interaction network, you will still need to tag interactions individually.

Option 2
• Get ROCKSTAR - phase space halo finder by Peter Behroozi
• Note that there is a bug in fast3tree.c in cases with periodic boundary conditions (i.e., all cosmological simluations). Line 251 should be:

if (c[i]+r > node->max[i]) return 0;

Update: Fixed in version 0.99.9 released Mar 13, 2013.

Option 3

### 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 on Fanning's website. The following are arranged in the order that they came to my mind and are probably 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 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)
•
Array Subscripting: Again an IDL 'feature' appears to be very dangerous. IDL will clip out of range subscripts (by wrapping the indices) and continue on silently. Thus, you will be able to access the 200th element in a 100 element array. To me is a problem with the code that I would have liked to know about. You can get around this by putting the following line in your start-up file.

compile_opt strictarrsubs

All of these compile_opt statements need to be put in *every* program that you ever write; otherwise, the default behaviour of IDL will be in effect. The compile_opt options in your startup file only affects your command-line environment.

• Type conversion: Most type conversion functions, e.g., fix, long will essentially chomp off the extra bits to return the appropriate number. However, byte will return modulo 256. So, if you try to force a range of 0-255 by using byte, then the numbers greater than 256 will wrap around and begin at 0. This can have some disastrous results if you happen to use that byte-returned value as a color index. High color indices will now actually get mapped into the low color indices. If you really, must do this, first use fix and then use byte to map into the color table.

### 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).
The booktabs tabular package in LaTeX

Have you ever been in a situation where you want to do a \cline but the neighbouring \cline's join and produce one continuous line. If so, the booktabs package is the solution. Here is the pdf for the booktabs manual

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)

Wrapping long commands in bash

I had a big problem in bash where commands extending beyond the line would not wrap and start over-writing the front of the line (i.e., the PROMPT and so on..). The fix for this situation is:

set horizontal-scroll-mode on

Copying hidden files with scp (on linux)

If you are copying files with scp, the typical usage

scp -pr source/* dest 

will only copy he normal files and ignore the hidden files. If you want to copy those hidden files/directories as well, you will need to use this command instead:

scp -pr source/. dest 

(And yes, I/you should really be using rsnync instead)

### 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.