Learn IDL - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Learn IDL

Description:

An Introduction to Using IDL in Meteorology ... PLOT, smoothed, TITLE = 'Smoothed with boxcar average' June 9, 2006. Basic Programming ... – PowerPoint PPT presentation

Number of Views:393
Avg rating:3.0/5.0
Slides: 25
Provided by: thomas323
Category:
Tags: idl | boxcar | learn

less

Transcript and Presenter's Notes

Title: Learn IDL


1
Learn IDL
  • Wei Huang
  • huangwei_at_ucar.edu
  • Consulting Services Group
  • Scientific Computing Division

2
What is IDL?
  • IDL - Interactive Data Language
  • The company
  • ITT Visual Information Solutions
  • http//rsinc.com/idl/

3
Start IDL
  • Start IDL
  • idl, or
  • idlde
  • Command Line
  • PRINT, Hello, World!
  • Quit IDL
  • exit

4
Reference/Tutorial
  • Tutorial over Internet
  • http//www.msi.umn.edu/software/idl/tutorial/
  • http//amath.colorado.edu/scico/tutorials/idl/
  • An Introduction to Using IDL in Meteorology
  • http//cgam.nerc.ac.uk/visualisation/idl/guide/idl
    .pdf

5
IDL Variables
  • Commonly Used Variables

6
IDL Variables (Continued)
  • User can define new type (structure)
  • Dynamic (automatic) type definition
  • Array index starts from 0 (like C)

7
Getting Started with IDL-Command Line Input
  • Start with XY-Line Plot
  • Making a Dataset
  • original SIN((FINDGEN(200)/35)2.5)
  • PLOT
  • PLOT, original

8
Plot and Processing
  • Making a New Dataset
  • noisy ((RANDOMU(SEED, 200) - .5) / 2)
  • Plot
  • PLOT, noisy
  • Plot them together
  • PLOT, original, THICK 3,
    XTITLE Time, YTITLE Amplitude
  • OPLOT, originalnoisy

9
Files and Input/Output
  • Write data to a file, formatted
  • OPENW, 1, original.dat
  • OPENW, 2, noisy.dat
  • PRINTF, 1, original
  • PRINTF, 2, noisy
  • CLOSE, 1
  • CLOSE, 2

10
Files and Input/Output (Continue)
  • Read data from a file, formatted
  • base FLTARR(200)
  • pert FLTARR(200)
  • OPENR, 1, original.dat
  • OPENR, 2, noisy.dat
  • READF, 1, base
  • READF, 2, pert
  • CLOSE, 1
  • CLOSE, 2

11
Files and Input/Output (Continued)
  • IDL can handle lots data format
  • ASCII
  • Formatted, free-format
  • Binary
  • C-binary, Fortran-binary, etc.
  • NetCDF
  • Network Common Data Form
  • And More

12
More on Plot and Processing
  • Processing with SMOOTH
  • full base pert
  • smoothed SMOOTH(full, 5)
  • PLOT, smoothed, TITLE Smoothed Data
  • Filtering
  • y FINDGEN(200)
  • y101199 - REVERSE(y199)
  • filter 1.0 / (1 (y/40)10)
  • PLOT, filter
  • lowpass FFT(FFT(full, 1) filter, -1)
  • PLOT, lowpass
  • highpass FFT(FFT(full, 1) ( 1.0 - filter),
    -1)
  • PLOT, highpass

13
More on Plot and Processing
  • Put Together
  • !P.MULTI 0, 2, 3
  • PLOT, base, TITLE 'Original "Ideal" Data'
  • PLOT, full, TITLE 'Noisy Data'
  • PLOT, SHIFT(filter, 100), TITLE 'Filter
    Function'
  • PLOT, lowpass, TITLE 'Lowpass Filtered'
  • PLOT, highpass, TITLE 'Highpass Filtered'
  • PLOT, smoothed, TITLE 'Smoothed with boxcar
    average'

14
Basic Programming
  • DO-loop
  • FOR n0, number DO an fix(n)
  • FOR n0, number DO BEGIN
  • an fix(n)
  • Bn 2.0an2 4.0an 6.0
  • 8.0an(-2.5)
  • ENDFOR
  • NOTE is for continuation.

