Exercise and data courtesy Benjamin Bromley.
A file ~p6720/examples/lcrs/lcrs.e_gax contains a list of galaxy data (v_r [km/s], theta [radians], phi [radians], Mag [absolute magnitude in broad-band red light]) from the Las Campanas Redshift Survey. As in Assignment 1, Ex. 3, treat the recession velocity v_r as a radial coordinate, so that (v_r,theta,phi) are standard spherical polar coordinates.
Use gnuplot to make a 2-D map of the galaxies in space, with
each galaxy represented by a single dot. Tip: in the file name
In you answer file, give a copy of only your gpl source file, gax.gpl.
To generate the random numbers, just type normdist. You will be
prompted for the mean, st dev, number of values, and seed. To
generate the histogram with hist, you should pipe the output
from normdist into hist. Use the -g option to
generate a file suitable for input to gnuplot.
In your answer file, give the Unix command and any gnuplot commands
for generating the file to be plotted.
Then plot the file. Generate a Postscript output file and display it
with gv.
Then run the command make whoyou. Make should compile your
code.
What happens when you rerun make whoyou at this point without
making any changes to whoyou.cc? (Answer in the answer file.)
Use your editor to change the source file whoyou.cc and save
the change. (This change can be as trivial as inserting an extra
space somewhere.) Then rerun the make command. What happens now?
(Answer in the answer file.)
Modify the Makefile by inserting the -g compiler flag right
after the g++ (suppresses optimization). Rerun the make
command. Does the change in the Makefile itself lead to a
recompilation? Note that if you add Makefile to the dependency
line to say
x = v_r*cos(phi)*sin(theta) and y = v_r*sin(phi)*sin(theta);
This transformation converts the data from spherical polar coordinates
to rectangular coordinates and projects onto the x-y plane. Label
both the axes of the map in these new coordinates to say "km/s". [Hint:
see the "set xlabel" command.] Choose the point size to be 0.05 so you
can see the detail in the scatter plot. Then set up gnuplot so that
it writes your plot to a postscript file called gax.ps.
Finally, put all the relevant gnuplot commands into a text file called
gax.gpl (you can use emacs or gnuplot's
save utility). The objective is to be able to create the
postscript file with the single command gnuplot gax.gpl. There
is no need to copy the data file to your accounts; use the absolute
path given above to reference the file.
Exercise 2. Histograms
Generate a histogram for a Gaussian normal distribution using the
course random deviate utility normdist and the histogramming
course utility hist. Generate a distribution with mean 5
and standard deviation 1. Do this with 1000 random points using
random number seed 373.
Exercise 3. make
In an exercise last week on simple
C++ compilation you played with a program whoyou.cc. For
this exercise, create a file Makefile in the same directory as
the source file whoyou.cc with the following two lines:
whoyou: whoyou.cc
g++ whoyou.cc -o whoyou
Be sure that the second line is indented with a TAB as the first character.
Be sure that you hit "Enter" at the end of the second line, so every
line in the file ends with an end-of-line.
whoyou: whoyou.cc Makefile
then a change in only the Makefile would force an update the next time
you run make whoyou.