ebook img

Idl Programming PDF

511 Pages·2008·30.44 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Idl Programming

Foreword David Stern ,rednuoF Research Systems, Incorporated My goal in writing IDL has been to create a tool for scientists and engi- neers that could be used both for ad hoc data analysis and as a program- ming language for building technical applications. IDL is a specialized fourth-generation language providing a framework that includes func- tions and components for scientific computing and visualization. It is the ability to quickly and easily investigate data; to rapidly apply various fits, filters, and transformations; and to then immediately see the results that sets IDL users apart from those who run Fortran or C programs. Unlike ,C Fortran, or even Java, IDL is an interactive tool that can be programmed or scripted. I still enjoy using IDL for exploring new data sets and answering new questions. This is a fun and intellectually challenging trial-and-error process, somewhat akin to solving a mystery, which usually concludes with an answer. Once the researcher obtains the answer and learns how to analyze and visualize a given type of data using ad hoc methods, the next step is to automate the process, and then to perhaps embed it in a graphical user interface so that others may benefit from its use. Many IDL users are comfortable with ad hoc analysis and display but have not yet mastered the language features or skills necessary to build more complex programs or applications, in particular those driven by GUIs. This is not a particularly straightforward process, and this book does a great job in aiding this transition. droweroF Practical LDI Programming begins with a concise presentation of the basics of IDL, its syntax, and data and control structures. It then explains how to access data of various types in files, including the complicated and poorly understood netCDF and HDF formats. Four chapters are devoted to creating graphics, charts, and displaying images, on the screen, the printer, and for publication. The final chapter describes how to build an application with a graphical user interface for a wider range of users. Liam Gumley is eminently qualified to write a book on IDL. He has been a long-time user of IDL and has created a number of impressive applications used by many scientists. Professionally, he writes software applications for the Cooperative Institute for Meteorological Satellite Studies (CIMSS), at the University of Wisconsin. He posts frequently to the always-active IDL newsgroup, comp.lang.idl-pvwave, and is a respected voice there. Liam distills what he feels is important for an IDL programmer to know, rather than simply presenting a complete reference without editor- ial comments. In IDL, as in any reasonably complete package, there are usually 10 ways to perform any task. For any particular problem, one method will be the best, and one will be the worst, with the remainder falling somewhere in between. Liam's goal is to impart an understanding of IDL's operation to the reader, so that he or she can select the best method for the problem at hand. The IDL beginner will welcome this book because, while it starts with the basics, it is nonetheless a comprehensive treatment of the language. There are a multitude of examples, plus code for designing a GUI-based application for interactively viewing images. The experienced user will find the book valuable for its reference sections and discussions on the proper way to program in IDL, which unfortunately is not always obvious. On behalf of Research Systems Incorporated and the community of IDL users and programmers, I would like to thank Liam Gumley for writ- ing this valuable and long overdue book. Practical LDI Programming serves as a useful tutorial, source of examples, and reference for those wishing to learn or to master IDL. It gives me great pleasure to recom- mend this book to you. stnemgdelwonkcA This book arose from a desire to share the lessons I have learned from my work with IDL. Naturally, I did not learn about IDL all on my own. Instead, I am fortunate to work in a research environment with experi- enced and knowledgeable colleagues whose advice helped me to develop the ideas presented in this book. The genesis of this book was the morn- ing discussions over coffee with my good friend Paul van Deist, who chal- lenged and tested my ideas about IDL and programming in general. Paul Menzel provided me with enough data analysis and visualization chal- lenges that I had little choice but to hone my skills as an IDL programmer. And for everyone who stopped by my office to ask a "quick question" about IDL, this book is for you. Early in the project it was my good fortune to establish a working rela- tionship with Research Systems, Inc., the makers of IDL, and I have bene- fited greatly from their encouragement and support. In particular I must thank David Stern of RSI for kindly agreeing to write the foreword for this book. The team at Morgan Kaufmann, led by Denise Penrose, made it easier than I had ever hoped to bring the book to fruition, and they deserve credit for turning my manuscript into what I hope will be a pleas- ing and useful reference for IDL programmers. I am indebted to the following reviewers who played a large part in the development of the manuscript: Paul van Deist of the University of Wis- consin-Madison, Nick Bower of Curtin University of Technology, Martin Schultz of the Max-Planck-Institut fuer Meteorologic, Molly Houck of vii stnemgdelwonkcA RSI, and Randall Frank from Lawrence Livermore National Laboratory. Their suggestions dramatically improved the content, style, and organi- zation of the book, and any errors that remain are mine alone. I have also learned a great deal from the contributors to the Usenet newsgroup c0mp.lang, i dl-pvwave, whose willingness to discuss the intricacies of IDL often provided the stimulus to ii~vestigate a topic fur- ther. Some results of exchanges on the newsgroup are to be found in this book. Finally, I owe the greatest debt to my wife, Janine. If not for her patience and understanding, I would never have completed this book. Introduction T his book provides a solid foundation in the fundamentals of programming in Interac- tive Data Language (IDL), an array-oriented data analysis and visualiza- tion environment developed and marketed by Research Systems, Incor- porated (RSI) of Boulder, Colorado. IDL is available for Windows, MacOS, UNIX (including Linux), and SMV platforms. The first version of IDL for VAX/VMS was released in 1981 by ISR founder David Stern. Since then, IDL has emerged from its roots in the astronomical and space sciences to become a widely used tool in research, educational, and commercial settings in areas as diverse as the earth sciences, medical physics, and engineering test and analysis. Examples of real-world tasks where IDL is used include analyzing and visualizing images from the Hubble Space Telescope; rendering three- dimensional volumes of the human body from magnetic resonance imaging; and monitoring and controlling the plasma field of a nuclear fusion tokamak. The long-term success of IDL stems from its flexible modes of opera- tion, which include rapid interactive analysis and visualization; a power- ful programming environment; and fully developed cross-platform end- user applications that range from an advanced remote sensing image processing suite (ENVI) to a comprehensive terrain and river network analysis package (RiverTools). In addition, IDL offers a broad range of fundamental data types, making it possible to read almost any input data retpahC 1 Introduction format. The availability of IDL on all major UNIX platforms (including Linux), Windows, and MacOS facilitates data analysis in multiplatform environments and ensures that applications developed on one platform can be successfully ported to new platforms when hardware changes are necessary. Finally, the worldwide community of IDL users contributes to and maintains a collection of freely available Internet-based libraries, which at the time of writing included over 5,000 separate routines. 1.1 ABOUT THIS BOOK This book begins by explaining the fundamentals of IDL and then moves on to explain howt he fundamentals may be used to develop data analysis and visualization applications. The first chapter begins with a discussion of the philosophy behind the book; explains where the supporting mate- rials for the book may be found; and summarizes the conventions used for IDL code examples. The chapter continues with instructions on how to start an IDL session and how to use the built-in online help. The chap- ter concludes with an outline of the remaining chapters in the book. Who Should Read This Book? Readers of this book will include anyone who wishes to use IDL effec- tively to analyze and visualize data. Newcomers to IDL will find a thor- ough description of the basics of the IDL syntax, with special attention paid to the effective use of arrays, as well as the fundamentals of visual- ization in IDL. Readers with a moderate level of prior exposure to IDL (perhaps only in interactive mode) will learn the mechanics of writing understandable and efficient IDL programs and receive practical advice such as how to create publication-quality PostScript output. Advanced users of IDL will appreciate the many hard-won nuggets of advice about IDL peculiarities, such as a detailed description of the differences between 8-bit and 24-bit graphics modes and the implications for IDL programming. Readers at all levels will appreciate the realization of IDL programming concepts in example programs that can be used immedi- ately for real-world tasks. Prior exposure to a procedural language such as C or Fortran will be helpful, but not essential, for readers of this book. 1.1 About This Book Why Write This Book? I wrote this book to help IDL users at all levels advance to the point where writing understandable and efficient IDL programs is second nature. Part of the attraction of IDL is that you can accomplish a great deal with only a few commands in interactive mode. A side effect, however, is that a sizable fraction of IDL users never progress beyond the point of entering individ- ual commands and are never able to fully exploit the capabilities of lDL as a programming language. In my experience, the transition from casual command-line user to effective IDL programmer is often long and frus- trating, if the user makes the transition at all. All the necessary informa- tion can be found somewhere in the manuals that accompany IDL, but with several thousand pages spread over five or more volumes, it is often difficult to know exactly where to look when you have a question. I felt strongly that there was a place for a book written by an experienced IDL programmer that gathered together essential information about IDL pro- gramming, assembled it in a logical sequence, and presented it with prac- tical and illustrative example programs that solve real-world problems. What about Objects? A new object data type and an Object Graphics system were introduced in IDL 5.0 in 1996. These new features help to broaden the scope of the language and allow complex graphical displays to be constructed, partic- ularly in the area of three-dimensional visualization. However, effective object-oriented programming in IDL requires a rather different approach when compared to the more commonly used procedural programming paradigm that has existed in IDL since it was first released. In this book, I have chosen to limit the discussion strictly to procedural programming, since I believe a larger audience for this topic exists in the community of IDL users. Likewise, this book only describes the Direct Graphics system in IDL and does not explore the realm of the Object Graphics system. At the time of writing, the Direct Graphics system offered much simpler (i.e., easier to program) ways to create visualizations in IDL. To do justice to objects and the Object Graphics system in IDL, I believe a separate book is required that describes how object-oriented principles are applied in IDL; hopefully such a volume will emerge in the not-too-distant future. In retpahC 1 Introduction the meantime, the chapters of this book that describe the fundamental syntax of the language should prove useful to those writing object- oriented programs in IDL. Supporting Materials The source code for the example procedures and functions shown in this book are available online at the author's website: http'//www.guml ey.com It is recommended that you download the programs to a directory on your system, and then add the directory to the LDI path by one of the fol- lowing methods: (cid:12)9 Ifyou are running the LDI Development Environment, select File, Pref- erences, Path, and add the directory to the default search path. (cid:12)9 On UNIX platforms you may add the directory to the IDL path envi- ronment variable .HTI AP_LD For example, if you stored the programs in a directory named/h0me/bi 11 g/i dl, the syntaxw ould be as follows: % setenv HTAP_LDI ${IDL_PATH}./home/billg/idl (Cshell) $ export IDL_PATH=${IDL_PATH}'/home/bilIg/idl (Kornshell) Typographic Conventions Throughout this book the following typographic conventions are used. Commands that are intended to be entered at the LDI command line will appear as follows: IDL> tvscl, dist(256) Procedures and functions (i.e., programs) will appear as follows: ORP OLLEH print, 'Hello world' DNE The program text may be entered in the LDI Development Environment editor or in any other text editor. The name of the text file should be the 2.1 About IDL same as the procedure or function name (e.g., he l l o. pro), and lowercase file names are recommended. Special Characters IDL recognizes a number of special characters within IDL programs or when commands are entered at the command line. The most important special characters are described below. The semicolon character designates the beginning of a comment. Any text following a semicolon on a given line is ignored. For example: ORP OLLEH A (cid:12)9 simple program print, 'Hello world' (cid:12)9 This line prints a message DNE If the last character on a line is a dollar sign, the current command is continued on the next line. For example: IDL> print, 'The quick brown fox ', $ IDL> 'jumped over the lazy dog' If the first character on the line is a dollar sign, any text that follows is executed as an operating system command. For example, to list the con- tents of the current directory on a UNIX platform: IDL> $1s-I 1.2 ABOUT IDL One of the strengths of IDL is its support for a variety of hardware and operating system combinations. Whether you are accustomed to a Win- dows, MacOS, or UNIX (including Linux) environment, a version oflDL is probably available for your system. The platforms supported by IDL 5.4 are shown in Table 1.1. For an up-to-date list of supported platforms and operating system versions, see the RSI website (http://www. -hcraeser systems, com).

Description:
process, somewhat akin to solving a mystery, which usually concludes . The availability of IDL on all major UNIX platforms (including. Linux), Windows . MacOS. G3, G4, iMac. UNIX. Intel. Intel x86. Linux. SUN. SPARC. Solaris. SUN. Intel x86. Solaris. HP. PA-RISC. HP-UX. IBM. RS/6000. AIX. SGI.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.