PHYCS 3730/5720
Assignment 2

Fall Semester 2000


Home | Announcements | Lecture Plan | Assignments | Exercises | References | Web Resources

This assignment requires some facility with gnuplot or sm. Help pages are available, just follow the links listed on the Web Resources page.


Exercise 1.

Here are some simple warm-ups related to printing:

a) Show how you set the environment variable PRINTER so that the unix lpr command sends output to a printer in South Physics Rm 205. Show how you would send something to the SP Rm 205 printers without setting the environment variable. (Hint: use an option of the lpr command -- see the man pages.)

b) On Physics Department machines, you are requested to use mprint instead of lpr. Find out what mprint does (which and more [or less] could be helpful here along with direct experimentation). Note that you will encounter a shell script in the process. Do not worry about the details, but it may help to kmow that if you type mprint blah blah, the script refers to the arguments blah blah with the symbol $*. The commands contained in the script are executed by the C shell (csh).

The exercise here is just to write down a command that has the same effect as

mprint lala.txt
and the user's choice of option 5 (this prints postscript on one of the SP 205 printers).

c) The Gnu enscript command is very useful for getting hardcopy of source code or other plain text documents. Describe the effect of the following:

enscript -2rh file.txt -o file.ps
Put your answers to parts a, b & c in a single textfile, print.txt, to be submitted.


Exercise 2.

This is an exercise dealing with generating 2-D plots using points, lines, and histograms.

a) A file /u/course/p5720/data/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. 4, 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. The galaxies all lie an a "survey volume" that is roughly shaped like two curved pizza slices with their pointed-ends touching at the origin. Plot x versus y where

x = v_r*cos(phi*sin(theta)) and y = v_r*sin(phi*sin(theta));
this transformation has the effect of unwrapping the pizza slices, originally in spherical polar coordinates, and flattening them down in a rectilinear coordinate system. Label the axes of the map in these new coordinates to indicate "distance" units of km/s. Choose the point type to be 0. 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). Ultimately, you want the gax.gpl file to be something with you can execute using gnuplot's load command; the net result of typing
gnuplot gax.gpl
should be to make the postscript file. Please do not copy the data file to your accounts; use the absolute path given above to reference the file. Submit only your gpl source file, gax.gpl.

b) With sm, make a histogram of the number of galaxies in recession-velocity bins of 500 km/s, from 0 to 60,000 km/s. Again, do not copy the data, use the absolute path to reference the datafile (i.e., the full filename -- use double quotes). Use the set command to trim off those galaxies with recession veolcities exceeding 60,000 km/s, and the calc command to get the average absolute magnitude of remaining data. Put the histogram, with axis labels, in the upper of two vertically stacked plotting windows. Note that at large recession velocities the number of galaxies in each bin is falling off with v_r as a result of the flux limit of the survey--at large enough distance (recall v_r is approximately a coordinate distance) even the brightest galaxies are not observed in a survey with a fixed detector limit on the *observed* flux.

In the lower window, use sm's connect command to plot the x-y data in /u/course/p5720/data/lcrs.dens (using this absolute pathname). The first column is the recession velocity v_r in units of the speed of light, and the second column is the number density of galaxies (arbitrary units) averaged inside v_r. The density was calculated by taking into account the distribution of the galaxies' intrinsic brightness, the limiting observed brightness threshold of the telescope, and the geometry of spacetime in an expanding universe as expected in the big bang scenario. The assignment here is simply to generate a 2D plot showing density (averaged within a region bounded by v_r) versus v_r. Use the greek symbol rho (\rho in sm) to indicate the density as the y-axis label and use v_r to label the x axis (the underscore "_" will make "r" a subscript). Use (and indicate in the axis label) units of km/s for recession velocity. Then have sm dump the plot to a postscript file dens.ps. Gather all the commands necessary to read in the data, plot the two panels, and write to the postscript file in a file called dens.sm. You may execute this file from within sm or simply redirect input so that sm executes the commands automatically by typing

sm < dens.sm
at your shell prompt. (In either case, sm should generate the postscript plot.) Submit only your "executable" sm script, dens.sm.

Files to be submitted for this exercise:

gax.gpl
dens.sm


Exercise 3.

This last exercise deals with representing 3-D data

A digital elevation model of part of the SLC valley is available from a website maintained by the U.S. Geological Survey. The data obtained as a result of USGS and Department of Defense programs, consist of elevation (in meters) on a regular square 2D grid.

The assignment is threefold:

a) Use either of sm or gnuplot to make a contour plot of SLC topography from the data stored in

/u/course/p5720/data/slc.map.gpl (for gnuplot)
/u/course/p5720/data/slc.map.sm (for sm)
(201x201 gridpoints. Formats are plot-utility specific: the gpl file is three-column x,y,z, with skipped lines as expected by gnuplot; the *.sm file is in sm's "C-format" -- see this link for more information.) ) Please do not copy the file; use absolute pathnames instead. Generate a postscript version of your plot and convert it to PDF using the unix utility ps2pdf, e.g.,
ps2pdf contour.ps contour.pdf
Turn in the PDF file, calling it contour.pdf, along with the plotting script (either contour.sm or contour.gpl) that you used to generate the plot. (The *.sm or *.gpl file need not generate postscript output.)

b) Same as part (a) except generate a surface plot of the SLC topography with these lower-resolution data:

/u/course/p5720/data/slc.map_thinned.gpl (for gnuplot)
/u/course/p5720/data/slc.map_thinned.sm (for sm)
(51 x 51 gridpoints). Again, please do not copy the file; use absolute pathnames instead. Submit a PDF file surface.pdf and the script (surface.sm or surface.gpl) that you used to generate the plot.

c) Make a color image of the SLC topography, starting with the PPM image file

/u/course/p5720/data/slc.ppm
(Please do not copy this data file). Use gimp or xv to view this file and to change the color map from black-and-white (where brightness correlates with elevation) to a scheme where blue indicates the lowest elevations green means higher elevations, yellow (mix green and red with no blue) is higher still, then red, and finally, for the highest peaks, white (mix red green and blue together). Save the file in jpeg format using the name color.jpg.

If you use sm for this exercise you may find useful information here. For gnuplot, try the online help under ?splot, ?contour and ?surface.

Files to be submitted for this exercise:

contour.pdf
contour.sm/gpl
surface.pdf
surface.sm/gpl
color.jpg

bcb 10-Sep-98, minor changes 10-Sep-99, 6-Sep-2000.