Python for Matlab Users - CSDMS · Python for Matlab Users ... Python Snakes Its Way Into HPC Andy...

30
CU Research Computing: University of Colorado Boulder Python for Matlab Users Thomas Hauser Director of Research Computing [email protected] Monte Lunacek HPC Application Specialist [email protected]

Transcript of Python for Matlab Users - CSDMS · Python for Matlab Users ... Python Snakes Its Way Into HPC Andy...

CU Research Computing: University of Colorado Boulder

Python for Matlab UsersThomas Hauser Director of Research Computing [email protected] 

Monte Lunacek HPC Application Specialist [email protected] 

Who are we?

CU Research Computing: University of Colorado Boulder 2/30

What is Python?

CU Research Computing: University of Colorado Boulder 3/30

What is Python?

CU Research Computing: University of Colorado Boulder

Flexible, powerful programming language

Easy, clean syntaxVery readable codeBalanced high level programming with low­level optimization

Large community of support

Free as in free beerFree as in free speech

·Object orientedRuns everywhereTesting framework

­­­

···

Pyrex, CythonF2py

­­

·Modular system, large number of libraries­

··

4/30

Minimum packages for computationalscience

CU Research Computing: University of Colorado Boulder

python: the base languagenumpy: arrays, fast operations on arraysscipy: higher level computational routinesmatplotlib: plottingipython: notebooks, flexible shell, and parallelpandas: data analysis

······

5/30

What can you do with Python?

CU Research Computing: University of Colorado Boulder

OS support: manage files and directoriesGlue existing applicationsLAPACK and BLAS: access powerful C and Fortran librariesParallelData AnalysisVisualizationGUI programmingScrape websitesBuild websitesAnything!

··········

6/30

OutlinePart One

Part Two

CU Research Computing: University of Colorado Boulder

Python Overview (30 minutes)

Lab (10 minutes)Break (10 minutes)

·IPython and NotebookFunctions, lists, and Dictionaries

­­

··

Numpy (20 minutes)Plotting with Matplotlib (10 minutes)Lab (10 minutes)Data Analysis (20 minutes)

····

7/30

Python OverviewTest driving three ways to interact with PythonFunctions, lists, dictionaries

··

Hello World

What do you notice about this code?

CU Research Computing: University of Colorado Boulder

#!/Users/mlunacek/anaconda/bin/python

def say_hello(): print 'hello world'

say_hello()

PYTHON

9/30

Three ways to run

CU Research Computing: University of Colorado Boulder 10/30

Terminal

CU Research Computing: University of Colorado Boulder

$ ls hello_world.py hello_world.py$ python hello_world.py hello world$ ./hello_world.py hello worldbash-mac$

BASH

11/30

IPython shell

CU Research Computing: University of Colorado Boulder

OS supportFormatted printTab Completion%run

HistoryIntrospection (?,??)%paste and %cpaste

····

Persistence­···

12/30

Quick Introduction to Python

How

CU Research Computing: University of Colorado Boulder

FunctionsListsDictionaries

···

IPython terminalNotebook

··

13/30

/Users/mlunacek/Documents/tutorials/python/python_hpc/Python4Matlab

data_analysis

dictionary_and_lab

functions_and_lists

matplotlib

numpyTutorial

python4matlab

To import a notebook, drag the file onto the listing below or click here.

CU Research Computing: University of Colorado Boulder 14/30

CU Research Computing: University of Colorado Boulder

Lab and BreakDictionaries

15/30

Endthought

http://www.enthought.com/

CU Research Computing: University of Colorado Boulder 16/30

Anaconda

https://store.continuum.io/cshop/anaconda

CU Research Computing: University of Colorado Boulder 17/30

Github

https://github.com/ResearchComputing/python_hpc

CU Research Computing: University of Colorado Boulder 18/30

Lab

CU Research Computing: University of Colorado Boulder

Go to the directory where you dowloaded the codeunzip the fileNavigate to Python4MatlabLaunch IPython Notebook

····

ipython notebook

dictionary_and_lab

­­

19/30

/Users/mlunacek/Documents/tutorials/python/python_hpc/Python4Matlab

data_analysis

dictionary_and_lab

functions_and_lists

matplotlib

numpyTutorial

python4matlab

To import a notebook, drag the file onto the listing below or click here.

CU Research Computing: University of Colorado Boulder 20/30

CU Research Computing: University of Colorado Boulder

Numpy and Matplotlib

21/30

/Users/mlunacek/Documents/tutorials/python/python_hpc/Python4Matlab

data_analysis

dictionary_and_lab

functions_and_lists

matplotlib

numpyTutorial

python4matlab

To import a notebook, drag the file onto the listing below or click here.

CU Research Computing: University of Colorado Boulder 22/30

CU Research Computing: University of Colorado Boulder

Lab 2Numpy and Matplotlib

23/30

/Users/mlunacek/Documents/tutorials/python/python_hpc/Python4Matlab

data_analysis

dictionary_and_lab

functions_and_lists

matplotlib

numpyTutorial

python4matlab

To import a notebook, drag the file onto the listing below or click here.

CU Research Computing: University of Colorado Boulder 24/30

CU Research Computing: University of Colorado Boulder

PandasData Analysis

25/30

/Users/mlunacek/Documents/tutorials/python/python_hpc/Python4Matlab

data_analysis

dictionary_and_lab

functions_and_lists

matplotlib

numpyTutorial

python4matlab

To import a notebook, drag the file onto the listing below or click here.

CU Research Computing: University of Colorado Boulder 26/30

What did we learn?

CU Research Computing: University of Colorado Boulder

Python's syntax is cleanNotebook, IPython terminalData structures

Ways to act on these containersPlotting with matplotlib

···

Lists, dictionaries,numpy arrayspandas DataFrame

­­­

··

27/30

What's next?

CU Research Computing: University of Colorado Boulder 28/30

Links

CU Research Computing: University of Colorado Boulder

Scientific Programming: scipyParallel Computing

Performance

Templates: jinja2SQL database: sqlalchemyWebsites: djangoHardware Raspbery Pi

··

IPython Parallelmpi4py

­­

·profilingf2pycythonctypes

­­­­

····

29/30

References

Thank you!

CU Research Computing: University of Colorado Boulder

Python Scripting for Computational SciencePython Snakes Its Way Into HPCAndy Terrel: Getting Started with Python in HPCPython TutorialThink PythonEnthoughtAnacondaData Analysis with Python

········

30/30