Postprocessing with Python



Similar documents
Python for Scientific Computing.

Introduction to Python

Scientific Programming, Analysis, and Visualization with Python. Mteor 227 Fall 2015

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Scientific Programming in Python

SUNPY: PYTHON FOR SOLAR PHYSICS. AN IMPLEMENTATION FOR LOCAL CORRELATION TRACKING

Computational Mathematics with Python

Introduction Our choice Example Problem Final slide :-) Python + FEM. Introduction to SFE. Robert Cimrman

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

Computational Mathematics with Python

A Comparison of C, MATLAB, and Python as Teaching Languages in Engineering

Computational Mathematics with Python

Python. Python. 1 Python. M.Ulvrova, L.Pouilloux (ENS LYON) Informatique L3 Automne / 25

Analysis Programs DPDAK and DAWN

Introduction to Python

An Introduction to Using Python with Microsoft Azure

Programming Languages & Tools

Main Bullet #1 Main Bullet #2 Main Bullet #3

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Material for tutorial. Twitter: prabhu_r. Slides: Demos:

From mathematics to a nice figure in a LaTeX document

Code Estimation Tools Directions for a Services Engagement

HPC Wales Skills Academy Course Catalogue 2015

Introduction to ACENET Accelerating Discovery with Computational Research May, 2015

ANSA and μeta as a CAE Software Development Platform

3D Data visualization with Mayavi

Integrated Open-Source Geophysical Processing and Visualization

Introduction Installation Comparison. Department of Computer Science, Yazd University. SageMath. A.Rahiminasab. October9, / 17

Part VI. Scientific Computing in Python

Introduction to Python

Availability of the Program A free version is available of each (see individual programs for links).

CE 504 Computational Hydrology Computational Environments and Tools Fritz R. Fiedler

Python for Chemistry in 21 days

JMulTi/JStatCom - A Data Analysis Toolkit for End-users and Developers

The Piranha computer algebra system. introduction and implementation details

The Linux System. o Updating without touching the user's files and configurations.

Scientific Programming with Python. Randy M. Wadkins, Ph.D. Asst. Prof. of Chemistry & Biochem.

Getting more out of Matplotlib with GR

GlueTrack interpreter for S2E beam dynamic simulations. Igor Zagorodnov BDGM, DESY

David Boddie. PyCon UK 2007, Birmingham

Part I Courses Syllabus

An Introduction to APGL

Modelling cellular processes with Python and Scipy

Installing Java (Windows) and Writing your First Program

VisIt Visualization Tool

SIM-PL: Software for teaching computer hardware at secondary schools in the Netherlands

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

D is for Science. John Colvin

GR A universal framework for visualization applications

GUI application set up using QT designer. Sana Siddique. Team 5


Advanced Techniques with Newton. Gerald Ragghianti Advanced Newton workshop Sept. 22, 2011

Chemical and Biological Engineering Calculations using Python 3. Jeffrey J. Heys

Critical Strategies for Improving the Code Quality and Cross-Disciplinary Impact of the Computational Earth Sciences

Python for Computational Science and Engineering

How To Train A Face Recognition In Python And Opencv

Post-processing and Visualization with Open-Source Tools. Journée Scientifique Centre Image April 9, Julien Jomier

The Julia Language Seminar Talk. Francisco Vidal Meca

Setting up PostgreSQL

Developing a Computational Science IDE for HPC Systems

NaviCell Data Visualization Python API

Rebuild Perfume With Python and PyPI

CIS 192: Lecture 13 Scientific Computing and Unit Testing

Neutron Science Visualization Software

USE OF PYTHON AS A SATELLITE OPERATIONS AND TESTING AUTOMATION LANGUAGE

Supported platforms & compilers Required software Where to download the packages Geant4 toolkit installation (release 9.6)

Web development... the server side (of the force)

William E. Hart Carl Laird Jean-Paul Watson David L. Woodruff. Pyomo Optimization. Modeling in Python. ^ Springer

The University of Melbourne cyclone tracking software

Oracle Tools and Bindings with languages

GGobi meets R: an extensible environment for interactive dynamic data visualization

MayaVi: A free tool for CFD data visualization

