Difference between revisions of "Python"

From Chemical Engineering @ UP wiki
Jump to: navigation, search
(Scientific computing)
Line 1: Line 1:
 
== Python ==
 
== Python ==
Python is a popular scripting language. It is on the top 10 of the [http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html TIOBE index], and is often used in scientific programming outside of the major commercial platforms like Matlab or Mathematica.
+
Python is a popular scripting language. It is on the top 5 of the [http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html TIOBE index], and is very popular in scientific computing, in some fields more popular than commercial platforms like Matlab or Mathematica.
  
* Check out the [http://www.python.org Python website] for more information
+
* Check out the [http://www.python.org Python website] for more information about Python itself, but don't download Python from that website!
  
 
=== Installation ===
 
=== Installation ===
  
* Windows: The MPR module uses [http://ftp.ee.up.ac.za/pub/windows/python/Python(x,y)-2.7.10.0.exe Python(x,y)]. This is a distribution which supplies a full scientific programming environment. If that local link does not work, look for a Python(x,y) executable installer [http://ftp.ee.up.ac.za/pub/windows/python/ here] or download directly from the [http://python-xy.github.io/ Python(x,y) website]. Note that the [http://continuum.io/downloads Anaconda] distribution is probably a lot better. There is a local mirror of that [http://ftp.ee.up.ac.za/pub/windows/python/ here]. Use Anaconda3.
+
* The MPR module uses [https://www.continuum.io/downloads Anaconda]. This is a distribution which supplies a full scientific programming environment. There is a local mirror of that [http://ftp.ee.up.ac.za/pub/windows/python/ here]. Use Anaconda3.
* Linux: Install python along with Matplotlib and Numpy/Scipy
+
* Mac: Use [http://continuum.io/downloads Anaconda].
+
  
 
=== Python 2 vs Python 3 ===
 
=== Python 2 vs Python 3 ===
 +
 
Python 3 came out in 2008. The problem was that it was not backwards compatible with all Python 2 programs. This delayed adoption, especially in the scientific community. There is probably no reason to use Python 2 any more.
 
Python 3 came out in 2008. The problem was that it was not backwards compatible with all Python 2 programs. This delayed adoption, especially in the scientific community. There is probably no reason to use Python 2 any more.
  

Revision as of 16:58, 9 March 2017

Python

Python is a popular scripting language. It is on the top 5 of the TIOBE index, and is very popular in scientific computing, in some fields more popular than commercial platforms like Matlab or Mathematica.

  • Check out the Python website for more information about Python itself, but don't download Python from that website!

Installation

  • The MPR module uses Anaconda. This is a distribution which supplies a full scientific programming environment. There is a local mirror of that here. Use Anaconda3.

Python 2 vs Python 3

Python 3 came out in 2008. The problem was that it was not backwards compatible with all Python 2 programs. This delayed adoption, especially in the scientific community. There is probably no reason to use Python 2 any more.

Scientific computing

Numeric calculations are done using the NumPy or SciPy modules. Here is a handy starting point for someone used to Matlab/Octave to get into NumpPy/Scipy.

Plotting is done using the matplotlib library. The website contains documentation as well as a large gallery of examples.

The SciPy website also has a lot of examples in their Cookbook. Topical ones include

The department also maintains a small cookbook notebook.

Thermo-Physical Properties of Materials

Have a look at CoolProp. It is a thermo-physical property database with properties of many common pure substances. It has a python package as well as an Excel add-in.

Symbolic computing

The sympy module is a very capable symbolic module for Python. It plays well with the IPython notebook