Name _____________________________________________ Date ______________

Astronomy 421 IDL Assignment 1

Start IDL. We are going to use the JOURNAL function to start a journal file and record your session for emailing to your instructor before the assignment due date.

Before you get too far along in this assignment, it's best of you practice starting and stopping a journal file. Inspect the file to see what kinds of communications between you and the IDL session are actually recorded. Journal files are actually written to disk by IDL only after another JOURNAL command or EXIT. It would be horrible if you put in hours of work and all was lost.

NOTE: There are questions embedded within this exercise. You can include them in your work as follows at the IDL prompt:

IDL> ;this is an answer to one of the questions posed within this exercise

IDL> ;the semi-colon tells IDL to ignore what comes after it, but my instructor won't

Before starting the exercises, give the IDL command:

IDL> ON_ERROR,1

This will return control to the main program level if an error occurs in a called routine.

Practice with Scalars and Strings

  1. Define X and Y to be two different integers
  2. Print their sum and difference to the terminal screen
  3. Repeat, all on one IDL command line, using the "&" character
  4. Print the result of adding 3 times X to 2 times Y
  5. Print the product of (X-Y) and (X+Y)
  6. Test which variable is the smaller of the two integers and print the answer.
  7. Print the common logarithm of the absolute value of X+Y (use the ABS and ALOG10 functions)
  8. Confirm this result by raising 10.0 to the power you just obtained
  9. What is the difference between X = 5/2 and Y = 5./2 ?
  10. Between X = FLOAT(5/2) and Y = FLOAT(5)/2 ?
  11. String example: define a string variable for each word in the sentence: "This is a concatenation"; then concatenate them and print the result.

Simple Array Functions

  1. Create a 2-D array, A, with 5 columns and 3 rows using the INDGEN function
  2. Print the array to the screen and verify its structure and contents
  3. Now let B=[0,1,2]
  4. Predict (writing your answers next to the equations below), then verify, the outcome of the following operations:

C = A+1

C = A*0

C = A^2

C = A*(A+3)

C = A/A

C = EXP(A)

C = A+B

C = A*B

C = A(*,2)*B

C = A(4,2)*B

When we calculate the absorption coefficient for atomic hydrogen, we are going to need something called the gaunt factor. For the gaunt factor for bound-free transitions:

Here, m represents the quantum number of the m th state, and x is the inverse wavelength, with the wavelength in microns. Here is a table of the coefficients a, b, and c:

m

am

bm

cm

m

am

bm

cm

1

0.9916

0.09068

-0.2524

6

1.097

0.

0.

2

1.105

-0.7922

0.4536

7

1.098

0.

0.

3

1.101

-0.329

0.1152

8

1.

0.

0.

4

0.9736

0.

0.

9

1.

0.

0.

5

1.03

0.

0.

10

1.

0.

0.

Construct 3 arrays a, b, c of 10 elements each, with these coefficients. Call the dependent variable something like 'gauntbf.' Notice that decimals are included for all of the values. This is to ensure that IDL recognizes the numbers as floating-point and not integer. (It may not make a difference, but in old programming switching between floating-point and integer caused unexpected bad results.)

We will work with these arrays further in assignment 3, but, for now test your program for m = 2 and a wavelength of 5000 Angstroms (how about converting the wavelength to inverse in microns within the IDL program?). Remember: your array indices start with '0' so you don't want a[2], b[2], or c[2] . Which array elements do you want?