OpenCobolIDE Documentation

Programming Languages

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003

Sourcery Overview & Virtual Machine Installation

Enterprise Web Developer : Using the Emprise Javascript Charting Widgets.

Building a Python Plugin

Introduction to UNIX and SFTP

Integrating TAU With Eclipse: A Performance Analysis System in an Integrated Development Environment

SCIENTIFIC COMPUTING AND PROGRAMMING IN THE CLOUD USING OPEN SOURCE PLATFORMS: AN ILLUSTRATION USING WEIGHTED VOTING SYSTEMS

OS X Modular Imaging and Deployment using Free and Open Source Tools

Web Services for Management Perl Library VMware ESX Server 3.5, VMware ESX Server 3i version 3.5, and VMware VirtualCenter 2.5

CRASH COURSE PYTHON. Het begint met een idee

Parallels Virtualization SDK ReadMe CONTENTS:

Using Python in Climate and Meteorology

Functions of NOS Overview of NOS Characteristics Differences Between PC and a NOS Multiuser, Multitasking, and Multiprocessor Systems NOS Server

arxiv: v1 [cs.ce] 16 Jul 2012

by Pearson Education, Inc. All Rights Reserved.

Introduction to Linux and Cluster Basics for the CCR General Computing Cluster

Linux Cluster Computing An Administrator s Perspective

OpenMake Dynamic DevOps Suite 7.5 Road Map. Feature review for Mojo, Meister, CloudBuilder and Deploy+

Installing TeamCall Server on Mac OS X

Setting up Python 3.4 and numpy and matplotlib on your own Windows PC or laptop

Tutorial on XRF Data Analysis

Network operating systems typically are used to run computers that act as servers. They provide the capabilities required for network operation.

Database and data-analysis infrastructure for atmospheric studies. Takeshi Horinouchi RISH, Kyoto Univ.

Course MS10975A Introduction to Programming. Length: 5 Days

Transcription:

Postprocessing with Python Boris Dintrans (CNRS & University of Toulouse) dintrans@ast.obs-mip.fr Collaborator: Thomas Gastine (PhD)

Outline

Outline Introduction - what s Python and why using it? - Installation procedure

Outline Introduction - what s Python and why using it? - Installation procedure Python and the Pencil Code - the Python repository and initialization - Migrating from IDL to Python - Some examples & tricks - Parallel Python with Pypar - Doing widgets with PyQt

Outline Introduction - what s Python and why using it? - Installation procedure Python and the Pencil Code - the Python repository and initialization - Migrating from IDL to Python - Some examples & tricks - Parallel Python with Pypar - Doing widgets with PyQt Conclusion/Outlook

What s Python?

What s Python? Python was created in 1991 by Guido van Rossum (CWI, Centrum voor Wiskunde en Informatica, Amsterdam) Benevolent Dictator for Life (BDFL)

What s Python? Python was created in 1991 by Guido van Rossum (CWI, Centrum voor Wiskunde en Informatica, Amsterdam) Benevolent Dictator for Life (BDFL)

What s Python? Python was created in 1991 by Guido van Rossum (CWI, Centrum voor Wiskunde en Informatica, Amsterdam) Benevolent Dictator for Life (BDFL)

The first release in 1991 on alt.sources

DARPA funding proposal Computer Programming for Everybody (1999):

DARPA funding proposal Computer Programming for Everybody (1999): an easy and intuitive language just as powerful as major competitors open source, so anyone can contribute to its development code that is as understandable as plain English suitability for everyday tasks, allowing for short development times

DARPA funding proposal Computer Programming for Everybody (1999): an easy and intuitive language just as powerful as major competitors open source, so anyone can contribute to its development code that is as understandable as plain English suitability for everyday tasks, allowing for short development times year 1991 1994 1995 2001 2003 2007 2009 version 0.9 1.0 1.2 2.0 2.2 2.5 3.0

DARPA funding proposal Computer Programming for Everybody (1999): an easy and intuitive language just as powerful as major competitors open source, so anyone can contribute to its development code that is as understandable as plain English suitability for everyday tasks, allowing for short development times year 1991 1994 1995 2001 2003 2007 2009 version 0.9 1.0 1.2 2.0 2.2 2.5 3.0 Why Python? - it s free! ;-) - quite easy to use; object-oriented; highly modular, etc... - much more rapid than IDL and even PARALLEL