15
Basic Programming
  • IF-THEN BLOCK
  • IF (logical-statement) THEN something
  • IF (logical-statement) THEN BEGIN
  • Something
  • Other thing
  • ENDIF
  • IF (logical-statement) THEN BEGIN
  • Something
  • Other thing
  • ENDIF ELSE some-other-thing

16
Basic Programming
  • CASE
  • CASE name OF
  • Match_1 do-something
  • Match_2 do-other thing
  • ELSE do-things not-matched
  • ENDCASE

17
IDL Programming-An Example
  • PRO xplot
  • sockeye 463, 459, 437, 433, 431, 433, 431,
    428, 430, 431, 430
  • coho 468, 461, 431, 430, 427, 425, 424,
    420, 418, 421, 420
  • chinook 514, 509, 495, 497, 497, 494, 493,
    492, 492, 493, 493
  • humpback 467, 465, 449, 446, 445, 444, 443,
    443, 443, 443, 445
  • year 1967, 1970, INDGEN(9) 1975
  • allpts coho, sockeye, humpback,
    chinook
  • names 'Coho', 'Sockeye', 'Humpback',
    'Chinook'
  • n1 N_ELEMENTS(year) - 1

18
IDL Programming (continued)
  • PLOT, year, coho, yrange MIN(allpts),
    MAX(allpts), title
    'Salmon Population', xtitle 'Year',
    xrange 1975, 1990, /XSTYLE, ytitle 'Fish
    (thousands)
  • FOR i 1, 3 DO OPLOT, year, allpts, i, LINE
    I
  • FOR i 0, 3 DO XYOUTS, 1984, allptsn1, i,
    namesi
  • END

19
IDL Programming (Exercise)
  • Run the above program
  • Save it as xplot.pro
  • All IDL programs have suffix .pro
  • At IDL pommand line prompt
  • idlgt.compile xplot
  • idlgtxplot

20
Contour Plot Example
  • PRO contour_plot
  • nx 400
  • ny 300
  • axfltarr(nx)
  • ayfltarr(ny)
  • xfindgen(nx)
  • yfindgen(ny)
  • ax2!PI/nxx
  • ay2!PI/nyy
  • z fltarr(nx, ny)
  • FOR j0, ny-1 DO BEGIN
  • FOR i0, nx-1 DO BEGIN
  • zi,j 100.0 COS(axi) SIN(ayj)
  • ENDFOR
  • ENDFOR

21
Contour Plot Example (continued)
  • CONTOUR, z, NLEVELS 21, /FILL
  • CONTOUR, /FOLLOW, z,
  • LEVELS -80 findgen(5) 40,
  • XSTYLE 1, YSTYLE 1, YMARGIN 5,
    MAX_VALUE 100,
  • C_LINESTYLE 2, 1, 0,
  • C_THICK 1, 1, 3, 1, 1,
  • C_LABELS 1, 1, 3, 1, 1,
  • C_CHARSIZE 1.25, FONT 0,
  • TITLE 'COS x SIN',
  • SUBTITLE 'Interval 10',
  • XTITLE 'X - AXIS',
  • YTITLE 'Y - AXIS',
  • /NOERASE
  • END

22
Check Before You Write
  • IDL has lots of functions
  • SIN, COS, MIN, MAX, etc.
  • Check if there is a function you can use, before
    writing your own
  • Get help from IDL
  • gtidlhelp on-site line user guide
  • gtidldemo see what IDL has done

23
Look Beyond the Basics
  • We have covered xy-plot, contour
  • IDL is not just this
  • Advanced IDL Features
  • Surface plot
  • Iso-surface
  • Volume
  • Image
  • And more

24
Questions?
  • Send email to us
  • huangwei_at_ucar.edu
  • consult1_at_ucar.edu
  • Call us
  • 303-497-1278 (consulting)
  • 303-497-8924 (Wei Huang)
Write a Comment
User Comments (0)
About PowerShow.com