PyCAS

Some notes from the Centre for Atmospheric Science Python user group.

About PyCAS

We are an informal group of Python users in the Centre of Atmospheric Science, University of Manchester. We plan on meeting roughly every two weeks to discuss Python-related problems, and learn some new Python along the way.

Meetings

(Notes from the previous meetings can be found here)

The next meeting will be on Friday 6th May at 12:30pm in Room 1.10. Biscuits will be provided. Bring your own lunch.

Next Focus Topic

Text files, importing data, extracting what you want from arrays

Format of the meeting

In general meetings will take the following format:

We start with a brief informal discussion (~20 mins) session where people can ask about any Python-related question they like. Maybe you’ve heard of some cool new Python feature or Python-news. People may also bring bits of Python code they are having trouble getting to work, and we can collectively try and find solutions. There is not set theme of discussion.

The remainder of the meeting we will focus on a pre-arranged Python topic. About a week before the meeting I’ll send out a task or bit of code for us all to work through (It will not be a massive task to complete! Maybe half an hour if things go smoothly…) Then, in the meeting we will go through a solution to the problem, and we can talk about any problems we ran into, and how we might extend it to our own work. Note: Anyone can volunteer to lead this session or set the task!

The meeting should last no more than an hour roughly. You are welcome to come to either half, both, or neither.

Learning Python

We decided that the meetings will not be a step-by-step guide to learning Python from scratch. There are lots of good resources and courses out there on the internet that can do that sort of thing better, so you are encouraged to have a look at those. Python is said to be an intuitive language to learn, especially if you already have some programming knowledge, so hopefully you’ll pick it up quickly!

Online courses

Python for the Scientific Researcher.
These are a series of courses covering NumPy, matplotlib, cartopy, and iris. Developed by the Met Office, they can be read as static pages, but are best experienced by downloading the IPython notebook files and running through them interactively with the ipython notebook viewer on your own PC. (You may need to install ipython first).

Python for Earth Scientists.
Some good, concise notes about using Python for geosciences/atmos sciences. Includes Numpy, Matplotlib, etc.

Basemap tutorial.
Basemap is a standard extension of matplotlib for plotting 2D data over outline maps. It has a large library of maps and projections and is fairly straightforward to use.

The alternative to Basemap is Cartopy. It requires separate installation on top of matplotlib (fairly painless), but is arguably more powerful and feature-rich.

Real-life courses with humans

Introduction to Numerical Computing with Python
Internal course run by research IT. Requires UoM login to book.

Scientific Python
Organised by ARCHER/PRACE. The date is yet to be confirmed but will be held in Liverpool.

Useful Resources

More permanent links and resources. Documentation and guides to Python, NumPy, matplotlib etc.

IPython Notebook
The IPython notebook is a useful tool to interactively play with Python and Matplotlib, rendering the output instantly in your browser. You need to have Ipython installed on your PC. Then you can start it from the terminal with:ipython notebook

The Matplotlib gallery
Sometimes the best way to learn matplotlib is to browse the sample gallery of plots, and then adapt a script to your own needs. There are all kinds of plot types available. The documentation is also well written.

Arrays and Matrices

NumPy
NumPy is one of the main add-on modules for Python used in scientific computing. It is designed to efficiently arrange and process data in arrays or matrices. (Python’s built-in array functionality is somewhat limited without NumPy.). For Matlab converts, they even have a site dedicated to switching over to the light side: MATLAB vs NumPy differences. NumPy is intended to mirror the functionality of languages like Matlab, IDL, etc.

Statistical and Scientific Functions

SciPy
SciPy is a Python module that contains a range of scientific functions. If Fourier transforms, linear algebra, statistaical analysis, signal processing, image processing, etc., is your thing, you will probably find a function for it in SciPy. It covers most of the functionality of the R programming language, as well as the expensive add-on packages for Matlab.

Links to useful bits of python go here:

You can link directly to iPython Notebooks on github:
Plotting netCDF data
Radar data plotting
Erosion Law Uncertainty Plots

The Rules of Python Club

  1. Talk about Python Club. Tell your friends and loved ones how amazing Python and how it is the future of Scientific Computing.
  2. Talk about Python Club. How many times have you talked about Python today? Less than four? Try harder.
  3. There are no silly questions.
  4. There is no code problem too small.
  5. There is no problem that cannot be solved with Python. (Except synthesising the sound of a Bassoon.)
  6. Do not talk about IDL. Unless it’s “How do I re-write this god-awful IDL script in Python.”
  7. Please wear clothing to meetings. Shoes are optional.
  8. Python Club will exist for as long as it has to.
  9. If this is your first time to Python Club, you get a biscuit.