Anda di halaman 1dari 14

Scientific Python for Engineering Faculty

A Numerical Computation and Data Visualization Platform


for Teaching and Research

Satish Annigeri
Professor, Civil Engineering Department

B.V.B. College of Engineering & Technology


Hubli 580 031

16 Aug, 2014

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 1 / 14
What is Python

Python is a modern programming language that supports both


procedural and object oriented programming paradigms.
Python is an interpreted programming language with dynamic typing.
It is designed to be highly readable and easy to learn.
Python is open source.
Python has a huge number of libraries for a wide variety of
applications.
You can develop a variety of applications for the desktop, web and
mobile.
Has a rich set of data types, many more than most programming
languages - Lists, Tuples, Dictionaries, Sets.
Python libraries are called modules.
Modules can be written in Python, C/C++ or Fortran.
Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 2 / 14
Scientific Python

Python does not have a built-in array data type, instead it has List,
which is a generalized array but is inefficient to represent an array.
NumPy module implements the general n-dimensioned array data
type for Python and operations on these n-dim arrays.
Matplotlib module implements a Matlab-like graph plotting library
based on NumPy arrays.
SciPy module implements a number of algorithms for numerical
computations using NumPy arrays.
Together, they are the basic components of Scientific Python,
sometimes referred to as Pylab.
You may require additional modules depending on your applications
area.

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 3 / 14
Application Areas

Statistics, Statistical Modelling, Big Data


Pandas module implements Data Frame data structure for data
munging, data input and output, basic statistics and data plotting.
statsmodels module for statistical modelling, including regression
analysis.
scikit-learn module for machine learning.
Image Processing
scikit-image module for image processing
OpenCV and SimpleCV modules for computer vision.
Bioinformatics
Biopython and/or scikit-bio for Bioinformatics
Finite Element Method
FEniCS and DOLFIN or SfePy modules for Finite Element Method

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 4 / 14
Python is Versatile

Multiple mode of computing: Interactive or Programming mode


Multiple programming paradigms: Procedural or Object Oriented
Multiple GUI frameworks: wxPython, PySide, PyQT
Huge collection of modules to do almost anything you want
Multiple development environments: IPython, Spyder IDE, IPython
Notebook, PyDev (Eclipse Python plugin)
Use any existing C/C++ library with little or no modification
Speed up execution with little or no modification to Python code
Used as a scripting language for many popular programs
Abaqus Finite Element Analysis application
ArcGIS GIS application
BioNumerics
Blender 3D modelling, animation, effects and rendering
Autodesk Maya 3D modelling, animation, effects and rendering
Autodesk Inventor Object oriented 3D toolkit
Parallel computing
Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 5 / 14
IPython Notebook as a Pedagogical Tool

Ipython Notebook combines code, documentation and output in a


single file
IPython Notebook is in JSON format, which is a simple text format
It completely reproduces a numerical experiment at a given point of
time - Reproducible research
Is easy to share
Can be converted to multiple formats - HTML, LATEX, PDF (via LATEX),
Slide show
IPython Notebook in the Cloud
Wakari
SageNotebook
Google Docs (very soon)
IPython Notebook is programming Language agnostic
Julia
R
Haskell
Scilab
Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 6 / 14
Benefits of Learning Python

Being Open Source, you get access to the source code to core Python
as well as all the modules
Python has an extremely friendly community, and all contributions are
welcomed
You and your students can contribute to many Python Projects
You can customize many complex applications, such as Abaqus
IPython Notebook is an excellent pedagogical tool
IPython Notebooks are created, viewed and modified within a web
browser
IPython Notebook is a combination of a document and an IDE
Documentation can be written in simple markup language called
Markdown and can contain LATEX equations, images, video and
content from other websites
Code can be written, modified and executed within the Notebook
Output of the code, including graphs, are displayed in the Notebook
Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 7 / 14
Installing Scientific Python

Easiest way - Ready to install, complete scientific Python stack, in


binary format
Anaconda from Continuum Analytics with conda package manager
and virtual environment manager
Canopy from Enthought with enpkg package manager
Easy way - From Python Package Index (PiPI) using pip package
manager
Not so easy way - Install from source
Operating Systems and Versions
Microsoft Windows, GNU/Linux and Mac OS X
Available in 32-bit and 64-bit versions for each operating system
Available in Python 2 and Python 3
Current versions are Python 2.7.x and Python 3.4.x

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 8 / 14
Source of Scientific Python Modules

Python Package Index (PyPI) - pip


Anaconda Package Repository - conda
Canopy Package Index - enpkg

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 9 / 14
Installing Anaconda on Microsoft Windows

Download 32-bit or 64-bit version of Anaconda, as appropriate for


your operating system from http://continuum.io/downloads.
Run the downloaded file and choose all default options during
installation.
By default, Anaconda will be added to your Start menu.
Run and test each of the following components from the Start menu:
IPython text console:
ipython
Spyder GUI IDE:
spyder
IPython Notebook:
ipython notebook
Remember to shutdown the IPython Notebook server when finished
working with Notebooks. Go to the MS-DOS prompt (or Linux
Terminal) from where you started the server and press Ctrl+C twice
Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 10 / 14
Adding Packages to an Existing Anaconda Installation

Installing a package from Anaconda package repository using conda


Get help on using conda:
conda help
Search for a package by name:
conda search package
Install a package:
conda install package
Update an installed package:
conda update package
List installed packages:
conda list
Uninstall an installed package:
conda remove package

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 11 / 14
Adding Packages into an Existing Anaconda Environment

Installing a package from PyPI (Python Package Index) using conda


Get help on using conda:
pip -h
Search for a package by name:
pip search package
Install a package:
pip install package
Update an installed package:
pip install -U package
List installed packages:
pip list
Uninstall an installed package:
pip uninstall package
Install from PyPI (using pip) only the package is not available in
Anaconda repository

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 12 / 14
Virtual Environments using conda

A virtual environment is a sandboxed Python installation that can


coexist with other virtual Python environments
Each virtual environment has a unique name and can have its own
Python version and set of packages customized for a specific
application
The sequence of operations usually involves the following steps:
Create a new virtual environment with default version of Python:
conda create -n env
Create a virtual environment, with its own name and possibly its own
version of Python:
conda create -n env python=3.4
Activate a virtual environment by name:
activate env
Deactivate a virtual environment:
deactivate
Install a package into an existing environment:
conda install -n env package
Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 13 / 14
Thank You

Satish Annigeri (BVBCET, Hubli) Scientific Python for Engineering Faculty 16 Aug, 2014 14 / 14

Anda mungkin juga menyukai