This is an old revision of the document!
As can be expected, there is a lot of online python documentation available, and it's easy to get lost. You can always use google to find an answer to your problem, and you will probably end up looking at lots of answers on Stack Overflow or a similar site. But it's always better to know where you can find some good documentation… and to spend some time to read the documentation
This page tries to list some python for the scientist related resources, in a suggested reading order. Do not print anything (or at least not everything), but it's a good idea to download all the pdf files in the same place, so that you can easily open and search the documents
You do not need to read all the python documentation at this step, but it is really well made and you should at least have a look at it. The Tutorial is really well made, and you should have a look at the table of content of the Python Standard Library. There is a lot in the default library that can make your life easier
Summary: Python provides ordered objects (e.g. lists, strings, …) and some math operators, but you can't do real heavy computation with these. Numpy makes it possible to work with data arrays and using array syntax and masks (instead of explicit nested loops and tests) and the apropriate numpy functions will allow you to get performance similar to what you would get with a compiled program! Scipy adds more scientific functions
How to get started?
0
and that the last element of an array is at index -1
! Learn about indexing and slicing by manipulating a string (try 'This document by JY is awesome!'[::-1]
)Summary: there are lots of python libraries that you can use for plotting, but Matplotlib has become a de facto standard
Where: Matplotlib web site
The documentation is good, but not always easy to use. A good way to start with matplotlib is to:
Summary: Basemap is an extension of Matplotlib that you can use for plotting maps, using different projections
Where: Basemap web site
How to use basemap?
Summary: One document to learn numerics, science, and data with Python
This is a really nice document that is regularly updated and used for the EuroScipy tutorials
You can already get a very efficient script by checking the following:
If your script is still not fast enough, there is a lot you can do to improve it, without resorting to parallelization (that may introduce extra bugs rather that extra performance). See the sections below
Hint: before optimizing your script, you should spent some time profiling it, in order to only spend time improving the slow parts of your script
The official Porting Python 2 Code to Python 3 page gives the required information to make the transition from python 2 to python 3. It is still safe to use Python 2.7, so there is no rush to change to Python 3.
[ PMIP3 Wiki Home ] - [ Help! ] - [ Wiki syntax ]