Academics:Astro480

From Astronomy Facility Wiki

Jump to: navigation, search

Contents

Can we actually see anything from Seattle??

Seattle clear sky predictions

Astronomy 480 Class Wiki

We will use this wiki to keep current on possible modifications, tips, and tricks pertinent to the various techniques and exercises that will be used throughout the quarter. Remember that this is a wiki - that means that you can edit it as well, so when you find mistakes or figure out a more efficient way of doing something, make sure you share it with the rest of us! I (Rok) am by no means the world's expert on all things IRAF or computing, so please keep these notes up to date with your own experience!


Initial Setup

We've decided to go ahead and use a slightly more user-friendly version of IRAF (I know, it sounds like an oxymoron) called pyraf - it's actually still the same old IRAF but dressed up nicely. This simplifies a lot of things and brings some of the nice functionality that we enjoy in linux to the IRAF command line. It also means that there are a few practical differences in the way we'll set everything up.

Environment

To start, we need to modify and simplify your overall Linux environment a bit. Right now, your environment is set up through a number of files in a subdirectory called ENV in your home directory. If you're not aware of its existence, that's fine, don't worry about it - if you are aware of it and you've modified the ~/ENV/.cshrc.personal file or any of the other files in there, we'll need to be a bit more careful, but it shouldn't be too dificult. We won't touch any of the files in ~/ENV, so we can always revert to your old setup if needed.

For now, from your home directory simply do

  cp .cshrc .cshrc_old
  cp ~roskar/.cshrc_basic .cshrc

this will backup your existing set up and copy the basic environment set up to your home directory, which includes proper definitions for IDL, IRAF and other astro software that we'll need.

Log out and log back in - everything should look more or less the same on the surface - if so, then we're OK.

Pyraf

One of the subtle advantages of pyraf is that, unlike regular iraf, it doesn't require you to have a login.cl file in the directory where you start the program - it simply requires that you have a login.cl file located in a directory called "iraf" in your home directory. So, if you don't already have it there, type

 mkdir iraf 

from your home directory.

If you've already done the "Getting the Computer Set Up to Run IRAF" exercise, then you've created a directory for yourself in /net/projects/Astro480 and you've run mkiraf in there - all you need to do now is copy the login.cl file from that directory to your newly-created iraf directory and you're done. If you haven't done the set up exercise, then simply run mkiraf in the iraf directory we've just created and you'll be fine.

Symbolic Links

Directory names can get to be *really* long in Linux - that's why we can use symbolic links to make our lives easier. A symbolic link works like a shortcut. So, for example, it would be a pain to have to type /net/projects/Astro480/Spring08/roskar every time I wanted to get to my exercises for this course. Instead, I create a *symbolic link* to that directory by typing

  ln -s /net/projects/Astro_480/spring-08/roskar Astro480

from my home directory. Now, in my home directory, there is a link called "Astro480" and typing

  cd Astro480 

takes me immediately to /net/projects/Astro_480/spring-08/roskar which saves me lots of typing.

Changing the size of xgterm

xgterm by default uses a very small font size - to change this, try running xgterm with something like:

 xgterm -fn 10x20

This should give you a window with larger (easier to read!) fonts.

Installing IRAF at home

Scisoft can be used to install IRAF on Macs and on Linux provided you are running Fedora Core 6.

http://www.eso.org/sci/data-processing/software/scisoft/

It can sometimes be made to work for other versions of Linux. The workaround install method usually requires installing the entire Scisoft collection.

http://www.eso.org/sci/data-processing/software/scisoft/INSTALL_Jun2007

Here is a good guide for installing IRAF more directly on Ubuntu 7.04 32-bit. It also works on the current 7.10 release, and should also work for many other 32-bit Debian-based distros.

http://astronomy.byu.edu/jake/ubuntu.php?page=iraf

You may not have xgterm available by default. You can test this by attempting to run it. If it is missing, go to your /usr/local/bin/ directory, and execute the following. Operations within this path will require admin privileges. For Ubuntu & similar, prefix the commands with sudo.

  wget ftp://iraf.noao.edu/pub/xgterm.fedora
  mv xgterm.fedora xgterm
  chmod 711 xgterm

