Python, Part 2
Python, Part 2
Python: part II
Advanced Research Computing
Outline
• MPI programming in Python
• NumPy (SciPy) arrays
• Plotting in Python:
– bar-charts, pie-charts, mesh-grids
• Plotting and image processing in Python
– image representation, conversion to array and
processing (interpolation)
Taken from
http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/
python/arrays.html
Advanced Research Computing
Anatomy of Nd-arrays (2)
Taken from
http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/
python/arrays.html
Advanced Research Computing
Constructing Arrays (1)
a = np.array([[1,2,3],[4,5,6]])
b = np.array([i*i for i in range(10) if i%2==1])
c = np.zeros(100) # array of float zeros
d = np.zeros((2,4), int) # 2x4array of int zeros
e = np.ones(10, int) # array of int ones
f = np.ones((5,5))
i = np.eye(10,10, int)
a[:, 1] # column 1
a[:, -8:] # a slab of width 8
$ more data.csv
"name","worth","age"
Donald Trump,30,65
Bill Gates,580,55
Tom Cruise,40,41
Mr Manager,10,41
Questions?