The main Python website: www.python.org

The SciPy website: www.scipy.org

How to install Python?

How to install Python? Required: python 2.5: the engine numpy: the scientific computing package (arrays, linear algebra, FFT, random numbers, etc...); [replaces old numarray and numeric] scipy: modules for integrating ODEs, optimizing functions, etc... [tends to federate all of Python scientific modules] matplotlib: MATLAB-inspired mostly-2d plotting modules

How to install Python? Required: python 2.5: the engine numpy: the scientific computing package (arrays, linear algebra, FFT, random numbers, etc...); [replaces old numarray and numeric] scipy: modules for integrating ODEs, optimizing functions, etc... [tends to federate all of Python scientific modules] matplotlib: MATLAB-inspired mostly-2d plotting modules Optional: ipython: convenient shell to develop and run Python basemap: map projections Pypar: parallel Python (interface with MPI libraries) PyQt: to do Qt-like widgets VERY easily under Python MayaVi: 3D plotting

http://python.org/download/

From sources or binary packages?

From sources or binary packages? For all platforms: everything can be compiled from sources For Linux, Windows & Mac (at least): binaries are provided (Linux: yum, apt-get, dpkg; Mac: Fink, MacPorts, dmg)

From sources or binary packages? For all platforms: everything can be compiled from sources For Linux, Windows & Mac (at least): binaries are provided (Linux: yum, apt-get, dpkg; Mac: Fink, MacPorts, dmg) Linux (FedoraCore 7) Mac OS X 10.4 (Tiger) Python 2.5.12 2.5.2 Numpy 1.0.3 1.0.4 Scipy 0.6.0 0.7.0 Matplotlib 0.90.0 0.90.1 ipython 0.8.1 0.8.2

Typical installation on a Linux box

Python on Mac OSX: www.pythonmac.org/packages/py25-fat

Scipy Superpack for OS X: http://macinscience.org/?page_id=6

Python packages on my Macbook Pro (SciPy Superpack)

Python in the Pencil Code repository: f90/pencil-code/numpy commited by Jeff in fall of 2007 revision 1.1 date: 2007-11-16 13:57:04 +0000; author: joishi; state: Exp; * added python scripts for reading pencil code data. they require only the numpy package, but matplotlib is useful for plotting. almost all of these routines are simplified clones of their idl counterparts. i'd love to make a more OO pencil-code package, but my current occupational constraints make that unlikely in the near term. NB: the byte ordering in python is C, not fortran, so these routines return an f array with shape f[nvar,nz,ny,nx]--the reverse of pencil. * added nl2python to take advantage of the amazing perl F90Namelist.pm * modified F90Namelist.pm to output python * i hope these are moderately useful to people!

The actual Python tree: 3 directories The reading stuff numpy/pencil/files init.py yzaver.py yaver.py xyaver.py npfile.py dim.py param.py grid.py slices.py zprof.py index.py var.py ts.py

The actual Python tree: 3 directories The reading stuff The math stuff numpy/pencil/math numpy/pencil/files init.py yzaver.py yaver.py xyaver.py npfile.py dim.py param.py grid.py slices.py zprof.py index.py var.py ts.py init.py vector_multiplication.py derivatives/ numpy/pencil/math/derivatives init.py der.py div_grad_curl.py der_6th_order_w_ghosts.py

...and the initialization of $PYTHONPATH in f90/pencil-code/sourceme.csh # Set PYTHON path if ($?PYTHONPATH) then setenv PYTHONPATH "${PYTHONPATH}:${PENCIL_HOME}/numpy" else setenv PYTHONPATH "${PENCIL_HOME}/numpy" endif

...and the initialization of $PYTHONPATH in f90/pencil-code/sourceme.csh # Set PYTHON path if ($?PYTHONPATH) then setenv PYTHONPATH "${PYTHONPATH}:${PENCIL_HOME}/numpy" else setenv PYTHONPATH "${PENCIL_HOME}/numpy" endif These modules are loaded when importing the whole pencil directory due to the init.py file

