Presentation is loading. Please wait.

Presentation is loading. Please wait.

IDL Tutorials: Day 1 Michael Hahn

Similar presentations


Presentation on theme: "IDL Tutorials: Day 1 Michael Hahn"— Presentation transcript:

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

2 What is IDL Interactive Data Language- for easy manipulation of large data sets Many useful functions already in large library Used by - Nasa - Lockheed-Martin - Medical Imaging http://www.rsinc.com/ http://idlastro.gsfc.nasa.gov/homepage.html http://www.astro.washington.edu/deutsch/idl/htmlhelp/index.html http://www.ugastro.berkeley.edu/tutorials/tutorials.html http://www.lmsal.com/solarsoft

3 General Strategies Know the problem before you start programming Search to see if a similar problem has already been solved -IDL help menu (>?) - xdoc (sswidl) Don’t Memorize Use the help Screen Keep notes on your work Write programs in steps Learn by doing

4 Using sswidl(de) and Help SSW:= solar software, useful for solar physicists Calling sswidl or sswidlde calls IDL with specified paths - paths with useful programs for solar physics work To manually set paths talk to _______________ Calling sswidlde calls a developer - graphical interface - real time information about your code Any text editor can be used - nedit, emacs, pico, vi >? Calls up help index for information on procedures Help, [variable],[…] for properties of variable or status

5 Journal Procedure Records everything you enter into a textfile Syntax: IDL> journal, “text_file” ; opens the file & starts record IDL> command line statements IDL> journal ; closes the file IDL is not case sensitive but Unix is IDL> help, var = IDL> HELP, Var but IDL> journal, “text_file”  Journal, “Text_File” Open journal file with any text editor % nedit text_file

6 Basic Variable Types Strings - Text - Must be contained within “ “ or ‘ ‘ - cannot perform numerical operations Integers - only range from –32,768 to 32,767 Longword Integers - long(#) for 32 bit integers - long64(#) for 62 bit integers Float - floating point number with 32 bit word length Double - a floating point number with 64 bit word length

7 Assigning a Variable a Value 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 = double(value)

8 Naming Variables Assign ‘readable’ variable names that make sense Variable names must start with a letter - NO: 6a=“gamma” OK: a6=“gamma” Variables should not have the same name as IDL functions - NO: plot=6.0 Variable names may not have spaces in them - NO: A 6=5 OK: A_6=5 Some characters are illegal or have special meanings - NO: a@=5, a.b=5 (used for structures), A+=5, A#=5

9 Arrays Variables, of any type, that contain multiple values Array Indexing: IDL arrays start at index zero - e.g. A=[1,2,3,4] print, A[0] 1 print, A[1] 2 Multiple ways to create arrays intarr(), fltarr(), dblarr(), strarr() indgen(), findgen(), dindgen() - Look up the above in the IDL help (e.g. >? Intarr) Array operations, see the help menu or experiment

10 Structures Structures are variables that contain multiple variables (scalars, arrays, or other structures) Each variable contained within a structure is called a tag Syntax: struct={[struct_type], tag_name1: tag_value1,…} e.g. Stars={star_name, Name:”alpha centauri a”, $ spec_type:’g2 V’, coords:[“14 38.0”, “-60 44”],$ Distance:double(1.31)} Stars=replicate(stars,3) stars.name=[”alpha centauri a”, “alpha centauri b”, $ “alpha centauri c”] Print, stars.name Print, stars[0].name Note: you don’t need to name a structure type

11 Miscellaneous >? Gives you the help menu > ; starts a comment line and is ignored by IDL - often helpful to comment copiously $ tells IDL to treat the next line as if it is part of the current line IDL is case and space insensitive. Unix is not! Most math operators work just the way you’d think they do x=5*3-16 print, x


Download ppt "IDL Tutorials: Day 1 Michael Hahn"

Similar presentations


Ads by Google