1 / 8

IDL Tutorial: Day 2

IDL Tutorial: Day 2. Michael Hahn (hahn@solar.physics.montana.edu). Today’s Topics. Using Functions and Procedures already written - e.g. plotting Xdoc Writing Scripts (Macros) Save and Restore Structures. Functions and Procedures. Two basic types of programs Functions:

tacita
Télécharger la présentation

IDL Tutorial: Day 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IDL Tutorial: Day 2 Michael Hahn (hahn@solar.physics.montana.edu)

  2. Today’s Topics • Using Functions and Procedures already written - e.g. plotting • Xdoc • Writing Scripts (Macros) • Save and Restore • Structures

  3. Functions and Procedures • Two basic types of programs • Functions: result=function_name(parameter, Keyword=Set, …) Examples: size, n_elements, sin, cos, reverse, where - Functions can be placed anywhere you can put a value • Procedures: procedure_name, param1, param2, Keyword=Set… Examples: help, print, open, printf, plot, set_plot, device, save - Procedures do stuff, but don’t 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

  4. xdoc • Xdoc allows you to graphically brose the lbirary of Solarsoft routines • Type in xdoc at IDL command prompt • Can search for the name of a procedure/function • Usually you don’t know the name, xdoc makes it ‘easy’ for you to search for it

  5. Commonly Used Procedures • print: for printing stuff (to screen) e.g. > print, sin(x) • plot: plot variables to the current graphics device (usually screen) > plot, x, sin(x), Title=“sin Plot”, xtitle=“x”, $ ytitle=“sine of x” • set_plot: tells idl where to send plots to. Screen (Xdisplay) is default - set_plot,”x” ;sends output to the x display - set_plot, “ps”; sends the output to a postscript file with default name idl.ps. Read ps files with ghostview unix_prompt> gv idl.ps • device: changes properties of the device currently enabled by set_plot. See help menu.

  6. Commonly Used Functions • Many math operators are functions > y=sin(x) > y=cos(x) >y=exp(x); exponential function • Where allows you to pick out the index of an array that meets some criterion > index=where(new_array eq 15) (more on boolean operators later) • Replicate makes copies of variables, arrays, structures, etc... > stars=replicate(stars,15) • dialog_pickfile allows you to graphically pick out file names > file_name=dialog_pickfile()

  7. 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: > .run program_name > .rnew program_name

  8. 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: save, variable1, variable1, file=‘file.sav’ • Restore allows you to restore saved variables to a session Example: restore, ‘file.sav’

More Related