You will also likely need to install ds9. This can usually be accomplished either through Synaptic Package Manager (search for saods9) or through aptitude (apt-get install saods9). Sometimes this version will give errors when you execute the display command from within IRAF. If this is the case, obtain a binary version of ds9 and place it in /usr/local/bin.

Consult Michael Hutchinson's guide for installation under 64-bit Debian-based distros.

http://mjhutchinson.com/journal/2006/11/05/install_iraf_on_ubuntu_edgy_amd64

Fun with simple shell scripts

You can automate a few things via very basic scripts, which can then be started from a launcher icon. It is easiest if you put the script in your home directory, but you can put it elsewhere if you include the path when executing it. Scripts should always end with a blank line to keep things from exploding (.dat files too, but that's another story). The launcher type should be Application and *not* Application in Terminal for these.

Instant IRAF - brings up a complete IRAF + DS9 session. No more forgotten steps or long startups!

Launcher command should be:

  xgterm -e './yourscriptname'

Script should contain:

  ds9 &
  cl -ecl
  

SSH to the lab - straight to the password prompt. If you don't have or like gnome-terminal, substitute something appropriate - the syntax works for a number of the options. A good backup plan is to change it to xterm. (DS9 seems to behave very poorly over SSH, so you may want to install IRAF & DS9 locally - but this will give you access to the high-cost stuff like IDL and SuperMongo, as well as your 480 files.)

Launcher command should be:

  gnome-terminal -e './yourscriptname'

Script should contain:

  ssh -X yourusername@astrolab03.astro.washington.edu
  


Printing in IRAF

For some reason, the usual way of printing from the graphics window doesn't work. But, there is (luckily) a pretty easy workaround. Just follow these simple steps:

  • create a wonderful, insightful plot
  • switch the cursor over to the plot window (if you're using imexam you do this by typing 'g' while the focus is in ds9)
  • in the graphics window, type (note the '.'!!!!)
  :.write myplot
  • this created a file called 'myplot' in your current directory containing the plot information
  • exit the plotting/imexam by typing 'q'
  • create a postscript file with the plot that you can email, print, etc by
  cl> stdplot myplot dev="eps"
  • now you can open up the plot using any postscript viewer

IRAF Exercise 1

Dynamic range of display command

The default behavior of the "display" command can be a little funny - for example, if you open up the test-f1.fits file by typing

  display test-f1 1

you will not be able to see the overscan region at all, no matter how you try to adjust the scaling with your cursor. That's because by default, the display command scales the pixels linearly - the overscan region is by default the lowest signal (bias) so it doesn't show up because the dynamic range of the display is not large enough- but that doesn't mean the overscan isn't there! To fix this open up the display parameters with

 epar display

and set the value of "ztrans" to "log" - this makes the scaling logarithmic, allowing us to see both, the low and the high end values. Now repeat the display command and open up the image again - you should be able to see the overscan region with the right contrast adjustment.

Characterizing the CCD exercise

Finding the band gap energy using IDL

The exercise asks you to plot the data in excel and fit an exponential to it, but I'd like you to start thinking about doing things like this in IDL - so please try to complete this exercise in IDL. Please print out and turn in whatever code you end up writing!

To get you started, you'll first need to follow the instructions above under *Environment*. Then you'll need to create an idl directory in your home directory and copy a file called "idl_startup.pro" there - this file includes some useful definitions that I've set up, mainly to make plots more readable by increasing the default character size and line thickness etc- feel free to change it, it's yours to play around with. The file you want is

 ~roskar/Astro480/idl/idl_startup.pro

so copy that to your idl directory.

If you've never used IDL before (or maybe never programed before), I would strongly advise you to try this anyway - it might take a little more effort now, but IDL is widely used by astronomers and has lots of useful routines built in that will make your life easier in the future. Luckily, you don't need to know a whole lot about IDL to do this exercise, but to get you started, take a look at this quick tutorial as well as this tutorial - this will introduce you to basic concepts of the IDL programming language, including useful stuff like plotting. Please ask me (Rok) questions if any of it isn't making sense! There's no reason to bang your head against the wall (too much) at this point... to start IDL, just type idl at the command prompt. This will start the IDL environment.

A few useful hints:

  • the online help is really good - learn how to use it and use it frequently - to access it just type ? at the 'IDL>' prompt
  • use the IDL libraries browser to find routines which aren't included in the standard IDL package - there are many astronomy-specific libraries that will make your life easier!
  • USE THE PROCEDURE READCOL (FIND IT IN THE LIBRARIES BROWSER) TO READ IN YOUR DATA!

Now, to do the exercise, you'll want to enter the table data into a simple text file and then read this text file into IDL (see the hint above), so that you'll have an array of temperatures and an array of corresponding dark current values. You can now easily plot and manipulate this data within IDL. When plotting, make sure to include axis labels and units - a plot without proper labels is completely useless!

To do the fits, you will want to read up in the help documentation about the function "curvefit". This procedure requires a separate function that defines what you are trying to fit, in this case an exponential. I've prepared this function for you - copy over to your directory:

 ~roskar/Astro480/idl/expfunc.pro

This function takes an input x value and returns f(x) as well as partial derivatives of your function with respect to the fitting variables. I.e. we have f(x) = a*exp(-b*x) + c, and the function also computes df/da, df/db, and df/dc and returns this information to the fitting routine.

The way to call curvefit is something like

 fit = curvefit(x, y, weights, A, function_name = 'expfunc')

We don't have any sensible way of weighting the data points, so leave weights as a dummy undefined variable (i.e. don't worry about defining it prior to the curvefit call). The variable 'A' holds the actual parameter values - you need to set it before calling curvefit, and whatever values you set are used as initial guesses to curvefit. 'A' is an array with an element for each of your parameters (free or fixed!). So, before the curvefit call you might do something like

  A = [1,2,3]

in the case where you have three parameters you're fitting. If you're lucky, curvefit completes and when it finishes, the variable 'A' holds the fitted values of your parameters. The way I've set up expfunc.pro, f(x) = a*exp(-b*x)+c so A[0] = a, A[1] = b and A[2] = c.

Note that fitting is a bit of a black art - if your initial guesses are too far off, your fits won't converge. Try to make these initial guesses educated! What do you expect for the value of the constant inside the exponential? Try plotting both, your actual data and a few guesses for the model parameters, to see roughly what the values should be. If you're having trouble with the fitting, please come see me or email me. If the fitting seems to work OK, but you're getting an error that your fit didn't converge after 20 iterations, try setting the maximum iterations to something larger like

 itmax = 1000 

itmax is a keyword in curvefit, so to set its value you simply add it to the curvefit call, as in

  fit = curvefit(x, y, weights, A, function_name='expfunc', itmax=1000)

Also, the function expfunc.pro includes a baseline offset, i.e. it's a function of the form y = a*exp(b/x)+c - we know that c must be zero (because we know the function we are trying to fit). There is a way to tell curvefit to hold certain parameters fixed, so make sure you do so!

  • HINT: to fix the third parameter, look at the "fita" keyword for curvefit in the IDL help browser

Technically, we shouldn't be fitting the "constant" in front of the exponential because we could determine all of those values by hand, but it'll work OK if we just leave it as a free parameter for now.

How can you know if your fit is reasonable? Simple - overplot the function on top of the actual data (hint: use the oplot procedure)!

Extra bonus: can you modify the fitting procedure to do the fit properly, i.e. without ignoring the T1.5 factor?

Last minute hint: The difference between IDL exploding with random and unpredictable errors and actually parsing your data on this one can be surprisingly small no matter how high you set your itmax. If IDL is spewing a bunch of CHISQ increasing and FP over/underflow errors, you probably need to fix your guesses.


IRAF Exercise 2

question 5 hints

You can change many parameters for the fitting functions used with imexam from within imexam - no need to exit the function and doing epar rimexam. Try this:

  • do a fit to a star of your choice using the 'r' command within imexam - this should display the pixel values as a function of radius and overplot the fit
  • now type '?' - a help listing opens up in your terminal window - you can move up and down with 'u' and 'd' keys - go down to where "Colon Commands" section begins
  • the "Colon Commands" correspond to many of the parameters used in epar rimexam - a very useful feature is that we can change the fit radius without exiting imexam!
  • type ":radius 4" for example, to change the fitting radius to 4 pixels - note that the ":" prompt is displayed in the plot window
  • when you change the radius, the plot is automatically updated, allowing you to see right away what effect your parameter choices are having on the fits and you can read off the fit results such as FWHM and magnitude immediately

Planning Your Observations

Worrying about Galactic Extinction?

If the science that you're attempting is sensitive to galactic extinction (faint extragalactic work, precise colors of stars in a cluster etc.) you'll want to use the NASA Galactic Dust Reddening and Extinction Tool to assess the implications.

Defining a Galaxy Sample

There is a nifty tool for defining galaxy samples called the HyperLeda. It will return a list of objects given your constraints. So, for example, you can specify a range of RA and DEC, a range of galaxy hubble types, a range of inclination angles etc. So, if you want to observe edge-on spiral galaxies, you could define a sample that includes only galaxies of hubble type t = 4 or later and has an inclination angle greater than 80 degrees. To start defining your sample, here are some things to consider:

  • what is the range of RA and DEC you can observe? Figure out which RA/DEC ranges are observable in May when the moon is new (you really don't want to observe galaxies with the moon in the sky)
  • which types of galaxies do you want? Limit the range of hubble types you're interested in
  • Size? This is important! You want just the right size galaxies so you get maximum information about the galaxy, but still have enough space on the CCD for things like sky subtraction or dithering
  • Luminosity - we have a small telescope, i.e. we can't observe dwarfs so choose bright galaxies (maybe you want to ask students from previous years what surface brightness objects they were able to observe)

In HyperLEDA, you'll want to do an SQL search. Spend some time reading about the different parameters and how they are defined (most of them are a little counter intuitive). Figure out what constraints you want to impose and try to construct an SQL query. Here's an example:

 select pgc, objname, al2000, de2000, type where de2000 > 70 and al2000 < 1 and t > 1

This will spit out a list of object names (objname), their RA and DEC (al2000 and de2000) and morphological type (type) based on the constraints that the DEC > 70 degrees, RA < 1 and hubble type greater than 1 (corresponding to Sa).


Figuring out exposure times for extended objects

Extended object surface brightness is measured in units of magnitudes per square arcsecond - this isn't the same as point source magnitudes! Usually exposure time calculators only work for point sources "out of the box" and you need to tweak their output to estimate exposure times for extended sources. Luckily, you can trick the exposure time calculator to give you estimates of S/N for a given surface brightness. Here's how it works.

This calculator gives you an estimate for number of sky photons - but you can give it any value for sky brightness you want. Sky is measured in mag/sq.arcsec, which are the same units as any other extended source. So, in principle, we can use this to estimate the number of photons we would get from an extended source of a given surface brightness. Then, to estimate the S/N for a given surface brightness, repeat the process to get the actual number of sky photons, plug into the S/N equation (we get the read noise for free as well) and that's it. We'll see if this simple trick actually holds up when we observe!

IRAF Exercise #4

Printing out your magnitude plot

the tutorial asks you to print out your magnitude plot - a good way to do this is to output the plot to a file and print it out using evince or something similar. This is very simple to do, just modify the command on pg. 5 of the exercise to be:

  txdump m920004.mag.1 mag, merr yes | graph point+ device="eps"

The plot is now saved in your current directory in a postscript file with some bizarre name like sgi6268.eps. Go one step further - do "lpar graph" and notice that there is a way to set the x and y axis labels... make sure your plots have labels on them!

Of course, the alternative is always to export the data to a file and use IDL to make the plots.


IRAF Exercise 6

Making multiple panels in IDL

to create a plot with multiple panels on one page, you need to define the !p variable. To get two panels arranged vertically, do

 !p.multi = [0,1,2]  - this means 1 column, 2 rows

similarly, to get them arranged horizontally, do

 !p.multi = [0,2,1]

To reset to single panel plotting, do

 !p.multi = 0


Specifying exact plot ranges

To make visual comparison of scatter reasonable in this exercise, you need to specify your y-range exactly. IDL typically takes the liberty of changing your range slightly in order to make it look better. But, to force it to use the range you specify, do something like

  plot, x, y, yrange = [-1.2,1.2], ystyle = 1

the "ystyle = 1" keyword tells it to use the exact range specified.


Observing Projects

How to align and combine a series of images

When you take a series of exposures of an object, the object will likely shift slightly in your frame. To get a properly co-added final image, you need to correct for the image offsets. A good explanation on how to accomplish this with IRAF is here.

We've tested this with AWO data and have added additional clarifying examples. It's not clear from the above web page just how the 3 individual files relate to each other. Please see: [1].

Personal tools