cat numpy/pencil/ init.py

cat numpy/pencil/ init.py In [1]: import pencil as pc In [2]: pc.read_ts()

An important point: Python s classes Python is an object-oriented interpreted language: instead of doing pc.read_ts(), it is better to do a=pc.read_ts()

An important point: Python s classes Python is an object-oriented interpreted language: instead of doing pc.read_ts(), it is better to do a=pc.read_ts()... and we can plot the other variables read in time_series.dat and embedded in object a

Another example when using pc.read_var()

Another example when using pc.read_var()...and we plot the entropy at the top of the 32^3 box

Another examples of postprocesing with Python MayaVi: 3D plots Basemap: various kind of map projections

http://code.enthought.com/projects/mayavi/

Be careful: Python s arrays are ordered like f[nvar,mz,my,mx] i.e. REVERSED ORDER COMPARED TO PENCIL- CODE OR IDL!!!

Migrating from IDL to Python: some useful Web Guides http://www.stsci.edu/resources/software_hardware/numarray/idl2numarray

http://mathesaurus.sourceforge.net/idl-numpy.html

For lazy guys: the i2py converter http://code.google.com/p/i2py/

Some tricks when using Python...

Some tricks when using Python... plays with ~/.ipython/ipythonrc to load modules by default (import_all pencil) and thus use read_var instead of pc.read_var(), etc...

Some tricks when using Python... plays with ~/.ipython/ipythonrc to load modules by default (import_all pencil) and thus use read_var instead of pc.read_var(), etc... import just what you need! (a cleaning is certainly needed in that respect in the PC tree...)

Some tricks when using Python... plays with ~/.ipython/ipythonrc to load modules by default (import_all pencil) and thus use read_var instead of pc.read_var(), etc... import just what you need! (a cleaning is certainly needed in that respect in the PC tree...) launch ipython with the -pylab option to call directly plot, contour, imshow, etc...

Some tricks when using Python... plays with ~/.ipython/ipythonrc to load modules by default (import_all pencil) and thus use read_var instead of pc.read_var(), etc... import just what you need! (a cleaning is certainly needed in that respect in the PC tree...) launch ipython with the -pylab option to call directly plot, contour, imshow, etc... accelerate the VAR* reading by passing param, grid, index, etc... [tricks.py]

Some tricks when using Python... plays with ~/.ipython/ipythonrc to load modules by default (import_all pencil) and thus use read_var instead of pc.read_var(), etc... import just what you need! (a cleaning is certainly needed in that respect in the PC tree...) launch ipython with the -pylab option to call directly plot, contour, imshow, etc... accelerate the VAR* reading by passing param, grid, index, etc... [tricks.py] accelerate the graphics by using an handle [tricks.py]

Some tricks when using Python... plays with ~/.ipython/ipythonrc to load modules by default (import_all pencil) and thus use read_var instead of pc.read_var(), etc... import just what you need! (a cleaning is certainly needed in that respect in the PC tree...) launch ipython with the -pylab option to call directly plot, contour, imshow, etc... accelerate the VAR* reading by passing param, grid, index, etc... [tricks.py] accelerate the graphics by using an handle [tricks.py] take advantage of class and objects (a.shape instead of shape(a))

Parallel Python using the Pypar module http://sourceforge.net/projects/pypar

Pypar example 1: compute a vertical profile in parallel

Pypar example 2: write PNG files in parallel for a movie

Widgets using Qt Designer + PyQt

Conclusion/Outlook

Conclusion/Outlook Python can do a very good job in the Pencil Code postprocessing Its using is rapidly increasing in astrophysics (NASA, ESA, ESO, labs,...) More in the Pencil Code philosophy (i.e. under GPL) compared to IDL

Conclusion/Outlook Python can do a very good job in the Pencil Code postprocessing Its using is rapidly increasing in astrophysics (NASA, ESA, ESO, labs,...) More in the Pencil Code philosophy (i.e. under GPL) compared to IDL the actual Python subroutines must be rewritten in a more oriented-object form (class inheritance) the Python tree shall maybe be re-organized in something like f90/pencil-code/python or??? what s about the calling of Fortran or C subroutines to increase the speed?