Scientific python + IPython intro Alexey Buzmakov

Shubnikov Institute of Crystallography RAS, Moscow 28/11/2013, XFEL, Hamburg

Scientific python + Ipython intro

Outline Headline  Why python?  What is python?  How to use python and IPython?

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

2

Scientific python + Ipython intro

Why Python? The scientist’s needs  Get data (simulation, experiment control, data files)  Manipulate and process data.  Visualize results... to understand what we are doing!  Communicate results: produce figures for reports or publications, write presentations.

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

3

Scientific python + Ipython intro

Existing solutions   

Compiled languages: C, C++, Fortran, etc. Scripting languages: Matlab Other scripting languages: Scilab, Octave, Igor, R, IDL, etc.

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

4

Scientific python + Ipython intro

Python 

General characteristics of Python:

 clean and simple language: Easy-to-read and intuitive code, easy-to-learn minimalistic syntax, maintainability scales well with size of projects.  expressive language: Fewer lines of code, fewer bugs, easier to maintain. 

Technical details:

 dynamically typed: No need to define the type of variables, function arguments or return types.  automatic memory management: No need to explicitly allocate and deallocate memory for variables and data arrays. No memory leak bugs.  interpreted: No need to compile the code. The Python interpreter reads and executes the python code directly. Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

5

Scientific python + Ipython intro

What about Python?  Advantages: 







Very rich scientific computing libraries (a bit less than Matlab, though) Well thought out language, allowing to write very readable and well structured code: we “code what we think”. Many libraries for other tasks than scientific computing (web server management, serial port access, etc.) Free and open-source software, widely spread, with a vibrant community.

 Drawbacks: 



– less pleasant development environment than, for example, Matlab. (More geek-oriented). – Not all the algorithms that can be found in more specialized software or toolboxes.

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

6

Scientific python + Ipython intro

Scientific Python building blocks

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

7

Scientific python + Ipython intro

Versions of python 





There are currently two versions of python:  Python 2 and Python 3.  Python 3 will eventually supercede Python 2, but it is not backward-compatible with Python 2.  A lot of existing python code and packages has been written for Python 2, and it is still the most widespread version. To see which version of Python you have, run  $ python --version Several versions of Python can be installed in parallel

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

8

Scientific python + Ipython intro

Python interpreter 

For example, to run a file my-program.py that contains python code from the command prompt, use:  $ python my-program.py  or run interpretator $python

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

9

Scientific python + Ipython intro

Why IPython?  



In scientific computing, we typically don’t know what we’re doing IPython is an Interactive shell that addresses the limitation of the standard python interpreter, and it is a work-horse for scientific use of python. It provides an interactive prompt to the python interpreter with a greatly improved user-friendliness.

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

10

Scientific python + Ipython intro

IPython notebook

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

11

Scientific python + Ipython intro

Ipython, numpy and scipy demonstration   

http://bit.ly/WPG-wiki -> Tutorial files -> Ipython presentation Download it Run in this folder  ipython notebook

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

12

Scientific python + Ipython intro

Publishing Ipython notebooks  

Generate html and pdf reports Free online publishing service http://nbviewer.ipython.org/

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

13

Scientific python + Ipython intro

14



Python http://www.python.org/



Numpy + Scipy + matplotlib http://www.scipy.org/



H5py http://www.h5py.org/



Numpy for Matlab users http://wiki.scipy.org/NumPy_for_Matlab_Users



Free tutorials (some materials was taken in this tutorials)  http://scipy-lectures.github.io/

 http://jrjohansson.github.io/ 

Free binary distribution with a lots of scientific stuff (especially for windows users)  https://store.continuum.io/cshop/anaconda/



Free scientific python IDE (Matlab like)  https://code.google.com/p/spyderlib/

Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, Hamburg. Alexey Buzmakov, Shubnikov Institute of Crystallography RAS, Moscow, Russia

Scientific python + IPython intro - GitHub

2. Tutorial course on wavefront propagation simulations, 28/11/2013, XFEL, ... written for Python 2, and it is still the most wide- ... Generate html and pdf reports.

290KB Sizes 85 Downloads 250 Views

Recommend Documents

The IPython notebook - GitHub
tool chain to compile the notebook to a publishable PDF, has inspired me to .... I have tested the HTML outputs on my Galaxy S3 and S4, IPAD and Nexus7.

IPython Notebooks - GitHub
IPython had become a popular choice for doing interactive scientific work. ... The Complete Talk GitHub Website can be accessed here ... tool chain to compile the notebook to a publishable PDF, has inspired me to maybe even try and .... execution, te

