Computer Tips
Links to help you get you Mac set up for astronomy:
- A 64 bit suite of Python/Numpy/Scipy/Pylab/iPython that all work together on OS 10.6.X
can be found at this link. You
potentially need the gfortran compiler and fftw installed. But maybe not.
- To get find commander to properly load packages on OS 10.6.X, you probably need to
change the version of perl that it is looking for. More details at this
link.
To get CMBfast running on your Mac (intel version):
- download the source code here
- at the prompt type: gunzip cmbfast.tar.gz
- at the prompt type: tar -xvf cmbfast.tar
- obtain the open source intel binary of the gnu compiler g77 here
- at the prompt type: gunzip g77-intel.bin.tar.gz
- at the prompt type: sudo tar -xvf g77-intel-bin.tar -C /.
- start a new shell, or quit out of x11 and restart it
- in the cmbfast directory, run the following configure command at the prompt: ./configure --f77=g77 --f77-flags=-I.
- type make at the prompt
The secret here is that g77 cannot find the include files without the flag
-I.
Some Python Tricks:
- Want a legend on a plot with multiple histograms? The pylab hist
module returns more than you expect: the y values, the x values,
and the list of rectangles it drew on the screen. It's these latter
that you want to access for the legend. But you can't feed it the
the whole list of them, only one element of the list, say the 0th.
Here is an example code and picture.
- Simple movie making tool in python, here's a LINK
- If you want a value between 0 and 1 mapped to a color, you can use a colormap. More info
here
Some useful VIM Tricks:
- Re-distribute carriage returns so that text fits neatly in a window (add
carriage returns if there are none)
- Highlight the region by going to the
beginning and typing v (or control v), move the cursor to the end of the
region, and type g w => Done! (Many thanks to Jordan Carlson for teaching
me this.)
Tricks in the shell (csh):
- Make the shell set variables and do arithmetic
- To set a variable >>set gg=7
- To use it's value >>echo $gg will print "7" or >>cd run$gg will change
to the "run7" directory
- To add >>hh=`expr 1001 + $gg` Here the ` quotes cause the inside part
to be evaluated first, and passed to the outside part. Note: the spaces
before and after the + sign are vital here, this will not work without
the spaces.
- Multiplication uses the *, but you have to escape it from its usual
meaning which is a wild card, specifically >> hh=`expr 2 \* $gg`
Also, the shell
does not always use the same prioritization (multiplication/division
evaluated before addition and subtraction) so make sure it does what
you think it should do.