logo资料库

Modern IDL.pdf

第1页 / 共464页
第2页 / 共464页
第3页 / 共464页
第4页 / 共464页
第5页 / 共464页
第6页 / 共464页
第7页 / 共464页
第8页 / 共464页
资料共464页,剩余部分请下载后查看
Modern IDL
Table of Contents
Preface
1. Why IDL?
2. Who is this book for?
3. How this book is organized
4. Example code
5. Developers from other languages
6. How to contact me
7. Acknowledgments
Chapter 1. Introduction to IDL
1.1. Getting starting with IDL
1.2. Read and display an image
1.3. Visualizing 3-dimensional geometry
1.4. More examples
1.5. Summary
Chapter 2. The IDL environment
2.1. The IDL command line
2.2. Executive commands
2.3. Preferences
2.4. The IDL Workbench
References
Chapter 3. Variables
3.1. Introduction
3.2. Variable names
3.3. Variable types
3.4. Arrays
3.5. Structures
3.6. Operators
Exercises
3.7. Variable information
3.8. Strings
3.9. Regular expressions
3.10. System variables
3.11. Pointers
3.12. Objects
3.13. Lists and hashes
3.14. Common blocks
3.15. Shared memory
3.16. Summary
References
Chapter 4. File Input/Output
4.1. Handling files
4.2. Supported file formats
4.3. High-level input and output routines
4.4. Low-level input and output routines
Exercises
4.5. .sav files
4.6. Scientific data formats: HDF5 overview
4.7. Networking
4.8. XML
4.9. Summary
References
Chapter 5. Programming
5.1. Introduction
5.2. Looping constructs
5.3. Truth and conditionals
5.4. Routines
Exercises
5.5. Error handling
5.6. Debugging
5.7. Main-level programs
5.8. Batch files
5.9. The compile_opt statement
5.10. Distribution of IDL code
5.11. Summary
References
Chapter 6. Direct graphics
6.1. Direct graphics vs. object graphics
6.2. Color
6.3. Handling graphics windows
6.4. Line plots
6.5. Coordinate systems
6.6. Annotation
6.7. Images
6.8. Surface plots
6.9. Contour plots
6.10. Combining 3-dimensional plots
6.11. Maps
6.12. Polygonal meshes
6.13. Vector fields
6.14. Volumes
6.15. Animation
6.16. Graphics devices
6.17. Summary
References
Chapter 7. Objects
7.1. Concepts
7.2. Writing a class
7.3. Inheritance
7.4. Operator overloading
7.5. Tricks and techniques
7.6. For those familiar with other object-oriented languages
References
Chapter 8. Widgets
8.1. Introduction
8.2. Simple example: mg_xplot
Exercises
8.3. Widget programming details
8.4. A more complicated example: mg_ximage
8.5. Dialogs
8.6. Compound widgets
8.7. Object widgets
8.8. Summary
References
Chapter 9. Object graphics
9.1. Introduction
9.2. Displaying an image in object graphics
9.3. The theory
9.4. A 3-dimensional example
9.5. The transformation matrix
9.6. Properties
9.7. Sample visualizations
9.8. Texture mapping and transparency
9.9. Inheriting from an IDLgr class: MGgrCube
9.10. Composite graphics classes
9.11. Sending output to other destinations
9.12. Creating a new destination: MGgrWindow3D
9.13. Widgets and objects graphics: interaction
Exercises
9.14. Widgets and object graphics: tiled imagery
Exercises
9.15. New graphics
9.16. Summary
References
Chapter 10. Using the iTools
10.1. What are the iTools?
10.2. iTools basics
10.3. Advanced iTools features
10.4. Scripting the iTools
10.5. Summary
References
Chapter 11. Performance
11.1. Introduction
11.2. Timing
11.3. Vectorization
Exercises
11.4. Logic
11.5. Array and matrix techniques
11.6. The clever use of histogram
11.7. Memory usage
11.8. Object-oriented techniques
11.9. Summary
References
Chapter 12. External development
12.1. Techniques
12.2. spawn
12.3. call_external
12.4. Dynamically loadable modules
12.5. Bridges
12.6. Python
12.7. Summary
References
Appendix A. Resources
A.1. Online help
A.2. Resources in the IDL distribution
A.3. Resources on the Internet
A.4. Books on IDL
Bibliography
A.5. IDL code libraries
A.6. IDL open source projects
Appendix B. Starting IDL
Appendix C. A style guide
C.1. General principles
C.2. Layout
C.3. Comments
C.4. Statement formatting
C.5. Variables
C.6. Routines
C.7. Object-oriented programming
References
Appendix D. The IDL library
D.1. Animation
Animation compound widget
File formats for animation
Animation display
D.2. Application development
D.3. Arrays
Array allocation
Index array creation
Miscellaneous array creation
Manipulating and querying arrays
D.4. Color
Color system conversions
Creating and modifying color tables
Loading and storing color tables
Miscellaneous color routines
Compound widget to handle color table selection
D.5. Date and time
D.6. Debugging
Routines
Executive commands
D.7. Dialogs
D.8. Error handling
D.9. External development
Calling external code from within IDL
Calling IDL code from another language
D.10. File input/output
General routines
Supported formats
D.11. Fonts
D.12. Images
Contrast enhancement and filtering
Feature extraction/image segmentation
Image display
Image geometry transformations
Morphological image operators
Regions of interest
D.13. Internationalization
D.14. Introspection
D.15. Mapping
Display
Computing map projections
Miscellaneous
D.16. Mathematics
Complex numbers
Curve and surface fitting
Differentiation and integration
Eigenvalues and eigenvectors
Gridding and interpolation
LAPACK routines
Linear systems
Mathematical error assessment
Matrix
Miscellaneous
Multivariate analysis
Nonlinear equations
Optimization
Sparse arrays
Special functions
Time-series analysis
Transcendental functions
Transforms
D.17. Networking
D.18. Object library
D.19. OS access
D.20. Plotting
Line plots
Surface and contour plots
Polygonal meshes
Volumes
Annotation
D.21. Profiling
D.22. Signal processing
D.23. Statistics and probability
General statistical routines
Hypothesis testing
Statistical fitting
Probability
D.24. Strings
General operations
Formatting strings
Filename operations
D.25. Structures
D.26. Type
D.27. Vector fields
Display
Advecting a particle
D.28. Wavelet Toolkit
Wavelet visualizations
Wavelet transforms
Wavelet functions
D.29. Widgets
Primitive widgets
Compound widgets
Helper routines
D.30. Windows
Glossary
Index
1. About the author
2. Colophon
Modern IDL A Guide to IDL Programming Michael Galloy
Modern IDL: A Guide to IDL Programming Michael Galloy 4485 Comanche Dr. #2 Boulder, CO 80303 United States of America 303.800.7205 mgalloy@idldev.com modernidl.idldev.com Version history Version 1.0 Initial publication, 29 April 2011 Published 13 May 2011 Copyright © 2011, Michael D. Galloy. All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of the trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
This book is dedicated to the posters on the Usenet newsgroup comp.lang.idl-pvwave; whether you wrote questions or answers, I learned a lot from you. i
ii
Table of Contents Preface ........................................................................................................................................... xiii 1. Why IDL? .......................................................................................................................... xiii 2. Who is this book for? ........................................................................................................... xiii 3. How this book is organized .................................................................................................... xiv 4. Example code ...................................................................................................................... xvi 5. Developers from other languages ............................................................................................ xvi 6. How to contact me .............................................................................................................. xvii 7. Acknowledgments ............................................................................................................... xvii 1. Introduction to IDL ......................................................................................................................... 1 1.1. Getting starting with IDL ....................................................................................................... 1 1.2. Read and display an image .................................................................................................... 3 1.3. Visualizing 3-dimensional geometry ........................................................................................ 6 1.4. More examples .................................................................................................................... 7 1.5. Summary ............................................................................................................................ 9 2. The IDL environment .................................................................................................................... 11 2.1. The IDL command line ....................................................................................................... 11 2.2. Executive commands ........................................................................................................... 12 2.3. Preferences ........................................................................................................................ 13 2.4. The IDL Workbench ........................................................................................................... 16 3. Variables ..................................................................................................................................... 25 3.1. Introduction ....................................................................................................................... 25 3.2. Variable names .................................................................................................................. 25 3.3. Variable types .................................................................................................................... 26 3.4. Arrays .............................................................................................................................. 29 3.5. Structures .......................................................................................................................... 35 3.6. Operators .......................................................................................................................... 39 3.7. Variable information ........................................................................................................... 43 3.8. Strings .............................................................................................................................. 43 3.9. Regular expressions ............................................................................................................ 47 3.10. System variables ............................................................................................................... 53 3.11. Pointers ........................................................................................................................... 56 3.12. Objects ............................................................................................................................ 64 3.13. Lists and hashes ............................................................................................................... 65 3.14. Common blocks ................................................................................................................ 70 3.15. Shared memory ................................................................................................................ 72 3.16. Summary ......................................................................................................................... 73 4. File Input/Output ........................................................................................................................... 75 4.1. Handling files .................................................................................................................... 75 4.2. Supported file formats ......................................................................................................... 77 4.3. High-level input and output routines ...................................................................................... 80 4.4. Low-level input and output routines ....................................................................................... 83 4.5. .sav files .......................................................................................................................... 91 4.6. Scientific data formats: HDF5 overview ................................................................................. 93 iii
4.7. Networking ...................................................................................................................... 100 4.8. XML .............................................................................................................................. 102 4.9. Summary ......................................................................................................................... 105 5. Programming .............................................................................................................................. 107 5.1. Introduction ..................................................................................................................... 107 5.2. Looping constructs ............................................................................................................ 107 5.3. Truth and conditionals ....................................................................................................... 111 5.4. Routines .......................................................................................................................... 113 5.5. Error handling .................................................................................................................. 119 5.6. Debugging ....................................................................................................................... 122 5.7. Main-level programs .......................................................................................................... 123 5.8. Batch files ....................................................................................................................... 124 5.9. The compile_opt statement ................................................................................................ 125 5.10. Distribution of IDL code .................................................................................................. 128 5.11. Summary ....................................................................................................................... 129 6. Direct graphics ............................................................................................................................ 131 6.1. Direct graphics vs. object graphics ....................................................................................... 131 6.2. Color .............................................................................................................................. 132 6.3. Handling graphics windows ................................................................................................ 137 6.4. Line plots ........................................................................................................................ 139 6.5. Coordinate systems ............................................................................................................ 145 6.6. Annotation ....................................................................................................................... 147 6.7. Images ............................................................................................................................ 152 6.8. Surface plots .................................................................................................................... 156 6.9. Contour plots ................................................................................................................... 158 6.10. Combining 3-dimensional plots .......................................................................................... 161 6.11. Maps ............................................................................................................................. 163 6.12. Polygonal meshes ............................................................................................................ 165 6.13. Vector fields ................................................................................................................... 167 6.14. Volumes ........................................................................................................................ 170 6.15. Animation ...................................................................................................................... 173 6.16. Graphics devices ............................................................................................................. 176 6.17. Summary ....................................................................................................................... 182 7. Objects ...................................................................................................................................... 185 7.1. Concepts .......................................................................................................................... 186 7.2. Writing a class ................................................................................................................. 186 7.3. Inheritance ....................................................................................................................... 192 7.4. Operator overloading ......................................................................................................... 195 7.5. Tricks and techniques ........................................................................................................ 199 7.6. For those familiar with other object-oriented languages ............................................................ 200 8. Widgets ..................................................................................................................................... 203 8.1. Introduction ..................................................................................................................... 203 8.2. Simple example: MG_XPLOT .............................................................................................. 204 8.3. Widget programming details ............................................................................................... 209 8.4. A more complicated example: MG_XIMAGE ......................................................................... 210 8.5. Dialogs ............................................................................................................................ 217 iv
8.6. Compound widgets ............................................................................................................ 219 8.7. Object widgets .................................................................................................................. 223 8.8. Summary ......................................................................................................................... 234 9. Object graphics ........................................................................................................................... 237 9.1. Introduction ..................................................................................................................... 237 9.2. Displaying an image in object graphics ................................................................................. 237 9.3. The theory ....................................................................................................................... 239 9.4. A 3-dimensional example ................................................................................................... 243 9.5. The transformation matrix .................................................................................................. 247 9.6. Properties ........................................................................................................................ 250 9.7. Sample visualizations ......................................................................................................... 251 9.8. Texture mapping and transparency ....................................................................................... 268 9.9. Inheriting from an IDLgr class: MGgrCube ........................................................................... 272 9.10. Composite graphics classes ............................................................................................... 276 9.11. Sending output to other destinations ................................................................................... 277 9.12. Creating a new destination: MGgrWindow3D ....................................................................... 278 9.13. Widgets and objects graphics: interaction ............................................................................. 283 9.14. Widgets and object graphics: tiled imagery .......................................................................... 287 9.15. New graphics .................................................................................................................. 295 9.16. Summary ....................................................................................................................... 308 10. Using the iTools ........................................................................................................................ 309 10.1. What are the iTools? ........................................................................................................ 309 10.2. iTools basics .................................................................................................................. 310 10.3. Advanced iTools features .................................................................................................. 314 10.4. Scripting the iTools ......................................................................................................... 316 10.5. Summary ....................................................................................................................... 322 11. Performance .............................................................................................................................. 323 11.1. Introduction .................................................................................................................... 323 11.2. Timing .......................................................................................................................... 324 11.3. Vectorization .................................................................................................................. 326 11.4. Logic ............................................................................................................................ 333 11.5. Array and matrix techniques .............................................................................................. 335 11.6. The clever use of HISTOGRAM ......................................................................................... 339 11.7. Memory usage ................................................................................................................ 347 11.8. Object-oriented techniques ................................................................................................ 349 11.9. Summary ....................................................................................................................... 352 12. External development ................................................................................................................. 353 12.1. Techniques ..................................................................................................................... 353 12.2. SPAWN ......................................................................................................................... 354 12.3. CALL_EXTERNAL .......................................................................................................... 355 12.4. Dynamically loadable modules ........................................................................................... 356 12.5. Bridges .......................................................................................................................... 365 12.6. Python ........................................................................................................................... 367 12.7. Summary ....................................................................................................................... 368 A. Resources .................................................................................................................................. 371 A.1. Online help ..................................................................................................................... 371 v
A.2. Resources in the IDL distribution ........................................................................................ 371 A.3. Resources on the Internet ................................................................................................... 372 A.4. Books on IDL .................................................................................................................. 372 A.5. IDL code libraries ............................................................................................................ 373 A.6. IDL open source projects ................................................................................................... 374 B. Starting IDL ............................................................................................................................... 375 C. A style guide ............................................................................................................................. 379 C.1. General principles ............................................................................................................. 379 C.2. Layout ............................................................................................................................ 380 C.3. Comments ....................................................................................................................... 381 C.4. Statement formatting ......................................................................................................... 383 C.5. Variables ......................................................................................................................... 386 C.6. Routines .......................................................................................................................... 387 C.7. Object-oriented programming ............................................................................................. 388 D. The IDL library .......................................................................................................................... 391 D.1. Animation ....................................................................................................................... 391 D.2. Application development ................................................................................................... 391 D.3. Arrays ............................................................................................................................ 392 D.4. Color .............................................................................................................................. 393 D.5. Date and time .................................................................................................................. 394 D.6. Debugging ...................................................................................................................... 395 D.7. Dialogs ........................................................................................................................... 395 D.8. Error handling ................................................................................................................. 396 D.9. External development ........................................................................................................ 396 D.10. File input/output ............................................................................................................. 396 D.11. Fonts ............................................................................................................................ 398 D.12. Images .......................................................................................................................... 399 D.13. Internationalization .......................................................................................................... 402 D.14. Introspection .................................................................................................................. 402 D.15. Mapping ....................................................................................................................... 403 D.16. Mathematics .................................................................................................................. 404 D.17. Networking .................................................................................................................... 412 D.18. Object library ................................................................................................................. 412 D.19. OS access ...................................................................................................................... 413 D.20. Plotting ......................................................................................................................... 413 D.21. Profiling ........................................................................................................................ 416 D.22. Signal processing ............................................................................................................ 416 D.23. Statistics and probability .................................................................................................. 417 D.24. Strings .......................................................................................................................... 418 D.25. Structures ...................................................................................................................... 419 D.26. Type ............................................................................................................................. 420 D.27. Vector fields .................................................................................................................. 420 D.28. Wavelet Toolkit .............................................................................................................. 421 D.29. Widgets ........................................................................................................................ 421 D.30. Windows ....................................................................................................................... 423 Glossary ........................................................................................................................................ 425 vi
分享到:
收藏