Practical IDL Programming


  • Liam Gumley, University of Wisconsin-Madison
  • Liam Gumley, University of Wisconsin-Madison

Increasingly, scientists and engineers must quickly and efficiently analyze and visualize extremely large sets of data. Interactive Data Language, IDL, was designed to address just this need. A popular data analysis and visualization programming environment, IDL is used worldwide by scientists and engineers in fields as diverse as the physical sciences, medical physics, and engineering test and analysis.

In Practical IDL Programming, Liam E. Gumley provides a solid foundation in the fundamentals of procedural programming in IDL. He presents concise information on how to develop IDL programmers that are well structured, reliable, and efficient. The example programs in the book demonstrate key concepts and provide functionality that can be applied immediately. In addition, the book offers readers practical tips and advice on IDL programming, which they would otherwise discover only after years of experience.

While only modest prior programming experience is assumed, readers with experience in any procedural language will quickly translate their skills to IDL, learning the best programming practices for this new environment. Scientists, engineers, and students in educational, government, and commercial research and development environments will all appreciate the author's guidance in helping them effectively analyze and visualize data.

View full description


IDL users and programmers


Book information

  • Published: July 2001
  • ISBN: 978-1-55860-700-2


"Precisely the book I wished to have available when I first learned IDL"
—Martin Schultz, Max Planck Institut fuer Meteorologie

"A well presented explanation of the practical application of IDL"
—Paul van Delst, University of Wisconsin-Madison
"A fantastic achievement for maintaining a nice balance for beginners and advanced users"
—Nick Bower, Curtin University of Technology
"On behalf of Research Systems Incorporated and the community of IDL users and programmers, I would like to thank Liam Gumley for writing this valuable and long overdue book. Practical IDL Programming serves as a useful tutorial, source of examples, and reference for those wishing to learn or master IDL. It gives me great pleasure to recommend this book to you."
—From the Forward by David Stern, Founder, Research Systems Incorporated

Table of Contents

