# Python for Chemical Engineers Python crash course designed for chemical engineers and scientists with no previous knowledge. The real goal here isn’t to teach you everything about Python, but you will learn basic concepts via something you will need to do soon or later: analyze data. These informal lessons are divided into 1 hour/week and will be based on [Software-Carpentry Lessons](http://software-carpentry.org/lessons.html) ## Day #0 * Motivation of learning Python and [why Nature recommends it](http://www.nature.com/news/programming-pick-up-python-1.16833) ([live demo!](http://www.nature.com/news/ipython-interactive-demo-7.21492)). [[1](https://speakerdeck.com/fperez/ipython-and-project-jupyter-a-language-independent-architecture-for-open-computing-and-data-science), [2](http://www.slideshare.net/teoliphant/python-as-the-zen-of-data-science), [3](http://nbviewer.ipython.org/github/fperez/pycon2014-keynote/blob/master/Index.ipynb)] * Installation of Python in your computer. Please, [download Anaconda](https://www.continuum.io/downloads) Python 3.5 (64-bit) [(why?)](http://www.slideshare.net/continuumio/distributed-computing-on-your-cluster-with-anaconda-webinar-2015) * Introduction to the material we will follow: [Software-Carpentry Lessons](http://software-carpentry.org/lessons.html) (+[other](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks) [resources](https://automatetheboringstuff.com/)) * Open discussion ## Day #1: NumPy * Explain what a library is, and what libraries are used for. * Load a Python library and use the things it contains. * Read tabular data from a file into a program. * Assign values to variables. * Select individual values and subsections from data. * Perform operations on arrays of data. * Display simple graphs. Materials: - [Download the data](http://swcarpentry.github.io/python-novice-inflammation/setup/) - [Read the full lesson](http://swcarpentry.github.io/python-novice-inflammation/01-numpy/) ## Day #2: Loops and lists * Explain what a for loop does. * Correctly write for loops to repeat simple calculations. * Trace changes to a loop variable as the loop runs. * Trace changes to other variables as they are updated by a for loop. * Explain what a list is. * Create and index lists of simple values. Materials: - Read the full lessons:[L2](http://swcarpentry.github.io/python-novice-inflammation/02-loop), [L3](http://swcarpentry.github.io/python-novice-inflammation/03-lists) - [matplotlib gallery](http://matplotlib.org/gallery) - NumPy - MATLAB: [CheatSheet](http://sebastianraschka.com/Articles/2014_matlab_vs_numpy) and [differences](https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users). - [Python tutor](http://www.pythontutor.com/) (to visualize Python programs) *** ## Day #3: Lists and how to proces multiple files * Explain what a list is (recap). * Create and index lists of simple values (recap). ## Day #5: Lists and how to proces multiple files * Use a library function to get a list of filenames that match a simple wildcard pattern. * Use a for loop to process multiple files. * Plotting graphs (recap) Materials: - Read the full lessons:[L3](http://swcarpentry.github.io/python-novice-inflammation/03-lists), [L4](http://swcarpentry.github.io/python-novice-inflammation/04-files) - [Python tutor](http://www.pythontutor.com/) (to visualize Python programs) ## Day #6: Analyzing Data from Multiple Files [How to repeat operations on many different files?](http://swcarpentry.github.io/python-novice-inflammation/04-files/) ## Day #7: Making Choices and Functions [How can my programs do different things based on data values?](http://swcarpentry.github.io/python-novice-inflammation/) [Creating Functions](http://swcarpentry.github.io/python-novice-inflammation/06-func/) ___ ___ Where to go from here? * [Rest of Software Carpentry Lessons](http://swcarpentry.github.io/python-novice-inflammation/) * [Prof. Kitchin blog](http://kitchingroup.cheme.cmu.edu/blog/2013/12/30/Python-as-alternative-to-Matlab-for-engineering-calculations/) and [free book](http://kitchingroup.cheme.cmu.edu/pycse/) * [CAChemE learn](https://github.com/CAChemE/learn#chemical-and-process-engineering-interactive-simulations) (Education resources for Chemical and Process Engineering written as interactive Jupyter Notebooks) * Lorena Barba tutorials: [12 Steps to Navier Stokes](https://github.com/barbagroup/CFDPython#welcome-to-cfd-python), [Numerical-mooc](https://github.com/numerical-mooc/numerical-mooc), [AeroPython](https://github.com/barbagroup/AeroPython#aerodynamics-hydrodynamics-with-python) * **[A gallery of interesting IPython Notebooks](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks)** * [Introduction to Chemical Engineering Analysis](http://jckantor.github.io/CBE20255/)