Presentation is loading. Please wait.

Presentation is loading. Please wait.

Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party.

Similar presentations


Presentation on theme: "Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party."— Presentation transcript:

1 Guy Griffiths

2 General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party libraries (currently 21,054 on the main python package website) Free!

3 Numpy Numerical library for python Written in C, wrapped by python Fast Scipy Built on top of numpy (i.e. Also fast!) Common maths, science, engineering routines Matplotlib Hugely flexible plotting library Similar syntax to Matlab Produces publication-quality output

4

5 An integrated graphical environment like Matlab (although there are tools which put it in one – e.g. Spyder) Specifically designed for scientists/mathematicians (but the 3 rd -party libraries for plotting/numerical work are some of the best around) High performance (but it is very easy to wrap C/Fortran libraries in Python code)

6 Yahoo Maps/Groups Google NASA ESRI Linux distros Met Office Me

7 How about several cool things that Python can do?

8 It can do everything Fast mathematical operations Easy file manipulation Format conversion Plotting Scripting Command line OK, not everything Write papers for you

9 Run programWrite to fileOpen MatlabRead in filePlot/AnalyzeClose Matlab

10 Run program which does plotting and analysis (and writes analysis to file) Have a break

11 Interactive prompt is great for experimenting iPython is a fantastic interactive environment I mostly write code in iPython interactively, then copy it out into a script when Im done print is easy and intuitive to use Yes, you should use a proper debugger, but lets face it – print statements are quicker and easier. Well, print statements in python are even quicker and easier than that.

12 Readable code You have to indent all of your loops, conditionals, etc. This means that your code will always be indented in a helpful way Inline documentation

13 3 rd -party libraries Numpy, Scipy, Matplotlib are standard libraries for scientific computing cf-python is written with meteorologists in mind There are 3 rd -party libraries for many, many things If you want to do something that isnt particularly uncommon, there will be a library to do it for you

14 No. But python can wrap your existing C/Fortran/R code... You can get the benefits of a high-level language whilst keeping your fast C/Fortran routines This is what Numpy does (and why Numpy is fast)...and Matlab code translates pretty easily to python.

15 A good language to teach Questions you wont hear if you teach python: What does Segmentation fault mean? Why do I have to click build before I run this every time? Do you know where I can download a license for this so I can use it at home? Questions you may still hear: Whats a variable? Why do we have to do this?

16 Lets have a look at a few python libraries in action

17 Firstly, get version 2.7.x. Python 3 is probably more trouble than its worth right now. Windows – Python(x,y) [www.pythonxy.com] This is a scientific/engineering oriented distribution of python. It includes everything you need to get started Linux – its already there! Unless youre running a very unusual distro (in which case you probably already know what youre doing). Mac – its already there on OS X, but its old. Get a more up-to-date one [www.python.org]

18 The official python tutorial: Software Carpentry: Dive into Python: Learn Python the Hard Way: A Byte of Python:

19 Python Essential Reference David M. Beazley (Addison Wesley) Programming in Python 3: A Complete Introduction to the Python Language Mark Summerfield (Addison Wesley) Learning Python Mark Lutz (OReilly Media)

20


Download ppt "Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party."

Similar presentations


Ads by Google