Python Resources
There are loads of python blogs on the internet. The aspiration of this blog is to provide useful tips on using Python for data analysis for climate science. To start, here are some Python resources I have found useful.
-
Johnny Lin’s book A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences is a friendly introduction. He also runs a Python climate science user mailing list and has a list of climate science python tutorials. More recently, there’s this book: Python Programming and Visualization for Scientists.
-
Wes McKinney’s book Python for Data Analysis is another good primer with chapters devoted to Numpy, Pandas and matplotlib. Wes McKinney has a finance background and is the original author of the Pandas library, as a result, examples from the book are of less interest to climate scientists.
-
Pandas is an excellent python tool for manipulating 2d data sets. There is an overview of Pandas here.
-
PyData is a twice annual conference on using Python for scientists, engineers, and data analysts. You can watch some of the presentations from the March 2012 conference here. The videos are a great way to get an overview and learn about the ragedy edge in our favourite modules.
-
The ‘ARC Center of Excellence for Climate System Science’ has a code repository on github. The repository includes Python scripts. The idea is to provide a common space where all the CCRC/ARC CoECSS staff/students share functions, scripts and programs that might be useful for people working on climate science problems.
-
netcdf4-python is now the standard python interface netCDF. There’s a list of other Python netCDF paraphernalia here and here.
-
Pip or Conda and IPython will make your python life a million times more pleasant. Use it. Speaking of pleasant, make IPython use Vi editing and automatic indenting (in particular where it turns tabs into spaces).
-
Want to just start hacking from examples? Check out these gems and these gems.
-
Need some great practical tips on best practice?
-
Pdb is a handy built-in debugger. There’s a quick tour here.
-
Python logging is worth the effort (i.e. it really is better than print statements).
-
Since we want our results to be transparent and reproducible, there’s really no excuse for not using version control. Bitbucket and Git work wonderfully.
-
Felipe Fernandes writes an interesting blog not dissimilar to this, he has tips and examples for using Python in oceanography.
Plotting using matplotlib:
Coming from matlab? The following two links are a cheat sheet and instructions on how to import .mat files.
If there are other resources you think are great, send me an email and I’ll look into it.