IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures - PowerPoint PPT Presentation

About This Presentation
Title:

IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures

Description:

Many useful functions are available in large library. Used by - Nasa - Lockheed-Martin ... http://idlastro.gsfc.nasa.gov/homepage.html ... – PowerPoint PPT presentation

Number of Views:157
Avg rating:3.0/5.0
Slides: 15
Provided by: solarPhys
Category:

less

Transcript and Presenter's Notes

Title: IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures


1
IDL Tutorial Day 1Goals1) Introduce IDL
basics2) Describe fundamental IDL structures
  • Angela Des Jardins
  • (desjardins_at_physics.montana.edu)

2
What is IDL?
  • Interactive Data Language (IDL) is a powerful,
    interactive command language with all of the
    program control options of a standard programming
    language.
  • Many useful functions are available in large
    library
  • Used by
  • - Nasa
  • - Lockheed-Martin
  • - Medical Imaging Fields
  • http//www.rsinc.com/
  • http//idlastro.gsfc.nasa.gov/homepage.html
  • http//www.astro.washington.edu/deutsch/idl/htmlhe
    lp/index.html
  • http//www.ugastro.berkeley.edu/tutorials/tutorial
    s.html
  • http//www.lmsal.com/solarsoft

3
Note In this tutorial, IDLgt refers to the IDL
prompt.Once in IDL, you type the stuff that
comes after this. For example to enter the print
command, Ill have IDLgtprint,aand you would
type in print,a at the command line.Also,
brackets in an IDL description indicate an
optional item.
4
Starting IDL
  • In a terminal window, once an IDL path is setup
    (.idl_startup), type idl, idlde, sswidl, or
    sswidlde
  • sswidl IDL solar software, useful for solar
    physicists
  • Calling sswidl or sswidlde calls IDL with
    specified paths which have useful programs for
    solar physics work. Youll almost always use
    sswidl or sswidlde.
  • To manually set the paths needed for your work,
    talk to your research advisor
  • Calling sswidlde calls a graphical developer,
    where sswidl simply works in your terminal window
  • To use an OS command, enter prior to it
    IDLgtls Exceptions pwd, cd,/disk
  • To exit out of IDL, type IDLgtexit

5
Journal Procedure
  • Records everything you enter, plus any error or
    processing messages output by IDL, into a text
    file
  • Syntax
  • IDLgt journal,text_file opens the file starts
    record
  • IDLgt command line statements
  • IDLgt journal closes the file
  • To view, open journal file with any text editor
  • emacs text_file
  • Journal is also useful for starting a program you
    want to write, or for creating batch files

6
General Strategies
  • IDL help menu IDLgt?
  • sswidl (solar) help IDLgtxdoc
  • IDLgthelp, variable, /str For properties of
    variables and status
  • IDLgtwhich,program.pro Tells you which program
    youre using
  • To modify a program you want to call in IDL, many
    text editors can be used nedit, emacs, pico,
    vi
  • Dont memorize all commands
  • Keep notes on your work and use the IDL journal
  • Write programs in steps
  • Learn by doing - dont be afraid to make mistakes

7
Some basic syntax
  • IDL is not case sensitive but Unix is
  • IDLgt help, var () IDLgt HELP, Var
  • IDLgt journal, text_file (NOT ) journal,
    Text_File
  • Use the up arrow key to recall the most recent
    IDL input lines
  • Commas are used to separate arguments from one
    another
  • Use to enter more than one command on a line
  • Use at the end of a line that needs to continue
  • All programs end with .pro
  • comments out an IDL line

8
Basic Variable Types
  • Strings (Text)
  • - Must be contained within or
  • - cannot perform numerical operations
  • Integers
  • - only range from 32,768 to 32,767
  • Long word Integers
  • - IDLgtlong() for 32 bit integers
  • - IDLgtlong64() for 62 bit integers
  • Float
  • - floating point number with 32 bit word length
  • - IDLgt3./2. Or IDLgtfloat(3)/float(2)
  • Double
  • - a floating point number with 64 bit word
    length

9
Assigning a Variable a Value, math
  • Variable_name value
  • - will automatically select a variable type
  • Variable_name function_name(argument)
  • Variable_name string(value)
  • Variable_name long(value)
  • Variable_name fix(value) for integers
  • Variable_name float(value)
  • Variable_name double(value)
  • Math works the way you think it would
  • IDLgttry5./3.4.1
  • IDLgtprint,try 5.7667

10
Naming Variables
  • Assign readable variable names that make sense
  • Variable names must start with a letter
  • - NO 6agamma OK a6gamma
  • Variables should not have the same name as IDL
    functions (youll probably learn this the hard
    way switch example)
  • -NO plot6.0
  • Variable names may not have spaces in them
  • - NO A 65 OK A_65
  • Some characters are illegal or have special
    meanings
  • - NO a_at_5, a.b5 (used for structures), A5,
    A5

11
Arrays
  • Variables, of any type, that contain multiple
    values
  • Array Indexing IDL arrays start at index zero
  • IDLgtA1,2,3,4
  • IDLgtprint, A0 1
  • IDLgtprint, A1 2
  • Multiple ways to create arrays
  • intarr(), fltarr(), dblarr(), strarr()
  • indgen(), findgen(), dindgen()
  • IDLgtbfindgen(4)
  • IDLgtprint,b02 0.00000 1.00000 2.00000

12
Array operations
  • Simple math operations
  • IDLgtDfindgen(3)
  • IDLgtA2D
  • IDLgtprint,A 0.00000 2.00000 4.00000
  • More complex math
  • Manipulating arrays - multiply an array by
    another, matrix operations look in help
  • Useful functions
  • Total(array) computes a sum of all elements
  • Min(array) outputs the min value also Max
  • Minmax(array) outputs the min then max
  • N_elements(array) gives total of elements

13
Structures
  • Structures are variables that contain multiple
    variables
  • (scalars, arrays, or other structures)
  • Each variable contained within a structure is
    called a tag
  • Syntax structstruct_type, tag_name1
    tag_value1,
  • IDLgt listfrstfindgen(10),scndfindgen(10)2,thr
    dfindgen(10)1
  • IDLgt print,list.frst
  • 0.00000 1.00000 2.00000 3.00000 4.0000 5.00000
    6.00000 7.00000 8.00000 9.00000
  • IDLgt print,list.scnd2 4.00000
  • IDLgt help,list,/str
  • FRST FLOAT Array10
  • SCND FLOAT Array10
  • THRD FLOAT Array10

14
Homework
  • Try these examples (in IDL!) on your own
  • Print out the answer in double precision of
    Pi36.2
  • Make an array of 15 floating point numbers that
    count from 3 to 17.
  • Make a structure with four tags, each tag having
    5 values. Print the value of the third element of
    the second tag.
  • What is the name of the journal file you (should
    have!) created when practicing the above tasks?
  • What is one question you have about the basics of
    IDL?
Write a Comment
User Comments (0)
About PowerShow.com