Programming in IDL 1
Programming in IDL 1
Programming in IDL 1
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Try the follow<strong>in</strong>g statements. The left column gives the statement you should type <strong>in</strong>to <strong>IDL</strong><br />
through the command l<strong>in</strong>e. The right column gives you notes <strong>in</strong> italics and questions <strong>in</strong> regular<br />
text. Record your <strong>in</strong>put and answers to the questions <strong>in</strong> an Emacs file.<br />
<strong>IDL</strong> Statements Notes and Questions<br />
> pr<strong>in</strong>t, 3*5 1. What happens if you don't use a comma?<br />
> pr<strong>in</strong>t, 3*5 ; Hello there! 2. What does the ";" do? (try it without the ; )<br />
> a=3*5 This equal sign is an assignment. Read this as "a gets<br />
the value of 3 times 5."<br />
> help,a<br />
> help,A<br />
> d=32767<br />
> pr<strong>in</strong>t,d+1<br />
3. What does help do? What's the difference between<br />
us<strong>in</strong>g a and A? “INT” means <strong>in</strong>teger.<br />
Integers run from -32768 to + 32768.<br />
4. What happened?<br />
> pr<strong>in</strong>t,d+1. 5. What is the difference between us<strong>in</strong>g d+1 and d+1.?<br />
> x = d+1.<br />
> help, x<br />
> pr<strong>in</strong>t,3/5<br />
> pr<strong>in</strong>t,3/5.<br />
> width = 20<br />
> height = 5*9<br />
> pr<strong>in</strong>t, width * height<br />
> a=[1,2,3,4,5,6]<br />
> a=[a,7]<br />
Float: Float<strong>in</strong>g-po<strong>in</strong>t, with six significant places.<br />
Double: Float<strong>in</strong>g-po<strong>in</strong>t with approximately sixteen<br />
decimal digits.<br />
Str<strong>in</strong>g: A sequence of 0 to 32,767 characters.<br />
One float<strong>in</strong>g number makes the result a float.<br />
6. Expla<strong>in</strong> what happened <strong>in</strong> these three l<strong>in</strong>es.<br />
<strong>IDL</strong> 1<br />
<strong>IDL</strong> variables can be (multi-dimensional) arrays. You<br />
can lengthen array A by add<strong>in</strong>g value at the end.<br />
7. Lengthen array "a" by add<strong>in</strong>g the number 8. Provide<br />
your command.<br />
> pr<strong>in</strong>t, a, 1E6*a S<strong>in</strong>gle precision: 6 significant digits, pr<strong>in</strong>t, a, 1D6*a Double precision: 16 significant digits<br />
> pr<strong>in</strong>t, a, 1/a<br />
> pr<strong>in</strong>t, a, 1./a<br />
> pr<strong>in</strong>t, a, a^2<br />
> pr<strong>in</strong>t, a, alog10(10^a)<br />
> a=1.*a Converts <strong>in</strong>to floats<br />
8. What's the difference between the output of these two<br />
l<strong>in</strong>es? Why?<br />
alog10 is what you normally mean when you write "log"<br />
> pr<strong>in</strong>t, a, alog10(10^a) 9. Expla<strong>in</strong> the output of this statement.<br />
> pr<strong>in</strong>t, a, alog(exp(a))<br />
> pr<strong>in</strong>t, a, acos(cos(a))<br />
> pr<strong>in</strong>t, a, a mod 2 12. What does “mod” do?<br />
10. Expla<strong>in</strong> the output of these two l<strong>in</strong>es (h<strong>in</strong>t: what is<br />
“alog,” “exp,” etc? Use idlhelp).<br />
11. Do the same as the above, but replace “cos” and<br />
“acos” with s<strong>in</strong>e and arcs<strong>in</strong>e. Provide your command.<br />
2