In Class Assignment: IC2

Due 9/15 11:59PM

You should be doing this assignment on serenity.
Put solutions for each problem in a file called IC2.txt

1. cd into ~dpawlows/Practice. We are going to use the files in this directory to practice using wildcards/basic regular expressions. Note all commands that you are using to complete each task in your text file.

2. Somewhere in one of the sub-directories in the directory ~dpawlows/ on serenity, there is a file called sunspot.dat. Find it using the find command. Then, using a set of commands in a single line (i.e. execute all commands with a singe press of the enter key. Look at the use of the semi-colon, ;, in the command line), create a directory called data in your home directory, copy the file to that directory, and use the wc command to determine the number of lines and words in the file. Note the commands that you used and the results of wc.

3. Answer the following questions:

4. The file ~dpawlows/Public/Phy380/IC2/lcrs.bright_gax contains a list of data from galaxies observed in the Las Campanas Redshift Survey. Copy it to your newly created data directory. The file is a 4 column text file except that the first few lines contain comments (this is the file header); the first column is recession velocity (km/s), the second two are polar angles theta and phi, the last is Absolute Magnitude in red light. In what follows, treat recession velocity, v, as a radial distance so that the first three columns describe spherical coordinates in 3D space, with the origin at the sun. (To get an approximate real distance, just divide v by the Hubble parameter, believed to be around 60-80 km/s/Mpc, where 1 Mpc = 1 megaparsec = 3.086x10^24 cm.) Note that absolute magnitude is a measure of the intrinsic brightness or luminosity (emitted energy per second) of a galaxy. For historical reasons, more negative numbers mean brighter objects.

Use the grep command to strip off all lines containing comments (what do comment lines have in common?) (there may be a useful flag for this!!!!) and use redirection to create your own purely numerical data file. Then, write the commands that you used in IC2.txt.

Use the sort command on the numerical data file that you created to find:

a) the smallest and largest recession velocities

b) the recession velocities of the brightest (most negative Absolute Magnitude) and faintest galaxies.

c) the absolute magnitudes of the ten slowest receding galaxies and the absolute magnitudes of the ten fastest. Only output 10 lines, not all of them, and use redirection to put those 10 lines in a file. The head and tail commands may be useful here. Also, I don't want four columns of data here. Only output the recession velocity and the absolute magnitude. You should be doing all sorts of fun stuff on this one, including piping and redirection! Once you get all of this working, use the commands to redirect both sets of 10 lines to append to IC2.txt. Then add the commands that you used to do this to IC2.txt.

d) The data were taken from a survey that used flux limits to determine which galaxies were to be observed. This means that galaxies had to have an observed brightness which was brighter than a certain threshold in order to be included in the survey. Are your results in part b) consistent with this fact? Explain qualitatively.

5. Don't make a copy of this file, just take a look at ~dpawlows/UpperAtmosphere/Weather/2017.dat using the more or less commands. Don't copy that file, it's big! Let's say you were writing code that needed to grab only the tmax (only the number, no other information) for each weather station (the first column tells you the station identifier). Figure out the command that you would use. Then write that command in IC2.txt. Careful, this is a large file...


Use the submit command to submit your files:

 submit IC2 IC2.txt