Size: 883
Comment:
|
Size: 1721
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 38: | Line 43: |
== 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 [[http://www.scipy.org/NumPy_for_Matlab_Users| differences]] but many similarities. == 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
Matplotlib/pylab for interactive plotting