Its important that you spend the majority of class time today on the second part of this tutorial, because a lot of new IDL commands and functions will be introduced. In this tutorial, I ask you to generate two figures to send me by Thursday Sept 25.

To students who electronically requested H205 accounts but have been unable to log in: Please email Joe Cammisa (jcammisa@haverford) and ask him to please create an account for you. For this to work, you must have already also clicked on the online account generator.

Making your first Hess diagram: Part 2

This tutorial exercise is intended to pick up where you left off last Thursday, and to guide you through the IDL you need to complete Project Set 2, Section 2, Question 2.

1. Go back and finish the Hess diagram tutorial for last Thursday, if you haven't already done so. This Hess diagram is scaled so that black = a relatively small number of stars and white = a relatively large number of stars. Reverse this scaling by simply reversing the sign on the 2d histogram that contains your Hess diagram. (i.e. maghist = -maghist). Once you have successfully debugged and created a good looking Hess diagram for a single Milky Way field, do the same for all four of the Milky Way fields.

2. Play around with the pixel sizes you are using for these CMD images. Iterate a bit until you find pixels sizes that look appealing - i.e. each pixel is large enough to have enough stars so that the pixel values are statistically significant, and is small enough to see features in the CMD.

3. Save these Hess diagrams to a .ps file and email it to me by class on Thursday Sept 25 (along with the figure you will create below). Its important that you spend a substantial amount of Tuesday class on the second part of this tutorial, so feel free to move on to that once you are comfortable making these basic Hess diagrams.

Calculating the measurement uncertainty on apparent magnitude in SDSS as f(m_r)

This tutorial exercise will substantially help you with Project Set 2, Section 1, Question 4. The new functions and IDL commands that you learn will also substantially help you with all programming-based assignments. We want to empirically determine the typical measurement error on stars in the SDSS data that we are using, as a function of apparent magnitude. We will then make a plot with IDL that shows sigma_r vs. r magnitude.

1. Start this tutorial in a new IDL program. Read in one of the SDSS data files you've been working with. It doesn't matter which one, because the data all come from the same survey and thus have the same measurement errors. Thus far, we've only used the ra, dec, and apparent magnitudes contained with these files. We will now also use the magnitude measurement errors, which we have been reading in as "uerr, gerr, ierr, rerr, zerr".

2. The function "AVG" returns the average value of an array and "MEDIAN" returns the median value of an array. Find the average and median r-magnitude measurement error of all stars in the data you've read in. Use the IDL Searchable Help to find the correct syntax for average. Now find the minimum and maximum r-band apparent magnitudes of stars in your dataset. An easy way to do this is with the "MINMAX" function.

3. Take an eyeball look at what the distribution of measurement errors looks like. Try doing this in a couple of ways. If you want to see these figures on the screen, you may need to now tell IDL set_plot, 'x' so that your figures pop up on the screen rather than in a .ps file. You can plot a quick histogram of the data with:

plothist, rerr, bin = 0.025

bin = 0.025 just sets the histogram bin size to 0.025 magnitudes. For this histogram to look sensible, you will need to play around with the xrange and perhaps also the bin size. (plothist takes the same xrange = [a,b] format as plot does). Now take a look at the magnitude measurement error as a function of apparent magnitude:

plot, r, rerr, psym = 4, xtitle = 'sigma_r', ytitle = 'r'

You will also need to play around with the xrange and yrange on this figure for it to look reasonable. You will likely need to play around with the symbol size as well, using the "symsize" keyword in your plot statement.

We next want to collapse the information contained in this 2 dimensional figure into a one dimensional numerical function - sigma_r = f(r).

4. Define an array containing values of r for which we want to evaluate this function. You could do this in a simple brute force approach by typing out an array of values. For example:

rvals = [15.0,15.5,16.0,16.5,17.0,17.5,18.0,18.5,19.0,19.5,20.0,20.5,21.0,21.5]

But also try something more elegant and versatile:

rval_max = MAX(r) ;the maximum value of r magnitude
rval_min = MIN(r) ;the minimum value of r magnitude
rval_bin = 0.25 ;in magnitudes
num_vals = 1.+(rval_max-rval_min)/rval_bin
rvals = findgen(num_vals)*rval_bin + rval_min
print, rvals

The findgen function generates an array of floating point numbers. Each element contains the number of its array position (hence "F"loating-point "IN"teger "GEN"erator... or something like that). In the above example, you created an array with num_vals elements. Play with the findgen function:

a = findgen(5)
print, a

Now define an empty array to contain the MEDIAN magnitude measurement errors at all of these values of r-magnitude.

avg_magerr = fltarr(num_vals)

For each element of this array (for each value of rvals), calculate the median magnitude measurement error. The error needs to be calculated within a range of r-magnitude. The range we will use is 0.25 mag, the value of rval_bin. There is a small bug in the below lines of code. This bug is something you can figure out yourself, so I'm not going to fix it... from here on out you won't have so much code written for you anyway :):

FOR j = 0, n_elements(rvals) - 1 do begin
inbin = where (r ge rvals[j] and r lt rvals[j] + rval_bin
avg_magerr = MEDIAN(rerr(inbin))

5. Visually check your results by overplotting them on top of the scatter plot of rerr vs. r that you generated earlier in this tutorial. Keep in mind that we've defined our rvals vector to be the bright magnitude limit of each r-magnitude bin for which we've found the median measurement uncertainty. Email me this figure (along with the set of 4 Hess diagrams) by class on Thursday Sept 25.

6. If you have successfully completed all of the above, then start to work on Project Set 2, Section 1, Questions 3 and 4.

Last modified: Thu Sep 25 09:09:30 EDT 2008