IDL英文原版(很好的一份IDL教材)

An Introduction to Computer Programming Using Interactive Data Language(IDL) Kenneth P.Bowman Department of Atmospheric Sciences Texas A&M University 2004 January 31 Contents Preface ii I IDL BASICS 1 1 Introduction 2 1.1 What is IDL?...........................................2 1.2 IDL resources...........................................4 1.3 The IDL software system.....................................5 2 IDL Manuals and Books 9 2.1 Features of this book.......................................9 2.1.1 Example programs and data...............................9 2.1.2 Figures and illustrations.................................10 2.2 IDL documentation from Research Systems...........................11 2.3 Other IDL books.........................................12 Interactive IDL 14 3.1 IDL commands..........................................14 3.2 Before starting IDL........................................15 3.2.1 Operating system search path..............................16 3.2.2 The startup.pro file...................................16 3.3 Starting and exiting IDL.....................................20 3.4 Interrupting and restarting IDL calculations..........................21 3.5 Simple IDL statements......................................22 3.6 Getting information........................................25 3.7 Variables..............................................26 3.8 Arrays...............................................28 3.9 Graphics..............................................32 3.10 Summary.............................................35 3.11 Exercises..............................................37 IDL Scripts 39 4.1 IDL commands and notation...................................39ONTENTS vii 4.2 A note on files and file names..................................39 4.3 Making a script..........................................40 4.4 Journaling.............................................44 4.5 Summary.............................................46 4.6 Exercises..............................................46 Integer Constants and Variables 48 5.1 IDL commands and notation...................................48 5.2 Decimal and binary notation...................................49 5.3 BYTE constants and variables...................................49 5.4 INT constants and variables...................................55 5.5 LONG constants and variables...................................57 5.6 Other integer types........................................58 5.7 Converting one integer type to another.............................58 5.8 Summary.............................................59 5.9 Exercises..............................................60 Floating-Point Constants and Variables 62 6.1 IDL commands and notation...................................62 6.2 Development of floating-point methods.............................63ONTENTS viii 6.3 Problems with floating-point arithmetic.............................63 6.4 Single-precision constants and variables.............................65 6.5 Double-precision constants and variables............................67 6.6 Type conversion..........................................69 6.7 Rounding.............................................70 6.8 Infs and NaNs...........................................71 6.9 Summary.............................................74 6.10 Exercises..............................................75 Using Arrays 76 7.1 IDL procedures and functions..................................76 7.2 Arithmetic with arrays......................................77 7.3 Generating a coordinate array..................................79 7.4 Changing the shape of an array.................................81 7.5 Using part of an array......................................85 7.6 Rebinning an array........................................87 7.7 Reversing an array........................................91 7.8 Rotating or transposing an array................................93 7.9 Shifting an array.........................................94ONTENTS ix 7.10 Summary.............................................95 7.11 Exercises..............................................95 Searching and Sorting 96 8.1 IDL procedures and functions..................................96 8.2 Finding values in an array that satisfy a logical condition...................97 8.3 Sorting an array..........................................100 8.4 Finding a value in a sorted array................................101 8.5 Summary.............................................102 8.6 Exercises..............................................103 Structures 104 9.1 IDL commands and keywords..................................104 9.2 Named structures.........................................105 9.2.1 Automatic structure definition..............................107 9.3 Anonymous structures......................................109 9.4 Hierarchical structures......................................111 9.5 When to use named and anonymous structures.........................113 9.6 Topics not covered........................................114 9.7 Summary.............................................114ONTENTS x 9.8 Exercises..............................................114 INPUT AND OUTPUT 115 Printing Text 116 10.1 IDL commands and keywords..................................116 10.2 Free-format output........................................117 10.3 Formatted output.........................................118 10.3.1 Printing integers.....................................118 10.3.2 Printing floating-point numbers.............................120 10.4 Printing a table..........................................121 10.5 Output to files..........................................123 10.6 Summary.............................................124 10.7 Exercises..............................................125 Reading Text 126 11.1 IDL commands and keywords..................................126 11.2 Reading from the terminal....................................127 11.3 Reading from files.........................................128 11.4 Summary.............................................131ONTENTS xi 11.5 Exercises..............................................131 Binary Files 133 12.1 IDL commands and keywords..................................134 12.2 Writing binary files........................................134 12.3 Reading binary files........................................137 12.4 Exchanging files with Fortran programs.............................141 12.5 Summary.............................................142 12.6 Exercises..............................................142 Reading NetCDF Files 143 13.1 IDL procedures and functions files................................144 13.2 NetCDF basics..........................................144 13.3 Reading attributes........................................149 13.4 A real data file..........................................153 13.5 Summary.............................................156 13.6 Exercises..............................................156 Writing NetCDF Files 159 14.1 IDL procedures and functions..................................159 14.2 Writing a netCDF file......................................160ONTENTS xii 14.3 Writing parts of an array.....................................165 14.4 Summary.............................................166 14.5 Exercises..............................................167 I PROGRAM STRUCTURE AND CONTROL 168 Procedures and Functions 169 15.1 IDL commands and keywords..................................169 15.2 Built-in procedures and functions................................170 15.3 Writing procedures........................................172 15.4 Writing functions.........................................178 15.5 Keyword parameters.......................................182 15.6 Optional parameters.......................................185 15.7 Summary.............................................186 15.8 Exercises..............................................186 Program Control 189 16.1 IDL commands and keywords..................................189 16.2 BEGIN...END statements.....................................190 16.3 IF...THEN...ELSE statements..................................190ONTENTS xiii 16.3.1 Single-line form......................................190 16.3.2 Block form.........................................191 16.4 FOR loops.............................................192 16.4.1 Single-line form......................................192 16.4.2 Block form.........................................194 16.5 WHILE loops............................................194 16.6 Other control structures.....................................195 16.7 Summary.............................................196 GRAPHICS 197 Printing Graphics 198 17.1 IDL commands and keywords..................................198 17.2 Device drivers...........................................199 17.3 The PRINTER device........................................200 17.3.1 Setting up a printer under Mac OS X..........................200 17.3.2 Settting up the PRINTER device.............................200 17.3.3 Using the PRINTER device................................201 17.4 The Postscript device.......................................202ONTENTS xiv 17.4.1 Using the PS device....................................203 17.5 Some limitations of the PRINTER and PS devices........................203 17.6 Summary.............................................204 17.7 Exercises..............................................204 Line Graphs 205 18.1 IDL commands for plotting line graphs.............................205 18.2 Plotting styles...........................................206 18.2.1 Basic line graphs.....................................206 18.2.2 Logarithmic graphs....................................206 18.2.3 Plotting symbols.....................................208 18.2.4 Line styles.........................................210 18.3 Titles and labels.........................................214 18.4 Axes................................................214 18.5 Multiple plots per page......................................220 18.6 Summary.............................................221 Contour and Surface Plots 222 19.1 IDL commands and keywords..................................222 19.2 Contour plots...........................................223ONTENTS xv 19.3 Surface plots............................................230 19.4 Shaded surface plots.......................................231 19.5 Summary.............................................235 Mapping 236 20.1 IDL commands and keywords..................................236 20.2 Drawing maps...........................................237 20.2.1 Setting up the map projection..............................237 20.2.2 Cylindrical equidistant projection............................238 20.2.3 Hammer equal-area and conic projections........................241 20.2.4 Azimuthal equidistant projection............................242 20.2.5 Orthographic projection.................................246 20.3 Contour plots on maps......................................248 20.4 Other plots on maps.......................................250 20.5 Summary.............................................250 Color and Image Display 252 21.1 IDL commands and keywords..................................252 21.2 Color basics............................................253 21.2.1 Pixels...........................................253ONTENTS xvi 21.2.2 The RGB color system..................................253 21.2.3 The HSV color system..................................255 21.3 24-bit devices...........................................259 21.3.1 Specifying 24-bit colors..................................261 21.3.2 24-bit images.......................................265 21.3.3 Copying images from the screen.............................268 21.3.4 Saving images to files...................................270 21.3.5 Printing 24-bit color output...............................270 21.4 8-bit devices............................................271 21.5 Summary.............................................275 Animation 277 22.1 IDL commands and keywords..................................277 22.2 Background............................................277 22.3 Using XINTERANIMATE......................................278 22.3.1 Creating an animation..................................278 22.3.2 Animating files......................................282 22.3.3 Saving your animation..................................283 22.4 Summary.............................................284ONTENTS xvii 22.5 Exercises..............................................284 APPLICATIONS 285 Statistics and Pseudorandom Numbers 286 23.1 IDL commands and keywords..................................286 23.2 Pseudorandom numbers.....................................287 23.2.1 Background........................................287 23.2.2 IDL pseudorandom number functions..........................289 23.3 Basic statistics..........................................293 23.4 Regression and correlation....................................295 23.5 Curve fitting............................................297 23.6 Significance tests.........................................297 23.7 Summary.............................................297 Interpolation 298 24.1 IDL commands and keywords..................................298 24.2 Background............................................299 24.3 1-D interpolation.........................................299 24.4 Bilinear interpolation.......................................302ONTENTS xviii 24.5 Higher dimensions........................................306 24.6 Irregular grids...........................................306 24.7 Summary.............................................310 Fourier Analysis 311 25.1 IDL commands and keywords..................................311 25.2 Background............................................311 25.2.1 Basic Fourier theory...................................312 25.2.2 Fourier transforms for discrete data...........................315 25.2.3 The discrete Fourier transform..............................315 25.2.4 The fast Fourier transform(FFT)............................316 25.3 The IDL FFT...........................................317 25.3.1 Computing the Fourier transform............................317 25.3.2 Additional properties and keywords...........................324 25.4 Fourier filtering..........................................325 25.4.1 Filtering methods.....................................325 25.4.2 Types of filters......................................326 25.4.3 An ideal filter in IDL...................................326 25.5 Summary.............................................331ONTENTS xix 25.6 Exercises..............................................331 Setting up IDL Under Mac OS X 332 A.1 Hardware.............................................332 A.2 Software..............................................332 A.3 Getting started..........................................333 A.3.1 Login............................................333 A.3.2 Change your initial password..............................333 A.3.3 Configure the Dock....................................334 A.3.4 Set Finder preferences...................................334 A.3.5 Configure Finder windows................................335 A.3.6 Place items in the Dock.................................336 A.3.7 Configure the Favorites menu...............................336 A.3.8 Configure your Home directory.............................337 A.3.9 Configure IDL manuals..................................337 A.3.10 Configure BBEdit.....................................338 A.3.11 Configuring a printer...................................339 A.3.12 Configure your Unix shell................................339 A.3.13 Running IDL.......................................340ONTENTS xx A.3.14 Logging out........................................340 IDL Style Guide 341 B.1 IDL style rules..........................................342 B.1.1 Goals of the IDL style rules...............................342 B.1.2 Names and reserved words................................342 B.1.3 Spaces,alignment,and indentation...........................343 B.1.4 Comments.........................................344 B.2 Examples of good and bad style.................................344 B.2.1 An example of bad style.................................345 B.2.2 An example of mediocre style..............................345 B.2.3 An example of good style................................345 B.3 IDL reserved words........................................345 Example Procedures,Functions,Scripts,and Data Files 347 C.1 Example procedures,functions,and scripts...........................347 C.1.1 List of procedures,functions,and scripts by chapter..................347 C.1.2 Alphabetical list of procedures,functions,and scripts.................351 C.2 Data files.............................................355 注意,PDF打开会出错,请用CAJView打开 注意,PDF打开会出错,请用CAJView打开 注意,PDF打开会出错,请用CAJView打开 注意,PDF打开会出错,请用CAJView打开 注意,PDF打开会出错,请用CAJView打开





剩余380页未读,继续阅读


















评论10