IDL Tutorial: Day 2 - PowerPoint PPT Presentation

About This Presentation
Title:

IDL Tutorial: Day 2

Description:

2) Describe writing the simplest kind of programs. 3) Explain ... in the last year, number of trails hiked in the last year, and number of foods disliked. ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 8
Provided by: solarPhys
Category:
Tags: idl | day | hiked | tutorial

less

Transcript and Presenter's Notes

Title: IDL Tutorial: Day 2


1
IDL Tutorial Day 2
Goals1) Introduce functions and procedures2)
Describe writing the simplest kind of programs 3)
Explain saving and restoring
  • Angela Des Jardins
  • (desjardins_at_physics.montana.edu)

2
Functions and Procedures
  • Two basic types of programs
  • Functions
  • resultfunction_name(parameter, KeywordSet, )
  • Examples size, n_elements, sin, cos, reverse,
    where
  • - Functions can be placed anywhere you can put a
    value
  • Procedures
  • procedure_name, param1, param2, KeywordSet
  • Examples help, print, open, printf, plot,
    set_plot, device, save
  • - Procedures do stuff, but dont need to return
    a value
  • Exact syntax for particular Procedures or
    Functions can be found using the help menu, xdoc,
    or the doc_library procedure

3
Commonly Used Procedures
  • print for printing stuff to screen IDLgtprint,
    sin(x)
  • plot plot variables to the current graphics
    device (usually screen) IDLgtplot, x,
    y,titleblah,keywords
  • set_plot tells idl where to send plots to.
    Screen (Xdisplay) is default
  • - IDLgtset_plot,x sends output to the x
    display
  • - IDLgtset_plot, ps sends the output to a
    postscript file with default name idl.ps. Read ps
    files with ghostview
  • unix_promptgt gv idl.ps
  • device changes properties of the device
    currently enabled by set_plot. See help menu.

4
Save and Restore
  • Programs are saved by saving the text file you
    write them in
  • Save, the procedure, allows you to save variables
    to a file
  • Example
  • IDLgtsave, variable1, variable1, filefile.sav
  • Restore allows you to restore saved variables to
    a session
  • Example
  • restore, file.sav

5
Commonly Used Functions
  • Many math operators are functions
  • IDLgt ysin(x) IDLgt ycos(x) IDLgtyexp(x)
  • Where allows you to pick out the index of an
    array that meets some criterion
  • gt indexwhere(new_array eq 15)
  • (more on boolean operators later)
  • Replicate makes copies of variables, arrays,
    structures, etc...
  • gt starsreplicate(stars,15)
  • dialog_pickfile allows you to graphically pick
    out file names
  • gt file_namedialog_pickfile()

6
Macros (Scripts)
  • Simplest form of Program
  • In the editor window write commands just like you
    would at command prompt
  • At the end type END so IDL knows when program is
    over
  • Save the program with a unique name (i.e. save
    the text file)
  • At the command prompt type either
  • gt .run program_name
  • gt .rnew program_name
  • Shortcoming no loops allowed in macros.

7
Homework
  • Make a macro in which you plot, on a good scale,
    with labels, yex. Also, have it print to the
    screen, You did it right! Make a post script
    copy of your plot.
  • Make a file using emacs (or your favorite editor)
    which contains a row for each student in this
    class and a column for each of the following
    distance (in miles) of the students home from
    Bozeman, year in college, favorite color (in
    Angstroms), number of books read in the last
    year, number of trails hiked in the last year,
    and number of foods disliked . Use ascii_template
    and read_ascii to make a structure containing
    your numbers. Using the plot procedure, find out
    if there are any correlations among yourselves!
Write a Comment
User Comments (0)
About PowerShow.com