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.)

Major Errata

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 following changes: The print function syntax now looks like any other function, e.g., print("Hello") .

function syntax now looks like any other function, e.g., . The xrange function no longer exists. Wherever you see xrange in the book, just assume it says range .

function no longer exists. Wherever you see in the book, just assume it says . The division operator ( / ) uses floating point division, even when both the numerator and denominator are integers.

) uses floating point division, even when both the numerator and denominator are integers. Using raise to raise an exception has a new syntax.

to raise an exception has a new syntax. Dictionary methods keys and values no longer return lists. Neither does range . To make lists out of the return values, use the list function, e.g., list(mydict.keys()) .

and no longer return lists. Neither does . To make lists out of the return values, use the function, e.g., . Dictionaries no longer have the has_key method. Test instead for key in mydict (where key is the key of interest and mydict is your dictionary object). Note that if a value in your dictionary is the same as key , the membership testing will not return True .

method. Test instead for (where is the key of interest and is your dictionary object). Note that if a value in your dictionary is the same as , the membership testing will not return . Relative imports (i.e., importing a module in the current directory) require the use of . in front of the module name.

in front of the module name. The version of NumPy generally installed with Python 3.x has a function ndim that gives the number of dimensions of an array, rather than rank .

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.

Summary

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 Cover? Yes Yes No 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

Additional Resources Related to the Book

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.