Foreword by David SternAcknowledgementsChapter 1: IntroductionWho Should Read This Book?Why Write This Book?What About Objects?Supporting MaterialsTypographic ConventionsSpecial Characters1.1 About IDLIDL in PerspectiveObtaining IDL1.2 Running IDLOn-line Help1.3 Chapter OutlineChapter 2: Fundamentals of IDL Syntax2.1 Interactive and Compiled ModesInteractive ModeCompiled Mode2.2 VariablesData TypesKeeping Track of Variable TypesType ConversionsConverting Floats to IntegersConverting between String and Numeric TypesVariable Names2.3 Introduction to ArraysCreating ArraysArray Storage FormatFunctions for Creating ArraysFloating Point Grid Arrays2.4 Array IndexingArray Indexing ExamplesMulti-dimensional Array Indexing ExamplesOne-dimensional IndexingIndex SamplingMulti-dimensional Index Sampling2.5 Expressions and Arithmetic OperatorsType Conversion in ExpressionsGuarding Against Division by an IntegerOperatorsOperator PrecedenceArithmetic Operations on ArraysOperator Precedence and Efficiency of Array OperationsMinimum, Maximum, and Modulo OperatorsArray and Matrix Multiplication Operators2.6 Relational and Boolean OperatorsRelational OperatorsBoolean Operatorsnot Operatorand Operatoror Operatorxor OperatorCombining Relational and Boolean OperatorsBit Manipulation2.7 StructuresAnonymous StructuresArrays of StructuresNamed StructuresWorking with Structures2.8 PointersTypes of PointersCreating PointersFreeing PointersChecking Pointer ValidityPointer De-ReferencingAvoiding Pointer Problems2.9 Array PropertiesNumber of Array ElementsArray Size and TypeMinimum and Maximum ValuesMean, Variance, and Standard Deviation2.10 Locating Values Within an ArrayFinding Values Which Meet Selection CriteriaWorking with 1D indices from whereFinding Values Which Don't Meet Selection Criteria2.11 Array ReorderingChanging Array DimensionsReversing Array ElementsRotating ArraysTransposing ArraysShifting ArraysSorting ArraysFinding Unique Array Values2.12 Array ResizingResizing by an Integer FactorResizing to Arbitrary SizeResizing to Arbitrary Size with Custom InterpolationRemoving Rows or ColumnsChapter 3: Writing IDL Programs3.1 Defining and Compiling ProgramsProceduresFunctionsNaming and Editing Source FilesManual CompilationAutomatic CompilationReturning to the Main Level after an Error3.2 Control Statementsif Statementcase Statementfor Statementwhile Statementrepeat Statementreturn Statementgoto Statementswitch Statementbreak Statementcontinue Statement3.3 Parameters and KeywordsParametersKeywordsUsing Parameters and KeywordsArgument Passing MechanismExtra KeywordsExtra Keyword PrecedenceExtra Keyword Passing Mechanism3.4 Checking Parameters and KeywordsChecking Input ParametersDon't Modify Input ParametersChecking Boolean KeywordsChecking Output Parameters and Keywords3.5 Scripts, Include Files, and JournalingScriptsInclude FilesJournaling3.6 Global VariablesRead-only System VariablesWritable System VariablesUser-Defined System VariablesCommon Blocks3.7 Error HandlingIntercepting ErrorsMath ErrorsResetting the IDL Session3.8 Efficient ProgrammingConserving MemoryUsing Efficient MethodsChapter 4: Input and Output4.1 Standard Input and OutputWriting to Standard OutputReading from Standard InputFree Format InputReading from a StringWriting to a StringLegal and Illegal read Arguments4.2 Working with FilesOpening FilesSelecting a FileObtaining Information about FilesClosing Files4.4 Reading and Writing Formatted (ASCII) FilesReading a Formatted FileWriting a Formatted File4.5 Reading and Writing Unformatted (Binary) FilesReading an Unformatted File (Single Data Type)Reading an Unformatted File (Mixed Data Types)Reading a FORTRAN-77 Unformatted FileRepositioning the File PointerByte Swapping (or Big-endian versus Little-endian)Writing Binary Data to an Unformatted FilePrograms to Write and Read Portable Binary DataReading Binary Data via an Associated VariableSaving and Restoring IDL Variables4.6 Scientific Data FormatsSpecialized Formats4.7 Reading and Writing netCDF FilesReading a Variable from a netCDF fileReading an Attribute from a netCDF fileDiscovering the Contents of a netCDF fileWriting to a netCDF fileStandard AttributesCoordinate Variables4.8 Reading and Writing HDF FilesReading a Variable from a HDF fileUsing a Wrapper Procedure to Read a VariableReading an Attribute from a HDF fileDiscovering the Contents of a HDF fileWriting to a HDF fileCoordinate VariablesChapter 5: Direct Graphics5.1 Graphics DevicesSelecting a Graphics DeviceConfiguring the Graphics Device5.2 Display Modes8-bit Display Mode24-bit Display ModeDisplay Mode ComparisonObtaining Display Mode InformationSelecting a Display Mode: Windows and MacOS platformsSelecting a Display Mode: UNIX platformsSelecting a Display Mode via a Startup File5.3 Graphics WindowsCreating a WindowWorking with Existing WindowsInvisible Graphics Windows (Pixmaps) and AnimationScrolling Graphics Windows5.4 Working with ColorsColor ModesIndexed ColorWorking with the Color TableColor Table Updates in 24-bit modeDecomposed Color5.5 Display Mode TroubleshootingChapter 6: Plotting Data6.1 Plotting OverviewLine PlotsOverplottingScatter PlotsPolar PlotsPlot CoordinatesCoordinate ConversionsPlotting in Normal and Device CoordinatesSystem Variables6.2 Plot PositioningSpecifying a Plot PositionComputing a Plot PositionPositioning Multiple Plots6.3 Plot CustomizationGeneral Plot PropertiesGeneral Axis PropertiesConfiguring Axis Range and StyleCreating AxesLogarithmic AxesTick Marks and Labels6.4 Plot ColorsIndexed ColorsDecomposed Colors6.5 Titles, Labels, and SymbolsTitlesLabelsMathematical Symbols6.6 Error Bar, Histogram, and Bar PlotsError Bar PlotsHistogram PlotsBar Plots6.7 Contour PlotsContour Plotting OverviewContouring Irregularly Spaced DataFilled Contours6.8 Mesh and Shaded Surface PlotsIrregularly Spaced DataShaded Surface PlotsCombined Mesh and Shaded Surface Plots6.9 MappingCreating a Map ProjectionConfiguring a Map ProjectionSelecting Map LimitsContinental OutlinesMap Grid LinesContour Plots on Map ProjectionsDisplaying Regularly Gridded Images on Map ProjectionsChapter 7: Displaying Images7.1 Image FundamentalsPseudoColor ImagesTrueColor Images7.2 Image Display RoutinesDisplaying Unscaled Images: tvDisplaying Scaled Images: tvsclBottom-up vs. Top-down displayKeywords for tv and tvscl7.3 Customizing Image ScalingImage Scaling via bytsclColor Table SplittingDisplaying Multiple Images with Separate Color TablesHistogram ClippingHistogram Equalization7.4 Sizing the Image to Fit the DisplayComputing Image Size and Offset Automatically7.5 Displaying TrueColor ImagesDisplaying TrueColor Images in 24-bit Display ModeDisplaying TrueColor Images in 8-bit Display Mode7.6 Displaying Images on the PostScript and Printer DevicesDisplaying PseudoColor Images on the PostScript DeviceDisplaying PseudoColor Images on the Printer DeviceDisplaying TrueColor Images on the PostScript DeviceDisplaying TrueColor Images on the Printer Device7.7 An Image Display ProcedureChapter 8 Creating Graphical Output8.1 Bitmap and Vector OutputBitmap and Vector Formats8.2 Creating Bitmap Output FilesReading from the Display: tvrdReading from an 8-bit DisplayReading from a 24-bit DisplayA Wrapper Function for tvrdSelecting a Bitmap Output FormatSaving an 8-bit Image to a Bitmap Output FileSaving a 24-bit Image to a Bitmap Output FileA Program for Saving the Screen to a Bitmap Output File8.3 Creating PostScript OutputIntroduction to the PostScript DeviceConfiguring the PostScript DeviceSetting Size and Offset ManuallySetting Size and Offset AutomaticallyColor PostScript OutputUsing the Color Table in PostScript ModeReversed Background and Drawing ColorsFontsPostScript Device FontsTrueType FontsPositioning Graphics in the Drawable AreaAdding an EPS Preview8.4 Creating Printer OutputSelecting a PrinterConfiguring the Printer DeviceSetting Size and Offset ManuallySetting Size and Offset AutomaticallyColor Printer OutputFonts and PositioningChapter 9: Graphical User Interfaces (GUIs)9.1 Introduction to GUI ProgrammingGUI Components (Widgets)GUI Programming vs. Procedural ProgrammingGUI Design9.2 Creating WidgetsWidget BasicsWidget Attributeswidget_base functionwidget_button functionwidget_draw functionwidget_droplist functionwidget_label functionwidget_list functionwidget_slider functionwidget_table functionwidget_text functionWidget LayoutNaming ButtonsCompound Widgets9.3 Working with Existing WidgetsSetting Widget Properties: widget_controlGetting Widget Information: widget_info9.4 Events and Event HandlingEvent StructuresEvent ManagementEvent Handlers and Application State InformationMultiple Instances of an Application9.5 A GUI ApplicationDesign ImplicationsStartup ProcedureEvent Handler ProceduresService ProceduresCompiling and Running imguiAppendix A: IDL on the InternetResources by the AuthorRSI InformationIDL NewsgroupIDL LibrariesIDL Library Searchable DatabaseIDL PeopleIDL ApplicationsAppendix B: Mathematical RoutinesComplex NumbersCorrelation AnalysisCurve and Surface FittingDifferentiation and IntegrationEigenvalues and EigenvectorsGridding and InterpolationHypothesis TestingLinear SystemsMathematical Error AssessmentMiscellaneous Math RoutinesMultivariate AnalysisNonlinear EquationsOptimizationProbabilitySignal ProcessingSparse ArraysSpecial Math FunctionsStatistical FittingStatistical ToolsTime Series AnalysisTranscendental FunctionsTransformsAppendix C: Widget Event StructuresBase WidgetsButton WidgetsDraw WidgetsDroplist WidgetsLabel WidgetsList WidgetsSlider WidgetsTable WidgetsText WidgetsAppendix D: Widget PropertiesBase WidgetsButton WidgetsDraw WidgetsDroplist WidgetsLabel WidgetsList WidgetsSlider WidgetsTable WidgetsText WidgetsAppendix E: Graphics Device Properties