Preface
Notices
How to Use This Book
What Is and Why Python?
Python: The good and the bad
Examples of AOS uses for Python
Using the Python Interpreter and Interactive Development Environment
Getting and installing Python
The easiest way: EPD
The mostly easy way, but for Ubuntu 12.04
The not as easy way, but it's still free
Getting and installing the course files
The Python interpreter
The command-line environment
The IDLE environment
Exercises using Python programming environments
Basic Data and Control Structures
Overview of basic variables and operators
Strings
Booleans
NoneType
Lists and tuples
Exercises with lists and tuples
Dictionaries
Exercises with dictionaries
Functions
Logical constructs
Looping
Looping a definite number of times
Looping an indefinite number of times
Exercises on functions, logical constructs, and looping
Modules
A brief introduction to object syntax
Exercise that includes using a module
Exception handling
Summary
Array Operations
What is an array and the NumPy package
Creating arrays
Array indexing
Exercises in creating and indexing arrays
Array inquiry
Array manipulation
General array operations
General array operations: Method 1 (loops)
General array operations: Method 2 (array syntax)
Exercise on general array operations
Testing inside an array
Testing inside an array: Method 1 (loops)
Testing inside an array: Method 2 (array syntax)
Exercise on testing inside an array
Additional array functions
Summary
File Input and Output
File objects
Text input/output
Text input/output: Reading a file
Text input/output: Writing a file
Text input/output: Processing file contents
Exercise to read a multi-column text file
NetCDF input/output
NetCDF input/output: Reading a file
NetCDF input/output: Writing a file
Exercise to read and write a netCDF file
Summary
A ``Real'' AOS Project: Putting Together a Basic Data Analysis Routine
The assignment
Solution One: Fortran-like structure
Solution Two: Store results in arrays
Solution Three: Store results in dictionaries
Solution Four: Store results and functions in dictionaries
Exercises on using dictionaries and extending your basic data analysis routine
Summary
An Introduction to OOP Using Python: Part I—Basic Principles and Syntax
What is object-oriented programming
Procedural vs. object-oriented programming
The nuts and bolts of objects
Example of how objects work: Strings
Exercise on how objects work: Strings
Example of how objects work: Arrays
Exercise on how objects work: Arrays
Defining your own class
Exercise on defining your own class
Making classes work together to make complex programming easier
Case study 1: The bibliography example
Structuring the Bibliography class
What sort_entries_alpha illustrates about OOP
Exercise in extending the Bibliography class
What the write_bibliog_alpha method illustrates about OOP
Case study 2: Creating a class for geosciences work—Surface domain management
Summary
An Introduction to OOP Using Python: Part II—Application to Atmospheric Sciences Problems
Managing metadata and missing values
What are masked arrays and masked variables?
Constructing and deconstructing masked arrays
Exercise using masked arrays
Managing related but unknown data: Seeing if attributes are defined
Exercise to add to the Atmosphere class
Dynamically changing subroutine execution order (optional)
Summary
Visualization: Basic Line and Contour Plots
What is matplotlib?
Basic line plots
Controlling line and marker formatting
Annotation and adjusting the font size of labels
Plotting multiple figures and curves
Adjusting the plot size
Saving figures to a file
Exercise on basic line plots
Basic contour plots
Exercise on basic contour plots
Superimposing a map
Exercise on superimposing a map
Summary
What Next?
What Python topics would be good to cover next?
Some packages of interest to AOS users
Additional references
A parting invitation
Glossary
Acronyms
Bibliography
Index