Python 3.4.3
IIT Bombay is leading the effort to popularise Python for Scientific Computing in India. This is part of the Free and Open source Software for Science and Engineering Education (http://fossee.in) project, supported by the National Mission on Education through ICT of MHRD.
IIT Bombay is using Spoken Tutorials (http://spoken-tutorial.org) to create learning material for FOSS. This is the main page for the organisation of the scripts required for Standard two day workshop we conduct on "Python for Scientific Computing" spoken tutorials.
Learners: UG/PG CSE/IT/CS students and CBSE high school students
Contents
Note: Each numbered topic corresponds to a single spoken tutorial. Each bulleted point corresponds to a command or topic that must be covered in the given spoken tutorial.
Module 1: Basic Plotting
Getting started with ipython
- Use Python 3.5.2
- Use Ipython version 5.1.0
- IPython is an enhanced interactive Python interpreter.
- Invoke the IPython interpreter
- Quit the IPython interpreter
- Navigate the IPython session history
- Use tab-completion to work faster.
- See the documentation of functions using question mark.
- Interrupt commands using Ctrl + C when we make an error.
- round command
Using the plot command interactively
- ipython -pylab
- pylab brings in the libraries necessary for Scientific Computing.
- pylab brings in the libraries necessary for Scientific Computing.
-
linspace
,
-
len
-
clf
-
plot
- using the plot ui
Embellishing a plot
- Title
- Label
- line width, color, style
- annotations
Saving plots
- basic savefig
- png, pdf, ps, eps, svg
- going to OS and looking at the file
Multiple plots
- overlays
- linspace
- give one with very few points, more points
- show smoothness of the curve
- give one with very few points, more points
- linspace
- legend
- figure 1, figure2
Subplots
- run basic Python commands on the ipython console
- use Plots interactively
- Embellish a plot
Additional features of IPython
-
%save
,%history
,%run
Module 2: Plotting Experimental Data
loading data from files
- loadtxt with unpack=True
- primes.list (one col)
- pendulum.txt (two col)
- primes.list (one col)
Plotting the data
- plot L vs. T2
- using square function
- using square function
- problem with 3 cols
- 3rd column is error
- error bar
- 3rd column is error
Other types of plots
- scatter
- log-log plots
Plotting charts
- pie chart
- bar chart
- illustration of other plots, matplotlib help
Module 4: Handling Large Data Files
Getting started with lists
- empty
- filled lists
- heterogenity
- heterogenity
- accessing
- len
-
append
elements
- del (+ remove)
Getting started with for
- blocks in python
- (indentation)
- (indentation)
- blocks in ipython
- … prompt
- hitting enter
- … prompt
-
for
with a list
-
range
function
Getting started with strings
- strings
- single, double, triple quoted
- single, double, triple quoted
- accessing elements
- show immutability
- tell that there are methods for manipulation
Getting started with files
- show file object
- read the file with
read
- closing the file
- for line in file:
- print a line
- append the lines to a list
Parsing data
- explain what is parsing
- strip (with strings)
- split (with strings)
- with delimiters
- specify space as delimiter
- specify space as delimiter
- with delimiters
- datatype conversion
- reading from files
- do the same problem done with loadtxt (for pendulum)
- basic parse sslc text
- do the same problem done with loadtxt (for pendulum)
Statistics
- mean
- summing
- summing
- median
- std
Module 5: Arrays and Matrices
Getting started with arrays
- why arrays
- speed - simply say
- array level operations
- speed - simply say
- creating arrays
- direct data
- list conversion
- homogeneous
- builtins - identitiy, zeros,
- direct data
- array operations
-
+ - * /
-
Accessing parts of arrays
- accessing individual elements
- changing individual elements
- slicing, striding
- image manipulation
Matrices
- creating matrices
- direct data
- list conversion
- builtins - identitiy, zeros,
- direct data
- matrix operations
- + - * /
- dot
- inv
- det
- eig
- norm
- svd
- + - * /
Least square fit
- show pendulum
- use loadtxt
- use loadtxt
- lstsq
Module 6: Python Language: Basics
Basic datatypes & operators
- int
- L, long
- L, long
- float
- repr, str
- repr, str
- complex
- boolean
- conversion functions
- sequence datatypes & mutability
- list available sequence datatypes
- string
- list
- tuple
- string
- mutability
- conversion
- common stuff
- len
- in
- max, min, sum, sorted, reversed
- accessing individual elements
- slicing, striding
- len
- list available sequence datatypes
I/O
Input Output in Python
Conditionals
- if, elif, else
- pass
Loops
- while
- for
- pass, break, continue
Module 7: Python Language: Datastructures
Manipulating lists
- concatenation
- slicing
- striding
- .sort
- sorted
- .reverse
- reversed
Manipulating strings
- upper, lower,
- replace
- slicing
- [::-1]
- reversed
- palindrome check
Getting started with tuples
- immutability
- tuple packing, unpacking
- a, b = b, a
- a, b = b, a
- accessing individual elements
- slicing, striding
Dictionaries
- empty
- filled
- accessing via keys
- .values(), .keys()
- in
- iteration
Sets
Sets
About sets in python
Module 8: Python Language: Advanced
Getting started with functions
- defining function
- arguments
- docstrings
- return values
- can return multiple values
- code reading exercises
Advanced features of functions
- default arguments
- keyword arguments
- built-in functions show off
Using python modules
- scipy
- pylab
- sys
Writing python scripts
- import
Testing and debugging
Testing and debugging
Handling Errors and Exceptions
- ValueError exception
- ZeroDivisionError exception
- try except clause in Python
- debugging