Differences between revisions 2 and 3
Revision 2 as of 2013-04-03 19:39:40
Size: 1282
Editor: anonymous
Comment:
Revision 3 as of 2013-04-03 19:52:04
Size: 1721
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:

== Why Python? ==

 * [[http://journals.ametsoc.org/doi/full/10.1175/BAMS-D-12-00148.1|Why Python Is the Next Wave in Earth Sciences Computing]]
 
Line 60: Line 65:

== Documentation and tutorials ==

 * [[http://docs.python.org/2/tutorial/|Python tutorial]]
 * [[http://matplotlib.org/|Matplotlib/pylab]] for interactive plotting
 * [[http://docs.sympy.org/dev/tutorial/tutorial.en.html#first-steps-with-sympy|SymPy for symbolic mathematics]]

Python Quick Start

Why Python?

Starting the IPython shell

module load python/2.7-ve2

ipython -pylab

loads matplotlib module and enables interactive plotting

module load is a ZMAW specific environment setting! Version 2.7-ve2 is needed for the notebook version (see below).

Quit with CTRL-D

Getting help

help()
help modules

list available modules

Features of IPython:

  • Command history (up, down)
  • Word completion by typing TAB
  • System commands through magic functions cd, ls, env, pwd
  • Access to Unix shell by prefix !, e.g. !ls -s | sort -g

  • Debugging and profiling
  • Program control: run

  • Print interactive variables who, whos

Are you a Matlab user?

The exercise is to plot a sine wave:

Matlab/Octave:

>> x=linspace(0,2*pi,100)
>> y=sin(x)
>> plot(x,y)

Python

In [1]: x=linspace(0,2*pi,100)
In [2]: y=sin(x)
In [3]: plot(x,y)

So, it works pretty much the same way!

Of course there are some differences but many similarities.

Documentation and tutorials

LehreWiki: PythonQuickstart (last edited 2015-04-07 20:28:27 by anonymous)