Introduction to Scientific Computing in Python - GitHub
Apr 16, 2016 - 1 Introduction to scientific computing with Python ...... Support for multiple parallel back-end processes, that can run on computing clusters or cloud services .... system, file I/O, string management, network communication, and ...

Intro to Webapp - GitHub
The Public Data Availability panel ... Let's look at data availability for this cohort ... To start an analysis, we're going to select our cohort and click the New ...

intro slides - GitHub
Jun 19, 2017 - Learn core skills for doing data analysis effectively, efficiently, and reproducibly. 1. Interacting with your computer on command line (BASH/shell).

Intro to Webapp IGV - GitHub
Home Page or the IGV Github Repository. We are grateful to the IGV team for their assistance in integrating the IGV into the ISB-CGC web application.

Intro to Google Cloud - GitHub
The Cloud Datalab web UI has two main sections: Notebooks and Sessions. ... When you click on an ipynb file in GitHub, you see it rendered (as HTML).

Intro to Google Cloud - GitHub
Now that you know your way around the Google Cloud Console, you're ready to start exploring further! The ISB-CGC platform includes an interactive Web App, ...

Intro to Webapp SeqPeek - GitHub
brought to you by. The ISB Cancer Genomics Cloud. An Introduction to the ISB-CGC Web App SeqPeek. Page 2. https://isb-cgc.appspot.com. Main Landing ...

Intro to Google Cloud - GitHub
known as “Application Default Credentials” are now created automatically. You don't really need to click on the “Go to. Credentials”, but in case you do the next ...

Python Cryptography Toolkit - GitHub
Jun 30, 2008 - 1 Introduction. 1.1 Design Goals. The Python cryptography toolkit is intended to provide a reliable and stable base for writing Python programs that require cryptographic functions. ... If you're implementing an important system, don't

lecture 2: intro to statistics - GitHub
Continuous Variables. - Cumulative probability function. PDF has dimensions of x-1. Expectation value. Moments. Characteristic function generates moments: .... from realized sample, parameters are unknown and described probabilistically. Parameters a

Covers Python 3 and Python 2 - GitHub
Setting a custom figure size. You can make your plot as big or small as you want. Before plotting your data, add the following code. The dpi argument is optional ...

Covers Python 3 and Python 2 - GitHub
You can add as much data as you want when making a ... chart.add('Squares', squares) .... Some built-in styles accept a custom color, then generate a theme.

Data 8R Intro to Python Summer 2017 1 Express Yourself! 2 ... - GitHub
Mike had a tremendous growth spurt over the past year. Find his growth rate over this 1 year. (Hint: The Growth Rate is the absolute difference between the final.

Data 8R Intro to Python Summer 2017 1 Express Yourself! 2 ... - GitHub
An expression describes to the computer how to combine pieces of data. ... inputs to a call expression are expressions themselves, you can have another call ...

Annotated Algorithms in Python - GitHub
Jun 6, 2017 - 2.1.1 Python versus Java and C++ syntax . . . . . . . . 24. 2.1.2 help, dir ..... 10 years at the School of Computing of DePaul University. The lectures.

understanding scientific applications for cloud environments - GitHub
computing resources (e.g., networks, servers, storage, applications, and ser- vices) that can be .... neath, and each layer may include one or more services that share the same or equivalent ...... file/925013/3/EGEE-Grid-Cloud.pdf, 2008. 28.

Developing Scientific Applications with Loosely-Coupled ... - GitHub
application developer to focus on supporting the application characteristics and ... Jobs. Dist. Application Patterns / Usage Modes. Distributed Applications.

Optimizations which made Python 3.6 faster than Python 3.5 - GitHub
Benchmarks rewritten using perf: new project performance ... in debug hooks. Only numy misused the API (fixed) ... The Python test suite is now used, rather than ...

lecture 3: more statistics and intro to data modeling - GitHub
have more parameters than needed by the data: posteriors can be ... Modern statistical methods (Bayesian or not) .... Bayesian data analysis, Gelman et al.

Dan Dietz Greenville Django + Python Meetup - GitHub
Awaken your home: Python and the. Internet of Things. PyCon 2016. • Architecture. • Switch programming. • Automation component. Paulus Schoutsen's talk: ...

QuTiP: Quantum Toolbox in Python - GitHub
Good support for object-oriented and modular programming, packaging and reuse of code, ... integration with operating systems and other software packages.