Welcome to the home page for the book A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences, by Johnny Wei-Bing Lin! The latest edition is the First Edition (2012). If you have any questions, comments, errata reports, etc., please email me at: pyintro at johnny-lin.com. (Please make sure the word "Python" is somewhere in the Subject line.)
If you use the Enthought Python Distribution (as described on p. 8 of the book), you cannot run the code samples in the book that access netCDF files without implementing a small fix. Please see the entry for the book's p. 8 on the Addenda and Errata page for details on working around the issue.
The book was written for Python 2.7. If you are using Python 3.x (which most
new users probably will be), you need to be aware of the
xrange function no longer exists. Wherever you
xrange in the book, just assume it says
uses floating point division, even when both
the numerator and denominator are integers.
raise to raise an exception has a new syntax.
values no longer
return lists. Neither does
range. To make lists out
of the return values, use the
list function, e.g.,
Test instead for
key in mydict
key is the key of
mydict is your dictionary object). Note that if a
value in your dictionary is the same as
key, the membership
testing will not return
. in front of the module name.
ndim that gives the number of dimensions
of an array, rather than
I plan to update the book someday for Python 3.x, but it might take me a while. Additional errata are found on the Addenda and Errata page.
Python is a modern, open-source, interpreted computer language whose use in the atmospheric and oceanic sciences (AOS) is growing by leaps and bounds. Yet, while many excellent resources exist for learning Python, there have not been any resources specifically written for the AOS user. This book is a hands-on introduction to Python written for AOS researchers, graduate students, and advanced undergraduates who are new to Python (seasoned Python users will find the book of limited use). It focuses not on computer science but on how Python can help AOS users do AOS work. It is not a reference manual but a mini-course, filled with examples and exercises (plus solutions). While we take a gentle, informal, and (hopefully) fun approach to learning Python, we do not aim to teach programming. We assume readers already know the basics of programming (e.g., variable assignment, looping, conditionals) in some other language.
About the Author
Johnny Wei-Bing Lin graduated from Stanford University with a B.S. in Mechanical Engineering and an M.S. in Civil Engineering-Water Resources. His Ph.D. is in Atmospheric Sciences from UCLA. He has chaired the American Meteorological Society (AMS)'s Python Symposiums and has taught or co-taught some of the AMS Python short courses. Currently, he is a Senior Lecturer and Director of Undergraduate Computing Education in the Computing and Software Systems Division of the University of Washington Bothell and an Affiliate Professor of Physics and Engineering at North Park University in Chicago.
Testimonial and Review
- Scott Sellars (Ph.D. Candidate,
Department of Civil and Environmental Engineering,
The Henry Samueli School of Engineering,
University of California, Irvine: November 2012):
Dr. Johnny Wei-Bing Lin's book, "A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences" offers an excellent introduction, description and application of the programming language Python to the earth sciences. His clear explanations and hands-on approach provides the necessary background knowledge and practice examples needed to learn the fundamentals of Python. As a graduate student attempting to transition from traditional programming languages and software to a more object-oriented perspective, Dr. Lin's book is an excellent starting point for anyone wanting to learn Python while researching or working with environmental data.
- Christopher Slocum reviewed the book in the August 2013 issue of Bull. Amer. Meteor. Soc. (pp. 1228–1229). AMS members can access this issue of BAMS Digital Edition here.
Versions of the Book
There are three versions of the book available. While the textual content is the same in all of them, you should know about the differences, so you can find the one that works for you:
|Feature||Print Version||Full PDF Version||Free PDF Version|
|Colors for text and figures?||Black-and-white text and margin notes; black-and-white figures||Black-and-white text and colored margin notes; color figures||Black-and-white text and colored margin notes; color figures|
|Hyperlinks?||Would-be links are disabled and uncolored||Enabled and colored hyperlinks, to both internal and external locations||Would-be links are disabled and uncolored|
|Chapters together?||All chapters bound together||All chapters in a single file||Each chapter in a separate file|
|Margin formatting?||Formatted for binding||Formatted for no binding||Formatted for no binding|
|Cost?||$20 (but you also get a special free gift with it; please see below)||$5||Free (download below)|
Not sure which version to get? Here are some of my thoughts on which to get, if you think it will help.
Buy the Book
A special gift for purchasing the printed version: The original owners of a print copy of this book can download a copy of the Full PDF version of the book (the latest version) for free. Please see the last page of the printed book (the Colophon page) for details (the gift is not obtained via Lulu).
Free PDF Downloads of the Book
- Front Matter
- Chapter 1: What Is and Why Python?
- Chapter 2: Using the Python Interpreter and Interactive Development Environment
- Chapter 3: Basic Data and Control Structures
- Chapter 4: Array Operations
- Chapter 5: File Input and Output
- Chapter 6: A "Real" AOS Project: Putting Together a Basic Data Analysis Routine
- Chapter 7: An Introduction to OOP Using Python: Part I—Basic Principles and Syntax
- Chapter 8: An Introduction to OOP Using Python: Part II—Application to Atmospheric Sciences Problems
- Chapter 9: Visualization: Basic Line and Contour Plots
- Chapter 10: What Next?
- Back Matter
Additional Resources Related to the Book
- About the Front Cover's Background Image
- Addenda and Errata
- List of Packages Needed
- PyAOS: A blog and mailing list helping to build up the atmospheric and oceanic sciences Python community.
- The Under the Microscope Comic Home Page
Free Code and Dataset Files for the Book
These files are found in a directory the book calls course_files. You can obtain this directory in a few ways; see the page Getting the Course Files for detailed instructions.